#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 */

/* Variables and functions */
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, int *);
int main() {
  int i, grade, total = 0, average = 0;
  char letter_grade;
  do {
    printf("Enter five number grades for the student. \n\n");
    for (i = 0; i < 5; i++) {
      printf("Enter grade %d: ", i + 1);
      scanf("%d", &grade);
      total += grade;
    }
    average = (int)((total / 5) + 0.9999999);
    if (average >= 0)
      letter_grade = 'F';
    if (average >= 60)
      letter_grade = 'D';
    if (average >= 70)
      letter_grade = 'C';
    if (average >= 80)
      letter_grade = 'B';
    if (average >= 90)
      letter_grade = 'A';
    if (average > 100 || average < 0)
      letter_grade = 'I';
    switch (letter_grade) {
    case 'A':
      printf("Your grade is: %c! \n", letter_grade);
      break;
    case 'B':
      printf("Your grade is: %c! \n", letter_grade);
      break;
    case 'C':
      printf("Your grade is: %c! \n", letter_grade);
      break;
    case 'D':
      printf("Your grade is: %c! \n", letter_grade);
      break;
    case 'F':
      printf("Your grade is: %c! \n", letter_grade);
      break;
    case 'I':
      printf("Your grade result was invalid, try again. \n\n");
      break;
    }
  } while (letter_grade == 'I');
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
lea    0xee8(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x8(%rbp)
cmpl   $0x5,-0x8(%rbp)
jge    1197 <main+0x77>
mov    -0x8(%rbp),%esi
add    $0x1,%esi
lea    0xef0(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xef3(%rip),%rdi
lea    -0xc(%rbp),%rsi
call   1040 <scanf@plt>
mov    -0xc(%rbp),%eax
add    -0x10(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1152 <main+0x32>
mov    -0x10(%rbp),%eax
mov    $0x5,%ecx
cltd
idiv   %ecx
cvtsi2sd %eax,%xmm0
movsd  0xe52(%rip),%xmm1
addsd  %xmm1,%xmm0
cvttsd2si %xmm0,%eax
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jl     11c7 <main+0xa7>
movb   $0x46,-0x15(%rbp)
cmpl   $0x3c,-0x14(%rbp)
jl     11d5 <main+0xb5>
movb   $0x44,-0x15(%rbp)
cmpl   $0x46,-0x14(%rbp)
jl     11e3 <main+0xc3>
movb   $0x43,-0x15(%rbp)
cmpl   $0x50,-0x14(%rbp)
jl     11f1 <main+0xd1>
movb   $0x42,-0x15(%rbp)
cmpl   $0x5a,-0x14(%rbp)
jl     11ff <main+0xdf>
movb   $0x41,-0x15(%rbp)
cmpl   $0x64,-0x14(%rbp)
jg     1213 <main+0xf3>
cmpl   $0x0,-0x14(%rbp)
jge    1217 <main+0xf7>
movb   $0x49,-0x15(%rbp)
movsbl -0x15(%rbp),%eax
add    $0xffffffbf,%eax
mov    %eax,%ecx
mov    %rcx,-0x20(%rbp)
sub    $0x8,%eax
ja     12c2 <main+0x1a2>
mov    -0x20(%rbp),%rax
lea    0xdd0(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
movsbl -0x15(%rbp),%esi
lea    0xe21(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    12c2 <main+0x1a2>
movsbl -0x15(%rbp),%esi
lea    0xe0a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    12c2 <main+0x1a2>
movsbl -0x15(%rbp),%esi
lea    0xdf3(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    12c2 <main+0x1a2>
movsbl -0x15(%rbp),%esi
lea    0xddc(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    12c2 <main+0x1a2>
movsbl -0x15(%rbp),%esi
lea    0xdc5(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    12c2 <main+0x1a2>
lea    0xdc7(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    12c7 <main+0x1a7>
movsbl -0x15(%rbp),%eax
cmp    $0x49,%eax
je     113d <main+0x1d>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
lea    0xede(%rip),%r15
lea    0xee8(%rip),%r12
lea    0x4(%rsp),%rbx
mov    $0x41,%ebp
mov    $0x49,%r13d
xor    %r14d,%r14d
nopl   0x0(%rax)
lea    0xee2(%rip),%rdi
call   1030 <puts@plt>
mov    %r15,%rdi
mov    $0x1,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r12,%rdi
mov    %rbx,%rsi
call   1050 <scanf@plt>
add    0x4(%rsp),%r14d
mov    %r15,%rdi
mov    $0x2,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r12,%rdi
mov    %rbx,%rsi
call   1050 <scanf@plt>
add    0x4(%rsp),%r14d
mov    %r15,%rdi
mov    $0x3,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r12,%rdi
mov    %rbx,%rsi
call   1050 <scanf@plt>
add    0x4(%rsp),%r14d
mov    %r15,%rdi
mov    $0x4,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r12,%rdi
mov    %rbx,%rsi
call   1050 <scanf@plt>
add    0x4(%rsp),%r14d
mov    %r15,%rdi
mov    $0x5,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r12,%rdi
mov    %rbx,%rsi
call   1050 <scanf@plt>
add    0x4(%rsp),%r14d
movslq %r14d,%rax
imul   $0x66666667,%rax,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
sar    $0x21,%rax
add    %ecx,%eax
cvtsi2sd %eax,%xmm0
addsd  0xdd6(%rip),%xmm0
cvttsd2si %xmm0,%ecx
xor    %eax,%eax
test   %ecx,%ecx
sets   %al
lea    (%rax,%rax,2),%eax
add    $0x46,%eax
cmp    $0x3c,%ecx
mov    $0x44,%edx
cmovge %edx,%eax
cmp    $0x46,%ecx
mov    $0x43,%edx
cmovge %edx,%eax
cmp    $0x50,%ecx
mov    $0x42,%edx
cmovge %edx,%eax
cmp    $0x5a,%ecx
cmovge %ebp,%eax
cmp    $0x65,%ecx
cmovae %r13d,%eax
cmp    $0x49,%al
jne    127e <main+0x14e>
lea    0xe01(%rip),%rdi
call   1030 <puts@plt>
jmp    1160 <main+0x30>
add    $0xbf,%al
cmp    $0x5,%al
ja     12c6 <main+0x196>
movzbl %al,%eax
lea    0xd7a(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    $0x41,%esi
jmp    12b8 <main+0x188>
mov    $0x42,%esi
jmp    12b8 <main+0x188>
mov    $0x43,%esi
jmp    12b8 <main+0x188>
mov    $0x44,%esi
jmp    12b8 <main+0x188>
mov    $0x46,%esi
lea    0xd75(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [45 x i8] c"Enter five number grades for the student. \0A\0A\00"
@.str.1 = [17 x i8] c"Enter grade %d: \00"
@.str.2 = [3 x i8] c"%d\00"
@.str.3 = [21 x i8] c"Your grade is: %c! \0A\00"
@.str.4 = [45 x i8] c"Your grade result was invalid, try again. \0A\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i8
store i32 0, i32* %1
store i32 0, i32* %4
store i32 0, i32* %5
br label %7
7: ; preds = %81, %0
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %2
br label %9
9: ; preds = %20, %7
%10 = load i32, i32* %2
%11 = icmp slt i32 %10, 5
br i1 %11, label %12, label %23
12: ; preds = %9
%13 = load i32, i32* %2
%14 = add nsw i32 %13, 1
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0), i32 %14)
%16 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %3)
%17 = load i32, i32* %3
%18 = load i32, i32* %4
%19 = add nsw i32 %18, %17
store i32 %19, i32* %4
br label %20
20: ; preds = %12
%21 = load i32, i32* %2
%22 = add nsw i32 %21, 1
store i32 %22, i32* %2
br label %9
23: ; preds = %9
%24 = load i32, i32* %4
%25 = sdiv i32 %24, 5
%26 = sitofp i32 %25 to double
%27 = fadd double %26, 0x3FEFFFFFCA501ACB
%28 = fptosi double %27 to i32
store i32 %28, i32* %5
%29 = load i32, i32* %5
%30 = icmp sge i32 %29, 0
br i1 %30, label %31, label %32
31: ; preds = %23
store i8 70, i8* %6
br label %32
32: ; preds = %31, %23
%33 = load i32, i32* %5
%34 = icmp sge i32 %33, 60
br i1 %34, label %35, label %36
35: ; preds = %32
store i8 68, i8* %6
br label %36
36: ; preds = %35, %32
%37 = load i32, i32* %5
%38 = icmp sge i32 %37, 70
br i1 %38, label %39, label %40
39: ; preds = %36
store i8 67, i8* %6
br label %40
40: ; preds = %39, %36
%41 = load i32, i32* %5
%42 = icmp sge i32 %41, 80
br i1 %42, label %43, label %44
43: ; preds = %40
store i8 66, i8* %6
br label %44
44: ; preds = %43, %40
%45 = load i32, i32* %5
%46 = icmp sge i32 %45, 90
br i1 %46, label %47, label %48
47: ; preds = %44
store i8 65, i8* %6
br label %48
48: ; preds = %47, %44
%49 = load i32, i32* %5
%50 = icmp sgt i32 %49, 100
br i1 %50, label %54, label %51
51: ; preds = %48
%52 = load i32, i32* %5
%53 = icmp slt i32 %52, 0
br i1 %53, label %54, label %55
54: ; preds = %51, %48
store i8 73, i8* %6
br label %55
55: ; preds = %54, %51
%56 = load i8, i8* %6
%57 = sext i8 %56 to i32
switch i32 %57, label %80 [
i32 65, label %58
i32 66, label %62
i32 67, label %66
i32 68, label %70
i32 70, label %74
i32 73, label %78
]
58: ; preds = %55
%59 = load i8, i8* %6
%60 = sext i8 %59 to i32
%61 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.3, i64 0, i64 0), i32 %60)
br label %80
62: ; preds = %55
%63 = load i8, i8* %6
%64 = sext i8 %63 to i32
%65 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.3, i64 0, i64 0), i32 %64)
br label %80
66: ; preds = %55
%67 = load i8, i8* %6
%68 = sext i8 %67 to i32
%69 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.3, i64 0, i64 0), i32 %68)
br label %80
70: ; preds = %55
%71 = load i8, i8* %6
%72 = sext i8 %71 to i32
%73 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.3, i64 0, i64 0), i32 %72)
br label %80
74: ; preds = %55
%75 = load i8, i8* %6
%76 = sext i8 %75 to i32
%77 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.3, i64 0, i64 0), i32 %76)
br label %80
78: ; preds = %55
%79 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.4, i64 0, i64 0))
br label %80
80: ; preds = %55, %78, %74, %70, %66, %62, %58
br label %81
81: ; preds = %80
%82 = load i8, i8* %6
%83 = sext i8 %82 to i32
%84 = icmp eq i32 %83, 73
br i1 %84, label %7, label %85
85: ; preds = %81
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [17 x i8] c"Enter grade %d: \00"
@.str.2 = [3 x i8] c"%d\00"
@.str.3 = [21 x i8] c"Your grade is: %c! \0A\00"
@str = [44 x i8] c"Enter five number grades for the student. \0A\00"
@str.5 = [44 x i8] c"Your grade result was invalid, try again. \0A\00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
br label %3
3: ; preds = %44, %0
%4 = phi i32 [ 0, %0 ], [ %25, %44 ]
%5 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([44 x i8], [44 x i8]* @str, i64 0, i64 0))
%6 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0), i32 1)
%7 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %1)
%8 = load i32, i32* %1
%9 = add nsw i32 %8, %4
%10 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0), i32 2)
%11 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %1)
%12 = load i32, i32* %1
%13 = add nsw i32 %12, %9
%14 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0), i32 3)
%15 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %1)
%16 = load i32, i32* %1
%17 = add nsw i32 %16, %13
%18 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0), i32 4)
%19 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %1)
%20 = load i32, i32* %1
%21 = add nsw i32 %20, %17
%22 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0), i32 5)
%23 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %1)
%24 = load i32, i32* %1
%25 = add nsw i32 %24, %21
%26 = sdiv i32 %25, 5
%27 = sitofp i32 %26 to double
%28 = fadd double %27, 0x3FEFFFFFCA501ACB
%29 = fptosi double %28 to i32
%30 = icmp sgt i32 %29, -1
%31 = select i1 %30, i8 70, i8 73
%32 = icmp sgt i32 %29, 59
%33 = select i1 %32, i8 68, i8 %31
%34 = icmp sgt i32 %29, 69
%35 = select i1 %34, i8 67, i8 %33
%36 = icmp sgt i32 %29, 79
%37 = select i1 %36, i8 66, i8 %35
%38 = icmp sgt i32 %29, 89
%39 = select i1 %38, i8 65, i8 %37
%40 = icmp ugt i32 %29, 100
%41 = select i1 %40, i8 73, i8 %39
switch i8 %41, label %51 [
i8 65, label %46
i8 66, label %47
i8 67, label %48
i8 68, label %42
i8 70, label %43
i8 73, label %44
]
42: ; preds = %3
br label %48
43: ; preds = %3
br label %48
44: ; preds = %3
%45 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([44 x i8], [44 x i8]* @str.5, i64 0, i64 0))
br label %3
46: ; preds = %3
br label %48
47: ; preds = %3
br label %48
48: ; preds = %3, %47, %46, %42, %43
%49 = phi i32 [ 70, %43 ], [ 68, %42 ], [ 65, %46 ], [ 66, %47 ], [ 67, %3 ]
%50 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.3, i64 0, i64 0), i32 %49)
br label %51
51: ; preds = %3, %48
ret i32 0
}