// File: /workspace/github_c_makefile_star2_O1/vrancurel[P]ec/gf.c
// Function: utest
void utest()
{
#if W == 4
  assert(gmul(3, 7) == 9);
  assert(gmul(13, 10) == 11);  
  assert(gdiv(13, 10) == 3);
  assert(gdiv(3, 7) == 10);
  /* non-MDS vandermonde matrix */
  t_mat *mat = mat_vandermonde(3, 3);
  t_vec *vec = vec_xcalloc(3);
  VEC_ITEM(vec, 0) = 3;
  VEC_ITEM(vec, 1) = 13;
  VEC_ITEM(vec, 2) = 9;
  t_vec *output = vec_xcalloc(3);
  mat_mult(output, mat, vec);
  assert(VEC_ITEM(output, 0) == 7);
  assert(VEC_ITEM(output, 1) == 2);
  assert(VEC_ITEM(output, 2) == 9);
  VEC_ITEM(vec, 0) = 3;
  VEC_ITEM(vec, 1) = 1;
  VEC_ITEM(vec, 2) = 9;
  mat_mult(output, mat, vec);
  assert(VEC_ITEM(output, 0) == 11);
  assert(VEC_ITEM(output, 1) == 9);
  assert(VEC_ITEM(output, 2) == 12);
  MAT_ITEM(mat, 0, 0) = 1;
  MAT_ITEM(mat, 0, 1) = 0;
  MAT_ITEM(mat, 0, 2) = 0;
  MAT_ITEM(mat, 1, 0) = 1;
  MAT_ITEM(mat, 1, 1) = 1;
  MAT_ITEM(mat, 1, 2) = 1;
  MAT_ITEM(mat, 2, 0) = 1;
  MAT_ITEM(mat, 2, 1) = 2;
  MAT_ITEM(mat, 2, 2) = 3;
  VEC_ITEM(vec, 0) = 3;
  VEC_ITEM(vec, 1) = 11;
  VEC_ITEM(vec, 2) = 9;
  mat_inv(mat);
  mat_mult(output, mat, vec);
  assert(VEC_ITEM(output, 1) == 1);
  assert(VEC_ITEM(output, 2) == 9);
  vec_free(output);
  vec_free(vec);
  mat_free(mat);
  mat = mat_vandermonde_correct(3, 3);
  mat_free(mat);
  mat = mat_cauchy(3, 3);
  mat_free(mat);
#elif W == 8
  assert(gmul(3, 7) == 9);
  assert(gmul(13, 10) == 114);
  assert(gdiv(13, 10) == 40);
  assert(gdiv(3, 7) == 211);
#else
  //TBD
#endif
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movq 0x3b61(%rip), %rdi      # 0x50e8
movzwl 0x6(%rdi), %eax
movzwl 0xe(%rdi), %ecx
leal (%rcx,%rax), %edx
cmpl $0xf, %edx
leal -0xf(%rcx,%rax), %esi
cmovbl %edx, %esi
movq 0x3b4d(%rip), %rdx      # 0x50f0
cmpw $0x9, (%rdx,%rsi,2)
jne 0x17a6
movzwl 0x1a(%rdi), %esi
movzwl 0x14(%rdi), %edi
leal (%rdi,%rsi), %r8d
cmpl $0xf, %r8d
leal -0xf(%rdi,%rsi), %r9d
cmovbl %r8d, %r9d
cmpw $0xb, (%rdx,%r9,2)
jne 0x17c5
subl %edi, %esi
leal 0xf(%rsi), %edi
testl %esi, %esi
cmovnsl %esi, %edi
movslq %edi, %rsi
cmpw $0x3, (%rdx,%rsi,2)
jne 0x17e4
subl %ecx, %eax
leal 0xf(%rax), %ecx
testl %eax, %eax
cmovnsl %eax, %ecx
movslq %ecx, %rax
cmpw $0xa, (%rdx,%rax,2)
jne 0x1803
movl $0x3, %edi
movl $0x3, %esi
callq 0x24c3
movq %rax, %rbx
movl $0x3, %edi
callq 0x2d38
movq %rax, %r14
movq 0x8(%rax), %rax
movabsq $0xd00000003, %rcx      # imm = 0xD00000003
movq %rcx, (%rax)
movl $0x9, 0x8(%rax)
movl $0x3, %edi
callq 0x2d38
movq %rax, %r15
movq %rax, %rdi
movq %rbx, %rsi
movq %r14, %rdx
callq 0x2bb9
movq 0x8(%r15), %rax
cmpl $0x7, (%rax)
jne 0x1822
cmpl $0x2, 0x4(%rax)
jne 0x1841
cmpl $0x9, 0x8(%rax)
jne 0x1860
movq 0x8(%r14), %rax
movabsq $0x100000003, %rcx      # imm = 0x100000003
movq %rcx, (%rax)
movl $0x9, 0x8(%rax)
movq %r15, %rdi
movq %rbx, %rsi
movq %r14, %rdx
callq 0x2bb9
movq 0x8(%r15), %rax
cmpl $0xb, (%rax)
jne 0x187f
cmpl $0x9, 0x4(%rax)
jne 0x189e
cmpl $0xc, 0x8(%rax)
jne 0x18bd
movq 0x8(%rbx), %rax
movq $0x1, (%rax)
movl $0x0, 0x8(%rax)
movl 0x4(%rbx), %ecx
movl $0x1, %ebp
movl %ebp, (%rax,%rcx,4)
movl 0x4(%rbx), %ecx
incl %ecx
movl %ebp, (%rax,%rcx,4)
movl 0x4(%rbx), %ecx
addl $0x2, %ecx
movl %ebp, (%rax,%rcx,4)
movl 0x4(%rbx), %ecx
addl %ecx, %ecx
movl %ebp, (%rax,%rcx,4)
movl 0x4(%rbx), %ecx
addl %ecx, %ecx
movl $0x2, 0x4(%rax,%rcx,4)
movl 0x4(%rbx), %ecx
leal 0x2(,%rcx,2), %ecx
movl $0x3, (%rax,%rcx,4)
movq 0x8(%r14), %rax
movabsq $0xb00000003, %rcx      # imm = 0xB00000003
movq %rcx, (%rax)
movl $0x9, 0x8(%rax)
movq %rbx, %rdi
callq 0x291b
movq %r15, %rdi
movq %rbx, %rsi
movq %r14, %rdx
callq 0x2bb9
movq 0x8(%r15), %rax
cmpl %ebp, 0x4(%rax)
jne 0x18dc
cmpl $0x9, 0x8(%rax)
jne 0x18fb
movq %r15, %rdi
callq 0x2d78
movq %r14, %rdi
callq 0x2d78
movq %rbx, %rdi
callq 0x2448
movl $0x3, %edi
movl $0x3, %esi
callq 0x27ae
movq %rax, %rdi
callq 0x2448
movl $0x3, %edi
movl $0x3, %esi
callq 0x252b
movq %rax, %rdi
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
jmp 0x2448
leaq 0x185b(%rip), %rdi      # 0x3008
leaq 0x1864(%rip), %rsi      # 0x3018
leaq 0x1862(%rip), %rcx      # 0x301d
movl $0x86, %edx
callq 0x1090
leaq 0x185e(%rip), %rdi      # 0x302a
leaq 0x1845(%rip), %rsi      # 0x3018
leaq 0x1843(%rip), %rcx      # 0x301d
movl $0x87, %edx
callq 0x1090
leaq 0x1852(%rip), %rdi      # 0x303d
leaq 0x1826(%rip), %rsi      # 0x3018
leaq 0x1824(%rip), %rcx      # 0x301d
movl $0x88, %edx
callq 0x1090
leaq 0x1845(%rip), %rdi      # 0x304f
leaq 0x1807(%rip), %rsi      # 0x3018
leaq 0x1805(%rip), %rcx      # 0x301d
movl $0x89, %edx
callq 0x1090
leaq 0x1837(%rip), %rdi      # 0x3060
leaq 0x17e8(%rip), %rsi      # 0x3018
leaq 0x17e6(%rip), %rcx      # 0x301d
movl $0x92, %edx
callq 0x1090
leaq 0x1831(%rip), %rdi      # 0x3079
leaq 0x17c9(%rip), %rsi      # 0x3018
leaq 0x17c7(%rip), %rcx      # 0x301d
movl $0x93, %edx
callq 0x1090
leaq 0x182b(%rip), %rdi      # 0x3092
leaq 0x17aa(%rip), %rsi      # 0x3018
leaq 0x17a8(%rip), %rcx      # 0x301d
movl $0x94, %edx
callq 0x1090
leaq 0x1825(%rip), %rdi      # 0x30ab
leaq 0x178b(%rip), %rsi      # 0x3018
leaq 0x1789(%rip), %rcx      # 0x301d
movl $0x99, %edx
callq 0x1090
leaq 0x1820(%rip), %rdi      # 0x30c5
leaq 0x176c(%rip), %rsi      # 0x3018
leaq 0x176a(%rip), %rcx      # 0x301d
movl $0x9a, %edx
callq 0x1090
leaq 0x181a(%rip), %rdi      # 0x30de
leaq 0x174d(%rip), %rsi      # 0x3018
leaq 0x174b(%rip), %rcx      # 0x301d
movl $0x9b, %edx
callq 0x1090
leaq 0x1815(%rip), %rdi      # 0x30f8
leaq 0x172e(%rip), %rsi      # 0x3018
leaq 0x172c(%rip), %rcx      # 0x301d
movl $0xaa, %edx
callq 0x1090
leaq 0x1790(%rip), %rdi      # 0x3092
leaq 0x170f(%rip), %rsi      # 0x3018
leaq 0x170d(%rip), %rcx      # 0x301d
movl $0xab, %edx
callq 0x1090
nop