#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 EINVAL;
int err_pos(unsigned short);
int /*<<< orphan*/ find_4bit_err_coefs(unsigned short, unsigned short,
                                       unsigned short, unsigned short,
                                       unsigned short, unsigned short,
                                       unsigned short, unsigned short,
                                       unsigned short *);
int /*<<< orphan*/ find_4bit_err_pats(unsigned short, unsigned short,
                                      unsigned short, unsigned short,
                                      unsigned short, unsigned short,
                                      unsigned short, unsigned short,
                                      unsigned short *);
unsigned short gf4096_inv(unsigned short);
int gf4096_mul(unsigned short, unsigned short);
int chk_4_err_only(unsigned short *chk_syndrome_list,
                   unsigned short *err_info) {
  unsigned short coefs[4];
  unsigned short err_pats[4];
  int found_num_root = 0;
  unsigned short bit4_root0, bit4_root1, bit4_root2, bit4_root3;
  unsigned short bit4_root0_inv, bit4_root1_inv, bit4_root2_inv, bit4_root3_inv;
  unsigned short err_loc_eqn, test_root;
  find_4bit_err_coefs(chk_syndrome_list[0], chk_syndrome_list[1],
                      chk_syndrome_list[2], chk_syndrome_list[3],
                      chk_syndrome_list[4], chk_syndrome_list[5],
                      chk_syndrome_list[6], chk_syndrome_list[7], coefs);
  for (test_root = 0x1; test_root < 0xfff; test_root++) {
    err_loc_eqn =
        gf4096_mul(
            coefs[3],
            gf4096_mul(gf4096_mul(gf4096_mul(test_root, test_root), test_root),
                       test_root)) ^
        gf4096_mul(coefs[2],
                   gf4096_mul(gf4096_mul(test_root, test_root), test_root)) ^
        gf4096_mul(coefs[1], gf4096_mul(test_root, test_root)) ^
        gf4096_mul(coefs[0], test_root) ^ 0x1;
    if (err_loc_eqn == 0x0) {
      if (found_num_root == 0) {
        bit4_root0 = test_root;
        found_num_root = 1;
      } else if (found_num_root == 1) {
        bit4_root1 = test_root;
        found_num_root = 2;
      } else if (found_num_root == 2) {
        bit4_root2 = test_root;
        found_num_root = 3;
      } else {
        found_num_root = 4;
        bit4_root3 = test_root;
        break;
      }
    }
  }
  if (found_num_root != 4) {
    return -EINVAL;
  } else {
    bit4_root0_inv = gf4096_inv(bit4_root0);
    bit4_root1_inv = gf4096_inv(bit4_root1);
    bit4_root2_inv = gf4096_inv(bit4_root2);
    bit4_root3_inv = gf4096_inv(bit4_root3);
    find_4bit_err_pats(chk_syndrome_list[0], chk_syndrome_list[1],
                       chk_syndrome_list[2], chk_syndrome_list[3],
                       bit4_root0_inv, bit4_root1_inv, bit4_root2_inv,
                       bit4_root3_inv, err_pats);
    err_info[0] = 0x4;
    err_info[1] = (0x55e - err_pos(bit4_root0_inv));
    err_info[2] = (0x55e - err_pos(bit4_root1_inv));
    err_info[3] = (0x55e - err_pos(bit4_root2_inv));
    err_info[4] = (0x55e - err_pos(bit4_root3_inv));
    err_info[5] = err_pats[0];
    err_info[6] = err_pats[1];
    err_info[7] = err_pats[2];
    err_info[8] = err_pats[3];
    return 0;
  }
}


