#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 /*<<< orphan*/ print_class(int);
int /*<<< orphan*/ printf(char *, ...);
void view_m_win() {
  FILE *file;
  int class = 0, win = 0, lost = 0;
  int most_win = 0;
  file = fopen("Stats.txt", "r");
  while (fscanf(file, "%d %d %d", &class, &win, &lost) != EOF) {
    if (most_win == 0) {
      most_win = win;
    } else if (most_win < win) {
      most_win = win;
    }
  }
  fclose(file);
  file = fopen("Stats.txt", "r");
  printf("\n __________________________________ \n"
         ": Most wins is %d                  :\n"
         ":__________________________________:\n\n",
         most_win);
  while (fscanf(file, "%d %d %d", &class, &win, &lost) != EOF) {
    if (win == most_win) {
      print_class(class);
      printf(": Wins - %d   Loss - %d\n", win, lost);
    }
  }
  printf("\n:__________________________________:\n\n");
  fclose(file);
}


x86 assembly (clang, -O0):
<view_m_win>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
lea    0xe85(%rip),%rdi
lea    0xe88(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xe76(%rip),%rsi
lea    -0xc(%rbp),%rdx
lea    -0x10(%rbp),%rcx
lea    -0x14(%rbp),%r8
call   1050 <fscanf@plt>
mov    0x2e3a(%rip),%rcx
cmp    (%rcx),%rax
je     11e8 <view_m_win+0x98>
cmpl   $0x0,-0x18(%rbp)
jne    11cc <view_m_win+0x7c>
mov    -0x10(%rbp),%eax
mov    %eax,-0x18(%rbp)
jmp    11e3 <view_m_win+0x93>
mov    -0x18(%rbp),%eax
cmp    -0x10(%rbp),%eax
jge    11de <view_m_win+0x8e>
mov    -0x10(%rbp),%eax
mov    %eax,-0x18(%rbp)
jmp    11e3 <view_m_win+0x93>
jmp    118b <view_m_win+0x3b>
mov    -0x8(%rbp),%rdi
call   1030 <fclose@plt>
lea    0xe08(%rip),%rdi
lea    0xe0b(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x8(%rbp)
mov    -0x18(%rbp),%esi
lea    0xe03(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x8(%rbp),%rdi
lea    0xde8(%rip),%rsi
lea    -0xc(%rbp),%rdx
lea    -0x10(%rbp),%rcx
lea    -0x14(%rbp),%r8
call   1050 <fscanf@plt>
mov    0x2dac(%rip),%rcx
cmp    (%rcx),%rax
je     1272 <view_m_win+0x122>
mov    -0x10(%rbp),%eax
cmp    -0x18(%rbp),%eax
jne    126d <view_m_win+0x11d>
mov    -0xc(%rbp),%edi
call   1060 <print_class@plt>
mov    -0x10(%rbp),%esi
mov    -0x14(%rbp),%edx
lea    0xe21(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1219 <view_m_win+0xc9>
lea    0xde6(%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_m_win>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
movl   $0x0,0x14(%rsp)
movl   $0x0,0xc(%rsp)
movl   $0x0,0x10(%rsp)
lea    0xe73(%rip),%rdi
lea    0xe76(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,%r14
lea    0xe69(%rip),%rsi
lea    0x14(%rsp),%rdx
lea    0xc(%rsp),%rcx
lea    0x10(%rsp),%r8
mov    %rax,%rdi
call   1060 <fscanf@plt>
mov    0x2e27(%rip),%rcx
xor    %ebx,%ebx
cmp    (%rcx),%rax
je     1220 <view_m_win+0xc0>
xor    %ecx,%ecx
lea    0xe3b(%rip),%r15
lea    0x14(%rsp),%r12
lea    0xc(%rsp),%r13
lea    0x10(%rsp),%rbp
mov    %ecx,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    0xc(%rsp),%eax
cmp    %eax,%ecx
cmovl  %eax,%ebx
test   %ecx,%ecx
cmove  %eax,%ebx
mov    %r14,%rdi
mov    %r15,%rsi
mov    %r12,%rdx
mov    %r13,%rcx
mov    %rbp,%r8
call   1060 <fscanf@plt>
mov    %ebx,%ecx
mov    0x2dcd(%rip),%rdx
cmp    (%rdx),%rax
jne    11f0 <view_m_win+0x90>
mov    %r14,%rdi
call   1040 <fclose@plt>
lea    0xdd1(%rip),%rdi
lea    0xdd4(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,%r14
lea    0xdd0(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xdb7(%rip),%rsi
lea    0x14(%rsp),%rdx
lea    0xc(%rsp),%rcx
lea    0x10(%rsp),%r8
mov    %r14,%rdi
call   1060 <fscanf@plt>
mov    0x2d75(%rip),%r12
cmp    (%r12),%rax
jne    129c <view_m_win+0x13c>
lea    0xe20(%rip),%rdi
call   1030 <puts@plt>
mov    %r14,%rdi
call   1040 <fclose@plt>
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0x14(%rsp),%r13
lea    0xc(%rsp),%rbp
lea    0x10(%rsp),%r15
jmp    12ce <view_m_win+0x16e>
nopl   (%rax)
mov    %r14,%rdi
lea    0xd52(%rip),%rsi
mov    %r13,%rdx
mov    %rbp,%rcx
mov    %r15,%r8
call   1060 <fscanf@plt>
cmp    (%r12),%rax
je     1279 <view_m_win+0x119>
cmp    %ebx,0xc(%rsp)
jne    12b0 <view_m_win+0x150>
mov    0x14(%rsp),%edi
call   1070 <print_class@plt>
mov    0xc(%rsp),%esi
mov    0x10(%rsp),%edx
lea    0xd9b(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
jmp    12b0 <view_m_win+0x150>

LLVM IR (-O0):
@.str = [10 x i8] c"Stats.txt\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [9 x i8] c"%d %d %d\00"
@EOF = global i64 0
@.str.3 = [114 x i8] c"\0A __________________________________ \0A: Most wins is %d :\0A:__________________________________:\0A\0A\00"
@.str.4 = [25 x i8] c": Wins - %d Loss - %d\0A\00"
@.str.5 = [40 x i8] c"\0A:__________________________________:\0A\0A\00"
define void @view_m_win() {
%1 = alloca i32*
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i32 0, i32* %2
store i32 0, i32* %3
store i32 0, i32* %4
store i32 0, i32* %5
%6 = 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* %6, i32** %1
br label %7
7: ; preds = %24, %0
%8 = load i32*, i32** %1
%9 = call i64 @fscanf(i32* %8, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i32* %2, i32* %3, i32* %4)
%10 = load i64, i64* @EOF
%11 = icmp ne i64 %9, %10
br i1 %11, label %12, label %25
12: ; preds = %7
%13 = load i32, i32* %5
%14 = icmp eq i32 %13, 0
br i1 %14, label %15, label %17
15: ; preds = %12
%16 = load i32, i32* %3
store i32 %16, i32* %5
br label %24
17: ; preds = %12
%18 = load i32, i32* %5
%19 = load i32, i32* %3
%20 = icmp slt i32 %18, %19
br i1 %20, label %21, label %23
21: ; preds = %17
%22 = load i32, i32* %3
store i32 %22, i32* %5
br label %23
23: ; preds = %21, %17
br label %24
24: ; preds = %23, %15
br label %7
25: ; preds = %7
%26 = load i32*, i32** %1
%27 = call i32 @fclose(i32* %26)
%28 = 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* %28, i32** %1
%29 = load i32, i32* %5
%30 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([114 x i8], [114 x i8]* @.str.3, i64 0, i64 0), i32 %29)
br label %31
31: ; preds = %46, %25
%32 = load i32*, i32** %1
%33 = call i64 @fscanf(i32* %32, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i32* %2, i32* %3, i32* %4)
%34 = load i64, i64* @EOF
%35 = icmp ne i64 %33, %34
br i1 %35, label %36, label %47
36: ; preds = %31
%37 = load i32, i32* %3
%38 = load i32, i32* %5
%39 = icmp eq i32 %37, %38
br i1 %39, label %40, label %46
40: ; preds = %36
%41 = load i32, i32* %2
%42 = call i32 @print_class(i32 %41)
%43 = load i32, i32* %3
%44 = load i32, i32* %4
%45 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.4, i64 0, i64 0), i32 %43, i32 %44)
br label %46
46: ; preds = %40, %36
br label %31
47: ; preds = %31
%48 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.5, i64 0, i64 0))
%49 = load i32*, i32** %1
%50 = call i32 @fclose(i32* %49)
ret void
}

LLVM IR (-O2):
@.str = [10 x i8] c"Stats.txt\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [9 x i8] c"%d %d %d\00"
@EOF = global i64 0
@.str.3 = [114 x i8] c"\0A __________________________________ \0A: Most wins is %d :\0A:__________________________________:\0A\0A\00"
@.str.4 = [25 x i8] c": Wins - %d Loss - %d\0A\00"
@str = [39 x i8] c"\0A:__________________________________:\0A\00"
define void @view_m_win() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = bitcast i32* %1 to i8*
store i32 0, i32* %1
%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 = call i64 @fscanf(i32* %7, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i32* %1, i32* %2, i32* %3)
%9 = load i64, i64* @EOF
%10 = icmp eq i64 %8, %9
br i1 %10, label %21, label %11
11: ; preds = %0, %11
%12 = phi i32 [ %17, %11 ], [ 0, %0 ]
%13 = icmp eq i32 %12, 0
%14 = load i32, i32* %2
%15 = icmp slt i32 %12, %14
%16 = select i1 %13, i1 true, i1 %15
%17 = select i1 %16, i32 %14, i32 %12
%18 = call i64 @fscanf(i32* %7, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i32* %1, i32* %2, i32* %3)
%19 = load i64, i64* @EOF
%20 = icmp eq i64 %18, %19
br i1 %20, label %21, label %11
21: ; preds = %11, %0
%22 = phi i32 [ 0, %0 ], [ %17, %11 ]
%23 = call i32 @fclose(i32* %7)
%24 = 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))
%25 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([114 x i8], [114 x i8]* @.str.3, i64 0, i64 0), i32 %22)
%26 = call i64 @fscanf(i32* %24, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i32* %1, i32* %2, i32* %3)
%27 = load i64, i64* @EOF
%28 = icmp eq i64 %26, %27
br i1 %28, label %42, label %29
29: ; preds = %21, %38
%30 = load i32, i32* %2
%31 = icmp eq i32 %30, %22
br i1 %31, label %32, label %38
32: ; preds = %29
%33 = load i32, i32* %1
%34 = call i32 @print_class(i32 %33)
%35 = load i32, i32* %2
%36 = load i32, i32* %3
%37 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str.4, i64 0, i64 0), i32 %35, i32 %36)
br label %38
38: ; preds = %32, %29
%39 = call i64 @fscanf(i32* %24, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i32* %1, i32* %2, i32* %3)
%40 = load i64, i64* @EOF
%41 = icmp eq i64 %39, %40
br i1 %41, label %42, label %29
42: ; preds = %38, %21
%43 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([39 x i8], [39 x i8]* @str, i64 0, i64 0))
%44 = call i32 @fclose(i32* %24)
ret void
}