#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_top3(int, double, int, double, int, double);
int /*<<< orphan*/ printf(char *);
void worst_class() {
  FILE *file;
  int class = 0, win = 0, lost = 0, i = 0, delete = 0;
  double win_c = 0, lost_c = 0, runs = 0, temp_points = 0;
  int top1 = 0, top2 = 0, top3 = 0, top4 = 0, top5 = 0;
  double p1 = 100, p2 = 100, p3 = 100, p4 = 100, p5 = 100;
  double winp = 0.00;
  for (i = 0; i < 9; i++) {
    file = fopen("Stats.txt", "r");
    while (fscanf(file, "%d %d %d %d", &class, &win, &lost, &delete) != EOF) {
      if (delete == 0 && class == i + 1) {
        runs++;
        temp_points += win;
      }
    }
    fclose(file);
    p5 = temp_points / runs;
    if (p1 > p5) {
      p1 = p5;
      top1 = i + 1;
    } else if (p2 > p5) {
      p2 = p5;
      top2 = i + 1;
    } else if (p3 > p5) {
      p3 = p5;
      top3 = i + 1;
    }
    temp_points = 0;
    runs = 0;
  }
  printf("\n __________________________________ \n");
  printf(": Worst Three Played Classes       :\n"
         ": -------------------------------- :\n");
  print_top3(top1, p1, top2, p2, top3, p3);
  printf(":__________________________________:\n");
}


