#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*/ assert(int);
int fgetc(unsigned int);
unsigned int input(char *);
int /*<<< orphan*/ report(int);
int /*<<< orphan*/ wait_clocks(int);
void main() {
  unsigned a = input("a");
  wait_clocks(1000);
  assert(fgetc(a) == 1);
  wait_clocks(1000);
  assert(fgetc(a) == 2);
  wait_clocks(1000);
  assert(fgetc(a) == 3);
  wait_clocks(1000);
  assert(fgetc(a) == 4);
  wait_clocks(1000);
  assert(fgetc(a) == 5);
  wait_clocks(1000);
  assert(fgetc(a) == 6);
  wait_clocks(1000);
  assert(fgetc(a) == 7);
  wait_clocks(1000);
  assert(fgetc(a) == 8);
  wait_clocks(1000);
  assert(fgetc(a) == 9);
  wait_clocks(1000);
  assert(fgetc(a) == 10);
  report(1);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
lea    0xea1(%rip),%rdi
call   1030 <input@plt>
mov    %eax,-0x4(%rbp)
mov    $0x3e8,%edi
call   1060 <wait_clocks@plt>
mov    -0x4(%rbp),%edi
call   1040 <fgetc@plt>
cmp    $0x1,%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1050 <assert@plt>
mov    $0x3e8,%edi
call   1060 <wait_clocks@plt>
mov    -0x4(%rbp),%edi
call   1040 <fgetc@plt>
cmp    $0x2,%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1050 <assert@plt>
mov    $0x3e8,%edi
call   1060 <wait_clocks@plt>
mov    -0x4(%rbp),%edi
call   1040 <fgetc@plt>
cmp    $0x3,%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1050 <assert@plt>
mov    $0x3e8,%edi
call   1060 <wait_clocks@plt>
mov    -0x4(%rbp),%edi
call   1040 <fgetc@plt>
cmp    $0x4,%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1050 <assert@plt>
mov    $0x3e8,%edi
call   1060 <wait_clocks@plt>
mov    -0x4(%rbp),%edi
call   1040 <fgetc@plt>
cmp    $0x5,%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1050 <assert@plt>
mov    $0x3e8,%edi
call   1060 <wait_clocks@plt>
mov    -0x4(%rbp),%edi
call   1040 <fgetc@plt>
cmp    $0x6,%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1050 <assert@plt>
mov    $0x3e8,%edi
call   1060 <wait_clocks@plt>
mov    -0x4(%rbp),%edi
call   1040 <fgetc@plt>
cmp    $0x7,%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1050 <assert@plt>
mov    $0x3e8,%edi
call   1060 <wait_clocks@plt>
mov    -0x4(%rbp),%edi
call   1040 <fgetc@plt>
cmp    $0x8,%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1050 <assert@plt>
mov    $0x3e8,%edi
call   1060 <wait_clocks@plt>
mov    -0x4(%rbp),%edi
call   1040 <fgetc@plt>
cmp    $0x9,%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1050 <assert@plt>
mov    $0x3e8,%edi
call   1060 <wait_clocks@plt>
mov    -0x4(%rbp),%edi
call   1040 <fgetc@plt>
cmp    $0xa,%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1050 <assert@plt>
mov    $0x1,%edi
call   1070 <report@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
lea    0xea8(%rip),%rdi
call   1030 <input@plt>
mov    %eax,%ebx
mov    $0x3e8,%edi
call   1060 <wait_clocks@plt>
mov    %ebx,%edi
call   1040 <fgetc@plt>
xor    %edi,%edi
cmp    $0x1,%eax
sete   %dil
call   1050 <assert@plt>
mov    $0x3e8,%edi
call   1060 <wait_clocks@plt>
mov    %ebx,%edi
call   1040 <fgetc@plt>
xor    %edi,%edi
cmp    $0x2,%eax
sete   %dil
call   1050 <assert@plt>
mov    $0x3e8,%edi
call   1060 <wait_clocks@plt>
mov    %ebx,%edi
call   1040 <fgetc@plt>
xor    %edi,%edi
cmp    $0x3,%eax
sete   %dil
call   1050 <assert@plt>
mov    $0x3e8,%edi
call   1060 <wait_clocks@plt>
mov    %ebx,%edi
call   1040 <fgetc@plt>
xor    %edi,%edi
cmp    $0x4,%eax
sete   %dil
call   1050 <assert@plt>
mov    $0x3e8,%edi
call   1060 <wait_clocks@plt>
mov    %ebx,%edi
call   1040 <fgetc@plt>
xor    %edi,%edi
cmp    $0x5,%eax
sete   %dil
call   1050 <assert@plt>
mov    $0x3e8,%edi
call   1060 <wait_clocks@plt>
mov    %ebx,%edi
call   1040 <fgetc@plt>
xor    %edi,%edi
cmp    $0x6,%eax
sete   %dil
call   1050 <assert@plt>
mov    $0x3e8,%edi
call   1060 <wait_clocks@plt>
mov    %ebx,%edi
call   1040 <fgetc@plt>
xor    %edi,%edi
cmp    $0x7,%eax
sete   %dil
call   1050 <assert@plt>
mov    $0x3e8,%edi
call   1060 <wait_clocks@plt>
mov    %ebx,%edi
call   1040 <fgetc@plt>
xor    %edi,%edi
cmp    $0x8,%eax
sete   %dil
call   1050 <assert@plt>
mov    $0x3e8,%edi
call   1060 <wait_clocks@plt>
mov    %ebx,%edi
call   1040 <fgetc@plt>
xor    %edi,%edi
cmp    $0x9,%eax
sete   %dil
call   1050 <assert@plt>
mov    $0x3e8,%edi
call   1060 <wait_clocks@plt>
mov    %ebx,%edi
call   1040 <fgetc@plt>
xor    %edi,%edi
cmp    $0xa,%eax
sete   %dil
call   1050 <assert@plt>
mov    $0x1,%edi
pop    %rbx
jmp    1070 <report@plt>

LLVM IR (-O0):
@.str = [2 x i8] c"a\00"
define void @main() {
%1 = alloca i32
%2 = call i32 @input(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32 %2, i32* %1
%3 = call i32 @wait_clocks(i32 1000)
%4 = load i32, i32* %1
%5 = call i32 @fgetc(i32 %4)
%6 = icmp eq i32 %5, 1
%7 = zext i1 %6 to i32
%8 = call i32 @assert(i32 %7)
%9 = call i32 @wait_clocks(i32 1000)
%10 = load i32, i32* %1
%11 = call i32 @fgetc(i32 %10)
%12 = icmp eq i32 %11, 2
%13 = zext i1 %12 to i32
%14 = call i32 @assert(i32 %13)
%15 = call i32 @wait_clocks(i32 1000)
%16 = load i32, i32* %1
%17 = call i32 @fgetc(i32 %16)
%18 = icmp eq i32 %17, 3
%19 = zext i1 %18 to i32
%20 = call i32 @assert(i32 %19)
%21 = call i32 @wait_clocks(i32 1000)
%22 = load i32, i32* %1
%23 = call i32 @fgetc(i32 %22)
%24 = icmp eq i32 %23, 4
%25 = zext i1 %24 to i32
%26 = call i32 @assert(i32 %25)
%27 = call i32 @wait_clocks(i32 1000)
%28 = load i32, i32* %1
%29 = call i32 @fgetc(i32 %28)
%30 = icmp eq i32 %29, 5
%31 = zext i1 %30 to i32
%32 = call i32 @assert(i32 %31)
%33 = call i32 @wait_clocks(i32 1000)
%34 = load i32, i32* %1
%35 = call i32 @fgetc(i32 %34)
%36 = icmp eq i32 %35, 6
%37 = zext i1 %36 to i32
%38 = call i32 @assert(i32 %37)
%39 = call i32 @wait_clocks(i32 1000)
%40 = load i32, i32* %1
%41 = call i32 @fgetc(i32 %40)
%42 = icmp eq i32 %41, 7
%43 = zext i1 %42 to i32
%44 = call i32 @assert(i32 %43)
%45 = call i32 @wait_clocks(i32 1000)
%46 = load i32, i32* %1
%47 = call i32 @fgetc(i32 %46)
%48 = icmp eq i32 %47, 8
%49 = zext i1 %48 to i32
%50 = call i32 @assert(i32 %49)
%51 = call i32 @wait_clocks(i32 1000)
%52 = load i32, i32* %1
%53 = call i32 @fgetc(i32 %52)
%54 = icmp eq i32 %53, 9
%55 = zext i1 %54 to i32
%56 = call i32 @assert(i32 %55)
%57 = call i32 @wait_clocks(i32 1000)
%58 = load i32, i32* %1
%59 = call i32 @fgetc(i32 %58)
%60 = icmp eq i32 %59, 10
%61 = zext i1 %60 to i32
%62 = call i32 @assert(i32 %61)
%63 = call i32 @report(i32 1)
ret void
}

LLVM IR (-O2):
@.str = [2 x i8] c"a\00"
define void @main() {
%1 = tail call i32 @input(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%2 = tail call i32 @wait_clocks(i32 1000)
%3 = tail call i32 @fgetc(i32 %1)
%4 = icmp eq i32 %3, 1
%5 = zext i1 %4 to i32
%6 = tail call i32 @assert(i32 %5)
%7 = tail call i32 @wait_clocks(i32 1000)
%8 = tail call i32 @fgetc(i32 %1)
%9 = icmp eq i32 %8, 2
%10 = zext i1 %9 to i32
%11 = tail call i32 @assert(i32 %10)
%12 = tail call i32 @wait_clocks(i32 1000)
%13 = tail call i32 @fgetc(i32 %1)
%14 = icmp eq i32 %13, 3
%15 = zext i1 %14 to i32
%16 = tail call i32 @assert(i32 %15)
%17 = tail call i32 @wait_clocks(i32 1000)
%18 = tail call i32 @fgetc(i32 %1)
%19 = icmp eq i32 %18, 4
%20 = zext i1 %19 to i32
%21 = tail call i32 @assert(i32 %20)
%22 = tail call i32 @wait_clocks(i32 1000)
%23 = tail call i32 @fgetc(i32 %1)
%24 = icmp eq i32 %23, 5
%25 = zext i1 %24 to i32
%26 = tail call i32 @assert(i32 %25)
%27 = tail call i32 @wait_clocks(i32 1000)
%28 = tail call i32 @fgetc(i32 %1)
%29 = icmp eq i32 %28, 6
%30 = zext i1 %29 to i32
%31 = tail call i32 @assert(i32 %30)
%32 = tail call i32 @wait_clocks(i32 1000)
%33 = tail call i32 @fgetc(i32 %1)
%34 = icmp eq i32 %33, 7
%35 = zext i1 %34 to i32
%36 = tail call i32 @assert(i32 %35)
%37 = tail call i32 @wait_clocks(i32 1000)
%38 = tail call i32 @fgetc(i32 %1)
%39 = icmp eq i32 %38, 8
%40 = zext i1 %39 to i32
%41 = tail call i32 @assert(i32 %40)
%42 = tail call i32 @wait_clocks(i32 1000)
%43 = tail call i32 @fgetc(i32 %1)
%44 = icmp eq i32 %43, 9
%45 = zext i1 %44 to i32
%46 = tail call i32 @assert(i32 %45)
%47 = tail call i32 @wait_clocks(i32 1000)
%48 = tail call i32 @fgetc(i32 %1)
%49 = icmp eq i32 %48, 10
%50 = zext i1 %49 to i32
%51 = tail call i32 @assert(i32 %50)
%52 = tail call i32 @report(i32 1)
ret void
}