#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 */
scalar_t__ GetAnswer();
scalar_t__ PinGetOUTPUTS();
int /*<<< orphan*/ PinSetINPUTS(int);
int /*<<< orphan*/ PinSetLATCH_DATA(int);
int /*<<< orphan*/ PinSetLATCH_SHIFT(int);
int /*<<< orphan*/ UpdateShiftCount(int);
int /*<<< orphan*/ UpdateShiftData(int);
int /*<<< orphan*/ printf(char *);
int main(int argc, char **argv) {
  int a, b, c;
  for (a = 0; a < 8; a++) {
    PinSetINPUTS(a);
    PinSetLATCH_SHIFT(0);
    PinSetLATCH_SHIFT(1);
    UpdateShiftCount(a);
    for (b = 0; b < 256; b++) {
      for (c = 0; c < 256; c++) {
        PinSetINPUTS(b);
        UpdateShiftData(b);
        PinSetLATCH_DATA(0);
        PinSetLATCH_DATA(1);
        PinSetINPUTS(c);
        UpdateShiftData(c);
        PinSetLATCH_DATA(0);
        PinSetLATCH_DATA(1);
        if (PinGetOUTPUTS() != GetAnswer()) {
          printf("Mismatch\n");
          return -1;
        }
      }
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
cmpl   $0x8,-0x14(%rbp)
jge    12a5 <main+0x125>
mov    -0x14(%rbp),%edi
call   1030 <PinSetINPUTS@plt>
xor    %edi,%edi
call   1070 <PinSetLATCH_SHIFT@plt>
mov    $0x1,%edi
call   1070 <PinSetLATCH_SHIFT@plt>
mov    -0x14(%rbp),%edi
call   1060 <UpdateShiftCount@plt>
movl   $0x0,-0x18(%rbp)
cmpl   $0x100,-0x18(%rbp)
jge    1292 <main+0x112>
movl   $0x0,-0x1c(%rbp)
cmpl   $0x100,-0x1c(%rbp)
jge    127f <main+0xff>
mov    -0x18(%rbp),%edi
call   1030 <PinSetINPUTS@plt>
mov    -0x18(%rbp),%edi
call   1090 <UpdateShiftData@plt>
xor    %edi,%edi
call   1080 <PinSetLATCH_DATA@plt>
mov    $0x1,%edi
call   1080 <PinSetLATCH_DATA@plt>
mov    -0x1c(%rbp),%edi
call   1030 <PinSetINPUTS@plt>
mov    -0x1c(%rbp),%edi
call   1090 <UpdateShiftData@plt>
xor    %edi,%edi
call   1080 <PinSetLATCH_DATA@plt>
mov    $0x1,%edi
call   1080 <PinSetLATCH_DATA@plt>
mov    $0x0,%al
call   10a0 <PinGetOUTPUTS@plt>
mov    %rax,-0x28(%rbp)
mov    $0x0,%al
call   1040 <GetAnswer@plt>
mov    %rax,%rcx
mov    -0x28(%rbp),%rax
cmp    %rcx,%rax
je     126c <main+0xec>
lea    0xda5(%rip),%rdi
call   1050 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    12ac <main+0x12c>
jmp    1271 <main+0xf1>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    11e3 <main+0x63>
jmp    1284 <main+0x104>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    11cf <main+0x4f>
jmp    1297 <main+0x117>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    119d <main+0x1d>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
xor    %r14d,%r14d
mov    %r14d,%edi
call   1040 <PinSetINPUTS@plt>
xor    %edi,%edi
call   1070 <PinSetLATCH_SHIFT@plt>
mov    $0x1,%edi
call   1070 <PinSetLATCH_SHIFT@plt>
mov    %r14d,%edi
call   1060 <UpdateShiftCount@plt>
xor    %r15d,%r15d
xor    %ebx,%ebx
mov    %r15d,%edi
call   1040 <PinSetINPUTS@plt>
mov    %r15d,%edi
call   1090 <UpdateShiftData@plt>
xor    %edi,%edi
call   1080 <PinSetLATCH_DATA@plt>
mov    $0x1,%edi
call   1080 <PinSetLATCH_DATA@plt>
mov    %ebx,%edi
call   1040 <PinSetINPUTS@plt>
mov    %ebx,%edi
call   1090 <UpdateShiftData@plt>
xor    %edi,%edi
call   1080 <PinSetLATCH_DATA@plt>
mov    $0x1,%edi
call   1080 <PinSetLATCH_DATA@plt>
xor    %eax,%eax
call   10a0 <PinGetOUTPUTS@plt>
mov    %rax,%rbp
xor    %eax,%eax
call   1050 <GetAnswer@plt>
cmp    %rax,%rbp
jne    1230 <main+0xb0>
add    $0x1,%ebx
cmp    $0x100,%ebx
jne    11b0 <main+0x30>
add    $0x1,%r15d
cmp    $0x100,%r15d
jne    11ae <main+0x2e>
add    $0x1,%r14d
cmp    $0x8,%r14d
jne    118a <main+0xa>
xor    %eax,%eax
jmp    1241 <main+0xc1>
lea    0xdc9(%rip),%rdi
call   1030 <puts@plt>
mov    $0xffffffff,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [10 x i8] c"Mismatch\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %6
br label %9
9: ; preds = %53, %2
%10 = load i32, i32* %6
%11 = icmp slt i32 %10, 8
br i1 %11, label %12, label %56
12: ; preds = %9
%13 = load i32, i32* %6
%14 = call i32 @PinSetINPUTS(i32 %13)
%15 = call i32 @PinSetLATCH_SHIFT(i32 0)
%16 = call i32 @PinSetLATCH_SHIFT(i32 1)
%17 = load i32, i32* %6
%18 = call i32 @UpdateShiftCount(i32 %17)
store i32 0, i32* %7
br label %19
19: ; preds = %49, %12
%20 = load i32, i32* %7
%21 = icmp slt i32 %20, 256
br i1 %21, label %22, label %52
22: ; preds = %19
store i32 0, i32* %8
br label %23
23: ; preds = %45, %22
%24 = load i32, i32* %8
%25 = icmp slt i32 %24, 256
br i1 %25, label %26, label %48
26: ; preds = %23
%27 = load i32, i32* %7
%28 = call i32 @PinSetINPUTS(i32 %27)
%29 = load i32, i32* %7
%30 = call i32 @UpdateShiftData(i32 %29)
%31 = call i32 @PinSetLATCH_DATA(i32 0)
%32 = call i32 @PinSetLATCH_DATA(i32 1)
%33 = load i32, i32* %8
%34 = call i32 @PinSetINPUTS(i32 %33)
%35 = load i32, i32* %8
%36 = call i32 @UpdateShiftData(i32 %35)
%37 = call i32 @PinSetLATCH_DATA(i32 0)
%38 = call i32 @PinSetLATCH_DATA(i32 1)
%39 = call i64 (...) @PinGetOUTPUTS()
%40 = call i64 (...) @GetAnswer()
%41 = icmp ne i64 %39, %40
br i1 %41, label %42, label %44
42: ; preds = %26
%43 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0))
store i32 -1, i32* %3
br label %57
44: ; preds = %26
br label %45
45: ; preds = %44
%46 = load i32, i32* %8
%47 = add nsw i32 %46, 1
store i32 %47, i32* %8
br label %23
48: ; preds = %23
br label %49
49: ; preds = %48
%50 = load i32, i32* %7
%51 = add nsw i32 %50, 1
store i32 %51, i32* %7
br label %19
52: ; preds = %19
br label %53
53: ; preds = %52
%54 = load i32, i32* %6
%55 = add nsw i32 %54, 1
store i32 %55, i32* %6
br label %9
56: ; preds = %9
store i32 0, i32* %3
br label %57
57: ; preds = %56, %42
%58 = load i32, i32* %3
ret i32 %58
}