x86 assembly (clang, -O0):
<worst_class>:
push   %rbp
mov    %rsp,%rbp
sub    $0x90,%rsp
movl   $0x0,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x28(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x30(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x38(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x40(%rbp)
movl   $0x0,-0x44(%rbp)
movl   $0x0,-0x48(%rbp)
movl   $0x0,-0x4c(%rbp)
movl   $0x0,-0x50(%rbp)
movl   $0x0,-0x54(%rbp)
movsd  0xe37(%rip),%xmm0
movsd  %xmm0,-0x60(%rbp)
movsd  0xe2a(%rip),%xmm0
movsd  %xmm0,-0x68(%rbp)
movsd  0xe1d(%rip),%xmm0
movsd  %xmm0,-0x70(%rbp)
movsd  0xe10(%rip),%xmm0
movsd  %xmm0,-0x78(%rbp)
movsd  0xe03(%rip),%xmm0
movsd  %xmm0,-0x80(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x88(%rbp)
ff
movl   $0x0,-0x18(%rbp)
cmpl   $0x9,-0x18(%rbp)
jge    1359 <worst_class+0x209>
lea    0xdeb(%rip),%rdi
lea    0xdee(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xddc(%rip),%rsi
lea    -0xc(%rbp),%rdx
lea    -0x10(%rbp),%rcx
lea    -0x14(%rbp),%r8
lea    -0x1c(%rbp),%r9
call   1050 <fscanf@plt>
mov    0x2d8c(%rip),%rcx
cmp    (%rcx),%rax
je     12a6 <worst_class+0x156>
cmpl   $0x0,-0x1c(%rbp)
jne    12a1 <worst_class+0x151>
mov    -0xc(%rbp),%eax
mov    -0x18(%rbp),%ecx
add    $0x1,%ecx
cmp    %ecx,%eax
jne    12a1 <worst_class+0x151>
movsd  0xd80(%rip),%xmm0
addsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
cvtsi2sdl -0x10(%rbp),%xmm0
addsd  -0x40(%rbp),%xmm0
movsd  %xmm0,-0x40(%rbp)
jmp    1235 <worst_class+0xe5>
mov    -0x8(%rbp),%rdi
call   1030 <fclose@plt>
movsd  -0x40(%rbp),%xmm0
divsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x80(%rbp)
movsd  -0x60(%rbp),%xmm0
ucomisd -0x80(%rbp),%xmm0
jbe    12e6 <worst_class+0x196>
movsd  -0x80(%rbp),%xmm0
movsd  %xmm0,-0x60(%rbp)
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x44(%rbp)
jmp    133b <worst_class+0x1eb>
movsd  -0x68(%rbp),%xmm0
ucomisd -0x80(%rbp),%xmm0
jbe    130e <worst_class+0x1be>
movsd  -0x80(%rbp),%xmm0
movsd  %xmm0,-0x68(%rbp)
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x48(%rbp)
jmp    1336 <worst_class+0x1e6>
movsd  -0x70(%rbp),%xmm0
ucomisd -0x80(%rbp),%xmm0
jbe    1331 <worst_class+0x1e1>
movsd  -0x80(%rbp),%xmm0
movsd  %xmm0,-0x70(%rbp)
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4c(%rbp)
jmp    1336 <worst_class+0x1e6>
jmp    133b <worst_class+0x1eb>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x40(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x38(%rbp)
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1214 <worst_class+0xc4>
lea    0xcc8(%rip),%rdi
call   1040 <printf@plt>
lea    0xce3(%rip),%rdi
call   1040 <printf@plt>
mov    -0x44(%rbp),%edi
movsd  -0x60(%rbp),%xmm0
mov    -0x48(%rbp),%esi
movsd  -0x68(%rbp),%xmm1
mov    -0x4c(%rbp),%edx
movsd  -0x70(%rbp),%xmm2
call   1070 <print_top3@plt>
lea    0xd05(%rip),%rdi
call   1040 <printf@plt>
add    $0x90,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<worst_class>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x58,%rsp
movl   $0x0,0x14(%rsp)
movl   $0x0,0x24(%rsp)
movl   $0x0,0x4c(%rsp)
movl   $0x0,0x20(%rsp)
movsd  0xe7a(%rip),%xmm0
xor    %ecx,%ecx
lea    0x24(%rsp),%rbx
lea    0x4c(%rsp),%r14
lea    0x20(%rsp),%r15
mov    0x2e4a(%rip),%r13
movsd  %xmm0,0x38(%rsp)
movsd  %xmm0,0x30(%rsp)
movsd  %xmm0,0x40(%rsp)
movl   $0x0,0x1c(%rsp)
movl   $0x0,0x10(%rsp)
movl   $0x0,0x18(%rsp)
jmp    11f1 <worst_class+0xa1>
nopw   0x0(%rax,%rax,1)
mov    0x28(%rsp),%rcx
add    $0x1,%ecx
mov    %ecx,%eax
mov    %ecx,0x1c(%rsp)
movapd %xmm2,%xmm1
movsd  %xmm1,0x40(%rsp)
cmp    $0x9,%ecx
je     137c <worst_class+0x22c>
mov    %rcx,0x28(%rsp)
lea    0xe1b(%rip),%rdi
lea    0xe1e(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,%r12
mov    %rax,%rdi
lea    0xe0e(%rip),%rsi
lea    0x14(%rsp),%rdx
mov    %rbx,%rcx
mov    %r14,%r8
mov    %r15,%r9
call   1050 <fscanf@plt>
xorpd  %xmm0,%xmm0
movsd  %xmm0,0x8(%rsp)
xorpd  %xmm3,%xmm3
cmp    0x0(%r13),%rax
jne    12a0 <worst_class+0x150>
movsd  0x8(%rsp),%xmm0
divsd  %xmm3,%xmm0
movsd  %xmm0,0x8(%rsp)
mov    %r12,%rdi
call   1040 <fclose@plt>
movsd  0x8(%rsp),%xmm2
movsd  0x40(%rsp),%xmm1
ucomisd %xmm2,%xmm1
ja     11d0 <worst_class+0x80>
movsd  0x38(%rsp),%xmm0
ucomisd %xmm2,%xmm0
jbe    1350 <worst_class+0x200>
mov    0x28(%rsp),%rcx
add    $0x1,%ecx
mov    %ecx,%eax
mov    %ecx,0x18(%rsp)
movsd  %xmm2,0x38(%rsp)
jmp    11e2 <worst_class+0x92>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    0x28(%rsp),%rax
lea    0x1(%rax),%ebp
xorpd  %xmm0,%xmm0
xorps  %xmm1,%xmm1
movsd  %xmm1,0x8(%rsp)
movapd %xmm0,%xmm3
jmp    1301 <worst_class+0x1b1>
nopl   0x0(%rax,%rax,1)
movsd  %xmm3,0x50(%rsp)
addsd  %xmm1,%xmm2
movsd  %xmm2,0x8(%rsp)
mov    %r12,%rdi
lea    0xd4a(%rip),%rsi
lea    0x14(%rsp),%rdx
mov    %rbx,%rcx
mov    %r14,%r8
mov    %r15,%r9
call   1050 <fscanf@plt>
movsd  0x50(%rsp),%xmm3
movapd %xmm3,%xmm0
cmp    0x0(%r13),%rax
je     123d <worst_class+0xed>
mov    0x14(%rsp),%eax
xor    %ebp,%eax
or     0x20(%rsp),%eax
addsd  0xcf5(%rip),%xmm3
je     1330 <worst_class+0x1e0>
movsd  0xcf3(%rip),%xmm1
movsd  0x8(%rsp),%xmm2
je     12c0 <worst_class+0x170>
jmp    1345 <worst_class+0x1f5>
nopw   0x0(%rax,%rax,1)
xorps  %xmm1,%xmm1
cvtsi2sdl 0x24(%rsp),%xmm1
movsd  0x8(%rsp),%xmm2
je     12c0 <worst_class+0x170>
movapd %xmm0,%xmm3
jmp    12c0 <worst_class+0x170>
xchg   %ax,%ax
mov    0x28(%rsp),%rcx
add    $0x1,%ecx
movsd  0x30(%rsp),%xmm0
ucomisd %xmm2,%xmm0
mov    0x10(%rsp),%eax
cmova  %ecx,%eax
mov    %eax,0x10(%rsp)
minsd  %xmm0,%xmm2
movsd  %xmm2,0x30(%rsp)
jmp    11e2 <worst_class+0x92>
lea    0xcad(%rip),%rdi
call   1030 <puts@plt>
lea    0xcc7(%rip),%rdi
call   1030 <puts@plt>
mov    0x1c(%rsp),%edi
movsd  0x40(%rsp),%xmm0
mov    0x18(%rsp),%esi
movsd  0x38(%rsp),%xmm1
mov    0x10(%rsp),%edx
movsd  0x30(%rsp),%xmm2
call   1070 <print_top3@plt>
lea    0xce2(%rip),%rdi
call   1030 <puts@plt>
add    $0x58,%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 = [39 x i8] c"\0A __________________________________ \0A\00"
@.str.4 = [75 x i8] c": Worst Three Played Classes :\0A: -------------------------------- :\0A\00"
@.str.5 = [38 x i8] c":__________________________________:\0A\00"
define void @worst_class() {
%1 = alloca i32*
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca double
%8 = alloca double
%9 = alloca double
%10 = alloca double
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
%15 = alloca i32
%16 = alloca double
%17 = alloca double
%18 = alloca double
%19 = alloca double
%20 = alloca double
%21 = alloca double
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
store double 0.000000e+00, double* %7
store double 0.000000e+00, double* %8
store double 0.000000e+00, double* %9
store double 0.000000e+00, double* %10
store i32 0, i32* %11
store i32 0, i32* %12
store i32 0, i32* %13
store i32 0, i32* %14
store i32 0, i32* %15
store double 1.000000e+02, double* %16
store double 1.000000e+02, double* %17
store double 1.000000e+02, double* %18
store double 1.000000e+02, double* %19
store double 1.000000e+02, double* %20
store double 0.000000e+00, double* %21
store i32 0, i32* %5
br label %22
22: ; preds = %80, %0
%23 = load i32, i32* %5
%24 = icmp slt i32 %23, 9
br i1 %24, label %25, label %83
25: ; preds = %22
%26 = 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* %26, i32** %1
br label %27
27: ; preds = %47, %25
%28 = load i32*, i32** %1
%29 = call i64 @fscanf(i32* %28, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0), i32* %2, i32* %3, i32* %4, i32* %6)
%30 = load i64, i64* @EOF
%31 = icmp ne i64 %29, %30
br i1 %31, label %32, label %48
32: ; preds = %27
%33 = load i32, i32* %6
%34 = icmp eq i32 %33, 0
br i1 %34, label %35, label %47
35: ; preds = %32
%36 = load i32, i32* %2
%37 = load i32, i32* %5
%38 = add nsw i32 %37, 1
%39 = icmp eq i32 %36, %38
br i1 %39, label %40, label %47
40: ; preds = %35
%41 = load double, double* %9
%42 = fadd double %41, 1.000000e+00
store double %42, double* %9
%43 = load i32, i32* %3
%44 = sitofp i32 %43 to double
%45 = load double, double* %10
%46 = fadd double %45, %44
store double %46, double* %10
br label %47
47: ; preds = %40, %35, %32
br label %27
48: ; preds = %27
%49 = load i32*, i32** %1
%50 = call i32 @fclose(i32* %49)
%51 = load double, double* %10
%52 = load double, double* %9
%53 = fdiv double %51, %52
store double %53, double* %20
%54 = load double, double* %16
%55 = load double, double* %20
%56 = fcmp ogt double %54, %55
br i1 %56, label %57, label %61
57: ; preds = %48
%58 = load double, double* %20
store double %58, double* %16
%59 = load i32, i32* %5
%60 = add nsw i32 %59, 1
store i32 %60, i32* %11
br label %79
61: ; preds = %48
%62 = load double, double* %17
%63 = load double, double* %20
%64 = fcmp ogt double %62, %63
br i1 %64, label %65, label %69
65: ; preds = %61
%66 = load double, double* %20
store double %66, double* %17
%67 = load i32, i32* %5
%68 = add nsw i32 %67, 1
store i32 %68, i32* %12
br label %78
69: ; preds = %61
%70 = load double, double* %18
%71 = load double, double* %20
%72 = fcmp ogt double %70, %71
br i1 %72, label %73, label %77
73: ; preds = %69
%74 = load double, double* %20
store double %74, double* %18
%75 = load i32, i32* %5
%76 = add nsw i32 %75, 1
store i32 %76, i32* %13
br label %77
77: ; preds = %73, %69
br label %78
78: ; preds = %77, %65
br label %79
79: ; preds = %78, %57
store double 0.000000e+00, double* %10
store double 0.000000e+00, double* %9
br label %80
80: ; preds = %79
%81 = load i32, i32* %5
%82 = add nsw i32 %81, 1
store i32 %82, i32* %5
br label %22
83: ; preds = %22
%84 = call i32 @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.3, i64 0, i64 0))
%85 = call i32 @printf(i8* getelementptr inbounds ([75 x i8], [75 x i8]* @.str.4, i64 0, i64 0))
%86 = load i32, i32* %11
%87 = load double, double* %16
%88 = load i32, i32* %12
%89 = load double, double* %17
%90 = load i32, i32* %13
%91 = load double, double* %18
%92 = call i32 @print_top3(i32 %86, double %87, i32 %88, double %89, i32 %90, double %91)
%93 = call i32 @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.5, i64 0, i64 0))
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 = [38 x i8] c"\0A __________________________________ \00"
@str.6 = [74 x i8] c": Worst Three Played Classes :\0A: -------------------------------- :\00"
@str.7 = [37 x i8] c":__________________________________:\00"
define void @worst_class() {
%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
br label %9
9: ; preds = %0, %57
%10 = phi i32 [ 0, %0 ], [ %58, %57 ]
%11 = phi double [ 1.000000e+02, %0 ], [ %64, %57 ]
%12 = phi double [ 1.000000e+02, %0 ], [ %63, %57 ]
%13 = phi double [ 1.000000e+02, %0 ], [ %62, %57 ]
%14 = phi i32 [ 0, %0 ], [ %61, %57 ]
%15 = phi i32 [ 0, %0 ], [ %60, %57 ]
%16 = phi i32 [ 0, %0 ], [ %59, %57 ]
%17 = 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))
%18 = call i64 @fscanf(i32* %17, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0), i32* %1, i32* %2, i32* %3, i32* %4)
%19 = load i64, i64* @EOF
%20 = icmp eq i64 %18, %19
br i1 %20, label %40, label %21
21: ; preds = %9
%22 = add nuw nsw i32 %10, 1
br label %23
23: ; preds = %21, %23
%24 = phi double [ 0.000000e+00, %21 ], [ %36, %23 ]
%25 = phi double [ 0.000000e+00, %21 ], [ %35, %23 ]
%26 = load i32, i32* %4
%27 = icmp eq i32 %26, 0
%28 = load i32, i32* %1
%29 = icmp eq i32 %28, %22
%30 = select i1 %27, i1 %29, i1 false
%31 = fadd double %24, 1.000000e+00
%32 = load i32, i32* %2
%33 = sitofp i32 %32 to double
%34 = select i1 %30, double %33, double -0.000000e+00
%35 = fadd double %25, %34
%36 = select i1 %30, double %31, double %24
%37 = call i64 @fscanf(i32* %17, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0), i32* %1, i32* %2, i32* %3, i32* %4)
%38 = load i64, i64* @EOF
%39 = icmp eq i64 %37, %38
br i1 %39, label %40, label %23
40: ; preds = %23, %9
%41 = phi double [ 0.000000e+00, %9 ], [ %35, %23 ]
%42 = phi double [ 0.000000e+00, %9 ], [ %36, %23 ]
%43 = call i32 @fclose(i32* %17)
%44 = fdiv double %41, %42
%45 = fcmp ogt double %13, %44
br i1 %45, label %46, label %48
46: ; preds = %40
%47 = add nuw nsw i32 %10, 1
br label %57
48: ; preds = %40
%49 = fcmp ogt double %12, %44
br i1 %49, label %50, label %52
50: ; preds = %48
%51 = add nuw nsw i32 %10, 1
br label %57
52: ; preds = %48
%53 = fcmp ogt double %11, %44
%54 = add nuw nsw i32 %10, 1
%55 = select i1 %53, i32 %54, i32 %15
%56 = select i1 %53, double %44, double %11
br label %57
57: ; preds = %52, %50, %46
%58 = phi i32 [ %51, %50 ], [ %47, %46 ], [ %54, %52 ]
%59 = phi i32 [ %51, %50 ], [ %16, %46 ], [ %16, %52 ]
%60 = phi i32 [ %15, %50 ], [ %15, %46 ], [ %55, %52 ]
%61 = phi i32 [ %14, %50 ], [ %47, %46 ], [ %14, %52 ]
%62 = phi double [ %13, %50 ], [ %44, %46 ], [ %13, %52 ]
%63 = phi double [ %44, %50 ], [ %12, %46 ], [ %12, %52 ]
%64 = phi double [ %11, %50 ], [ %11, %46 ], [ %56, %52 ]
%65 = icmp eq i32 %58, 9
br i1 %65, label %66, label %9
66: ; preds = %57
%67 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([38 x i8], [38 x i8]* @str, i64 0, i64 0))
%68 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([74 x i8], [74 x i8]* @str.6, i64 0, i64 0))
%69 = call i32 @print_top3(i32 %61, double %62, i32 %59, double %63, i32 %60, double %64)
%70 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @str.7, i64 0, i64 0))
ret void
}