#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;
unsigned short err_pos(unsigned short);
int /*<<< orphan*/ gf4096_inv(unsigned short);
unsigned short gf4096_mul(unsigned short, int /*<<< orphan*/);
int chk_1_err_only(unsigned short *chk_syndrome_list,
                   unsigned short *err_info) {
  unsigned short tmp0, tmp1, tmp2, tmp3, tmp4, tmp5, tmp6;
  tmp0 = gf4096_mul(chk_syndrome_list[1], gf4096_inv(chk_syndrome_list[0]));
  tmp1 = gf4096_mul(chk_syndrome_list[2], gf4096_inv(chk_syndrome_list[1]));
  tmp2 = gf4096_mul(chk_syndrome_list[3], gf4096_inv(chk_syndrome_list[2]));
  tmp3 = gf4096_mul(chk_syndrome_list[4], gf4096_inv(chk_syndrome_list[3]));
  tmp4 = gf4096_mul(chk_syndrome_list[5], gf4096_inv(chk_syndrome_list[4]));
  tmp5 = gf4096_mul(chk_syndrome_list[6], gf4096_inv(chk_syndrome_list[5]));
  tmp6 = gf4096_mul(chk_syndrome_list[7], gf4096_inv(chk_syndrome_list[6]));
  if ((tmp0 == tmp1) & (tmp1 == tmp2) & (tmp2 == tmp3) & (tmp3 == tmp4) &
      (tmp4 == tmp5) & (tmp5 == tmp6)) {
    err_info[0] = 0x1;
    err_info[1] = err_pos(tmp0);
    err_info[1] = (unsigned short)(0x55e - err_info[1]);
    err_info[5] = chk_syndrome_list[0];
    return 0;
  } else
    return -EINVAL;
}


