#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 */
char getc(int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ stdin;
int main() {
  char c;
  int correct_answer_count = 0;
  printf("What is the capital of the UK?\n");
  printf("\ta - London\n");
  printf("\tb - Paris\n");
  printf("\tc - Washington\n");
  c = getc(stdin);
  getc(stdin);
  if (c == 'a') {
    correct_answer_count++;
  }
  printf("What is the capital of France?\n");
  printf("\ta - London\n");
  printf("\tb - Paris\n");
  printf("\tc - Washington\n");
  c = getc(stdin);
  getc(stdin);
  if (c == 'b') {
    correct_answer_count++;
  }
  printf("What is the capital of the USA?\n");
  printf("\ta - London\n");
  printf("\tb - Paris\n");
  printf("\tc - Washington\n");
  c = getc(stdin);
  getc(stdin);
  if (c == 'c') {
    correct_answer_count++;
  }
  if (correct_answer_count == 3) {
    printf("Cool you got em all!\n");
  } else if (correct_answer_count == 2) {
    printf("2 out of 3 aint bad!\n");
  } else if (correct_answer_count == 1) {
    printf("1 out 3! Needs improving\n");
  } else {
    printf("Terrible, 0 out of 3\n");
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0xc(%rbp)
lea    0xec3(%rip),%rdi
call   1030 <printf@plt>
lea    0xed7(%rip),%rdi
call   1030 <printf@plt>
lea    0xed8(%rip),%rdi
call   1030 <printf@plt>
lea    0xed8(%rip),%rdi
call   1030 <printf@plt>
mov    0x2e7b(%rip),%rax
mov    (%rax),%edi
call   1040 <getc@plt>
mov    %al,-0x5(%rbp)
mov    0x2e6a(%rip),%rax
mov    (%rax),%edi
call   1040 <getc@plt>
movsbl -0x5(%rbp),%eax
cmp    $0x61,%eax
jne    119b <main+0x7b>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
lea    0xea8(%rip),%rdi
call   1030 <printf@plt>
lea    0xe72(%rip),%rdi
call   1030 <printf@plt>
lea    0xe73(%rip),%rdi
call   1030 <printf@plt>
lea    0xe73(%rip),%rdi
call   1030 <printf@plt>
mov    0x2e16(%rip),%rax
mov    (%rax),%edi
call   1040 <getc@plt>
mov    %al,-0x5(%rbp)
mov    0x2e05(%rip),%rax
mov    (%rax),%edi
call   1040 <getc@plt>
movsbl -0x5(%rbp),%eax
cmp    $0x62,%eax
jne    1200 <main+0xe0>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
lea    0xe63(%rip),%rdi
call   1030 <printf@plt>
lea    0xe0d(%rip),%rdi
call   1030 <printf@plt>
lea    0xe0e(%rip),%rdi
call   1030 <printf@plt>
lea    0xe0e(%rip),%rdi
call   1030 <printf@plt>
mov    0x2db1(%rip),%rax
mov    (%rax),%edi
call   1040 <getc@plt>
mov    %al,-0x5(%rbp)
mov    0x2da0(%rip),%rax
mov    (%rax),%edi
call   1040 <getc@plt>
movsbl -0x5(%rbp),%eax
cmp    $0x63,%eax
jne    1265 <main+0x145>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
cmpl   $0x3,-0xc(%rbp)
jne    1280 <main+0x160>
lea    0xe15(%rip),%rdi
call   1030 <printf@plt>
jmp    12cc <main+0x1ac>
cmpl   $0x2,-0xc(%rbp)
jne    129b <main+0x17b>
lea    0xe10(%rip),%rdi
call   1030 <printf@plt>
jmp    12c7 <main+0x1a7>
cmpl   $0x1,-0xc(%rbp)
jne    12b6 <main+0x196>
lea    0xe0b(%rip),%rdi
call   1030 <printf@plt>
jmp    12c2 <main+0x1a2>
lea    0xe14(%rip),%rdi
call   1030 <printf@plt>
jmp    12c7 <main+0x1a7>
jmp    12cc <main+0x1ac>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
lea    0xece(%rip),%rdi
call   1030 <puts@plt>
lea    0xf20(%rip),%rbp
mov    %rbp,%rdi
call   1030 <puts@plt>
lea    0xf1d(%rip),%r15
mov    %r15,%rdi
call   1030 <puts@plt>
lea    0xf19(%rip),%r12
mov    %r12,%rdi
call   1030 <puts@plt>
mov    0x2e7d(%rip),%r13
mov    0x0(%r13),%edi
call   1040 <getc@plt>
mov    %eax,%ebx
mov    0x0(%r13),%edi
call   1040 <getc@plt>
xor    %r14d,%r14d
cmp    $0x61,%bl
sete   %r14b
lea    0xe8f(%rip),%rdi
call   1030 <puts@plt>
mov    %rbp,%rdi
call   1030 <puts@plt>
mov    %r15,%rdi
call   1030 <puts@plt>
mov    %r12,%rdi
call   1030 <puts@plt>
mov    0x0(%r13),%edi
call   1040 <getc@plt>
mov    %eax,%ebx
mov    0x0(%r13),%edi
call   1040 <getc@plt>
lea    0x1(%r14),%ebp
cmp    $0x62,%bl
cmovne %r14d,%ebp
lea    0xe6b(%rip),%rdi
call   1030 <puts@plt>
lea    0xe7f(%rip),%rdi
call   1030 <puts@plt>
mov    %r15,%rdi
call   1030 <puts@plt>
mov    %r12,%rdi
call   1030 <puts@plt>
mov    0x0(%r13),%edi
call   1040 <getc@plt>
mov    %eax,%ebx
mov    0x0(%r13),%edi
call   1040 <getc@plt>
xor    %eax,%eax
cmp    $0x63,%bl
sete   %al
add    %ebp,%eax
add    $0xffffffff,%eax
cmp    $0x2,%eax
ja     122c <main+0x10c>
cltq
lea    0xebd(%rip),%rcx
movslq (%rcx,%rax,4),%rdi
add    %rcx,%rdi
jmp    1233 <main+0x113>
lea    0xe52(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [32 x i8] c"What is the capital of the UK?\0A\00"
@.str.1 = [13 x i8] c"\09a - London\0A\00"
@.str.2 = [12 x i8] c"\09b - Paris\0A\00"
@.str.3 = [17 x i8] c"\09c - Washington\0A\00"
@stdin = global i32 0
@.str.4 = [32 x i8] c"What is the capital of France?\0A\00"
@.str.5 = [33 x i8] c"What is the capital of the USA?\0A\00"
@.str.6 = [22 x i8] c"Cool you got em all!\0A\00"
@.str.7 = [22 x i8] c"2 out of 3 aint bad!\0A\00"
@.str.8 = [26 x i8] c"1 out 3! Needs improving\0A\00"
@.str.9 = [22 x i8] c"Terrible, 0 out of 3\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i8
%3 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %3
%4 = call i32 @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0))
%5 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0))
%6 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0))
%7 = call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.3, i64 0, i64 0))
%8 = load i32, i32* @stdin
%9 = call signext i8 @getc(i32 %8)
store i8 %9, i8* %2
%10 = load i32, i32* @stdin
%11 = call signext i8 @getc(i32 %10)
%12 = load i8, i8* %2
%13 = sext i8 %12 to i32
%14 = icmp eq i32 %13, 97
br i1 %14, label %15, label %18
15: ; preds = %0
%16 = load i32, i32* %3
%17 = add nsw i32 %16, 1
store i32 %17, i32* %3
br label %18
18: ; preds = %15, %0
%19 = call i32 @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.4, i64 0, i64 0))
%20 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0))
%21 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0))
%22 = call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.3, i64 0, i64 0))
%23 = load i32, i32* @stdin
%24 = call signext i8 @getc(i32 %23)
store i8 %24, i8* %2
%25 = load i32, i32* @stdin
%26 = call signext i8 @getc(i32 %25)
%27 = load i8, i8* %2
%28 = sext i8 %27 to i32
%29 = icmp eq i32 %28, 98
br i1 %29, label %30, label %33
30: ; preds = %18
%31 = load i32, i32* %3
%32 = add nsw i32 %31, 1
store i32 %32, i32* %3
br label %33
33: ; preds = %30, %18
%34 = call i32 @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.5, i64 0, i64 0))
%35 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0))
%36 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0))
%37 = call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.3, i64 0, i64 0))
%38 = load i32, i32* @stdin
%39 = call signext i8 @getc(i32 %38)
store i8 %39, i8* %2
%40 = load i32, i32* @stdin
%41 = call signext i8 @getc(i32 %40)
%42 = load i8, i8* %2
%43 = sext i8 %42 to i32
%44 = icmp eq i32 %43, 99
br i1 %44, label %45, label %48
45: ; preds = %33
%46 = load i32, i32* %3
%47 = add nsw i32 %46, 1
store i32 %47, i32* %3
br label %48
48: ; preds = %45, %33
%49 = load i32, i32* %3
%50 = icmp eq i32 %49, 3
br i1 %50, label %51, label %53
51: ; preds = %48
%52 = call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.6, i64 0, i64 0))
br label %67
53: ; preds = %48
%54 = load i32, i32* %3
%55 = icmp eq i32 %54, 2
br i1 %55, label %56, label %58
56: ; preds = %53
%57 = call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.7, i64 0, i64 0))
br label %66
58: ; preds = %53
%59 = load i32, i32* %3
%60 = icmp eq i32 %59, 1
br i1 %60, label %61, label %63
61: ; preds = %58
%62 = call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.8, i64 0, i64 0))
br label %65
63: ; preds = %58
%64 = call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.9, i64 0, i64 0))
br label %65
65: ; preds = %63, %61
br label %66
66: ; preds = %65, %56
br label %67
67: ; preds = %66, %51
ret i32 0
}

