#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */

/* Variables and functions */
unsigned short gf4096_inv(unsigned short);
unsigned short gf4096_mul(unsigned short, unsigned short);
void solve_2x3(unsigned short m[2][3], unsigned short *coefs) {
  unsigned short minv;
  minv = gf4096_mul(m[1][1], gf4096_inv(m[0][1]));
  m[1][0] = m[1][0] ^ gf4096_mul(m[0][0], minv);
  m[1][2] = m[1][2] ^ gf4096_mul(m[0][2], minv);
  coefs[0] = gf4096_mul(m[1][2], gf4096_inv(m[1][0]));
  coefs[1] = gf4096_mul((gf4096_mul(coefs[0], m[0][0]) ^ m[0][2]),
                        gf4096_inv(m[0][1]));
}


x86 assembly (clang, -O0):
<solve_2x3>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rax
mov    0x8(%rax),%ax
mov    %ax,-0x22(%rbp)
mov    -0x8(%rbp),%rax
movzwl 0x2(%rax),%edi
call   1040 <gf4096_inv@plt>
mov    -0x22(%rbp),%cx
movzwl %cx,%edi
movzwl %ax,%esi
call   1030 <gf4096_mul@plt>
mov    %ax,-0x12(%rbp)
mov    -0x8(%rbp),%rax
movzwl 0x6(%rax),%eax
mov    %eax,-0x20(%rbp)
mov    -0x8(%rbp),%rax
mov    (%rax),%ax
movzwl %ax,%edi
movzwl -0x12(%rbp),%esi
call   1030 <gf4096_mul@plt>
mov    %ax,%cx
mov    -0x20(%rbp),%eax
movzwl %cx,%ecx
xor    %ecx,%eax
mov    %ax,%cx
mov    -0x8(%rbp),%rax
mov    %cx,0x6(%rax)
mov    -0x8(%rbp),%rax
movzwl 0xa(%rax),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x8(%rbp),%rax
mov    0x4(%rax),%ax
movzwl %ax,%edi
movzwl -0x12(%rbp),%esi
call   1030 <gf4096_mul@plt>
mov    %ax,%cx
mov    -0x1c(%rbp),%eax
movzwl %cx,%ecx
xor    %ecx,%eax
mov    %ax,%cx
mov    -0x8(%rbp),%rax
mov    %cx,0xa(%rax)
mov    -0x8(%rbp),%rax
mov    0xa(%rax),%ax
mov    %ax,-0x16(%rbp)
mov    -0x8(%rbp),%rax
movzwl 0x6(%rax),%edi
call   1040 <gf4096_inv@plt>
mov    -0x16(%rbp),%cx
movzwl %cx,%edi
movzwl %ax,%esi
call   1030 <gf4096_mul@plt>
mov    %ax,%cx
mov    -0x10(%rbp),%rax
mov    %cx,(%rax)
mov    -0x10(%rbp),%rax
mov    (%rax),%cx
mov    -0x8(%rbp),%rax
movzwl %cx,%edi
movzwl (%rax),%esi
call   1030 <gf4096_mul@plt>
movzwl %ax,%eax
mov    -0x8(%rbp),%rcx
movzwl 0x4(%rcx),%ecx
xor    %ecx,%eax
mov    %ax,-0x14(%rbp)
mov    -0x8(%rbp),%rax
movzwl 0x2(%rax),%edi
call   1040 <gf4096_inv@plt>
mov    -0x14(%rbp),%cx
movzwl %cx,%edi
movzwl %ax,%esi
call   1030 <gf4096_mul@plt>
mov    %ax,%cx
mov    -0x10(%rbp),%rax
mov    %cx,0x2(%rax)
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<solve_2x3>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%rbx
movzwl 0x8(%rdi),%ebp
movzwl 0x2(%rdi),%edi
call   1040 <gf4096_inv@plt>
movzwl %ax,%esi
mov    %ebp,%edi
call   1030 <gf4096_mul@plt>
movzwl 0x6(%rbx),%r15d
movzwl (%rbx),%edi
movzwl %ax,%ebp
mov    %ebp,%esi
call   1030 <gf4096_mul@plt>
xor    %r15w,%ax
mov    %ax,0x6(%rbx)
movzwl 0xa(%rbx),%r15d
movzwl 0x4(%rbx),%edi
mov    %ebp,%esi
call   1030 <gf4096_mul@plt>
mov    %eax,%ebp
xor    %r15w,%bp
mov    %bp,0xa(%rbx)
movzwl 0x6(%rbx),%edi
call   1040 <gf4096_inv@plt>
movzwl %bp,%edi
movzwl %ax,%esi
call   1030 <gf4096_mul@plt>
mov    %ax,(%r14)
movzwl (%rbx),%esi
movzwl %ax,%edi
call   1030 <gf4096_mul@plt>
mov    %eax,%ebp
xor    0x4(%rbx),%bp
movzwl 0x2(%rbx),%edi
call   1040 <gf4096_inv@plt>
movzwl %bp,%edi
movzwl %ax,%esi
call   1030 <gf4096_mul@plt>
mov    %ax,0x2(%r14)
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @solve_2x3([3 x i16]* %0, i16* %1) {
%3 = alloca [3 x i16]*
%4 = alloca i16*
%5 = alloca i16
store [3 x i16]* %0, [3 x i16]** %3
store i16* %1, i16** %4
%6 = load [3 x i16]*, [3 x i16]** %3
%7 = getelementptr inbounds [3 x i16], [3 x i16]* %6, i64 1
%8 = getelementptr inbounds [3 x i16], [3 x i16]* %7, i64 0, i64 1
%9 = load i16, i16* %8
%10 = load [3 x i16]*, [3 x i16]** %3
%11 = getelementptr inbounds [3 x i16], [3 x i16]* %10, i64 0
%12 = getelementptr inbounds [3 x i16], [3 x i16]* %11, i64 0, i64 1
%13 = load i16, i16* %12
%14 = call zeroext i16 @gf4096_inv(i16 zeroext %13)
%15 = call zeroext i16 @gf4096_mul(i16 zeroext %9, i16 zeroext %14)
store i16 %15, i16* %5
%16 = load [3 x i16]*, [3 x i16]** %3
%17 = getelementptr inbounds [3 x i16], [3 x i16]* %16, i64 1
%18 = getelementptr inbounds [3 x i16], [3 x i16]* %17, i64 0, i64 0
%19 = load i16, i16* %18
%20 = zext i16 %19 to i32
%21 = load [3 x i16]*, [3 x i16]** %3
%22 = getelementptr inbounds [3 x i16], [3 x i16]* %21, i64 0
%23 = getelementptr inbounds [3 x i16], [3 x i16]* %22, i64 0, i64 0
%24 = load i16, i16* %23
%25 = load i16, i16* %5
%26 = call zeroext i16 @gf4096_mul(i16 zeroext %24, i16 zeroext %25)
%27 = zext i16 %26 to i32
%28 = xor i32 %20, %27
%29 = trunc i32 %28 to i16
%30 = load [3 x i16]*, [3 x i16]** %3
%31 = getelementptr inbounds [3 x i16], [3 x i16]* %30, i64 1
%32 = getelementptr inbounds [3 x i16], [3 x i16]* %31, i64 0, i64 0
store i16 %29, i16* %32
%33 = load [3 x i16]*, [3 x i16]** %3
%34 = getelementptr inbounds [3 x i16], [3 x i16]* %33, i64 1
%35 = getelementptr inbounds [3 x i16], [3 x i16]* %34, i64 0, i64 2
%36 = load i16, i16* %35
%37 = zext i16 %36 to i32
%38 = load [3 x i16]*, [3 x i16]** %3
%39 = getelementptr inbounds [3 x i16], [3 x i16]* %38, i64 0
%40 = getelementptr inbounds [3 x i16], [3 x i16]* %39, i64 0, i64 2
%41 = load i16, i16* %40
%42 = load i16, i16* %5
%43 = call zeroext i16 @gf4096_mul(i16 zeroext %41, i16 zeroext %42)
%44 = zext i16 %43 to i32
%45 = xor i32 %37, %44
%46 = trunc i32 %45 to i16
%47 = load [3 x i16]*, [3 x i16]** %3
%48 = getelementptr inbounds [3 x i16], [3 x i16]* %47, i64 1
%49 = getelementptr inbounds [3 x i16], [3 x i16]* %48, i64 0, i64 2
store i16 %46, i16* %49
%50 = load [3 x i16]*, [3 x i16]** %3
%51 = getelementptr inbounds [3 x i16], [3 x i16]* %50, i64 1
%52 = getelementptr inbounds [3 x i16], [3 x i16]* %51, i64 0, i64 2
%53 = load i16, i16* %52
%54 = load [3 x i16]*, [3 x i16]** %3
%55 = getelementptr inbounds [3 x i16], [3 x i16]* %54, i64 1
%56 = getelementptr inbounds [3 x i16], [3 x i16]* %55, i64 0, i64 0
%57 = load i16, i16* %56
%58 = call zeroext i16 @gf4096_inv(i16 zeroext %57)
%59 = call zeroext i16 @gf4096_mul(i16 zeroext %53, i16 zeroext %58)
%60 = load i16*, i16** %4
%61 = getelementptr inbounds i16, i16* %60, i64 0
store i16 %59, i16* %61
%62 = load i16*, i16** %4
%63 = getelementptr inbounds i16, i16* %62, i64 0
%64 = load i16, i16* %63
%65 = load [3 x i16]*, [3 x i16]** %3
%66 = getelementptr inbounds [3 x i16], [3 x i16]* %65, i64 0
%67 = getelementptr inbounds [3 x i16], [3 x i16]* %66, i64 0, i64 0
%68 = load i16, i16* %67
%69 = call zeroext i16 @gf4096_mul(i16 zeroext %64, i16 zeroext %68)
%70 = zext i16 %69 to i32
%71 = load [3 x i16]*, [3 x i16]** %3
%72 = getelementptr inbounds [3 x i16], [3 x i16]* %71, i64 0
%73 = getelementptr inbounds [3 x i16], [3 x i16]* %72, i64 0, i64 2
%74 = load i16, i16* %73
%75 = zext i16 %74 to i32
%76 = xor i32 %70, %75
%77 = trunc i32 %76 to i16
%78 = load [3 x i16]*, [3 x i16]** %3
%79 = getelementptr inbounds [3 x i16], [3 x i16]* %78, i64 0
%80 = getelementptr inbounds [3 x i16], [3 x i16]* %79, i64 0, i64 1
%81 = load i16, i16* %80
%82 = call zeroext i16 @gf4096_inv(i16 zeroext %81)
%83 = call zeroext i16 @gf4096_mul(i16 zeroext %77, i16 zeroext %82)
%84 = load i16*, i16** %4
%85 = getelementptr inbounds i16, i16* %84, i64 1
store i16 %83, i16* %85
ret void
}

