#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 */
typedef int uint8_t;
typedef int int32_t;

/* Variables and functions */
int32_t hamming_84_decode(int32_t input, int *errcnt) {
  static const uint8_t dactab[128] = {
      16, 0,  0,  3,  0,  5,  14, 7,  0,  9,  14, 11, 14, 13, 30, 14,
      0,  9,  2,  7,  4,  7,  7,  23, 9,  25, 10, 9,  12, 9,  14, 7,
      0,  5,  2,  11, 5,  21, 6,  5,  8,  11, 11, 27, 12, 5,  14, 11,
      2,  1,  18, 2,  12, 5,  2,  7,  12, 9,  2,  11, 28, 12, 12, 15,
      0,  3,  3,  19, 4,  13, 6,  3,  8,  13, 10, 3,  13, 29, 14, 13,
      4,  1,  10, 3,  20, 4,  4,  7,  10, 9,  26, 10, 4,  13, 10, 15,
      8,  1,  6,  3,  6,  5,  22, 6,  24, 8,  8,  11, 8,  13, 6,  15,
      1,  17, 2,  1,  4,  1,  6,  15, 8,  1,  10, 15, 12, 15, 15, 31};
  int i;
  int parity;
  int32_t output;
  parity = input & 255;
  parity ^= parity >> 4;
  parity ^= parity >> 2;
  parity ^= parity >> 1;
  parity &= 1;
  i = dactab[input & 127];
  output = i & 15;
  if ((i & 16)) {
    if (parity)
      (*errcnt)++;
  } else {
    (*errcnt)++;
    if (parity == 0) {
      (*errcnt)++;
      output = -1;
    }
  }
  return output;
}