LLVM IR (-O2):
@stdin = global i32 0
@str = [31 x i8] c"What is the capital of the UK?\00"
@str.13 = [31 x i8] c"What is the capital of France?\00"
@str.17 = [32 x i8] c"What is the capital of the USA?\00"
@str.18 = [12 x i8] c"\09a - London\00"
@str.19 = [11 x i8] c"\09b - Paris\00"
@str.20 = [16 x i8] c"\09c - Washington\00"
@str.21 = [21 x i8] c"Terrible, 0 out of 3\00"
@str.22 = [25 x i8] c"1 out 3! Needs improving\00"
@str.23 = [21 x i8] c"2 out of 3 aint bad!\00"
@str.24 = [21 x i8] c"Cool you got em all!\00"
@reltable.main = [3 x i32] [i32 trunc (i64 sub (i64 ptrtoint ([25 x i8]* @str.22 to i64), i64 ptrtoint ([3 x i32]* @reltable.main to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([21 x i8]* @str.23 to i64), i64 ptrtoint ([3 x i32]* @reltable.main to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([21 x i8]* @str.24 to i64), i64 ptrtoint ([3 x i32]* @reltable.main to i64)) to i32)]
define i32 @main() {
%1 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @str, i64 0, i64 0))
%2 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @str.18, i64 0, i64 0))
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @str.19, i64 0, i64 0))
%4 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @str.20, i64 0, i64 0))
%5 = load i32, i32* @stdin
%6 = tail call signext i8 @getc(i32 %5)
%7 = load i32, i32* @stdin
%8 = tail call signext i8 @getc(i32 %7)
%9 = icmp eq i8 %6, 97
%10 = zext i1 %9 to i32
%11 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @str.13, i64 0, i64 0))
%12 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @str.18, i64 0, i64 0))
%13 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @str.19, i64 0, i64 0))
%14 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @str.20, i64 0, i64 0))
%15 = load i32, i32* @stdin
%16 = tail call signext i8 @getc(i32 %15)
%17 = load i32, i32* @stdin
%18 = tail call signext i8 @getc(i32 %17)
%19 = icmp eq i8 %16, 98
%20 = select i1 %9, i32 2, i32 1
%21 = select i1 %19, i32 %20, i32 %10
%22 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @str.17, i64 0, i64 0))
%23 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @str.18, i64 0, i64 0))
%24 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @str.19, i64 0, i64 0))
%25 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @str.20, i64 0, i64 0))
%26 = load i32, i32* @stdin
%27 = tail call signext i8 @getc(i32 %26)
%28 = load i32, i32* @stdin
%29 = tail call signext i8 @getc(i32 %28)
%30 = icmp eq i8 %27, 99
%31 = zext i1 %30 to i32
%32 = add nuw nsw i32 %21, %31
%33 = add nsw i32 %32, -1
%34 = icmp ult i32 %33, 3
br i1 %34, label %35, label %39
35: ; preds = %0
%36 = sext i32 %33 to i64
%37 = shl i64 %36, 2
%38 = call i8* @llvm.load.relative.i64(i8* bitcast ([3 x i32]* @reltable.main to i8*), i64 %37)
br label %39
39: ; preds = %0, %35
%40 = phi i8* [ %38, %35 ], [ getelementptr inbounds ([21 x i8], [21 x i8]* @str.21, i64 0, i64 0), %0 ]
%41 = tail call i32 @puts(i8* dereferenceable(1) %40)
ret i32 0
}