x86 assembly (clang, -O0):
<chk_4_err_only>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
movl   $0x0,-0x2c(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%di
mov    -0x10(%rbp),%rax
mov    0x2(%rax),%si
mov    -0x10(%rbp),%rax
mov    0x4(%rax),%dx
mov    -0x10(%rbp),%rax
mov    0x6(%rax),%cx
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%r8w
mov    -0x10(%rbp),%rax
mov    0xa(%rax),%r9w
mov    -0x10(%rbp),%rax
mov    0xc(%rax),%r11w
mov    -0x10(%rbp),%rax
mov    0xe(%rax),%r10w
lea    -0x20(%rbp),%rax
movzwl %di,%edi
movzwl %si,%esi
movzwl %dx,%edx
movzwl %cx,%ecx
movzwl %r8w,%r8d
movzwl %r9w,%r9d
movzwl %r11w,%r11d
mov    %r11d,(%rsp)
movzwl %r10w,%r10d
mov    %r10d,0x8(%rsp)
mov    %rax,0x10(%rsp)
call   1070 <find_4bit_err_coefs@plt>
movw   $0x1,-0x40(%rbp)
movzwl -0x40(%rbp),%eax
cmp    $0xfff,%eax
jge    1360 <chk_4_err_only+0x210>
mov    -0x1a(%rbp),%ax
mov    %ax,-0x54(%rbp)
mov    -0x40(%rbp),%ax
movzwl %ax,%edi
movzwl -0x40(%rbp),%esi
call   1040 <gf4096_mul@plt>
movzwl %ax,%edi
movzwl -0x40(%rbp),%esi
call   1040 <gf4096_mul@plt>
movzwl %ax,%edi
movzwl -0x40(%rbp),%esi
call   1040 <gf4096_mul@plt>
mov    -0x54(%rbp),%cx
movzwl %cx,%edi
movzwl %ax,%esi
call   1040 <gf4096_mul@plt>
mov    %eax,-0x50(%rbp)
mov    -0x1c(%rbp),%ax
mov    %ax,-0x52(%rbp)
mov    -0x40(%rbp),%ax
movzwl %ax,%edi
movzwl -0x40(%rbp),%esi
call   1040 <gf4096_mul@plt>
movzwl %ax,%edi
movzwl -0x40(%rbp),%esi
call   1040 <gf4096_mul@plt>
mov    -0x52(%rbp),%cx
movzwl %cx,%edi
movzwl %ax,%esi
call   1040 <gf4096_mul@plt>
mov    %eax,%ecx
mov    -0x50(%rbp),%eax
xor    %ecx,%eax
mov    %eax,-0x48(%rbp)
mov    -0x1e(%rbp),%ax
mov    %ax,-0x4a(%rbp)
mov    -0x40(%rbp),%ax
movzwl %ax,%edi
movzwl -0x40(%rbp),%esi
call   1040 <gf4096_mul@plt>
mov    -0x4a(%rbp),%cx
movzwl %cx,%edi
movzwl %ax,%esi
call   1040 <gf4096_mul@plt>
mov    %eax,%ecx
mov    -0x48(%rbp),%eax
xor    %ecx,%eax
mov    %eax,-0x44(%rbp)
mov    -0x20(%rbp),%ax
movzwl %ax,%edi
movzwl -0x40(%rbp),%esi
call   1040 <gf4096_mul@plt>
mov    %eax,%ecx
mov    -0x44(%rbp),%eax
xor    %ecx,%eax
xor    $0x1,%eax
mov    %ax,-0x3e(%rbp)
movzwl -0x3e(%rbp),%eax
cmp    $0x0,%eax
jne    134a <chk_4_err_only+0x1fa>
cmpl   $0x0,-0x2c(%rbp)
jne    12eb <chk_4_err_only+0x19b>
mov    -0x40(%rbp),%ax
mov    %ax,-0x2e(%rbp)
movl   $0x1,-0x2c(%rbp)
jmp    1345 <chk_4_err_only+0x1f5>
cmpl   $0x1,-0x2c(%rbp)
jne    1309 <chk_4_err_only+0x1b9>
mov    -0x40(%rbp),%ax
mov    %ax,-0x30(%rbp)
movl   $0x2,-0x2c(%rbp)
jmp    1340 <chk_4_err_only+0x1f0>
cmpl   $0x2,-0x2c(%rbp)
jne    1327 <chk_4_err_only+0x1d7>
mov    -0x40(%rbp),%ax
mov    %ax,-0x32(%rbp)
movl   $0x3,-0x2c(%rbp)
jmp    133b <chk_4_err_only+0x1eb>
movl   $0x4,-0x2c(%rbp)
mov    -0x40(%rbp),%ax
mov    %ax,-0x34(%rbp)
jmp    1360 <chk_4_err_only+0x210>
jmp    1340 <chk_4_err_only+0x1f0>
jmp    1345 <chk_4_err_only+0x1f5>
jmp    134a <chk_4_err_only+0x1fa>
jmp    134f <chk_4_err_only+0x1ff>
mov    -0x40(%rbp),%ax
add    $0x1,%ax
mov    %ax,-0x40(%rbp)
jmp    11e3 <chk_4_err_only+0x93>
cmpl   $0x4,-0x2c(%rbp)
je     137d <chk_4_err_only+0x22d>
xor    %eax,%eax
mov    0x2c6d(%rip),%rcx
sub    (%rcx),%eax
mov    %eax,-0x4(%rbp)
jmp    14cb <chk_4_err_only+0x37b>
movzwl -0x2e(%rbp),%edi
call   1050 <gf4096_inv@plt>
mov    %ax,-0x36(%rbp)
movzwl -0x30(%rbp),%edi
call   1050 <gf4096_inv@plt>
mov    %ax,-0x38(%rbp)
movzwl -0x32(%rbp),%edi
call   1050 <gf4096_inv@plt>
mov    %ax,-0x3a(%rbp)
movzwl -0x34(%rbp),%edi
call   1050 <gf4096_inv@plt>
mov    %ax,-0x3c(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%di
mov    -0x10(%rbp),%rax
mov    0x2(%rax),%si
mov    -0x10(%rbp),%rax
mov    0x4(%rax),%dx
mov    -0x10(%rbp),%rax
mov    0x6(%rax),%cx
mov    -0x36(%rbp),%r8w
mov    -0x38(%rbp),%r9w
mov    -0x3a(%rbp),%r11w
mov    -0x3c(%rbp),%r10w
lea    -0x28(%rbp),%rax
movzwl %di,%edi
movzwl %si,%esi
movzwl %dx,%edx
movzwl %cx,%ecx
movzwl %r8w,%r8d
movzwl %r9w,%r9d
movzwl %r11w,%r11d
mov    %r11d,(%rsp)
movzwl %r10w,%r10d
mov    %r10d,0x8(%rsp)
mov    %rax,0x10(%rsp)
call   1060 <find_4bit_err_pats@plt>
mov    -0x18(%rbp),%rax
movw   $0x4,(%rax)
movzwl -0x36(%rbp),%edi
call   1030 <err_pos@plt>
mov    %eax,%ecx
mov    $0x55e,%eax
sub    %ecx,%eax
mov    %ax,%cx
mov    -0x18(%rbp),%rax
mov    %cx,0x2(%rax)
movzwl -0x38(%rbp),%edi
call   1030 <err_pos@plt>
mov    %eax,%ecx
mov    $0x55e,%eax
sub    %ecx,%eax
mov    %ax,%cx
mov    -0x18(%rbp),%rax
mov    %cx,0x4(%rax)
movzwl -0x3a(%rbp),%edi
call   1030 <err_pos@plt>
mov    %eax,%ecx
mov    $0x55e,%eax
sub    %ecx,%eax
mov    %ax,%cx
mov    -0x18(%rbp),%rax
mov    %cx,0x6(%rax)
movzwl -0x3c(%rbp),%edi
call   1030 <err_pos@plt>
mov    %eax,%ecx
mov    $0x55e,%eax
sub    %ecx,%eax
mov    %ax,%cx
mov    -0x18(%rbp),%rax
mov    %cx,0x8(%rax)
mov    -0x28(%rbp),%cx
mov    -0x18(%rbp),%rax
mov    %cx,0xa(%rax)
mov    -0x26(%rbp),%cx
mov    -0x18(%rbp),%rax
mov    %cx,0xc(%rax)
mov    -0x24(%rbp),%cx
mov    -0x18(%rbp),%rax
mov    %cx,0xe(%rax)
mov    -0x22(%rbp),%cx
mov    -0x18(%rbp),%rax
mov    %cx,0x10(%rax)
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<chk_4_err_only>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %rsi,0x20(%rsp)
mov    %rdi,%rbp
movzwl (%rdi),%edi
movzwl 0x2(%rbp),%esi
movzwl 0x4(%rbp),%edx
movzwl 0x6(%rbp),%ecx
movzwl 0x8(%rbp),%r8d
movzwl 0xa(%rbp),%r9d
movzwl 0xc(%rbp),%eax
mov    %rbp,0x18(%rsp)
movzwl 0xe(%rbp),%ebp
sub    $0x8,%rsp
lea    0x18(%rsp),%rbx
push   %rbx
push   %rbp
push   %rax
call   1070 <find_4bit_err_coefs@plt>
add    $0x20,%rsp
xor    %r15d,%r15d
mov    $0x1,%r14w
jmp    11d3 <chk_4_err_only+0x83>
mov    $0x3,%r15d
mov    %r14d,%eax
mov    %r14w,0x6(%rsp)
nopw   0x0(%rax,%rax,1)
add    $0x1,%r14d
movzwl %r14w,%eax
cmp    $0xfff,%eax
je     12a0 <chk_4_err_only+0x150>
movzwl 0x16(%rsp),%ebx
movzwl %r14w,%ebp
mov    %ebp,%edi
mov    %ebp,%esi
call   1040 <gf4096_mul@plt>
movzwl %ax,%edi
mov    %ebp,%esi
call   1040 <gf4096_mul@plt>
movzwl %ax,%edi
mov    %ebp,%esi
call   1040 <gf4096_mul@plt>
movzwl %ax,%esi
mov    %ebx,%edi
call   1040 <gf4096_mul@plt>
mov    %eax,%r12d
movzwl 0x14(%rsp),%ebx
mov    %ebp,%edi
mov    %ebp,%esi
call   1040 <gf4096_mul@plt>
movzwl %ax,%edi
mov    %ebp,%esi
call   1040 <gf4096_mul@plt>
movzwl %ax,%esi
mov    %ebx,%edi
call   1040 <gf4096_mul@plt>
mov    %eax,%r13d
movzwl 0x12(%rsp),%ebx
mov    %ebp,%edi
mov    %ebp,%esi
call   1040 <gf4096_mul@plt>
movzwl %ax,%esi
mov    %ebx,%edi
call   1040 <gf4096_mul@plt>
mov    %eax,%ebx
xor    %r13d,%ebx
movzwl 0x10(%rsp),%edi
mov    %ebp,%esi
call   1040 <gf4096_mul@plt>
xor    %ebx,%eax
xor    %r12d,%eax
cmp    $0x1,%ax
jne    11c0 <chk_4_err_only+0x70>
cmp    $0x2,%r15d
je     11ab <chk_4_err_only+0x5b>
cmp    $0x1,%r15d
je     128c <chk_4_err_only+0x13c>
test   %r15d,%r15d
jne    12af <chk_4_err_only+0x15f>
mov    $0x1,%r15d
mov    %r14d,%eax
mov    %r14w,0x2(%rsp)
jmp    11c0 <chk_4_err_only+0x70>
mov    $0x2,%r15d
mov    %r14d,%eax
mov    %r14w,0x4(%rsp)
jmp    11c0 <chk_4_err_only+0x70>
mov    $0xfff,%r14w
cmp    $0x4,%r15d
jne    139e <chk_4_err_only+0x24e>
movzwl 0x2(%rsp),%edi
call   1050 <gf4096_inv@plt>
mov    %eax,%r12d
movzwl 0x4(%rsp),%edi
call   1050 <gf4096_inv@plt>
mov    %eax,%r13d
movzwl 0x6(%rsp),%edi
call   1050 <gf4096_inv@plt>
mov    %eax,%ebp
movzwl %r14w,%edi
call   1050 <gf4096_inv@plt>
mov    0x18(%rsp),%rcx
movzwl (%rcx),%edi
movzwl 0x2(%rcx),%esi
movzwl 0x4(%rcx),%edx
movzwl 0x6(%rcx),%ecx
sub    $0x8,%rsp
lea    0x10(%rsp),%r10
movzwl %ax,%r15d
movzwl %bp,%r14d
movzwl %r12w,%ebx
movzwl %r13w,%r12d
mov    %ebx,%r8d
mov    %r12d,%r9d
push   %r10
push   %r15
push   %r14
call   1060 <find_4bit_err_pats@plt>
add    $0x20,%rsp
mov    0x20(%rsp),%rbp
movw   $0x4,0x0(%rbp)
mov    %ebx,%edi
call   1030 <err_pos@plt>
mov    $0x55e,%ebx
mov    $0x55e,%ecx
sub    %eax,%ecx
mov    %cx,0x2(%rbp)
mov    %r12d,%edi
call   1030 <err_pos@plt>
mov    $0x55e,%ecx
sub    %eax,%ecx
mov    %cx,0x4(%rbp)
mov    %r14d,%edi
call   1030 <err_pos@plt>
mov    $0x55e,%ecx
sub    %eax,%ecx
mov    %cx,0x6(%rbp)
mov    %r15d,%edi
call   1030 <err_pos@plt>
sub    %eax,%ebx
mov    %bx,0x8(%rbp)
movzwl 0x8(%rsp),%eax
mov    %ax,0xa(%rbp)
movzwl 0xa(%rsp),%eax
mov    %ax,0xc(%rbp)
movzwl 0xc(%rsp),%eax
mov    %ax,0xe(%rbp)
movzwl 0xe(%rsp),%eax
mov    %ax,0x10(%rbp)
xor    %eax,%eax
jmp    13a9 <chk_4_err_only+0x259>
mov    0x2c3b(%rip),%rcx
xor    %eax,%eax
sub    (%rcx),%eax
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@EINVAL = global i32 0
define i32 @chk_4_err_only(i16* %0, i16* %1) {
%3 = alloca i32
%4 = alloca i16*
%5 = alloca i16*
%6 = alloca [4 x i16]
%7 = alloca [4 x i16]
%8 = alloca i32
%9 = alloca i16
%10 = alloca i16
%11 = alloca i16
%12 = alloca i16
%13 = alloca i16
%14 = alloca i16
%15 = alloca i16
%16 = alloca i16
%17 = alloca i16
%18 = alloca i16
store i16* %0, i16** %4
store i16* %1, i16** %5
store i32 0, i32* %8
%19 = load i16*, i16** %4
%20 = getelementptr inbounds i16, i16* %19, i64 0
%21 = load i16, i16* %20
%22 = load i16*, i16** %4
%23 = getelementptr inbounds i16, i16* %22, i64 1
%24 = load i16, i16* %23
%25 = load i16*, i16** %4
%26 = getelementptr inbounds i16, i16* %25, i64 2
%27 = load i16, i16* %26
%28 = load i16*, i16** %4
%29 = getelementptr inbounds i16, i16* %28, i64 3
%30 = load i16, i16* %29
%31 = load i16*, i16** %4
%32 = getelementptr inbounds i16, i16* %31, i64 4
%33 = load i16, i16* %32
%34 = load i16*, i16** %4
%35 = getelementptr inbounds i16, i16* %34, i64 5
%36 = load i16, i16* %35
%37 = load i16*, i16** %4
%38 = getelementptr inbounds i16, i16* %37, i64 6
%39 = load i16, i16* %38
%40 = load i16*, i16** %4
%41 = getelementptr inbounds i16, i16* %40, i64 7
%42 = load i16, i16* %41
%43 = getelementptr inbounds [4 x i16], [4 x i16]* %6, i64 0, i64 0
%44 = call i32 @find_4bit_err_coefs(i16 zeroext %21, i16 zeroext %24, i16 zeroext %27, i16 zeroext %30, i16 zeroext %33, i16 zeroext %36, i16 zeroext %39, i16 zeroext %42, i16* %43)
store i16 1, i16* %18
br label %45
45: ; preds = %113, %2
%46 = load i16, i16* %18
%47 = zext i16 %46 to i32
%48 = icmp slt i32 %47, 4095
br i1 %48, label %49, label %116
49: ; preds = %45
%50 = getelementptr inbounds [4 x i16], [4 x i16]* %6, i64 0, i64 3
%51 = load i16, i16* %50
%52 = load i16, i16* %18
%53 = load i16, i16* %18
%54 = call i32 @gf4096_mul(i16 zeroext %52, i16 zeroext %53)
%55 = trunc i32 %54 to i16
%56 = load i16, i16* %18
%57 = call i32 @gf4096_mul(i16 zeroext %55, i16 zeroext %56)
%58 = trunc i32 %57 to i16
%59 = load i16, i16* %18
%60 = call i32 @gf4096_mul(i16 zeroext %58, i16 zeroext %59)
%61 = trunc i32 %60 to i16
%62 = call i32 @gf4096_mul(i16 zeroext %51, i16 zeroext %61)
%63 = getelementptr inbounds [4 x i16], [4 x i16]* %6, i64 0, i64 2
%64 = load i16, i16* %63
%65 = load i16, i16* %18
%66 = load i16, i16* %18
%67 = call i32 @gf4096_mul(i16 zeroext %65, i16 zeroext %66)
%68 = trunc i32 %67 to i16
%69 = load i16, i16* %18
%70 = call i32 @gf4096_mul(i16 zeroext %68, i16 zeroext %69)
%71 = trunc i32 %70 to i16
%72 = call i32 @gf4096_mul(i16 zeroext %64, i16 zeroext %71)
%73 = xor i32 %62, %72
%74 = getelementptr inbounds [4 x i16], [4 x i16]* %6, i64 0, i64 1
%75 = load i16, i16* %74
%76 = load i16, i16* %18
%77 = load i16, i16* %18
%78 = call i32 @gf4096_mul(i16 zeroext %76, i16 zeroext %77)
%79 = trunc i32 %78 to i16
%80 = call i32 @gf4096_mul(i16 zeroext %75, i16 zeroext %79)
%81 = xor i32 %73, %80
%82 = getelementptr inbounds [4 x i16], [4 x i16]* %6, i64 0, i64 0
%83 = load i16, i16* %82
%84 = load i16, i16* %18
%85 = call i32 @gf4096_mul(i16 zeroext %83, i16 zeroext %84)
%86 = xor i32 %81, %85
%87 = xor i32 %86, 1
%88 = trunc i32 %87 to i16
store i16 %88, i16* %17
%89 = load i16, i16* %17
%90 = zext i16 %89 to i32
%91 = icmp eq i32 %90, 0
br i1 %91, label %92, label %112
92: ; preds = %49
%93 = load i32, i32* %8
%94 = icmp eq i32 %93, 0
br i1 %94, label %95, label %97
95: ; preds = %92
%96 = load i16, i16* %18
store i16 %96, i16* %9
store i32 1, i32* %8
br label %111
97: ; preds = %92
%98 = load i32, i32* %8
%99 = icmp eq i32 %98, 1
br i1 %99, label %100, label %102
100: ; preds = %97
%101 = load i16, i16* %18
store i16 %101, i16* %10
store i32 2, i32* %8
br label %110
102: ; preds = %97
%103 = load i32, i32* %8
%104 = icmp eq i32 %103, 2
br i1 %104, label %105, label %107
105: ; preds = %102
%106 = load i16, i16* %18
store i16 %106, i16* %11
store i32 3, i32* %8
br label %109
107: ; preds = %102
store i32 4, i32* %8
%108 = load i16, i16* %18
store i16 %108, i16* %12
br label %116
109: ; preds = %105
br label %110
110: ; preds = %109, %100
br label %111
111: ; preds = %110, %95
br label %112
112: ; preds = %111, %49
br label %113
113: ; preds = %112
%114 = load i16, i16* %18
%115 = add i16 %114, 1
store i16 %115, i16* %18
br label %45
116: ; preds = %107, %45
%117 = load i32, i32* %8
%118 = icmp ne i32 %117, 4
br i1 %118, label %119, label %122
119: ; preds = %116
%120 = load i32, i32* @EINVAL
%121 = sub nsw i32 0, %120
store i32 %121, i32* %3
br label %191
122: ; preds = %116
%123 = load i16, i16* %9
%124 = call zeroext i16 @gf4096_inv(i16 zeroext %123)
store i16 %124, i16* %13
%125 = load i16, i16* %10
%126 = call zeroext i16 @gf4096_inv(i16 zeroext %125)
store i16 %126, i16* %14
%127 = load i16, i16* %11
%128 = call zeroext i16 @gf4096_inv(i16 zeroext %127)
store i16 %128, i16* %15
%129 = load i16, i16* %12
%130 = call zeroext i16 @gf4096_inv(i16 zeroext %129)
store i16 %130, i16* %16
%131 = load i16*, i16** %4
%132 = getelementptr inbounds i16, i16* %131, i64 0
%133 = load i16, i16* %132
%134 = load i16*, i16** %4
%135 = getelementptr inbounds i16, i16* %134, i64 1
%136 = load i16, i16* %135
%137 = load i16*, i16** %4
%138 = getelementptr inbounds i16, i16* %137, i64 2
%139 = load i16, i16* %138
%140 = load i16*, i16** %4
%141 = getelementptr inbounds i16, i16* %140, i64 3
%142 = load i16, i16* %141
%143 = load i16, i16* %13
%144 = load i16, i16* %14
%145 = load i16, i16* %15
%146 = load i16, i16* %16
%147 = getelementptr inbounds [4 x i16], [4 x i16]* %7, i64 0, i64 0
%148 = call i32 @find_4bit_err_pats(i16 zeroext %133, i16 zeroext %136, i16 zeroext %139, i16 zeroext %142, i16 zeroext %143, i16 zeroext %144, i16 zeroext %145, i16 zeroext %146, i16* %147)
%149 = load i16*, i16** %5
%150 = getelementptr inbounds i16, i16* %149, i64 0
store i16 4, i16* %150
%151 = load i16, i16* %13
%152 = call i32 @err_pos(i16 zeroext %151)
%153 = sub nsw i32 1374, %152
%154 = trunc i32 %153 to i16
%155 = load i16*, i16** %5
%156 = getelementptr inbounds i16, i16* %155, i64 1
store i16 %154, i16* %156
%157 = load i16, i16* %14
%158 = call i32 @err_pos(i16 zeroext %157)
%159 = sub nsw i32 1374, %158
%160 = trunc i32 %159 to i16
%161 = load i16*, i16** %5
%162 = getelementptr inbounds i16, i16* %161, i64 2
store i16 %160, i16* %162
%163 = load i16, i16* %15
%164 = call i32 @err_pos(i16 zeroext %163)
%165 = sub nsw i32 1374, %164
%166 = trunc i32 %165 to i16
%167 = load i16*, i16** %5
%168 = getelementptr inbounds i16, i16* %167, i64 3
store i16 %166, i16* %168
%169 = load i16, i16* %16
%170 = call i32 @err_pos(i16 zeroext %169)
%171 = sub nsw i32 1374, %170
%172 = trunc i32 %171 to i16
%173 = load i16*, i16** %5
%174 = getelementptr inbounds i16, i16* %173, i64 4
store i16 %172, i16* %174
%175 = getelementptr inbounds [4 x i16], [4 x i16]* %7, i64 0, i64 0
%176 = load i16, i16* %175
%177 = load i16*, i16** %5
%178 = getelementptr inbounds i16, i16* %177, i64 5
store i16 %176, i16* %178
%179 = getelementptr inbounds [4 x i16], [4 x i16]* %7, i64 0, i64 1
%180 = load i16, i16* %179
%181 = load i16*, i16** %5
%182 = getelementptr inbounds i16, i16* %181, i64 6
store i16 %180, i16* %182
%183 = getelementptr inbounds [4 x i16], [4 x i16]* %7, i64 0, i64 2
%184 = load i16, i16* %183
%185 = load i16*, i16** %5
%186 = getelementptr inbounds i16, i16* %185, i64 7
store i16 %184, i16* %186
%187 = getelementptr inbounds [4 x i16], [4 x i16]* %7, i64 0, i64 3
%188 = load i16, i16* %187
%189 = load i16*, i16** %5
%190 = getelementptr inbounds i16, i16* %189, i64 8
store i16 %188, i16* %190
store i32 0, i32* %3
br label %191
191: ; preds = %122, %119
%192 = load i32, i32* %3
ret i32 %192
}

LLVM IR (-O2):
@EINVAL = global i32 0
define i32 @chk_4_err_only(i16* nocapture %0, i16* nocapture writeonly %1) {
%3 = alloca [4 x i16]
%4 = alloca [4 x i16]
%5 = bitcast [4 x i16]* %3 to i8*
%6 = bitcast [4 x i16]* %4 to i8*
%7 = load i16, i16* %0
%8 = getelementptr inbounds i16, i16* %0, i64 1
%9 = load i16, i16* %8
%10 = getelementptr inbounds i16, i16* %0, i64 2
%11 = load i16, i16* %10
%12 = getelementptr inbounds i16, i16* %0, i64 3
%13 = load i16, i16* %12
%14 = getelementptr inbounds i16, i16* %0, i64 4
%15 = load i16, i16* %14
%16 = getelementptr inbounds i16, i16* %0, i64 5
%17 = load i16, i16* %16
%18 = getelementptr inbounds i16, i16* %0, i64 6
%19 = load i16, i16* %18
%20 = getelementptr inbounds i16, i16* %0, i64 7
%21 = load i16, i16* %20
%22 = getelementptr inbounds [4 x i16], [4 x i16]* %3, i64 0, i64 0
%23 = call i32 @find_4bit_err_coefs(i16 zeroext %7, i16 zeroext %9, i16 zeroext %11, i16 zeroext %13, i16 zeroext %15, i16 zeroext %17, i16 zeroext %19, i16 zeroext %21, i16* %22)
%24 = getelementptr inbounds [4 x i16], [4 x i16]* %3, i64 0, i64 3
%25 = getelementptr inbounds [4 x i16], [4 x i16]* %3, i64 0, i64 2
%26 = getelementptr inbounds [4 x i16], [4 x i16]* %3, i64 0, i64 1
br label %27
27: ; preds = %2, %61
%28 = phi i16 [ 1, %2 ], [ %66, %61 ]
%29 = phi i32 [ 0, %2 ], [ %65, %61 ]
%30 = phi i16 [ undef, %2 ], [ %64, %61 ]
%31 = phi i16 [ undef, %2 ], [ %63, %61 ]
%32 = phi i16 [ undef, %2 ], [ %62, %61 ]
%33 = load i16, i16* %24
%34 = call i32 @gf4096_mul(i16 zeroext %28, i16 zeroext %28)
%35 = trunc i32 %34 to i16
%36 = call i32 @gf4096_mul(i16 zeroext %35, i16 zeroext %28)
%37 = trunc i32 %36 to i16
%38 = call i32 @gf4096_mul(i16 zeroext %37, i16 zeroext %28)
%39 = trunc i32 %38 to i16
%40 = call i32 @gf4096_mul(i16 zeroext %33, i16 zeroext %39)
%41 = load i16, i16* %25
%42 = call i32 @gf4096_mul(i16 zeroext %28, i16 zeroext %28)
%43 = trunc i32 %42 to i16
%44 = call i32 @gf4096_mul(i16 zeroext %43, i16 zeroext %28)
%45 = trunc i32 %44 to i16
%46 = call i32 @gf4096_mul(i16 zeroext %41, i16 zeroext %45)
%47 = xor i32 %46, %40
%48 = load i16, i16* %26
%49 = call i32 @gf4096_mul(i16 zeroext %28, i16 zeroext %28)
%50 = trunc i32 %49 to i16
%51 = call i32 @gf4096_mul(i16 zeroext %48, i16 zeroext %50)
%52 = xor i32 %47, %51
%53 = load i16, i16* %22
%54 = call i32 @gf4096_mul(i16 zeroext %53, i16 zeroext %28)
%55 = xor i32 %52, %54
%56 = and i32 %55, 65535
%57 = icmp eq i32 %56, 1
br i1 %57, label %58, label %61
58: ; preds = %27
switch i32 %29, label %73 [
i32 0, label %61
i32 1, label %59
i32 2, label %60
]
59: ; preds = %58
br label %61
60: ; preds = %58
br label %61
61: ; preds = %58, %27, %59, %60
%62 = phi i16 [ %32, %59 ], [ %28, %60 ], [ %32, %27 ], [ %32, %58 ]
%63 = phi i16 [ %28, %59 ], [ %31, %60 ], [ %31, %27 ], [ %31, %58 ]
%64 = phi i16 [ %30, %59 ], [ %30, %60 ], [ %30, %27 ], [ %28, %58 ]
%65 = phi i32 [ 2, %59 ], [ 3, %60 ], [ %29, %27 ], [ 1, %58 ]
%66 = add nuw nsw i16 %28, 1
%67 = icmp eq i16 %66, 4095
br i1 %67, label %68, label %27
68: ; preds = %61
%69 = icmp eq i32 %65, 4
br i1 %69, label %73, label %70
70: ; preds = %68
%71 = load i32, i32* @EINVAL
%72 = sub nsw i32 0, %71
br label %115
73: ; preds = %58, %68
%74 = phi i16 [ %62, %68 ], [ %32, %58 ]
%75 = phi i16 [ %63, %68 ], [ %31, %58 ]
%76 = phi i16 [ %64, %68 ], [ %30, %58 ]
%77 = phi i16 [ 4095, %68 ], [ %28, %58 ]
%78 = call zeroext i16 @gf4096_inv(i16 zeroext %76)
%79 = call zeroext i16 @gf4096_inv(i16 zeroext %75)
%80 = call zeroext i16 @gf4096_inv(i16 zeroext %74)
%81 = call zeroext i16 @gf4096_inv(i16 zeroext %77)
%82 = load i16, i16* %0
%83 = load i16, i16* %8
%84 = load i16, i16* %10
%85 = load i16, i16* %12
%86 = getelementptr inbounds [4 x i16], [4 x i16]* %4, i64 0, i64 0
%87 = call i32 @find_4bit_err_pats(i16 zeroext %82, i16 zeroext %83, i16 zeroext %84, i16 zeroext %85, i16 zeroext %78, i16 zeroext %79, i16 zeroext %80, i16 zeroext %81, i16* %86)
store i16 4, i16* %1
%88 = call i32 @err_pos(i16 zeroext %78)
%89 = trunc i32 %88 to i16
%90 = sub i16 1374, %89
%91 = getelementptr inbounds i16, i16* %1, i64 1
store i16 %90, i16* %91
%92 = call i32 @err_pos(i16 zeroext %79)
%93 = trunc i32 %92 to i16
%94 = sub i16 1374, %93
%95 = getelementptr inbounds i16, i16* %1, i64 2
store i16 %94, i16* %95
%96 = call i32 @err_pos(i16 zeroext %80)
%97 = trunc i32 %96 to i16
%98 = sub i16 1374, %97
%99 = getelementptr inbounds i16, i16* %1, i64 3
store i16 %98, i16* %99
%100 = call i32 @err_pos(i16 zeroext %81)
%101 = trunc i32 %100 to i16
%102 = sub i16 1374, %101
%103 = getelementptr inbounds i16, i16* %1, i64 4
store i16 %102, i16* %103
%104 = load i16, i16* %86
%105 = getelementptr inbounds i16, i16* %1, i64 5
store i16 %104, i16* %105
%106 = getelementptr inbounds [4 x i16], [4 x i16]* %4, i64 0, i64 1
%107 = load i16, i16* %106
%108 = getelementptr inbounds i16, i16* %1, i64 6
store i16 %107, i16* %108
%109 = getelementptr inbounds [4 x i16], [4 x i16]* %4, i64 0, i64 2
%110 = load i16, i16* %109
%111 = getelementptr inbounds i16, i16* %1, i64 7
store i16 %110, i16* %111
%112 = getelementptr inbounds [4 x i16], [4 x i16]* %4, i64 0, i64 3
%113 = load i16, i16* %112
%114 = getelementptr inbounds i16, i16* %1, i64 8
store i16 %113, i16* %114
br label %115
115: ; preds = %73, %70
%116 = phi i32 [ %72, %70 ], [ 0, %73 ]
ret i32 %116
}