#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*/ getchar();
int /*<<< orphan*/ gets(char *);
int /*<<< orphan*/ printf(char *, ...);
int strcmp(char *, char *);
main() {
  int i;
  int found = 1;
  int same = 1;
  char country[10];
  char *countries[10] = {"Austrailia", "Belgium", "China",  "Denmark",
                         "England",    "France",  "Greece", "Ireland",
                         "Scotland",   "Wales"};
  char *capitals[10] = {"Canberra",  "Brussels", "Beijing", "Copenhagan",
                        "London",    "Paris",    "Athens",  "Dublin",
                        "Edinbrugh", "Cardiff"};
  printf("Please enter the name of a country:\n");
  gets(country);
  for (i = 0; i < 10; i++) {
    same = strcmp(country, *(countries + i));
    if (same == 0) {
      printf("The Capital of %s is %s!", country, *(capitals + i));
      found = 0;
    }
    *countries[i]++;
    *capitals[i]++;
  }
  if (found == 1) {
    printf("Sorry, that Country is not in our registry");
  }
  getchar();
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xc0,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x1,-0xc(%rbp)
movl   $0x1,-0x10(%rbp)
lea    -0x70(%rbp),%rdi
lea    0x2c05(%rip),%rsi
mov    $0x50,%edx
call   1060 <memcpy@plt>
lea    -0xc0(%rbp),%rdi
lea    0x2c3d(%rip),%rsi
mov    $0x50,%edx
call   1060 <memcpy@plt>
lea    0xefc(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x1a(%rbp),%rdi
call   1070 <gets@plt>
movl   $0x0,-0x8(%rbp)
cmpl   $0xa,-0x8(%rbp)
jge    1241 <main+0xf1>
lea    -0x1a(%rbp),%rdi
movslq -0x8(%rbp),%rax
mov    -0x70(%rbp,%rax,8),%rsi
call   1040 <strcmp@plt>
mov    %eax,-0x10(%rbp)
cmpl   $0x0,-0x10(%rbp)
jne    1209 <main+0xb9>
lea    -0x1a(%rbp),%rsi
movslq -0x8(%rbp),%rax
mov    -0xc0(%rbp,%rax,8),%rdx
ff
lea    0xeca(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0xc(%rbp)
movslq -0x8(%rbp),%rax
mov    -0x70(%rbp,%rax,8),%rcx
add    $0x1,%rcx
mov    %rcx,-0x70(%rbp,%rax,8)
movslq -0x8(%rbp),%rax
mov    -0xc0(%rbp,%rax,8),%rcx
ff
add    $0x1,%rcx
mov    %rcx,-0xc0(%rbp,%rax,8)
ff
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    11bb <main+0x6b>
cmpl   $0x1,-0xc(%rbp)
jne    1259 <main+0x109>
lea    0xe8c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0x0,%al
call   1050 <getchar@plt>
mov    -0x4(%rbp),%eax
add    $0xc0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0xb8,%rsp
movaps 0x2c58(%rip),%xmm0
movaps %xmm0,0x90(%rsp)
movaps 0x2c39(%rip),%xmm0
movaps %xmm0,0x80(%rsp)
movaps 0x2c1a(%rip),%xmm0
movaps %xmm0,0x70(%rsp)
movaps 0x2bfe(%rip),%xmm0
movaps %xmm0,0x60(%rsp)
movaps 0x2be2(%rip),%xmm0
movaps %xmm0,0x50(%rsp)
movaps 0x2c66(%rip),%xmm0
movaps %xmm0,0x40(%rsp)
movaps 0x2c4a(%rip),%xmm0
movaps %xmm0,0x30(%rsp)
movaps 0x2c2e(%rip),%xmm0
movaps %xmm0,0x20(%rsp)
movaps 0x2c12(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
movaps 0x2bf6(%rip),%xmm0
movaps %xmm0,(%rsp)
lea    0xeff(%rip),%rdi
call   1030 <puts@plt>
lea    0xae(%rsp),%r15
mov    %r15,%rdi
call   1070 <gets@plt>
mov    $0x1,%r13b
xor    %ebp,%ebp
lea    0xe9a(%rip),%r14
add    $0x1,%rbp
nopw   0x0(%rax,%rax,1)
mov    0x48(%rsp,%rbp,8),%rbx
mov    %r15,%rdi
mov    %rbx,%rsi
call   1050 <strcmp@plt>
mov    -0x8(%rsp,%rbp,8),%r12
test   %eax,%eax
je     1250 <main+0x100>
add    $0x1,%rbx
mov    %rbx,0x48(%rsp,%rbp,8)
add    $0x1,%r12
mov    %r12,-0x8(%rsp,%rbp,8)
add    $0x1,%rbp
cmp    $0xb,%rbp
jne    1210 <main+0xc0>
jmp    127d <main+0x12d>
nopw   0x0(%rax,%rax,1)
xor    %r13d,%r13d
mov    %r14,%rdi
mov    %r15,%rsi
mov    %r12,%rdx
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x1,%rbx
mov    %rbx,0x48(%rsp,%rbp,8)
add    $0x1,%r12
mov    %r12,-0x8(%rsp,%rbp,8)
cmp    $0xa,%rbp
jne    1206 <main+0xb6>
jmp    1291 <main+0x141>
test   $0x1,%r13b
je     1291 <main+0x141>
lea    0xe2f(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
call   1060 <getchar@plt>
xor    %eax,%eax
add    $0xb8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [11 x i8] c"Austrailia\00"
@.str.1 = [8 x i8] c"Belgium\00"
@.str.2 = [6 x i8] c"China\00"
@.str.3 = [8 x i8] c"Denmark\00"
@.str.4 = [8 x i8] c"England\00"
@.str.5 = [7 x i8] c"France\00"
@.str.6 = [7 x i8] c"Greece\00"
@.str.7 = [8 x i8] c"Ireland\00"
@.str.8 = [9 x i8] c"Scotland\00"
@.str.9 = [6 x i8] c"Wales\00"
@__const.main.countries = [10 x i8*] [i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i32 0, i32 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i32 0, i32 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i32 0, i32 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i32 0, i32 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i32 0, i32 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.5, i32 0, i32 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.6, i32 0, i32 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.7, i32 0, i32 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.8, i32 0, i32 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.9, i32 0, i32 0)]
@.str.10 = [9 x i8] c"Canberra\00"
@.str.11 = [9 x i8] c"Brussels\00"
@.str.12 = [8 x i8] c"Beijing\00"
@.str.13 = [11 x i8] c"Copenhagan\00"
@.str.14 = [7 x i8] c"London\00"
@.str.15 = [6 x i8] c"Paris\00"
@.str.16 = [7 x i8] c"Athens\00"
@.str.17 = [7 x i8] c"Dublin\00"
@.str.18 = [10 x i8] c"Edinbrugh\00"
@.str.19 = [8 x i8] c"Cardiff\00"
@__const.main.capitals = [10 x i8*] [i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.10, i32 0, i32 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.11, i32 0, i32 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.12, i32 0, i32 0), i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.13, i32 0, i32 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.14, i32 0, i32 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.15, i32 0, i32 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.16, i32 0, i32 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.17, i32 0, i32 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.18, i32 0, i32 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.19, i32 0, i32 0)]
@.str.20 = [37 x i8] c"Please enter the name of a country:\0A\00"
@.str.21 = [25 x i8] c"The Capital of %s is %s!\00"
@.str.22 = [43 x i8] c"Sorry, that Country is not in our registry\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca [10 x i8]
%6 = alloca [10 x i8*]
%7 = alloca [10 x i8*]
store i32 0, i32* %1
store i32 1, i32* %3
store i32 1, i32* %4
%8 = bitcast [10 x i8*]* %6 to i8*
%9 = bitcast [10 x i8*]* %7 to i8*
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.20, i64 0, i64 0))
%11 = getelementptr inbounds [10 x i8], [10 x i8]* %5, i64 0, i64 0
%12 = call i32 @gets(i8* %11)
store i32 0, i32* %2
br label %13
13: ; preds = %47, %0
%14 = load i32, i32* %2
%15 = icmp slt i32 %14, 10
br i1 %15, label %16, label %50
16: ; preds = %13
%17 = getelementptr inbounds [10 x i8], [10 x i8]* %5, i64 0, i64 0
%18 = getelementptr inbounds [10 x i8*], [10 x i8*]* %6, i64 0, i64 0
%19 = load i32, i32* %2
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds i8*, i8** %18, i64 %20
%22 = load i8*, i8** %21
%23 = call i32 @strcmp(i8* %17, i8* %22)
store i32 %23, i32* %4
%24 = load i32, i32* %4
%25 = icmp eq i32 %24, 0
br i1 %25, label %26, label %34
26: ; preds = %16
%27 = getelementptr inbounds [10 x i8], [10 x i8]* %5, i64 0, i64 0
%28 = getelementptr inbounds [10 x i8*], [10 x i8*]* %7, i64 0, i64 0
%29 = load i32, i32* %2
%30 = sext i32 %29 to i64
%31 = getelementptr inbounds i8*, i8** %28, i64 %30
%32 = load i8*, i8** %31
%33 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.21, i64 0, i64 0), i8* %27, i8* %32)
store i32 0, i32* %3
br label %34
34: ; preds = %26, %16
%35 = load i32, i32* %2
%36 = sext i32 %35 to i64
%37 = getelementptr inbounds [10 x i8*], [10 x i8*]* %6, i64 0, i64 %36
%38 = load i8*, i8** %37
%39 = getelementptr inbounds i8, i8* %38, i32 1
store i8* %39, i8** %37
%40 = load i8, i8* %38
%41 = load i32, i32* %2
%42 = sext i32 %41 to i64
%43 = getelementptr inbounds [10 x i8*], [10 x i8*]* %7, i64 0, i64 %42
%44 = load i8*, i8** %43
%45 = getelementptr inbounds i8, i8* %44, i32 1
store i8* %45, i8** %43
%46 = load i8, i8* %44
br label %47
47: ; preds = %34
%48 = load i32, i32* %2
%49 = add nsw i32 %48, 1
store i32 %49, i32* %2
br label %13
50: ; preds = %13
%51 = load i32, i32* %3
%52 = icmp eq i32 %51, 1
br i1 %52, label %53, label %55
53: ; preds = %50
%54 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.22, i64 0, i64 0))
br label %55
55: ; preds = %53, %50
%56 = call i32 (...) @getchar()
%57 = load i32, i32* %1
ret i32 %57
}

