#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);
int /*<<< orphan*/ sort_coefs(int *, unsigned short *, int);
void solve_4x5(unsigned short m[4][5], unsigned short *coefs, int *row_order) {
  unsigned short tmp[4];
  tmp[0] = gf4096_mul(m[3][4], gf4096_inv(m[3][0]));
  tmp[1] =
      gf4096_mul((gf4096_mul(tmp[0], m[2][0]) ^ m[2][4]), gf4096_inv(m[2][1]));
  tmp[2] = gf4096_mul(
      (gf4096_mul(tmp[0], m[1][0]) ^ gf4096_mul(tmp[1], m[1][1]) ^ m[1][4]),
      gf4096_inv(m[1][2]));
  tmp[3] =
      gf4096_mul((gf4096_mul(tmp[0], m[0][0]) ^ gf4096_mul(tmp[1], m[0][1]) ^
                  gf4096_mul(tmp[2], m[0][2]) ^ m[0][4]),
                 gf4096_inv(m[0][3]));
  sort_coefs(row_order, tmp, 4);
  coefs[0] = tmp[0];
  coefs[1] = tmp[1];
  coefs[2] = tmp[2];
  coefs[3] = tmp[3];
}


x86 assembly (clang, -O0):
<solve_4x5>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x8(%rbp),%rax
mov    0x26(%rax),%ax
mov    %ax,-0x38(%rbp)
mov    -0x8(%rbp),%rax
movzwl 0x1e(%rax),%edi
call   1050 <gf4096_inv@plt>
mov    -0x38(%rbp),%cx
movzwl %cx,%edi
movzwl %ax,%esi
call   1030 <gf4096_mul@plt>
mov    %ax,-0x20(%rbp)
mov    -0x20(%rbp),%cx
mov    -0x8(%rbp),%rax
movzwl %cx,%edi
movzwl 0x14(%rax),%esi
call   1030 <gf4096_mul@plt>
movzwl %ax,%eax
mov    -0x8(%rbp),%rcx
movzwl 0x1c(%rcx),%ecx
xor    %ecx,%eax
mov    %ax,-0x36(%rbp)
mov    -0x8(%rbp),%rax
movzwl 0x16(%rax),%edi
call   1050 <gf4096_inv@plt>
mov    -0x36(%rbp),%cx
movzwl %cx,%edi
movzwl %ax,%esi
call   1030 <gf4096_mul@plt>
mov    %ax,-0x1e(%rbp)
mov    -0x20(%rbp),%cx
mov    -0x8(%rbp),%rax
movzwl %cx,%edi
movzwl 0xa(%rax),%esi
call   1030 <gf4096_mul@plt>
movzwl %ax,%eax
mov    %eax,-0x34(%rbp)
mov    -0x1e(%rbp),%cx
mov    -0x8(%rbp),%rax
movzwl %cx,%edi
movzwl 0xc(%rax),%esi
call   1030 <gf4096_mul@plt>
mov    %ax,%cx
mov    -0x34(%rbp),%eax
movzwl %cx,%ecx
xor    %ecx,%eax
mov    -0x8(%rbp),%rcx
movzwl 0x12(%rcx),%ecx
xor    %ecx,%eax
mov    %ax,-0x2e(%rbp)
mov    -0x8(%rbp),%rax
movzwl 0xe(%rax),%edi
call   1050 <gf4096_inv@plt>
mov    -0x2e(%rbp),%cx
movzwl %cx,%edi
movzwl %ax,%esi
call   1030 <gf4096_mul@plt>
mov    %ax,-0x1c(%rbp)
mov    -0x20(%rbp),%cx
mov    -0x8(%rbp),%rax
movzwl %cx,%edi
movzwl (%rax),%esi
call   1030 <gf4096_mul@plt>
movzwl %ax,%eax
mov    %eax,-0x2c(%rbp)
mov    -0x1e(%rbp),%cx
mov    -0x8(%rbp),%rax
movzwl %cx,%edi
movzwl 0x2(%rax),%esi
call   1030 <gf4096_mul@plt>
mov    %ax,%cx
mov    -0x2c(%rbp),%eax
movzwl %cx,%ecx
xor    %ecx,%eax
mov    %eax,-0x28(%rbp)
mov    -0x1c(%rbp),%cx
mov    -0x8(%rbp),%rax
movzwl %cx,%edi
movzwl 0x4(%rax),%esi
call   1030 <gf4096_mul@plt>
mov    %ax,%cx
mov    -0x28(%rbp),%eax
movzwl %cx,%ecx
xor    %ecx,%eax
mov    -0x8(%rbp),%rcx
movzwl 0x8(%rcx),%ecx
xor    %ecx,%eax
mov    %ax,-0x22(%rbp)
mov    -0x8(%rbp),%rax
movzwl 0x6(%rax),%edi
call   1050 <gf4096_inv@plt>
mov    -0x22(%rbp),%cx
movzwl %cx,%edi
movzwl %ax,%esi
call   1030 <gf4096_mul@plt>
mov    %ax,-0x1a(%rbp)
mov    -0x18(%rbp),%rdi
lea    -0x20(%rbp),%rsi
mov    $0x4,%edx
call   1040 <sort_coefs@plt>
mov    -0x20(%rbp),%cx
mov    -0x10(%rbp),%rax
mov    %cx,(%rax)
mov    -0x1e(%rbp),%cx
mov    -0x10(%rbp),%rax
mov    %cx,0x2(%rax)
mov    -0x1c(%rbp),%cx
mov    -0x10(%rbp),%rax
mov    %cx,0x4(%rax)
mov    -0x1a(%rbp),%cx
mov    -0x10(%rbp),%rax
mov    %cx,0x6(%rax)
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<solve_4x5>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rdx,0x8(%rsp)
mov    %rsi,0x10(%rsp)
mov    %rdi,%rbx
movzwl 0x26(%rdi),%ebp
movzwl 0x1e(%rdi),%edi
call   1050 <gf4096_inv@plt>
movzwl %ax,%esi
mov    %ebp,%edi
call   1030 <gf4096_mul@plt>
mov    %ax,(%rsp)
movzwl 0x14(%rbx),%esi
movzwl %ax,%r12d
mov    %r12d,%edi
call   1030 <gf4096_mul@plt>
mov    %eax,%ebp
xor    0x1c(%rbx),%bp
movzwl 0x16(%rbx),%edi
call   1050 <gf4096_inv@plt>
movzwl %bp,%edi
movzwl %ax,%esi
call   1030 <gf4096_mul@plt>
mov    %eax,%ebp
mov    %ax,0x2(%rsp)
movzwl 0xa(%rbx),%esi
mov    %r12d,%edi
call   1030 <gf4096_mul@plt>
mov    %eax,%r13d
movzwl 0xc(%rbx),%esi
movzwl %bp,%r15d
mov    %r15d,%edi
call   1030 <gf4096_mul@plt>
mov    %eax,%r14d
xor    %r13d,%r14d
xor    0x12(%rbx),%r14w
movzwl 0xe(%rbx),%edi
call   1050 <gf4096_inv@plt>
movzwl %r14w,%edi
movzwl %ax,%esi
call   1030 <gf4096_mul@plt>
mov    %eax,%r13d
mov    %ax,0x4(%rsp)
movzwl (%rbx),%esi
mov    %r12d,%edi
call   1030 <gf4096_mul@plt>
mov    %eax,%r14d
movzwl 0x2(%rbx),%esi
mov    %r15d,%edi
call   1030 <gf4096_mul@plt>
mov    %eax,%r15d
xor    %r14d,%r15d
movzwl 0x4(%rbx),%esi
movzwl %r13w,%edi
call   1030 <gf4096_mul@plt>
mov    %eax,%ebp
xor    %r15d,%ebp
xor    0x8(%rbx),%bp
movzwl 0x6(%rbx),%edi
call   1050 <gf4096_inv@plt>
movzwl %bp,%edi
movzwl %ax,%esi
call   1030 <gf4096_mul@plt>
mov    %ax,0x6(%rsp)
mov    %rsp,%rsi
mov    0x8(%rsp),%rdi
mov    $0x4,%edx
call   1040 <sort_coefs@plt>
movzwl (%rsp),%eax
mov    0x10(%rsp),%rcx
mov    %ax,(%rcx)
movzwl 0x2(%rsp),%eax
mov    %ax,0x2(%rcx)
movzwl 0x4(%rsp),%eax
mov    %ax,0x4(%rcx)
movzwl 0x6(%rsp),%eax
mov    %ax,0x6(%rcx)
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @solve_4x5([5 x i16]* %0, i16* %1, i32* %2) {
%4 = alloca [5 x i16]*
%5 = alloca i16*
%6 = alloca i32*
%7 = alloca [4 x i16]
store [5 x i16]* %0, [5 x i16]** %4
store i16* %1, i16** %5
store i32* %2, i32** %6
%8 = load [5 x i16]*, [5 x i16]** %4
%9 = getelementptr inbounds [5 x i16], [5 x i16]* %8, i64 3
%10 = getelementptr inbounds [5 x i16], [5 x i16]* %9, i64 0, i64 4
%11 = load i16, i16* %10
%12 = load [5 x i16]*, [5 x i16]** %4
%13 = getelementptr inbounds [5 x i16], [5 x i16]* %12, i64 3
%14 = getelementptr inbounds [5 x i16], [5 x i16]* %13, i64 0, i64 0
%15 = load i16, i16* %14
%16 = call zeroext i16 @gf4096_inv(i16 zeroext %15)
%17 = call zeroext i16 @gf4096_mul(i16 zeroext %11, i16 zeroext %16)
%18 = getelementptr inbounds [4 x i16], [4 x i16]* %7, i64 0, i64 0
store i16 %17, i16* %18
%19 = getelementptr inbounds [4 x i16], [4 x i16]* %7, i64 0, i64 0
%20 = load i16, i16* %19
%21 = load [5 x i16]*, [5 x i16]** %4
%22 = getelementptr inbounds [5 x i16], [5 x i16]* %21, i64 2
%23 = getelementptr inbounds [5 x i16], [5 x i16]* %22, i64 0, i64 0
%24 = load i16, i16* %23
%25 = call zeroext i16 @gf4096_mul(i16 zeroext %20, i16 zeroext %24)
%26 = zext i16 %25 to i32
%27 = load [5 x i16]*, [5 x i16]** %4
%28 = getelementptr inbounds [5 x i16], [5 x i16]* %27, i64 2
%29 = getelementptr inbounds [5 x i16], [5 x i16]* %28, i64 0, i64 4
%30 = load i16, i16* %29
%31 = zext i16 %30 to i32
%32 = xor i32 %26, %31
%33 = trunc i32 %32 to i16
%34 = load [5 x i16]*, [5 x i16]** %4
%35 = getelementptr inbounds [5 x i16], [5 x i16]* %34, i64 2
%36 = getelementptr inbounds [5 x i16], [5 x i16]* %35, i64 0, i64 1
%37 = load i16, i16* %36
%38 = call zeroext i16 @gf4096_inv(i16 zeroext %37)
%39 = call zeroext i16 @gf4096_mul(i16 zeroext %33, i16 zeroext %38)
%40 = getelementptr inbounds [4 x i16], [4 x i16]* %7, i64 0, i64 1
store i16 %39, i16* %40
%41 = getelementptr inbounds [4 x i16], [4 x i16]* %7, i64 0, i64 0
%42 = load i16, i16* %41
%43 = load [5 x i16]*, [5 x i16]** %4
%44 = getelementptr inbounds [5 x i16], [5 x i16]* %43, i64 1
%45 = getelementptr inbounds [5 x i16], [5 x i16]* %44, i64 0, i64 0
%46 = load i16, i16* %45
%47 = call zeroext i16 @gf4096_mul(i16 zeroext %42, i16 zeroext %46)
%48 = zext i16 %47 to i32
%49 = getelementptr inbounds [4 x i16], [4 x i16]* %7, i64 0, i64 1
%50 = load i16, i16* %49
%51 = load [5 x i16]*, [5 x i16]** %4
%52 = getelementptr inbounds [5 x i16], [5 x i16]* %51, i64 1
%53 = getelementptr inbounds [5 x i16], [5 x i16]* %52, i64 0, i64 1
%54 = load i16, i16* %53
%55 = call zeroext i16 @gf4096_mul(i16 zeroext %50, i16 zeroext %54)
%56 = zext i16 %55 to i32
%57 = xor i32 %48, %56
%58 = load [5 x i16]*, [5 x i16]** %4
%59 = getelementptr inbounds [5 x i16], [5 x i16]* %58, i64 1
%60 = getelementptr inbounds [5 x i16], [5 x i16]* %59, i64 0, i64 4
%61 = load i16, i16* %60
%62 = zext i16 %61 to i32
%63 = xor i32 %57, %62
%64 = trunc i32 %63 to i16
%65 = load [5 x i16]*, [5 x i16]** %4
%66 = getelementptr inbounds [5 x i16], [5 x i16]* %65, i64 1
%67 = getelementptr inbounds [5 x i16], [5 x i16]* %66, i64 0, i64 2
%68 = load i16, i16* %67
%69 = call zeroext i16 @gf4096_inv(i16 zeroext %68)
%70 = call zeroext i16 @gf4096_mul(i16 zeroext %64, i16 zeroext %69)
%71 = getelementptr inbounds [4 x i16], [4 x i16]* %7, i64 0, i64 2
store i16 %70, i16* %71
%72 = getelementptr inbounds [4 x i16], [4 x i16]* %7, i64 0, i64 0
%73 = load i16, i16* %72
%74 = load [5 x i16]*, [5 x i16]** %4
%75 = getelementptr inbounds [5 x i16], [5 x i16]* %74, i64 0
%76 = getelementptr inbounds [5 x i16], [5 x i16]* %75, i64 0, i64 0
%77 = load i16, i16* %76
%78 = call zeroext i16 @gf4096_mul(i16 zeroext %73, i16 zeroext %77)
%79 = zext i16 %78 to i32
%80 = getelementptr inbounds [4 x i16], [4 x i16]* %7, i64 0, i64 1
%81 = load i16, i16* %80
%82 = load [5 x i16]*, [5 x i16]** %4
%83 = getelementptr inbounds [5 x i16], [5 x i16]* %82, i64 0
%84 = getelementptr inbounds [5 x i16], [5 x i16]* %83, i64 0, i64 1
%85 = load i16, i16* %84
%86 = call zeroext i16 @gf4096_mul(i16 zeroext %81, i16 zeroext %85)
%87 = zext i16 %86 to i32
%88 = xor i32 %79, %87
%89 = getelementptr inbounds [4 x i16], [4 x i16]* %7, i64 0, i64 2
%90 = load i16, i16* %89
%91 = load [5 x i16]*, [5 x i16]** %4
%92 = getelementptr inbounds [5 x i16], [5 x i16]* %91, i64 0
%93 = getelementptr inbounds [5 x i16], [5 x i16]* %92, i64 0, i64 2
%94 = load i16, i16* %93
%95 = call zeroext i16 @gf4096_mul(i16 zeroext %90, i16 zeroext %94)
%96 = zext i16 %95 to i32
%97 = xor i32 %88, %96
%98 = load [5 x i16]*, [5 x i16]** %4
%99 = getelementptr inbounds [5 x i16], [5 x i16]* %98, i64 0
%100 = getelementptr inbounds [5 x i16], [5 x i16]* %99, i64 0, i64 4
%101 = load i16, i16* %100
%102 = zext i16 %101 to i32
%103 = xor i32 %97, %102
%104 = trunc i32 %103 to i16
%105 = load [5 x i16]*, [5 x i16]** %4
%106 = getelementptr inbounds [5 x i16], [5 x i16]* %105, i64 0
%107 = getelementptr inbounds [5 x i16], [5 x i16]* %106, i64 0, i64 3
%108 = load i16, i16* %107
%109 = call zeroext i16 @gf4096_inv(i16 zeroext %108)
%110 = call zeroext i16 @gf4096_mul(i16 zeroext %104, i16 zeroext %109)
%111 = getelementptr inbounds [4 x i16], [4 x i16]* %7, i64 0, i64 3
store i16 %110, i16* %111
%112 = load i32*, i32** %6
%113 = getelementptr inbounds [4 x i16], [4 x i16]* %7, i64 0, i64 0
%114 = call i32 @sort_coefs(i32* %112, i16* %113, i32 4)
%115 = getelementptr inbounds [4 x i16], [4 x i16]* %7, i64 0, i64 0
%116 = load i16, i16* %115
%117 = load i16*, i16** %5
%118 = getelementptr inbounds i16, i16* %117, i64 0
store i16 %116, i16* %118
%119 = getelementptr inbounds [4 x i16], [4 x i16]* %7, i64 0, i64 1
%120 = load i16, i16* %119
%121 = load i16*, i16** %5
%122 = getelementptr inbounds i16, i16* %121, i64 1
store i16 %120, i16* %122
%123 = getelementptr inbounds [4 x i16], [4 x i16]* %7, i64 0, i64 2
%124 = load i16, i16* %123
%125 = load i16*, i16** %5
%126 = getelementptr inbounds i16, i16* %125, i64 2
store i16 %124, i16* %126
%127 = getelementptr inbounds [4 x i16], [4 x i16]* %7, i64 0, i64 3
%128 = load i16, i16* %127
%129 = load i16*, i16** %5
%130 = getelementptr inbounds i16, i16* %129, i64 3
store i16 %128, i16* %130
ret void
}

