#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 */
scalar_t__ EOF;
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
scalar_t__ fscanf(int /*<<< orphan*/ *, char *, int *, int *, int *, int *);
int /*<<< orphan*/ print_class(int);
int /*<<< orphan*/ printf(char *, ...);
void view_late() {
  FILE *file;
  int class = 0, win = 0, lost = 0, i = 0, delete = 0;
  file = fopen("Stats.txt", "r");
  while (fscanf(file, "%d %d %d %d", &class, &win, &lost, &delete) != EOF) {
    if (delete == 0)
      i++;
  }
  printf("\n __________________________________ \n"
         ": Latest Arena Run  Nr. %d         :\n"
         ": -------------------------------- :\n",
         i);
  print_class(class);
  printf("\n: -------------------------------- :\n");
  printf(": Wins - %d   Loss - %d              :\n"
         ":__________________________________:\n\n",
         win, lost);
  fclose(file);
}


x86 assembly (clang, -O0):
<view_late>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
lea    0xe7e(%rip),%rdi
lea    0xe81(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xe6f(%rip),%rsi
lea    -0xc(%rbp),%rdx
lea    -0x10(%rbp),%rcx
lea    -0x14(%rbp),%r8
lea    -0x1c(%rbp),%r9
call   1050 <fscanf@plt>
mov    0x2e2f(%rip),%rcx
cmp    (%rcx),%rax
je     11da <view_late+0x8a>
cmpl   $0x0,-0x1c(%rbp)
jne    11d5 <view_late+0x85>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1192 <view_late+0x42>
mov    -0x18(%rbp),%esi
lea    0xe34(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0xc(%rbp),%edi
call   1060 <print_class@plt>
lea    0xe68(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x10(%rbp),%esi
mov    -0x14(%rbp),%edx
lea    0xe7b(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x8(%rbp),%rdi
call   1030 <fclose@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<view_late>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
movl   $0x0,0x14(%rsp)
movl   $0x0,0x10(%rsp)
movl   $0x0,0xc(%rsp)
movl   $0x0,0x8(%rsp)
lea    0xe6b(%rip),%rdi
lea    0xe6e(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,%rbx
lea    0xe61(%rip),%rsi
lea    0x14(%rsp),%rdx
lea    0x10(%rsp),%rcx
lea    0xc(%rsp),%r8
lea    0x8(%rsp),%r9
mov    %rax,%rdi
call   1060 <fscanf@plt>
mov    0x2e1a(%rip),%r15
xor    %ebp,%ebp
cmp    (%r15),%rax
je     121a <view_late+0xba>
xor    %ebp,%ebp
lea    0x10(%rsp),%r12
lea    0xc(%rsp),%r13
lea    0x8(%rsp),%r14
cs nopw 0x0(%rax,%rax,1)
cmpl   $0x1,0x8(%rsp)
adc    $0x0,%ebp
mov    %rbx,%rdi
lea    0xe0a(%rip),%rsi
lea    0x14(%rsp),%rdx
mov    %r12,%rcx
mov    %r13,%r8
mov    %r14,%r9
call   1060 <fscanf@plt>
cmp    (%r15),%rax
jne    11f0 <view_late+0x90>
lea    0xdf7(%rip),%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x14(%rsp),%edi
call   1070 <print_class@plt>
lea    0xe9d(%rip),%rdi
call   1030 <puts@plt>
mov    0x10(%rsp),%esi
mov    0xc(%rsp),%edx
lea    0xe3b(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %rbx,%rdi
call   1040 <fclose@plt>
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [10 x i8] c"Stats.txt\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [12 x i8] c"%d %d %d %d\00"
@EOF = global i64 0
@.str.3 = [113 x i8] c"\0A __________________________________ \0A: Latest Arena Run Nr. %d :\0A: -------------------------------- :\0A\00"
@.str.4 = [39 x i8] c"\0A: -------------------------------- :\0A\00"
@.str.5 = [78 x i8] c": Wins - %d Loss - %d :\0A:__________________________________:\0A\0A\00"
define void @view_late() {
%1 = alloca i32*
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store i32 0, i32* %2
store i32 0, i32* %3
store i32 0, i32* %4
store i32 0, i32* %5
store i32 0, i32* %6
%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
br label %8
8: ; preds = %19, %0
%9 = load i32*, i32** %1
%10 = call i64 @fscanf(i32* %9, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0), i32* %2, i32* %3, i32* %4, i32* %6)
%11 = load i64, i64* @EOF
%12 = icmp ne i64 %10, %11
br i1 %12, label %13, label %20
13: ; preds = %8
%14 = load i32, i32* %6
%15 = icmp eq i32 %14, 0
br i1 %15, label %16, label %19
16: ; preds = %13
%17 = load i32, i32* %5
%18 = add nsw i32 %17, 1
store i32 %18, i32* %5
br label %19
19: ; preds = %16, %13
br label %8
20: ; preds = %8
%21 = load i32, i32* %5
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([113 x i8], [113 x i8]* @.str.3, i64 0, i64 0), i32 %21)
%23 = load i32, i32* %2
%24 = call i32 @print_class(i32 %23)
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.4, i64 0, i64 0))
%26 = load i32, i32* %3
%27 = load i32, i32* %4
%28 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([78 x i8], [78 x i8]* @.str.5, i64 0, i64 0), i32 %26, i32 %27)
%29 = load i32*, i32** %1
%30 = call i32 @fclose(i32* %29)
ret void
}

LLVM IR (-O2):
@.str = [10 x i8] c"Stats.txt\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [12 x i8] c"%d %d %d %d\00"
@EOF = global i64 0
@.str.3 = [113 x i8] c"\0A __________________________________ \0A: Latest Arena Run Nr. %d :\0A: -------------------------------- :\0A\00"
@.str.5 = [78 x i8] c": Wins - %d Loss - %d :\0A:__________________________________:\0A\0A\00"
@str = [38 x i8] c"\0A: -------------------------------- :\00"
define void @view_late() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = bitcast i32* %1 to i8*
store i32 0, i32* %1
%6 = bitcast i32* %2 to i8*
store i32 0, i32* %2
%7 = bitcast i32* %3 to i8*
store i32 0, i32* %3
%8 = bitcast i32* %4 to i8*
store i32 0, i32* %4
%9 = 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))
%10 = call i64 @fscanf(i32* %9, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0), i32* %1, i32* %2, i32* %3, i32* %4)
%11 = load i64, i64* @EOF
%12 = icmp eq i64 %10, %11
br i1 %12, label %22, label %13
13: ; preds = %0, %13
%14 = phi i32 [ %18, %13 ], [ 0, %0 ]
%15 = load i32, i32* %4
%16 = icmp eq i32 %15, 0
%17 = zext i1 %16 to i32
%18 = add nuw nsw i32 %14, %17
%19 = call i64 @fscanf(i32* %9, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0), i32* %1, i32* %2, i32* %3, i32* %4)
%20 = load i64, i64* @EOF
%21 = icmp eq i64 %19, %20
br i1 %21, label %22, label %13
22: ; preds = %13, %0
%23 = phi i32 [ 0, %0 ], [ %18, %13 ]
%24 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([113 x i8], [113 x i8]* @.str.3, i64 0, i64 0), i32 %23)
%25 = load i32, i32* %1
%26 = call i32 @print_class(i32 %25)
%27 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([38 x i8], [38 x i8]* @str, i64 0, i64 0))
%28 = load i32, i32* %2
%29 = load i32, i32* %3
%30 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([78 x i8], [78 x i8]* @.str.5, i64 0, i64 0), i32 %28, i32 %29)
%31 = call i32 @fclose(i32* %9)
ret void
}