LLVM IR (-O2):
@.str = [11 x i8] c"Austrailia\00"
@.str.1 = [8 x i8] c"Belgium\00"
@.str.2 = [6 x i8] c"China\00"
@.str.3 = [8 x i8] c"Denmark\00"
@.str.4 = [8 x i8] c"England\00"
@.str.5 = [7 x i8] c"France\00"
@.str.6 = [7 x i8] c"Greece\00"
@.str.7 = [8 x i8] c"Ireland\00"
@.str.8 = [9 x i8] c"Scotland\00"
@.str.9 = [6 x i8] c"Wales\00"
@__const.main.countries = [10 x i8*] [i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i32 0, i32 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i32 0, i32 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i32 0, i32 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i32 0, i32 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i32 0, i32 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.5, i32 0, i32 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.6, i32 0, i32 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.7, i32 0, i32 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.8, i32 0, i32 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.9, i32 0, i32 0)]
@.str.10 = [9 x i8] c"Canberra\00"
@.str.11 = [9 x i8] c"Brussels\00"
@.str.12 = [8 x i8] c"Beijing\00"
@.str.13 = [11 x i8] c"Copenhagan\00"
@.str.14 = [7 x i8] c"London\00"
@.str.15 = [6 x i8] c"Paris\00"
@.str.16 = [7 x i8] c"Athens\00"
@.str.17 = [7 x i8] c"Dublin\00"
@.str.18 = [10 x i8] c"Edinbrugh\00"
@.str.19 = [8 x i8] c"Cardiff\00"
@__const.main.capitals = [10 x i8*] [i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.10, i32 0, i32 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.11, i32 0, i32 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.12, i32 0, i32 0), i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.13, i32 0, i32 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.14, i32 0, i32 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.15, i32 0, i32 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.16, i32 0, i32 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.17, i32 0, i32 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.18, i32 0, i32 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.19, i32 0, i32 0)]
@.str.21 = [25 x i8] c"The Capital of %s is %s!\00"
@.str.22 = [43 x i8] c"Sorry, that Country is not in our registry\00"
@str = [36 x i8] c"Please enter the name of a country:\00"
define i32 @main() {
%1 = alloca [10 x i8]
%2 = alloca [10 x i8*]
%3 = alloca [10 x i8*]
%4 = getelementptr inbounds [10 x i8], [10 x i8]* %1, i64 0, i64 0
%5 = bitcast [10 x i8*]* %2 to i8*
%6 = bitcast [10 x i8*]* %3 to i8*
%7 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([36 x i8], [36 x i8]* @str, i64 0, i64 0))
%8 = call i32 @gets(i8* %4)
br label %9
9: ; preds = %26, %0
%10 = phi i64 [ %31, %26 ], [ 0, %0 ]
%11 = phi i1 [ false, %26 ], [ true, %0 ]
br label %12
12: ; preds = %9, %20
%13 = phi i64 [ %24, %20 ], [ %10, %9 ]
%14 = getelementptr inbounds [10 x i8*], [10 x i8*]* %2, i64 0, i64 %13
%15 = load i8*, i8** %14
%16 = call i32 @strcmp(i8* %4, i8* dereferenceable(1) %15)
%17 = icmp eq i32 %16, 0
%18 = getelementptr inbounds [10 x i8*], [10 x i8*]* %3, i64 0, i64 %13
%19 = load i8*, i8** %18
br i1 %17, label %26, label %20
20: ; preds = %12
%21 = getelementptr inbounds i8, i8* %15, i64 1
store i8* %21, i8** %14
%22 = getelementptr inbounds [10 x i8*], [10 x i8*]* %3, i64 0, i64 %13
%23 = getelementptr inbounds i8, i8* %19, i64 1
store i8* %23, i8** %22
%24 = add nuw nsw i64 %13, 1
%25 = icmp eq i64 %24, 10
br i1 %25, label %33, label %12
26: ; preds = %12
%27 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str.21, i64 0, i64 0), i8* %4, i8* %19)
%28 = getelementptr inbounds i8, i8* %15, i64 1
store i8* %28, i8** %14
%29 = getelementptr inbounds [10 x i8*], [10 x i8*]* %3, i64 0, i64 %13
%30 = getelementptr inbounds i8, i8* %19, i64 1
store i8* %30, i8** %29
%31 = add nuw nsw i64 %13, 1
%32 = icmp eq i64 %31, 10
br i1 %32, label %36, label %9
33: ; preds = %20
br i1 %11, label %34, label %36
34: ; preds = %33
%35 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([43 x i8], [43 x i8]* @.str.22, i64 0, i64 0))
br label %36
36: ; preds = %26, %34, %33
%37 = call i32 (...) @getchar()
ret i32 0
}