LLVM IR (-O2):
define void @solve_4x5([5 x i16]* nocapture %0, i16* nocapture writeonly %1, i32* %2) {
%4 = alloca [4 x i16]
%5 = bitcast [4 x i16]* %4 to i8*
%6 = getelementptr inbounds [5 x i16], [5 x i16]* %0, i64 3, i64 4
%7 = load i16, i16* %6
%8 = getelementptr inbounds [5 x i16], [5 x i16]* %0, i64 3, i64 0
%9 = load i16, i16* %8
%10 = tail call zeroext i16 @gf4096_inv(i16 zeroext %9)
%11 = tail call zeroext i16 @gf4096_mul(i16 zeroext %7, i16 zeroext %10)
%12 = getelementptr inbounds [4 x i16], [4 x i16]* %4, i64 0, i64 0
store i16 %11, i16* %12
%13 = getelementptr inbounds [5 x i16], [5 x i16]* %0, i64 2, i64 0
%14 = load i16, i16* %13
%15 = tail call zeroext i16 @gf4096_mul(i16 zeroext %11, i16 zeroext %14)
%16 = getelementptr inbounds [5 x i16], [5 x i16]* %0, i64 2, i64 4
%17 = load i16, i16* %16
%18 = xor i16 %17, %15
%19 = getelementptr inbounds [5 x i16], [5 x i16]* %0, i64 2, i64 1
%20 = load i16, i16* %19
%21 = tail call zeroext i16 @gf4096_inv(i16 zeroext %20)
%22 = tail call zeroext i16 @gf4096_mul(i16 zeroext %18, i16 zeroext %21)
%23 = getelementptr inbounds [4 x i16], [4 x i16]* %4, i64 0, i64 1
store i16 %22, i16* %23
%24 = getelementptr inbounds [5 x i16], [5 x i16]* %0, i64 1, i64 0
%25 = load i16, i16* %24
%26 = tail call zeroext i16 @gf4096_mul(i16 zeroext %11, i16 zeroext %25)
%27 = getelementptr inbounds [5 x i16], [5 x i16]* %0, i64 1, i64 1
%28 = load i16, i16* %27
%29 = tail call zeroext i16 @gf4096_mul(i16 zeroext %22, i16 zeroext %28)
%30 = xor i16 %29, %26
%31 = getelementptr inbounds [5 x i16], [5 x i16]* %0, i64 1, i64 4
%32 = load i16, i16* %31
%33 = xor i16 %30, %32
%34 = getelementptr inbounds [5 x i16], [5 x i16]* %0, i64 1, i64 2
%35 = load i16, i16* %34
%36 = tail call zeroext i16 @gf4096_inv(i16 zeroext %35)
%37 = tail call zeroext i16 @gf4096_mul(i16 zeroext %33, i16 zeroext %36)
%38 = getelementptr inbounds [4 x i16], [4 x i16]* %4, i64 0, i64 2
store i16 %37, i16* %38
%39 = getelementptr inbounds [5 x i16], [5 x i16]* %0, i64 0, i64 0
%40 = load i16, i16* %39
%41 = tail call zeroext i16 @gf4096_mul(i16 zeroext %11, i16 zeroext %40)
%42 = getelementptr inbounds [5 x i16], [5 x i16]* %0, i64 0, i64 1
%43 = load i16, i16* %42
%44 = tail call zeroext i16 @gf4096_mul(i16 zeroext %22, i16 zeroext %43)
%45 = xor i16 %44, %41
%46 = getelementptr inbounds [5 x i16], [5 x i16]* %0, i64 0, i64 2
%47 = load i16, i16* %46
%48 = tail call zeroext i16 @gf4096_mul(i16 zeroext %37, i16 zeroext %47)
%49 = xor i16 %45, %48
%50 = getelementptr inbounds [5 x i16], [5 x i16]* %0, i64 0, i64 4
%51 = load i16, i16* %50
%52 = xor i16 %49, %51
%53 = getelementptr inbounds [5 x i16], [5 x i16]* %0, i64 0, i64 3
%54 = load i16, i16* %53
%55 = tail call zeroext i16 @gf4096_inv(i16 zeroext %54)
%56 = tail call zeroext i16 @gf4096_mul(i16 zeroext %52, i16 zeroext %55)
%57 = getelementptr inbounds [4 x i16], [4 x i16]* %4, i64 0, i64 3
store i16 %56, i16* %57
%58 = call i32 @sort_coefs(i32* %2, i16* %12, i32 4)
%59 = load i16, i16* %12
store i16 %59, i16* %1
%60 = load i16, i16* %23
%61 = getelementptr inbounds i16, i16* %1, i64 1
store i16 %60, i16* %61
%62 = load i16, i16* %38
%63 = getelementptr inbounds i16, i16* %1, i64 2
store i16 %62, i16* %63
%64 = load i16, i16* %57
%65 = getelementptr inbounds i16, i16* %1, i64 3
store i16 %64, i16* %65
ret void
}