#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 */
char EOF;
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
char fgetc(int /*<<< orphan*/ *);
scalar_t__ fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fscanf(int /*<<< orphan*/ *, char *, ...);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ rewind(int /*<<< orphan*/ *);
void main() {
  FILE *fp;
  char ch;
  char szLine[80] = {0};
  int health = 0, gold = 0;
  fp = fopen("Stats.txt", "r");
  if (fp == 0) {
    printf("ERROR: Could not find Stats.txt!\n");
    return;
  }
  printf("\n");
  while ((ch = fgetc(fp)) != EOF)
    printf("%c", ch);
  printf("\n");
  rewind(fp);
  while (fgets(szLine, 80, fp))
    printf("%s", szLine);
  printf("\n");
  rewind(fp);
  fscanf(fp, "Player: %s\n", szLine);
  fscanf(fp, "Health: %d\n", &health);
  fscanf(fp, "Gold: %d\n", &gold);
  printf("The Player's name is:   %s\n", szLine);
  printf("The Player's health is: %d\n", health);
  printf("The Player's gold is:   %d\n", gold);
  fclose(fp);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
lea    -0x60(%rbp),%rdi
xor    %esi,%esi
mov    $0x50,%edx
call   1060 <memset@plt>
movl   $0x0,-0x64(%rbp)
movl   $0x0,-0x68(%rbp)
lea    0xe53(%rip),%rdi
lea    0xe56(%rip),%rsi
call   10a0 <fopen@plt>
mov    %rax,-0x8(%rbp)
cmpq   $0x0,-0x8(%rbp)
jne    11db <main+0x5b>
lea    0xe3d(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1301 <main+0x181>
lea    0xe4a(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x8(%rbp),%rdi
call   1080 <fgetc@plt>
mov    %al,-0x9(%rbp)
movsbl %al,%eax
mov    0x2de9(%rip),%rcx
movsbl (%rcx),%ecx
cmp    %ecx,%eax
je     1221 <main+0xa1>
movsbl -0x9(%rbp),%esi
lea    0xe19(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    11e9 <main+0x69>
lea    0xe04(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x8(%rbp),%rdi
call   1050 <rewind@plt>
lea    -0x60(%rbp),%rdi
mov    -0x8(%rbp),%rdx
mov    $0x50,%esi
call   1090 <fgets@plt>
cmp    $0x0,%rax
je     126b <main+0xeb>
lea    -0x60(%rbp),%rsi
lea    0xdd2(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1238 <main+0xb8>
lea    0xdba(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x8(%rbp),%rdi
call   1050 <rewind@plt>
mov    -0x8(%rbp),%rdi
lea    -0x60(%rbp),%rdx
lea    0xda3(%rip),%rsi
mov    $0x0,%al
call   1070 <fscanf@plt>
mov    -0x8(%rbp),%rdi
lea    0xd9d(%rip),%rsi
lea    -0x64(%rbp),%rdx
mov    $0x0,%al
call   1070 <fscanf@plt>
mov    -0x8(%rbp),%rdi
lea    0xd93(%rip),%rsi
lea    -0x68(%rbp),%rdx
mov    $0x0,%al
call   1070 <fscanf@plt>
lea    -0x60(%rbp),%rsi
lea    0xd87(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x64(%rbp),%esi
lea    0xd92(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x68(%rbp),%esi
lea    0xd9d(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x8(%rbp),%rdi
call   1030 <fclose@plt>
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x60,%rsp
xorps  %xmm0,%xmm0
movaps %xmm0,0x50(%rsp)
movaps %xmm0,0x40(%rsp)
movaps %xmm0,0x30(%rsp)
movaps %xmm0,0x20(%rsp)
movaps %xmm0,0x10(%rsp)
movl   $0x0,0xc(%rsp)
movl   $0x0,0x8(%rsp)
lea    0xe34(%rip),%rdi
lea    0xe37(%rip),%rsi
call   10b0 <fopen@plt>
test   %rax,%rax
je     1320 <main+0x190>
mov    %rax,%r15
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    %r15,%rdi
call   1090 <fgetc@plt>
mov    0x2deb(%rip),%rbx
cmp    (%rbx),%al
je     1224 <main+0x94>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
movsbl %al,%edi
call   1030 <putchar@plt>
mov    %r15,%rdi
call   1090 <fgetc@plt>
cmp    (%rbx),%al
jne    1210 <main+0x80>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    %r15,%rdi
call   1070 <rewind@plt>
lea    0x10(%rsp),%rdi
mov    $0x50,%esi
mov    %r15,%rdx
call   10a0 <fgets@plt>
test   %rax,%rax
je     1282 <main+0xf2>
lea    0xdb8(%rip),%r14
lea    0x10(%rsp),%rbx
nopl   0x0(%rax)
mov    %r14,%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1060 <printf@plt>
mov    %rbx,%rdi
mov    $0x50,%esi
mov    %r15,%rdx
call   10a0 <fgets@plt>
test   %rax,%rax
jne    1260 <main+0xd0>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    %r15,%rdi
call   1070 <rewind@plt>
lea    0xd74(%rip),%rsi
lea    0x10(%rsp),%rbx
mov    %r15,%rdi
mov    %rbx,%rdx
xor    %eax,%eax
call   1080 <fscanf@plt>
lea    0xd67(%rip),%rsi
lea    0xc(%rsp),%rdx
mov    %r15,%rdi
xor    %eax,%eax
call   1080 <fscanf@plt>
lea    0xd5d(%rip),%rsi
lea    0x8(%rsp),%rdx
mov    %r15,%rdi
xor    %eax,%eax
call   1080 <fscanf@plt>
lea    0xd51(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1060 <printf@plt>
mov    0xc(%rsp),%esi
lea    0xd58(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    0x8(%rsp),%esi
lea    0xd62(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    %r15,%rdi
call   1050 <fclose@plt>
add    $0x60,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret
lea    0xd5e(%rip),%rdi
add    $0x60,%rsp
pop    %rbx
pop    %r14
pop    %r15
jmp    1040 <puts@plt>

LLVM IR (-O0):
@.str = [10 x i8] c"Stats.txt\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [34 x i8] c"ERROR: Could not find Stats.txt!\0A\00"
@.str.3 = [2 x i8] c"\0A\00"
@EOF = global i8 0
@.str.4 = [3 x i8] c"%c\00"
@.str.5 = [3 x i8] c"%s\00"
@.str.6 = [12 x i8] c"Player: %s\0A\00"
@.str.7 = [12 x i8] c"Health: %d\0A\00"
@.str.8 = [10 x i8] c"Gold: %d\0A\00"
@.str.9 = [28 x i8] c"The Player's name is: %s\0A\00"
@.str.10 = [28 x i8] c"The Player's health is: %d\0A\00"
@.str.11 = [28 x i8] c"The Player's gold is: %d\0A\00"
define void @main() {
%1 = alloca i32*
%2 = alloca i8
%3 = alloca [80 x i8]
%4 = alloca i32
%5 = alloca i32
%6 = bitcast [80 x i8]* %3 to i8*
store i32 0, i32* %4
store i32 0, i32* %5
%7 = call i32* @fopen(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %7, i32** %1
%8 = load i32*, i32** %1
%9 = icmp eq i32* %8, null
br i1 %9, label %10, label %12
10: ; preds = %0
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.2, i64 0, i64 0))
br label %56
12: ; preds = %0
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
br label %14
14: ; preds = %21, %12
%15 = load i32*, i32** %1
%16 = call signext i8 @fgetc(i32* %15)
store i8 %16, i8* %2
%17 = sext i8 %16 to i32
%18 = load i8, i8* @EOF
%19 = sext i8 %18 to i32
%20 = icmp ne i32 %17, %19
br i1 %20, label %21, label %25
21: ; preds = %14
%22 = load i8, i8* %2
%23 = sext i8 %22 to i32
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32 %23)
br label %14
25: ; preds = %14
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%27 = load i32*, i32** %1
%28 = call i32 @rewind(i32* %27)
br label %29
29: ; preds = %34, %25
%30 = getelementptr inbounds [80 x i8], [80 x i8]* %3, i64 0, i64 0
%31 = load i32*, i32** %1
%32 = call i64 @fgets(i8* %30, i32 80, i32* %31)
%33 = icmp ne i64 %32, 0
br i1 %33, label %34, label %37
34: ; preds = %29
%35 = getelementptr inbounds [80 x i8], [80 x i8]* %3, i64 0, i64 0
%36 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i8* %35)
br label %29
37: ; preds = %29
%38 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%39 = load i32*, i32** %1
%40 = call i32 @rewind(i32* %39)
%41 = load i32*, i32** %1
%42 = getelementptr inbounds [80 x i8], [80 x i8]* %3, i64 0, i64 0
%43 = call i32 (i32*, i8*, ...) @fscanf(i32* %41, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.6, i64 0, i64 0), i8* %42)
%44 = load i32*, i32** %1
%45 = call i32 (i32*, i8*, ...) @fscanf(i32* %44, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.7, i64 0, i64 0), i32* %4)
%46 = load i32*, i32** %1
%47 = call i32 (i32*, i8*, ...) @fscanf(i32* %46, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.8, i64 0, i64 0), i32* %5)
%48 = getelementptr inbounds [80 x i8], [80 x i8]* %3, i64 0, i64 0
%49 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.9, i64 0, i64 0), i8* %48)
%50 = load i32, i32* %4
%51 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.10, i64 0, i64 0), i32 %50)
%52 = load i32, i32* %5
%53 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.11, i64 0, i64 0), i32 %52)
%54 = load i32*, i32** %1
%55 = call i32 @fclose(i32* %54)
br label %56
56: ; preds = %37, %10
ret void
}

LLVM IR (-O2):
@.str = [10 x i8] c"Stats.txt\00"
@.str.1 = [2 x i8] c"r\00"
@EOF = global i8 0
@.str.5 = [3 x i8] c"%s\00"
@.str.6 = [12 x i8] c"Player: %s\0A\00"
@.str.7 = [12 x i8] c"Health: %d\0A\00"
@.str.8 = [10 x i8] c"Gold: %d\0A\00"
@.str.9 = [28 x i8] c"The Player's name is: %s\0A\00"
@.str.10 = [28 x i8] c"The Player's health is: %d\0A\00"
@.str.11 = [28 x i8] c"The Player's gold is: %d\0A\00"
@str = [33 x i8] c"ERROR: Could not find Stats.txt!\00"
define void @main() {
%1 = alloca [80 x i8]
%2 = alloca i32
%3 = alloca i32
%4 = getelementptr inbounds [80 x i8], [80 x i8]* %1, i64 0, i64 0
%5 = bitcast i32* %2 to i8*
store i32 0, i32* %2
%6 = bitcast i32* %3 to i8*
store i32 0, i32* %3
%7 = tail call i32* @fopen(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%8 = icmp eq i32* %7, null
br i1 %8, label %9, label %11
9: ; preds = %0
%10 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @str, i64 0, i64 0))
br label %44
11: ; preds = %0
%12 = tail call i32 @putchar(i32 10)
%13 = tail call signext i8 @fgetc(i32* %7)
%14 = load i8, i8* @EOF
%15 = icmp eq i8 %13, %14
br i1 %15, label %23, label %16
16: ; preds = %11, %16
%17 = phi i8 [ %20, %16 ], [ %13, %11 ]
%18 = sext i8 %17 to i32
%19 = tail call i32 @putchar(i32 %18)
%20 = tail call signext i8 @fgetc(i32* %7)
%21 = load i8, i8* @EOF
%22 = icmp eq i8 %20, %21
br i1 %22, label %23, label %16
23: ; preds = %16, %11
%24 = tail call i32 @putchar(i32 10)
%25 = tail call i32 @rewind(i32* %7)
%26 = call i64 @fgets(i8* %4, i32 80, i32* %7)
%27 = icmp eq i64 %26, 0
br i1 %27, label %32, label %28
28: ; preds = %23, %28
%29 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i8* %4)
%30 = call i64 @fgets(i8* %4, i32 80, i32* %7)
%31 = icmp eq i64 %30, 0
br i1 %31, label %32, label %28
32: ; preds = %28, %23
%33 = call i32 @putchar(i32 10)
%34 = call i32 @rewind(i32* %7)
%35 = call i32 (i32*, i8*, ...) @fscanf(i32* %7, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.6, i64 0, i64 0), i8* %4)
%36 = call i32 (i32*, i8*, ...) @fscanf(i32* %7, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.7, i64 0, i64 0), i32* %2)
%37 = call i32 (i32*, i8*, ...) @fscanf(i32* %7, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.8, i64 0, i64 0), i32* %3)
%38 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @.str.9, i64 0, i64 0), i8* %4)
%39 = load i32, i32* %2
%40 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @.str.10, i64 0, i64 0), i32 %39)
%41 = load i32, i32* %3
%42 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @.str.11, i64 0, i64 0), i32 %41)
%43 = call i32 @fclose(i32* %7)
br label %44
44: ; preds = %32, %9
ret void
}