#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 /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fscanf(int /*<<< orphan*/ *, char *, char **);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ scanf(char *, char **);
scalar_t__ strcmp(char *, char *);
int main(void) {
  FILE *secretWord;
  char secret[100];
  char guess[100];
  int counter;
  printf("You only have 3 chances to guess the secret word:\n");
  secretWord = fopen("secretword.txt", "r");
  if (secretWord == NULL) {
    printf("Cannot open secretWord for reading \n");
    exit(0);
  }
  fscanf(secretWord, "%s", &secret);
  fclose(secretWord);
  for (counter = 0; (counter < 3) && (strcmp(secret, guess) != 0); counter++) {
    scanf("%99s", &guess);
    if (strcmp(secret, guess) == 0) {
      printf("Well done. You got it right! You are very clever!!!!!!\n");
    } else {
      printf("%s is not the secret word, please try again:\n");
    }
  }
  for (counter = 0; (counter < 10000) && (strcmp(secret, guess) != 0);
       counter++) {
    if (strcmp(secret, guess) != 0) {
      printf("FAIL, FAIL, FAIL, FAIL, FAIL, FAIL, FAIL, FAIL, FAIL, FAIL\n");
      printf("!!!!!!!!!!!!!!!!!!!!!!!!FAIL!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n");
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x100,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe77(%rip),%rdi
call   1040 <printf@plt>
lea    0xe9e(%rip),%rdi
lea    0xea6(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    11c3 <main+0x53>
lea    0xe8d(%rip),%rdi
call   1040 <printf@plt>
xor    %edi,%edi
call   1090 <exit@plt>
mov    -0x10(%rbp),%rdi
lea    -0x80(%rbp),%rdx
lea    0xe97(%rip),%rsi
call   1050 <fscanf@plt>
mov    -0x10(%rbp),%rdi
call   1030 <fclose@plt>
movl   $0x0,-0xf4(%rbp)
xor    %eax,%eax
cmpl   $0x3,-0xf4(%rbp)
mov    %al,-0xf5(%rbp)
jge    121c <main+0xac>
lea    -0x80(%rbp),%rdi
lea    -0xf0(%rbp),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%rax
setne  %al
mov    %al,-0xf5(%rbp)
mov    -0xf5(%rbp),%al
test   $0x1,%al
jne    122f <main+0xbf>
jmp    1292 <main+0x122>
lea    -0xf0(%rbp),%rsi
lea    0xe2f(%rip),%rdi
call   1070 <scanf@plt>
lea    -0x80(%rbp),%rdi
lea    -0xf0(%rbp),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%rax
jne    126d <main+0xfd>
lea    0xe0e(%rip),%rdi
call   1040 <printf@plt>
jmp    1279 <main+0x109>
lea    0xe35(%rip),%rdi
call   1040 <printf@plt>
jmp    127e <main+0x10e>
mov    -0xf4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xf4(%rbp)
jmp    11ea <main+0x7a>
movl   $0x0,-0xf4(%rbp)
xor    %eax,%eax
cmpl   $0x2710,-0xf4(%rbp)
mov    %al,-0xf6(%rbp)
jge    12d1 <main+0x161>
lea    -0x80(%rbp),%rdi
lea    -0xf0(%rbp),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%rax
setne  %al
mov    %al,-0xf6(%rbp)
mov    -0xf6(%rbp),%al
test   $0x1,%al
jne    12e4 <main+0x174>
jmp    132f <main+0x1bf>
lea    -0x80(%rbp),%rdi
lea    -0xf0(%rbp),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%rax
je     1316 <main+0x1a6>
lea    0xdd2(%rip),%rdi
call   1040 <printf@plt>
lea    0xe02(%rip),%rdi
call   1040 <printf@plt>
jmp    131b <main+0x1ab>
mov    -0xf4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xf4(%rbp)
jmp    129c <main+0x12c>
xor    %eax,%eax
add    $0x100,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0xe0,%rsp
lea    0xeb1(%rip),%rdi
call   1030 <puts@plt>
lea    0xe5e(%rip),%rdi
lea    0xe66(%rip),%rsi
call   1090 <fopen@plt>
test   %rax,%rax
je     1339 <main+0x1b9>
mov    %rax,%rbx
lea    0xe50(%rip),%rsi
lea    0x70(%rsp),%r14
mov    %rax,%rdi
mov    %r14,%rdx
call   1060 <fscanf@plt>
mov    %rbx,%rdi
call   1040 <fclose@plt>
mov    %rsp,%rsi
mov    %r14,%rdi
call   1070 <strcmp@plt>
test   %rax,%rax
je     12cf <main+0x14f>
lea    0xe20(%rip),%rdi
mov    %rsp,%rbx
mov    %rbx,%rsi
call   1080 <scanf@plt>
lea    0x70(%rsp),%rdi
mov    %rbx,%rsi
call   1070 <strcmp@plt>
test   %rax,%rax
je     121f <main+0x9f>
lea    0xe01(%rip),%rdi
call   1050 <printf@plt>
jmp    122b <main+0xab>
lea    0xec9(%rip),%rdi
call   1030 <puts@plt>
lea    0x70(%rsp),%rdi
mov    %rsp,%rsi
call   1070 <strcmp@plt>
test   %rax,%rax
je     12cf <main+0x14f>
lea    0xdcc(%rip),%rdi
mov    %rsp,%rbx
mov    %rbx,%rsi
call   1080 <scanf@plt>
lea    0x70(%rsp),%rdi
mov    %rbx,%rsi
call   1070 <strcmp@plt>
test   %rax,%rax
je     1273 <main+0xf3>
lea    0xdad(%rip),%rdi
call   1050 <printf@plt>
jmp    127f <main+0xff>
lea    0xe75(%rip),%rdi
call   1030 <puts@plt>
lea    0x70(%rsp),%rdi
mov    %rsp,%rsi
call   1070 <strcmp@plt>
test   %rax,%rax
je     12cf <main+0x14f>
lea    0xd7c(%rip),%rdi
mov    %rsp,%rbx
mov    %rbx,%rsi
call   1080 <scanf@plt>
lea    0x70(%rsp),%rdi
mov    %rbx,%rsi
call   1070 <strcmp@plt>
test   %rax,%rax
je     12c3 <main+0x143>
lea    0xd5d(%rip),%rdi
call   1050 <printf@plt>
jmp    12cf <main+0x14f>
lea    0xe25(%rip),%rdi
call   1030 <puts@plt>
mov    $0x2710,%ebp
lea    0x70(%rsp),%r14
mov    %rsp,%rbx
lea    0xd96(%rip),%r15
lea    0xdca(%rip),%r12
jmp    12f5 <main+0x175>
nopl   0x0(%rax)
add    $0xffffffff,%ebp
je     1327 <main+0x1a7>
mov    %r14,%rdi
mov    %rbx,%rsi
call   1070 <strcmp@plt>
test   %rax,%rax
je     1327 <main+0x1a7>
mov    %r14,%rdi
mov    %rbx,%rsi
call   1070 <strcmp@plt>
test   %rax,%rax
je     12f0 <main+0x170>
mov    %r15,%rdi
call   1030 <puts@plt>
mov    %r12,%rdi
call   1030 <puts@plt>
jmp    12f0 <main+0x170>
xor    %eax,%eax
add    $0xe0,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xde6(%rip),%rdi
call   1030 <puts@plt>
xor    %edi,%edi
call   10a0 <exit@plt>

LLVM IR (-O0):
@.str = [51 x i8] c"You only have 3 chances to guess the secret word:\0A\00"
@.str.1 = [15 x i8] c"secretword.txt\00"
@.str.2 = [2 x i8] c"r\00"
@.str.3 = [37 x i8] c"Cannot open secretWord for reading \0A\00"
@.str.4 = [3 x i8] c"%s\00"
@.str.5 = [5 x i8] c"%99s\00"
@.str.6 = [56 x i8] c"Well done. You got it right! You are very clever!!!!!!\0A\00"
@.str.7 = [46 x i8] c"%s is not the secret word, please try again:\0A\00"
@.str.8 = [60 x i8] c"FAIL, FAIL, FAIL, FAIL, FAIL, FAIL, FAIL, FAIL, FAIL, FAIL\0A\00"
@.str.9 = [60 x i8] c"!!!!!!!!!!!!!!!!!!!!!!!!FAIL!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32*
%3 = alloca [100 x i8]
%4 = alloca [100 x i8]
%5 = alloca i32
store i32 0, i32* %1
%6 = call i32 @printf(i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str, i64 0, i64 0))
%7 = call i32* @fopen(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
store i32* %7, i32** %2
%8 = load i32*, i32** %2
%9 = icmp eq i32* %8, null
br i1 %9, label %10, label %13
10: ; preds = %0
%11 = call i32 @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.3, i64 0, i64 0))
%12 = call i32 @exit(i32 0)
unreachable
13: ; preds = %0
%14 = load i32*, i32** %2
%15 = bitcast [100 x i8]* %3 to i8**
%16 = call i32 @fscanf(i32* %14, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i8** %15)
%17 = load i32*, i32** %2
%18 = call i32 @fclose(i32* %17)
store i32 0, i32* %5
br label %19
19: ; preds = %41, %13
%20 = load i32, i32* %5
%21 = icmp slt i32 %20, 3
br i1 %21, label %22, label %27
22: ; preds = %19
%23 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%24 = getelementptr inbounds [100 x i8], [100 x i8]* %4, i64 0, i64 0
%25 = call i64 @strcmp(i8* %23, i8* %24)
%26 = icmp ne i64 %25, 0
br label %27
27: ; preds = %22, %19
%28 = phi i1 [ false, %19 ], [ %26, %22 ]
br i1 %28, label %29, label %44
29: ; preds = %27
%30 = bitcast [100 x i8]* %4 to i8**
%31 = call i32 @scanf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0), i8** %30)
%32 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%33 = getelementptr inbounds [100 x i8], [100 x i8]* %4, i64 0, i64 0
%34 = call i64 @strcmp(i8* %32, i8* %33)
%35 = icmp eq i64 %34, 0
br i1 %35, label %36, label %38
36: ; preds = %29
%37 = call i32 @printf(i8* getelementptr inbounds ([56 x i8], [56 x i8]* @.str.6, i64 0, i64 0))
br label %40
38: ; preds = %29
%39 = call i32 @printf(i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.7, i64 0, i64 0))
br label %40
40: ; preds = %38, %36
br label %41
41: ; preds = %40
%42 = load i32, i32* %5
%43 = add nsw i32 %42, 1
store i32 %43, i32* %5
br label %19
44: ; preds = %27
store i32 0, i32* %5
br label %45
45: ; preds = %64, %44
%46 = load i32, i32* %5
%47 = icmp slt i32 %46, 10000
br i1 %47, label %48, label %53
48: ; preds = %45
%49 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%50 = getelementptr inbounds [100 x i8], [100 x i8]* %4, i64 0, i64 0
%51 = call i64 @strcmp(i8* %49, i8* %50)
%52 = icmp ne i64 %51, 0
br label %53
53: ; preds = %48, %45
%54 = phi i1 [ false, %45 ], [ %52, %48 ]
br i1 %54, label %55, label %67
55: ; preds = %53
%56 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%57 = getelementptr inbounds [100 x i8], [100 x i8]* %4, i64 0, i64 0
%58 = call i64 @strcmp(i8* %56, i8* %57)
%59 = icmp ne i64 %58, 0
br i1 %59, label %60, label %63
60: ; preds = %55
%61 = call i32 @printf(i8* getelementptr inbounds ([60 x i8], [60 x i8]* @.str.8, i64 0, i64 0))
%62 = call i32 @printf(i8* getelementptr inbounds ([60 x i8], [60 x i8]* @.str.9, i64 0, i64 0))
br label %63
63: ; preds = %60, %55
br label %64
64: ; preds = %63
%65 = load i32, i32* %5
%66 = add nsw i32 %65, 1
store i32 %66, i32* %5
br label %45
67: ; preds = %53
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [15 x i8] c"secretword.txt\00"
@.str.2 = [2 x i8] c"r\00"
@.str.4 = [3 x i8] c"%s\00"
@.str.5 = [5 x i8] c"%99s\00"
@.str.7 = [46 x i8] c"%s is not the secret word, please try again:\0A\00"
@str = [50 x i8] c"You only have 3 chances to guess the secret word:\00"
@str.10 = [59 x i8] c"FAIL, FAIL, FAIL, FAIL, FAIL, FAIL, FAIL, FAIL, FAIL, FAIL\00"
@str.11 = [59 x i8] c"!!!!!!!!!!!!!!!!!!!!!!!!FAIL!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\00"
@str.12 = [55 x i8] c"Well done. You got it right! You are very clever!!!!!!\00"
@str.13 = [36 x i8] c"Cannot open secretWord for reading \00"
define i32 @main() {
%1 = alloca [100 x i8]
%2 = alloca [100 x i8]
%3 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 0
%4 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([50 x i8], [50 x i8]* @str, i64 0, i64 0))
%6 = tail call i32* @fopen(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%7 = icmp eq i32* %6, null
br i1 %7, label %8, label %11
8: ; preds = %0
%9 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([36 x i8], [36 x i8]* @str.13, i64 0, i64 0))
%10 = tail call i32 @exit(i32 0)
unreachable
11: ; preds = %0
%12 = bitcast [100 x i8]* %1 to i8**
%13 = call i32 @fscanf(i32* %6, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i8** %12)
%14 = call i32 @fclose(i32* %6)
%15 = bitcast [100 x i8]* %2 to i8**
%16 = call i64 @strcmp(i8* %3, i8* %4)
%17 = icmp eq i64 %16, 0
br i1 %17, label %48, label %18
18: ; preds = %11
%19 = call i32 @scanf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0), i8** %15)
%20 = call i64 @strcmp(i8* %3, i8* %4)
%21 = icmp eq i64 %20, 0
br i1 %21, label %22, label %24
22: ; preds = %18
%23 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([55 x i8], [55 x i8]* @str.12, i64 0, i64 0))
br label %26
24: ; preds = %18
%25 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([46 x i8], [46 x i8]* @.str.7, i64 0, i64 0))
br label %26
26: ; preds = %22, %24
%27 = call i64 @strcmp(i8* %3, i8* %4)
%28 = icmp eq i64 %27, 0
br i1 %28, label %48, label %29
29: ; preds = %26
%30 = call i32 @scanf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0), i8** %15)
%31 = call i64 @strcmp(i8* %3, i8* %4)
%32 = icmp eq i64 %31, 0
br i1 %32, label %35, label %33
33: ; preds = %29
%34 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([46 x i8], [46 x i8]* @.str.7, i64 0, i64 0))
br label %37
35: ; preds = %29
%36 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([55 x i8], [55 x i8]* @str.12, i64 0, i64 0))
br label %37
37: ; preds = %35, %33
%38 = call i64 @strcmp(i8* %3, i8* %4)
%39 = icmp eq i64 %38, 0
br i1 %39, label %48, label %40
40: ; preds = %37
%41 = call i32 @scanf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0), i8** %15)
%42 = call i64 @strcmp(i8* %3, i8* %4)
%43 = icmp eq i64 %42, 0
br i1 %43, label %46, label %44
44: ; preds = %40
%45 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([46 x i8], [46 x i8]* @.str.7, i64 0, i64 0))
br label %48
46: ; preds = %40
%47 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([55 x i8], [55 x i8]* @str.12, i64 0, i64 0))
br label %48
48: ; preds = %44, %46, %37, %26, %11
br label %49
49: ; preds = %48, %59
%50 = phi i32 [ %60, %59 ], [ 0, %48 ]
%51 = call i64 @strcmp(i8* %3, i8* %4)
%52 = icmp eq i64 %51, 0
br i1 %52, label %62, label %53
53: ; preds = %49
%54 = call i64 @strcmp(i8* %3, i8* %4)
%55 = icmp eq i64 %54, 0
br i1 %55, label %59, label %56
56: ; preds = %53
%57 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([59 x i8], [59 x i8]* @str.10, i64 0, i64 0))
%58 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([59 x i8], [59 x i8]* @str.11, i64 0, i64 0))
br label %59
59: ; preds = %53, %56
%60 = add nuw nsw i32 %50, 1
%61 = icmp eq i32 %60, 10000
br i1 %61, label %62, label %49
62: ; preds = %59, %49
ret i32 0
}