x86 assembly (clang, -O0):
<hamming_84_decode>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x4(%rbp),%eax
and    $0xff,%eax
mov    %eax,-0x18(%rbp)
mov    -0x18(%rbp),%eax
sar    $0x4,%eax
xor    -0x18(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0x18(%rbp),%eax
sar    $0x2,%eax
xor    -0x18(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0x18(%rbp),%eax
sar    $0x1,%eax
xor    -0x18(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0x18(%rbp),%eax
and    $0x1,%eax
mov    %eax,-0x18(%rbp)
mov    -0x4(%rbp),%eax
and    $0x7f,%eax
movslq %eax,%rcx
lea    0xead(%rip),%rax
mov    (%rax,%rcx,4),%eax
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
and    $0xf,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x14(%rbp),%eax
and    $0x10,%eax
cmp    $0x0,%eax
je     118b <hamming_84_decode+0x8b>
cmpl   $0x0,-0x18(%rbp)
je     1186 <hamming_84_decode+0x86>
mov    -0x10(%rbp),%rax
mov    (%rax),%ecx
add    $0x1,%ecx
mov    %ecx,(%rax)
jmp    11b7 <hamming_84_decode+0xb7>
mov    -0x10(%rbp),%rax
mov    (%rax),%ecx
add    $0x1,%ecx
mov    %ecx,(%rax)
cmpl   $0x0,-0x18(%rbp)
jne    11b2 <hamming_84_decode+0xb2>
mov    -0x10(%rbp),%rax
mov    (%rax),%ecx
add    $0x1,%ecx
mov    %ecx,(%rax)
movl   $0xffffffff,-0x1c(%rbp)
jmp    11b7 <hamming_84_decode+0xb7>
mov    -0x1c(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<hamming_84_decode>:
movzbl %dil,%eax
mov    %eax,%ecx
shr    $0x4,%ecx
xor    %eax,%ecx
mov    %ecx,%eax
shr    $0x2,%eax
xor    %ecx,%eax
mov    %eax,%edx
shr    %edx
xor    %eax,%edx
and    $0x7f,%edi
lea    0xede(%rip),%rax
mov    (%rax,%rdi,4),%ecx
mov    %ecx,%eax
and    $0xf,%eax
test   $0x10,%cl
jne    1145 <hamming_84_decode+0x45>
mov    (%rsi),%ecx
lea    0x1(%rcx),%edi
mov    %edi,(%rsi)
test   $0x1,%dl
jne    1151 <hamming_84_decode+0x51>
add    $0x2,%ecx
mov    $0xffffffff,%eax
jmp    114f <hamming_84_decode+0x4f>
test   $0x1,%dl
je     1151 <hamming_84_decode+0x51>
mov    (%rsi),%ecx
add    $0x1,%ecx
mov    %ecx,(%rsi)
ret

LLVM IR (-O0):
@hamming_84_decode.dactab = internal constant [128 x i32] [i32 16, i32 0, i32 0, i32 3, i32 0, i32 5, i32 14, i32 7, i32 0, i32 9, i32 14, i32 11, i32 14, i32 13, i32 30, i32 14, i32 0, i32 9, i32 2, i32 7, i32 4, i32 7, i32 7, i32 23, i32 9, i32 25, i32 10, i32 9, i32 12, i32 9, i32 14, i32 7, i32 0, i32 5, i32 2, i32 11, i32 5, i32 21, i32 6, i32 5, i32 8, i32 11, i32 11, i32 27, i32 12, i32 5, i32 14, i32 11, i32 2, i32 1, i32 18, i32 2, i32 12, i32 5, i32 2, i32 7, i32 12, i32 9, i32 2, i32 11, i32 28, i32 12, i32 12, i32 15, i32 0, i32 3, i32 3, i32 19, i32 4, i32 13, i32 6, i32 3, i32 8, i32 13, i32 10, i32 3, i32 13, i32 29, i32 14, i32 13, i32 4, i32 1, i32 10, i32 3, i32 20, i32 4, i32 4, i32 7, i32 10, i32 9, i32 26, i32 10, i32 4, i32 13, i32 10, i32 15, i32 8, i32 1, i32 6, i32 3, i32 6, i32 5, i32 22, i32 6, i32 24, i32 8, i32 8, i32 11, i32 8, i32 13, i32 6, i32 15, i32 1, i32 17, i32 2, i32 1, i32 4, i32 1, i32 6, i32 15, i32 8, i32 1, i32 10, i32 15, i32 12, i32 15, i32 15, i32 31]
define i32 @hamming_84_decode(i32 %0, i32* %1) {
%3 = alloca i32
%4 = alloca i32*
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
store i32 %0, i32* %3
store i32* %1, i32** %4
%8 = load i32, i32* %3
%9 = and i32 %8, 255
store i32 %9, i32* %6
%10 = load i32, i32* %6
%11 = ashr i32 %10, 4
%12 = load i32, i32* %6
%13 = xor i32 %12, %11
store i32 %13, i32* %6
%14 = load i32, i32* %6
%15 = ashr i32 %14, 2
%16 = load i32, i32* %6
%17 = xor i32 %16, %15
store i32 %17, i32* %6
%18 = load i32, i32* %6
%19 = ashr i32 %18, 1
%20 = load i32, i32* %6
%21 = xor i32 %20, %19
store i32 %21, i32* %6
%22 = load i32, i32* %6
%23 = and i32 %22, 1
store i32 %23, i32* %6
%24 = load i32, i32* %3
%25 = and i32 %24, 127
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds [128 x i32], [128 x i32]* @hamming_84_decode.dactab, i64 0, i64 %26
%28 = load i32, i32* %27
store i32 %28, i32* %5
%29 = load i32, i32* %5
%30 = and i32 %29, 15
store i32 %30, i32* %7
%31 = load i32, i32* %5
%32 = and i32 %31, 16
%33 = icmp ne i32 %32, 0
br i1 %33, label %34, label %42
34: ; preds = %2
%35 = load i32, i32* %6
%36 = icmp ne i32 %35, 0
br i1 %36, label %37, label %41
37: ; preds = %34
%38 = load i32*, i32** %4
%39 = load i32, i32* %38
%40 = add nsw i32 %39, 1
store i32 %40, i32* %38
br label %41
41: ; preds = %37, %34
br label %53
42: ; preds = %2
%43 = load i32*, i32** %4
%44 = load i32, i32* %43
%45 = add nsw i32 %44, 1
store i32 %45, i32* %43
%46 = load i32, i32* %6
%47 = icmp eq i32 %46, 0
br i1 %47, label %48, label %52
48: ; preds = %42
%49 = load i32*, i32** %4
%50 = load i32, i32* %49
%51 = add nsw i32 %50, 1
store i32 %51, i32* %49
store i32 -1, i32* %7
br label %52
52: ; preds = %48, %42
br label %53
53: ; preds = %52, %41
%54 = load i32, i32* %7
ret i32 %54
}

LLVM IR (-O2):
@hamming_84_decode.dactab = internal unnamed_addr constant [128 x i32] [i32 16, i32 0, i32 0, i32 3, i32 0, i32 5, i32 14, i32 7, i32 0, i32 9, i32 14, i32 11, i32 14, i32 13, i32 30, i32 14, i32 0, i32 9, i32 2, i32 7, i32 4, i32 7, i32 7, i32 23, i32 9, i32 25, i32 10, i32 9, i32 12, i32 9, i32 14, i32 7, i32 0, i32 5, i32 2, i32 11, i32 5, i32 21, i32 6, i32 5, i32 8, i32 11, i32 11, i32 27, i32 12, i32 5, i32 14, i32 11, i32 2, i32 1, i32 18, i32 2, i32 12, i32 5, i32 2, i32 7, i32 12, i32 9, i32 2, i32 11, i32 28, i32 12, i32 12, i32 15, i32 0, i32 3, i32 3, i32 19, i32 4, i32 13, i32 6, i32 3, i32 8, i32 13, i32 10, i32 3, i32 13, i32 29, i32 14, i32 13, i32 4, i32 1, i32 10, i32 3, i32 20, i32 4, i32 4, i32 7, i32 10, i32 9, i32 26, i32 10, i32 4, i32 13, i32 10, i32 15, i32 8, i32 1, i32 6, i32 3, i32 6, i32 5, i32 22, i32 6, i32 24, i32 8, i32 8, i32 11, i32 8, i32 13, i32 6, i32 15, i32 1, i32 17, i32 2, i32 1, i32 4, i32 1, i32 6, i32 15, i32 8, i32 1, i32 10, i32 15, i32 12, i32 15, i32 15, i32 31]
define i32 @hamming_84_decode(i32 %0, i32* nocapture %1) {
%3 = and i32 %0, 255
%4 = lshr i32 %3, 4
%5 = xor i32 %4, %3
%6 = lshr i32 %5, 2
%7 = xor i32 %6, %5
%8 = lshr i32 %7, 1
%9 = xor i32 %8, %7
%10 = and i32 %9, 1
%11 = and i32 %0, 127
%12 = zext i32 %11 to i64
%13 = getelementptr inbounds [128 x i32], [128 x i32]* @hamming_84_decode.dactab, i64 0, i64 %12
%14 = load i32, i32* %13
%15 = and i32 %14, 15
%16 = and i32 %14, 16
%17 = icmp eq i32 %16, 0
br i1 %17, label %23, label %18
18: ; preds = %2
%19 = icmp eq i32 %10, 0
br i1 %19, label %32, label %20
20: ; preds = %18
%21 = load i32, i32* %1
%22 = add nsw i32 %21, 1
br label %29
23: ; preds = %2
%24 = load i32, i32* %1
%25 = add nsw i32 %24, 1
store i32 %25, i32* %1
%26 = icmp eq i32 %10, 0
br i1 %26, label %27, label %32
27: ; preds = %23
%28 = add nsw i32 %24, 2
br label %29
29: ; preds = %20, %27
%30 = phi i32 [ %28, %27 ], [ %22, %20 ]
%31 = phi i32 [ -1, %27 ], [ %15, %20 ]
store i32 %30, i32* %1
br label %32
32: ; preds = %29, %23, %18
%33 = phi i32 [ %15, %18 ], [ %15, %23 ], [ %31, %29 ]
ret i32 %33
}