LLVM IR (-O2):
define void @solve_2x3([3 x i16]* nocapture %0, i16* nocapture writeonly %1) {
%3 = getelementptr inbounds [3 x i16], [3 x i16]* %0, i64 1, i64 1
%4 = load i16, i16* %3
%5 = getelementptr inbounds [3 x i16], [3 x i16]* %0, i64 0, i64 1
%6 = load i16, i16* %5
%7 = tail call zeroext i16 @gf4096_inv(i16 zeroext %6)
%8 = tail call zeroext i16 @gf4096_mul(i16 zeroext %4, i16 zeroext %7)
%9 = getelementptr inbounds [3 x i16], [3 x i16]* %0, i64 1, i64 0
%10 = load i16, i16* %9
%11 = getelementptr inbounds [3 x i16], [3 x i16]* %0, i64 0, i64 0
%12 = load i16, i16* %11
%13 = tail call zeroext i16 @gf4096_mul(i16 zeroext %12, i16 zeroext %8)
%14 = xor i16 %13, %10
store i16 %14, i16* %9
%15 = getelementptr inbounds [3 x i16], [3 x i16]* %0, i64 1, i64 2
%16 = load i16, i16* %15
%17 = getelementptr inbounds [3 x i16], [3 x i16]* %0, i64 0, i64 2
%18 = load i16, i16* %17
%19 = tail call zeroext i16 @gf4096_mul(i16 zeroext %18, i16 zeroext %8)
%20 = xor i16 %19, %16
store i16 %20, i16* %15
%21 = load i16, i16* %9
%22 = tail call zeroext i16 @gf4096_inv(i16 zeroext %21)
%23 = tail call zeroext i16 @gf4096_mul(i16 zeroext %20, i16 zeroext %22)
store i16 %23, i16* %1
%24 = load i16, i16* %11
%25 = tail call zeroext i16 @gf4096_mul(i16 zeroext %23, i16 zeroext %24)
%26 = load i16, i16* %17
%27 = xor i16 %26, %25
%28 = load i16, i16* %5
%29 = tail call zeroext i16 @gf4096_inv(i16 zeroext %28)
%30 = tail call zeroext i16 @gf4096_mul(i16 zeroext %27, i16 zeroext %29)
%31 = getelementptr inbounds i16, i16* %1, i64 1
store i16 %30, i16* %31
ret void
}