GNU Assembler(x86_64 Mac OS X), 97 bytes
#GNU Assembler(x86_64 Mac OS X), 97 bytes ThisThis is a proper function that can be called from C:
.text
.globl _f
_f:
movq %rdi,%xmm0;movq %rsi,%xmm1;pclmulqdq $0,%xmm1,%xmm0;movq %xmm0,%rax;ret
& can be tested with this C program:
#include <stdio.h>
int f(int a, int b);
#define p(a,b) printf("%d %d %d\n", a, b, f(a, b))
int main(void)
{
p(0,1);
p(1,2);
p(9,0);
p(6,1);
p(3,3);
p(2,5);
p(7,9);
p(13,11);
p(5,17);
p(14,13);
p(19,1);
p(63,63);
}
Note that on Mac OS X, you have to use clang -x c
to compile it as C & not C++.
For linux(if I remember right), the code would be 95 bytes:
.text
.globl f
f:
movq %rdi,%xmm0;movq %rsi,%xmm1;pclmulqdq $0,%xmm1,%xmm0;movq %xmm0,%rax;ret
Strangely enough, this version is actually longer than defining the function in inline assembly, but that one was longer than the pure C solution we already have, so I decided to try assembly.
edit
###edit IfIf it's counted by the assembled size(excluding any labels &c.), then it's #x86_64 Assembler, 22 bytes: 0: 66 48 0f 6e c7 movq %rdi, %xmm0 5: 66 48 0f 6e ce movq %rsi, %xmm1 a: 66 0f 3a 44 c1 00 pclmullqlqdq $0, %xmm1,%xmm0 10: 66 48 0f 7e c0 movq %xmm0, %rax 15: c3 ret
x86_64 Assembler, 22 bytes:
0: 66 48 0f 6e c7 movq %rdi, %xmm0
5: 66 48 0f 6e ce movq %rsi, %xmm1
a: 66 0f 3a 44 c1 00 pclmullqlqdq $0, %xmm1,%xmm0
10: 66 48 0f 7e c0 movq %xmm0, %rax
15: c3 ret