#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 */
int /*<<< orphan*/ find_2x2_soln(unsigned short, unsigned short, unsigned short,
                                 unsigned short, unsigned short, unsigned short,
                                 unsigned short *);
unsigned short gf4096_mul(unsigned short, unsigned short);
void find_3bit_err_pats(unsigned short s0, unsigned short s1, unsigned short s2,
                        unsigned short r0, unsigned short r1, unsigned short r2,
                        unsigned short *pats) {
  find_2x2_soln(r0 ^ r2, r1 ^ r2, gf4096_mul(r0, r0 ^ r2),
                gf4096_mul(r1, r1 ^ r2), gf4096_mul(s0, r2) ^ s1,
                gf4096_mul(s1, r2) ^ s2, pats);
  pats[2] = s0 ^ pats[0] ^ pats[1];
}


x86 assembly (clang, -O0):
<find_3bit_err_pats>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %r8d,-0x28(%rbp)
mov    %ecx,%eax
mov    -0x28(%rbp),%ecx
mov    %eax,-0x24(%rbp)
mov    %edx,%eax
mov    -0x24(%rbp),%edx
mov    %eax,-0x20(%rbp)
mov    %esi,%eax
mov    -0x20(%rbp),%esi
mov    %eax,-0x1c(%rbp)
mov    %edi,%r8d
mov    -0x1c(%rbp),%edi
mov    %r9w,%ax
mov    0x10(%rbp),%r9
mov    %r8w,-0x2(%rbp)
mov    %di,-0x4(%rbp)
mov    %si,-0x6(%rbp)
mov    %dx,-0x8(%rbp)
mov    %cx,-0xa(%rbp)
mov    %ax,-0xc(%rbp)
movzwl -0x8(%rbp),%eax
movzwl -0xc(%rbp),%ecx
xor    %ecx,%eax
mov    %ax,-0x16(%rbp)
movzwl -0xa(%rbp),%eax
movzwl -0xc(%rbp),%ecx
xor    %ecx,%eax
mov    %ax,-0x14(%rbp)
mov    -0x8(%rbp),%cx
movzwl -0x8(%rbp),%eax
movzwl -0xc(%rbp),%edx
xor    %edx,%eax
movzwl %cx,%edi
movzwl %ax,%esi
call   1030 <gf4096_mul@plt>
mov    %ax,-0x12(%rbp)
mov    -0xa(%rbp),%cx
movzwl -0xa(%rbp),%eax
movzwl -0xc(%rbp),%edx
xor    %edx,%eax
movzwl %cx,%edi
movzwl %ax,%esi
call   1030 <gf4096_mul@plt>
mov    %ax,-0x10(%rbp)
mov    -0x2(%rbp),%ax
movzwl %ax,%edi
movzwl -0xc(%rbp),%esi
call   1030 <gf4096_mul@plt>
movzwl %ax,%eax
movzwl -0x4(%rbp),%ecx
xor    %ecx,%eax
mov    %ax,-0xe(%rbp)
mov    -0x4(%rbp),%ax
movzwl %ax,%edi
movzwl -0xc(%rbp),%esi
call   1030 <gf4096_mul@plt>
mov    -0x16(%rbp),%di
mov    -0x14(%rbp),%si
mov    -0x12(%rbp),%dx
mov    -0x10(%rbp),%cx
mov    -0xe(%rbp),%r8w
movzwl %ax,%eax
movzwl -0x6(%rbp),%r9d
xor    %r9d,%eax
mov    %ax,%r9w
mov    0x10(%rbp),%rax
movzwl %di,%edi
movzwl %si,%esi
movzwl %dx,%edx
movzwl %cx,%ecx
movzwl %r8w,%r8d
movzwl %r9w,%r9d
mov    %rax,(%rsp)
call   1040 <find_2x2_soln@plt>
movzwl -0x2(%rbp),%eax
mov    0x10(%rbp),%rcx
movzwl (%rcx),%ecx
xor    %ecx,%eax
mov    0x10(%rbp),%rcx
movzwl 0x2(%rcx),%ecx
xor    %ecx,%eax
mov    %ax,%cx
mov    0x10(%rbp),%rax
mov    %cx,0x4(%rax)
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<find_3bit_err_pats>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %r9d,%ebp
mov    %r8d,%r13d
mov    %edx,0x14(%rsp)
mov    %esi,%r15d
mov    %edi,%r14d
mov    %edi,0x10(%rsp)
mov    %r9d,%r12d
xor    %ecx,%r12d
mov    %r9d,%ebx
xor    %r8d,%ebx
mov    %ecx,%edi
mov    %r12d,%esi
call   1030 <gf4096_mul@plt>
mov    %ax,0xe(%rsp)
mov    %r13d,%edi
mov    %ebx,%esi
call   1030 <gf4096_mul@plt>
mov    %eax,%r13d
mov    %r14d,%edi
mov    %ebp,%esi
call   1030 <gf4096_mul@plt>
mov    %eax,%r14d
xor    %r15d,%r14d
mov    %r15d,%edi
mov    %ebp,%esi
call   1030 <gf4096_mul@plt>
xor    0x14(%rsp),%eax
mov    0x50(%rsp),%rbp
mov    %rbp,(%rsp)
movzwl 0xe(%rsp),%edx
movzwl %r13w,%ecx
movzwl %r14w,%r8d
movzwl %ax,%r9d
mov    %r12d,%edi
mov    %ebx,%esi
call   1040 <find_2x2_soln@plt>
movzwl 0x0(%rbp),%eax
xor    0x10(%rsp),%ax
xor    0x2(%rbp),%ax
mov    %ax,0x4(%rbp)
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
define void @find_3bit_err_pats(i16 zeroext %0, i16 zeroext %1, i16 zeroext %2, i16 zeroext %3, i16 zeroext %4, i16 zeroext %5, i16* %6) {
%8 = xor i16 %5, %3
%9 = xor i16 %5, %4
%10 = tail call zeroext i16 @gf4096_mul(i16 zeroext %3, i16 zeroext %8)
%11 = tail call zeroext i16 @gf4096_mul(i16 zeroext %4, i16 zeroext %9)
%12 = tail call zeroext i16 @gf4096_mul(i16 zeroext %0, i16 zeroext %5)
%13 = xor i16 %12, %1
%14 = tail call zeroext i16 @gf4096_mul(i16 zeroext %1, i16 zeroext %5)
%15 = xor i16 %14, %2
%16 = tail call i32 @find_2x2_soln(i16 zeroext %8, i16 zeroext %9, i16 zeroext %10, i16 zeroext %11, i16 zeroext %13, i16 zeroext %15, i16* %6)
%17 = load i16, i16* %6
%18 = xor i16 %17, %0
%19 = getelementptr inbounds i16, i16* %6, i64 1
%20 = load i16, i16* %19
%21 = xor i16 %18, %20
%22 = getelementptr inbounds i16, i16* %6, i64 2
store i16 %21, i16* %22
ret void
}