LLVM IR (-O2):
@str = [9 x i8] c"Mismatch\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
br label %3
3: ; preds = %2, %32
%4 = phi i32 [ 0, %2 ], [ %33, %32 ]
%5 = tail call i32 @PinSetINPUTS(i32 %4)
%6 = tail call i32 @PinSetLATCH_SHIFT(i32 0)
%7 = tail call i32 @PinSetLATCH_SHIFT(i32 1)
%8 = tail call i32 @UpdateShiftCount(i32 %4)
br label %9
9: ; preds = %3, %29
%10 = phi i32 [ 0, %3 ], [ %30, %29 ]
br label %14
11: ; preds = %14
%12 = add nuw nsw i32 %15, 1
%13 = icmp eq i32 %12, 256
br i1 %13, label %29, label %14
14: ; preds = %9, %11
%15 = phi i32 [ 0, %9 ], [ %12, %11 ]
%16 = tail call i32 @PinSetINPUTS(i32 %10)
%17 = tail call i32 @UpdateShiftData(i32 %10)
%18 = tail call i32 @PinSetLATCH_DATA(i32 0)
%19 = tail call i32 @PinSetLATCH_DATA(i32 1)
%20 = tail call i32 @PinSetINPUTS(i32 %15)
%21 = tail call i32 @UpdateShiftData(i32 %15)
%22 = tail call i32 @PinSetLATCH_DATA(i32 0)
%23 = tail call i32 @PinSetLATCH_DATA(i32 1)
%24 = tail call i64 (...) @PinGetOUTPUTS()
%25 = tail call i64 (...) @GetAnswer()
%26 = icmp eq i64 %24, %25
br i1 %26, label %11, label %27
27: ; preds = %14
%28 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @str, i64 0, i64 0))
br label %35
29: ; preds = %11
%30 = add nuw nsw i32 %10, 1
%31 = icmp eq i32 %30, 256
br i1 %31, label %32, label %9
32: ; preds = %29
%33 = add nuw nsw i32 %4, 1
%34 = icmp eq i32 %33, 8
br i1 %34, label %35, label %3
35: ; preds = %32, %27
%36 = phi i32 [ -1, %27 ], [ 0, %32 ]
ret i32 %36
}