x86 assembly (clang, -O0):
<chk_1_err_only>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    0x2(%rax),%ax
mov    %ax,-0x34(%rbp)
mov    -0x10(%rbp),%rax
movzwl (%rax),%edi
call   1050 <gf4096_inv@plt>
mov    %eax,%esi
mov    -0x34(%rbp),%ax
movzwl %ax,%edi
call   1040 <gf4096_mul@plt>
mov    %ax,-0x1a(%rbp)
mov    -0x10(%rbp),%rax
mov    0x4(%rax),%ax
mov    %ax,-0x32(%rbp)
mov    -0x10(%rbp),%rax
movzwl 0x2(%rax),%edi
call   1050 <gf4096_inv@plt>
mov    %eax,%esi
mov    -0x32(%rbp),%ax
movzwl %ax,%edi
call   1040 <gf4096_mul@plt>
mov    %ax,-0x1c(%rbp)
mov    -0x10(%rbp),%rax
mov    0x6(%rax),%ax
mov    %ax,-0x30(%rbp)
mov    -0x10(%rbp),%rax
movzwl 0x4(%rax),%edi
call   1050 <gf4096_inv@plt>
mov    %eax,%esi
mov    -0x30(%rbp),%ax
movzwl %ax,%edi
call   1040 <gf4096_mul@plt>
mov    %ax,-0x1e(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%ax
mov    %ax,-0x2e(%rbp)
mov    -0x10(%rbp),%rax
movzwl 0x6(%rax),%edi
call   1050 <gf4096_inv@plt>
mov    %eax,%esi
mov    -0x2e(%rbp),%ax
movzwl %ax,%edi
call   1040 <gf4096_mul@plt>
mov    %ax,-0x20(%rbp)
mov    -0x10(%rbp),%rax
mov    0xa(%rax),%ax
mov    %ax,-0x2c(%rbp)
mov    -0x10(%rbp),%rax
movzwl 0x8(%rax),%edi
call   1050 <gf4096_inv@plt>
mov    %eax,%esi
mov    -0x2c(%rbp),%ax
movzwl %ax,%edi
call   1040 <gf4096_mul@plt>
mov    %ax,-0x22(%rbp)
mov    -0x10(%rbp),%rax
mov    0xc(%rax),%ax
mov    %ax,-0x2a(%rbp)
mov    -0x10(%rbp),%rax
movzwl 0xa(%rax),%edi
call   1050 <gf4096_inv@plt>
mov    %eax,%esi
mov    -0x2a(%rbp),%ax
movzwl %ax,%edi
call   1040 <gf4096_mul@plt>
mov    %ax,-0x24(%rbp)
mov    -0x10(%rbp),%rax
mov    0xe(%rax),%ax
mov    %ax,-0x28(%rbp)
mov    -0x10(%rbp),%rax
movzwl 0xc(%rax),%edi
call   1050 <gf4096_inv@plt>
mov    %eax,%esi
mov    -0x28(%rbp),%ax
movzwl %ax,%edi
call   1040 <gf4096_mul@plt>
mov    %ax,-0x26(%rbp)
movzwl -0x1a(%rbp),%eax
movzwl -0x1c(%rbp),%ecx
cmp    %ecx,%eax
sete   %al
and    $0x1,%al
movzbl %al,%eax
movzwl -0x1c(%rbp),%ecx
movzwl -0x1e(%rbp),%edx
cmp    %edx,%ecx
sete   %cl
and    $0x1,%cl
movzbl %cl,%ecx
and    %ecx,%eax
movzwl -0x1e(%rbp),%ecx
movzwl -0x20(%rbp),%edx
cmp    %edx,%ecx
sete   %cl
and    $0x1,%cl
movzbl %cl,%ecx
and    %ecx,%eax
movzwl -0x20(%rbp),%ecx
movzwl -0x22(%rbp),%edx
cmp    %edx,%ecx
sete   %cl
and    $0x1,%cl
movzbl %cl,%ecx
and    %ecx,%eax
movzwl -0x22(%rbp),%ecx
movzwl -0x24(%rbp),%edx
cmp    %edx,%ecx
sete   %cl
and    $0x1,%cl
movzbl %cl,%ecx
and    %ecx,%eax
movzwl -0x24(%rbp),%ecx
movzwl -0x26(%rbp),%edx
cmp    %edx,%ecx
sete   %cl
and    $0x1,%cl
movzbl %cl,%ecx
and    %ecx,%eax
cmp    $0x0,%eax
je     1342 <chk_1_err_only+0x212>
mov    -0x18(%rbp),%rax
movw   $0x1,(%rax)
movzwl -0x1a(%rbp),%edi
call   1030 <err_pos@plt>
mov    %ax,%cx
mov    -0x18(%rbp),%rax
mov    %cx,0x2(%rax)
mov    -0x18(%rbp),%rax
movzwl 0x2(%rax),%ecx
mov    $0x55e,%eax
sub    %ecx,%eax
mov    %ax,%cx
mov    -0x18(%rbp),%rax
mov    %cx,0x2(%rax)
mov    -0x10(%rbp),%rax
mov    (%rax),%cx
mov    -0x18(%rbp),%rax
mov    %cx,0xa(%rax)
movl   $0x0,-0x4(%rbp)
jmp    1350 <chk_1_err_only+0x220>
xor    %eax,%eax
mov    0x2c95(%rip),%rcx
sub    (%rcx),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<chk_1_err_only>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rsi,0x10(%rsp)
mov    %rdi,%rbx
movzwl 0x2(%rdi),%ebp
movzwl (%rdi),%edi
call   1050 <gf4096_inv@plt>
mov    %ebp,%edi
mov    %eax,%esi
call   1040 <gf4096_mul@plt>
mov    %ax,0xe(%rsp)
movzwl 0x4(%rbx),%ebp
movzwl 0x2(%rbx),%edi
call   1050 <gf4096_inv@plt>
mov    %ebp,%edi
mov    %eax,%esi
call   1040 <gf4096_mul@plt>
mov    %ax,0xc(%rsp)
movzwl 0x6(%rbx),%ebp
movzwl 0x4(%rbx),%edi
call   1050 <gf4096_inv@plt>
mov    %ebp,%edi
mov    %eax,%esi
call   1040 <gf4096_mul@plt>
mov    %eax,%r13d
movzwl 0x8(%rbx),%ebp
movzwl 0x6(%rbx),%edi
call   1050 <gf4096_inv@plt>
mov    %ebp,%edi
mov    %eax,%esi
call   1040 <gf4096_mul@plt>
mov    %eax,%r12d
movzwl 0xa(%rbx),%ebp
movzwl 0x8(%rbx),%edi
call   1050 <gf4096_inv@plt>
mov    %ebp,%edi
mov    %eax,%esi
call   1040 <gf4096_mul@plt>
mov    %eax,%r14d
movzwl 0xc(%rbx),%ebp
movzwl 0xa(%rbx),%edi
call   1050 <gf4096_inv@plt>
mov    %ebp,%edi
mov    %eax,%esi
call   1040 <gf4096_mul@plt>
mov    %eax,%r15d
movzwl 0xe(%rbx),%ebp
movzwl 0xc(%rbx),%edi
call   1050 <gf4096_inv@plt>
mov    %ebp,%edi
mov    %eax,%esi
call   1040 <gf4096_mul@plt>
movzwl 0xc(%rsp),%edx
movzwl 0xe(%rsp),%ecx
cmp    %dx,%cx
jne    124b <chk_1_err_only+0x11b>
cmp    %r13w,%dx
jne    124b <chk_1_err_only+0x11b>
cmp    %r12w,%r13w
jne    124b <chk_1_err_only+0x11b>
cmp    %r14w,%r12w
jne    124b <chk_1_err_only+0x11b>
cmp    %r15w,%r14w
jne    124b <chk_1_err_only+0x11b>
cmp    %ax,%r15w
jne    124b <chk_1_err_only+0x11b>
mov    0x10(%rsp),%rbp
movw   $0x1,0x0(%rbp)
movzwl %cx,%edi
call   1030 <err_pos@plt>
mov    $0x55e,%ecx
sub    %eax,%ecx
mov    %cx,0x2(%rbp)
movzwl (%rbx),%eax
mov    %ax,0xa(%rbp)
xor    %eax,%eax
jmp    1256 <chk_1_err_only+0x126>
mov    0x2d8e(%rip),%rcx
xor    %eax,%eax
sub    (%rcx),%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
@EINVAL = global i32 0
define i32 @chk_1_err_only(i16* nocapture %0, i16* nocapture writeonly %1) {
%3 = getelementptr inbounds i16, i16* %0, i64 1
%4 = load i16, i16* %3
%5 = load i16, i16* %0
%6 = tail call i32 @gf4096_inv(i16 zeroext %5)
%7 = tail call zeroext i16 @gf4096_mul(i16 zeroext %4, i32 %6)
%8 = getelementptr inbounds i16, i16* %0, i64 2
%9 = load i16, i16* %8
%10 = load i16, i16* %3
%11 = tail call i32 @gf4096_inv(i16 zeroext %10)
%12 = tail call zeroext i16 @gf4096_mul(i16 zeroext %9, i32 %11)
%13 = getelementptr inbounds i16, i16* %0, i64 3
%14 = load i16, i16* %13
%15 = load i16, i16* %8
%16 = tail call i32 @gf4096_inv(i16 zeroext %15)
%17 = tail call zeroext i16 @gf4096_mul(i16 zeroext %14, i32 %16)
%18 = getelementptr inbounds i16, i16* %0, i64 4
%19 = load i16, i16* %18
%20 = load i16, i16* %13
%21 = tail call i32 @gf4096_inv(i16 zeroext %20)
%22 = tail call zeroext i16 @gf4096_mul(i16 zeroext %19, i32 %21)
%23 = getelementptr inbounds i16, i16* %0, i64 5
%24 = load i16, i16* %23
%25 = load i16, i16* %18
%26 = tail call i32 @gf4096_inv(i16 zeroext %25)
%27 = tail call zeroext i16 @gf4096_mul(i16 zeroext %24, i32 %26)
%28 = getelementptr inbounds i16, i16* %0, i64 6
%29 = load i16, i16* %28
%30 = load i16, i16* %23
%31 = tail call i32 @gf4096_inv(i16 zeroext %30)
%32 = tail call zeroext i16 @gf4096_mul(i16 zeroext %29, i32 %31)
%33 = getelementptr inbounds i16, i16* %0, i64 7
%34 = load i16, i16* %33
%35 = load i16, i16* %28
%36 = tail call i32 @gf4096_inv(i16 zeroext %35)
%37 = tail call zeroext i16 @gf4096_mul(i16 zeroext %34, i32 %36)
%38 = icmp eq i16 %7, %12
%39 = icmp eq i16 %12, %17
%40 = and i1 %38, %39
%41 = icmp eq i16 %17, %22
%42 = and i1 %40, %41
%43 = icmp eq i16 %22, %27
%44 = and i1 %42, %43
%45 = icmp eq i16 %27, %32
%46 = and i1 %44, %45
%47 = icmp eq i16 %32, %37
%48 = and i1 %46, %47
br i1 %48, label %49, label %55
49: ; preds = %2
store i16 1, i16* %1
%50 = tail call zeroext i16 @err_pos(i16 zeroext %7)
%51 = getelementptr inbounds i16, i16* %1, i64 1
%52 = sub i16 1374, %50
store i16 %52, i16* %51
%53 = load i16, i16* %0
%54 = getelementptr inbounds i16, i16* %1, i64 5
store i16 %53, i16* %54
br label %58
55: ; preds = %2
%56 = load i32, i32* @EINVAL
%57 = sub nsw i32 0, %56
br label %58
58: ; preds = %55, %49
%59 = phi i32 [ 0, %49 ], [ %57, %55 ]
ret i32 %59
}