#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*/ int0;
typedef int /*<<< orphan*/ buf0;
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
unsigned int atoi(char *);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ fgets(char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fread(unsigned int *, int, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ stdin;
int main() {
  FILE *ran_file;
  unsigned int int0;
  int i;
  for (i = 0; i < 50; i++) {
    printf("%d days without an incident.\n", i);
    ran_file = fopen("/dev/urandom", "r");
    fread(&int0, sizeof(int0), 1, ran_file);
    fclose(ran_file);
    int0 = int0 % 100;
    char buf0[10];
    fgets(buf0, sizeof(buf0), stdin);
    if (int0 != atoi(buf0)) {
      printf("Well that didn't take long.\n");
      printf("You should have used %d.\n", int0);
      exit(0);
    }
  }
  printf("How very unpredictable. Level Cleared\n");
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x18(%rbp)
cmpl   $0x32,-0x18(%rbp)
jge    1253 <main+0xe3>
mov    -0x18(%rbp),%esi
lea    0xe66(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xe76(%rip),%rdi
lea    0xe7c(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rcx
lea    -0x14(%rbp),%rdi
mov    $0x4,%esi
mov    $0x1,%edx
call   1030 <fread@plt>
mov    -0x10(%rbp),%rdi
call   1040 <fclose@plt>
mov    -0x14(%rbp),%eax
mov    $0x64,%ecx
xor    %edx,%edx
div    %ecx
mov    %edx,-0x14(%rbp)
lea    -0x22(%rbp),%rdi
mov    0x2df6(%rip),%rax
mov    (%rax),%edx
mov    $0xa,%esi
call   1060 <fgets@plt>
mov    -0x14(%rbp),%eax
mov    %eax,-0x28(%rbp)
lea    -0x22(%rbp),%rdi
call   1080 <atoi@plt>
mov    %eax,%ecx
mov    -0x28(%rbp),%eax
cmp    %ecx,%eax
je     1240 <main+0xd0>
lea    0xe0c(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x14(%rbp),%esi
lea    0xe18(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
xor    %edi,%edi
call   1090 <exit@plt>
jmp    1245 <main+0xd5>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1186 <main+0x16>
lea    0xe0a(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
lea    0x8(%rsp),%r13
mov    0x2e4e(%rip),%r12
lea    0xe(%rsp),%r15
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
lea    0xe49(%rip),%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1060 <printf@plt>
lea    0xe57(%rip),%rdi
lea    0xe5d(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,%rbx
mov    %r13,%rdi
mov    $0x4,%esi
mov    $0x1,%edx
mov    %rax,%rcx
call   1040 <fread@plt>
mov    %rbx,%rdi
call   1050 <fclose@plt>
mov    0x8(%rsp),%r14d
imul   $0x51eb851f,%r14,%rax
shr    $0x25,%rax
imul   $0x64,%eax,%eax
sub    %eax,%r14d
mov    %r14d,0x8(%rsp)
mov    (%r12),%edx
mov    %r15,%rdi
mov    $0xa,%esi
call   1070 <fgets@plt>
mov    %r15,%rdi
call   1090 <atoi@plt>
cmp    %eax,%r14d
jne    1255 <main+0xd5>
add    $0x1,%ebp
cmp    $0x32,%ebp
jne    11b0 <main+0x30>
lea    0xe08(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xe11(%rip),%rdi
call   1030 <puts@plt>
lea    0xdc5(%rip),%rdi
mov    %r14d,%esi
xor    %eax,%eax
call   1060 <printf@plt>
xor    %edi,%edi
call   10a0 <exit@plt>

LLVM IR (-O0):
@.str = [30 x i8] c"%d days without an incident.\0A\00"
@.str.1 = [13 x i8] c"/dev/urandom\00"
@.str.2 = [2 x i8] c"r\00"
@stdin = global i32 0
@.str.3 = [29 x i8] c"Well that didn't take long.\0A\00"
@.str.4 = [26 x i8] c"You should have used %d.\0A\00"
@.str.5 = [39 x i8] c"How very unpredictable. Level Cleared\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32*
%3 = alloca i32
%4 = alloca i32
%5 = alloca [10 x i8]
store i32 0, i32* %1
store i32 0, i32* %4
br label %6
6: ; preds = %32, %0
%7 = load i32, i32* %4
%8 = icmp slt i32 %7, 50
br i1 %8, label %9, label %35
9: ; preds = %6
%10 = load i32, i32* %4
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0), i32 %10)
%12 = call i32* @fopen(i8* getelementptr inbounds ([13 x i8], [13 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* %12, i32** %2
%13 = load i32*, i32** %2
%14 = call i32 @fread(i32* %3, i32 4, i32 1, i32* %13)
%15 = load i32*, i32** %2
%16 = call i32 @fclose(i32* %15)
%17 = load i32, i32* %3
%18 = urem i32 %17, 100
store i32 %18, i32* %3
%19 = getelementptr inbounds [10 x i8], [10 x i8]* %5, i64 0, i64 0
%20 = load i32, i32* @stdin
%21 = call i32 @fgets(i8* %19, i32 10, i32 %20)
%22 = load i32, i32* %3
%23 = getelementptr inbounds [10 x i8], [10 x i8]* %5, i64 0, i64 0
%24 = call i32 @atoi(i8* %23)
%25 = icmp ne i32 %22, %24
br i1 %25, label %26, label %31
26: ; preds = %9
%27 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.3, i64 0, i64 0))
%28 = load i32, i32* %3
%29 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.4, i64 0, i64 0), i32 %28)
%30 = call i32 @exit(i32 0)
unreachable
31: ; preds = %9
br label %32
32: ; preds = %31
%33 = load i32, i32* %4
%34 = add nsw i32 %33, 1
store i32 %34, i32* %4
br label %6
35: ; preds = %6
%36 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.5, i64 0, i64 0))
%37 = load i32, i32* %1
ret i32 %37
}

LLVM IR (-O2):
@.str = [30 x i8] c"%d days without an incident.\0A\00"
@.str.1 = [13 x i8] c"/dev/urandom\00"
@.str.2 = [2 x i8] c"r\00"
@stdin = global i32 0
@.str.4 = [26 x i8] c"You should have used %d.\0A\00"
@str = [38 x i8] c"How very unpredictable. Level Cleared\00"
@str.6 = [28 x i8] c"Well that didn't take long.\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [10 x i8]
%3 = bitcast i32* %1 to i8*
%4 = getelementptr inbounds [10 x i8], [10 x i8]* %2, i64 0, i64 0
br label %5
5: ; preds = %0, %21
%6 = phi i32 [ 0, %0 ], [ %22, %21 ]
%7 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0), i32 %6)
%8 = call i32* @fopen(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%9 = call i32 @fread(i32* %1, i32 4, i32 1, i32* %8)
%10 = call i32 @fclose(i32* %8)
%11 = load i32, i32* %1
%12 = urem i32 %11, 100
store i32 %12, i32* %1
%13 = load i32, i32* @stdin
%14 = call i32 @fgets(i8* %4, i32 10, i32 %13)
%15 = call i32 @atoi(i8* %4)
%16 = icmp eq i32 %12, %15
br i1 %16, label %21, label %17
17: ; preds = %5
%18 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @str.6, i64 0, i64 0))
%19 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.4, i64 0, i64 0), i32 %12)
%20 = call i32 @exit(i32 0)
unreachable
21: ; preds = %5
%22 = add nuw nsw i32 %6, 1
%23 = icmp eq i32 %22, 50
br i1 %23, label %24, label %5
24: ; preds = %21
%25 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([38 x i8], [38 x i8]* @str, i64 0, i64 0))
ret i32 0
}