#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 x, n, i, y, a, b, c, d, e;
  printf("Enter n:");
  scanf("%d", &n);
  a = b = c = d = e = 0;
  for (i = 1; i <= n; i++) {
    printf("Enter grade %d:", i);
    scanf("%d", &x);
    y = x / 10;
    switch (y) {
    case 10:
    case 9:
      a++;
      break;
    case 8:
      b++;
      break;
    case 7:
      c++;
      break;
    case 6:
      d++;
      break;
    default:
      e++;
      break;
    }
  }
  printf("The number of A(90~100):%d\n", a);
  printf("The number of B(80~89):%d\n", b);
  printf("The number of C(70~79):%d\n", c);
  printf("The number of D(60~69):%d\n", d);
  printf("The number of E(0~59):%d\n", e);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xede(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xed9(%rip),%rdi
lea    -0xc(%rbp),%rsi
call   1040 <scanf@plt>
movl   $0x0,-0x28(%rbp)
movl   $0x0,-0x24(%rbp)
movl   $0x0,-0x20(%rbp)
movl   $0x0,-0x1c(%rbp)
movl   $0x0,-0x18(%rbp)
movl   $0x1,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0xc(%rbp),%eax
jg     123c <main+0x11c>
mov    -0x10(%rbp),%esi
lea    0xe93(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xe82(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
movslq -0x8(%rbp),%rax
imul   $0x66666667,%rax,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
sar    $0x22,%rax
add    %ecx,%eax
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
add    $0xfffffffa,%eax
mov    %eax,%ecx
mov    %rcx,-0x30(%rbp)
sub    $0x4,%eax
ja     1220 <main+0x100>
mov    -0x30(%rbp),%rax
lea    0xe21(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1229 <main+0x109>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1229 <main+0x109>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    1229 <main+0x109>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1229 <main+0x109>
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    122e <main+0x10e>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1177 <main+0x57>
mov    -0x18(%rbp),%esi
lea    0xdea(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x1c(%rbp),%esi
lea    0xdf5(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x20(%rbp),%esi
lea    0xdff(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x24(%rbp),%esi
lea    0xe09(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x28(%rbp),%esi
lea    0xe13(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
lea    0xedf(%rip),%rdi
xor    %ebp,%ebp
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xed8(%rip),%rdi
lea    0x10(%rsp),%rsi
call   1040 <scanf@plt>
cmpl   $0x0,0x10(%rsp)
movl   $0x0,(%rsp)
movl   $0x0,0x4(%rsp)
movl   $0x0,0x8(%rsp)
movl   $0x0,0xc(%rsp)
jle    1227 <main+0x107>
lea    0xea0(%rip),%rbx
lea    0xe96(%rip),%r14
lea    0x14(%rsp),%r15
lea    0xe6d(%rip),%r13
xor    %r12d,%r12d
movl   $0x0,0xc(%rsp)
movl   $0x0,0x8(%rsp)
movl   $0x0,0x4(%rsp)
movl   $0x0,(%rsp)
xor    %ebp,%ebp
jmp    11c7 <main+0xa7>
addl   $0x1,0xc(%rsp)
xchg   %ax,%ax
cmp    0x10(%rsp),%r12d
jge    1227 <main+0x107>
add    $0x1,%r12d
mov    %rbx,%rdi
mov    %r12d,%esi
xor    %eax,%eax
call   1030 <printf@plt>
mov    %r14,%rdi
mov    %r15,%rsi
call   1040 <scanf@plt>
movslq 0x14(%rsp),%rax
imul   $0x66666667,%rax,%rax
mov    %rax,%rcx
sar    $0x22,%rcx
shr    $0x3f,%rax
add    %ecx,%eax
add    $0xfffffffa,%eax
cmp    $0x4,%eax
ja     11b9 <main+0x99>
movslq 0x0(%r13,%rax,4),%rax
add    %r13,%rax
jmp    *%rax
add    $0x1,%ebp
jmp    11c0 <main+0xa0>
addl   $0x1,0x8(%rsp)
jmp    11c0 <main+0xa0>
addl   $0x1,0x4(%rsp)
jmp    11c0 <main+0xa0>
addl   $0x1,(%rsp)
jmp    11c0 <main+0xa0>
lea    0xe02(%rip),%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xe0e(%rip),%rdi
mov    (%rsp),%esi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xe18(%rip),%rdi
mov    0x4(%rsp),%esi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xe21(%rip),%rdi
mov    0x8(%rsp),%esi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xe2a(%rip),%rdi
mov    0xc(%rsp),%esi
xor    %eax,%eax
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [9 x i8] c"Enter n:\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [16 x i8] c"Enter grade %d:\00"
@.str.3 = [28 x i8] c"The number of A(90~100):%d\0A\00"
@.str.4 = [27 x i8] c"The number of B(80~89):%d\0A\00"
@.str.5 = [27 x i8] c"The number of C(70~79):%d\0A\00"
@.str.6 = [27 x i8] c"The number of D(60~69):%d\0A\00"
@.str.7 = [26 x i8] c"The number of E(0~59):%d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
store i32 0, i32* %1
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0))
%12 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %3)
store i32 0, i32* %10
store i32 0, i32* %9
store i32 0, i32* %8
store i32 0, i32* %7
store i32 0, i32* %6
store i32 1, i32* %4
br label %13
13: ; preds = %40, %0
%14 = load i32, i32* %4
%15 = load i32, i32* %3
%16 = icmp sle i32 %14, %15
br i1 %16, label %17, label %43
17: ; preds = %13
%18 = load i32, i32* %4
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0), i32 %18)
%20 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%21 = load i32, i32* %2
%22 = sdiv i32 %21, 10
store i32 %22, i32* %5
%23 = load i32, i32* %5
switch i32 %23, label %36 [
i32 10, label %24
i32 9, label %24
i32 8, label %27
i32 7, label %30
i32 6, label %33
]
24: ; preds = %17, %17
%25 = load i32, i32* %6
%26 = add nsw i32 %25, 1
store i32 %26, i32* %6
br label %39
27: ; preds = %17
%28 = load i32, i32* %7
%29 = add nsw i32 %28, 1
store i32 %29, i32* %7
br label %39
30: ; preds = %17
%31 = load i32, i32* %8
%32 = add nsw i32 %31, 1
store i32 %32, i32* %8
br label %39
33: ; preds = %17
%34 = load i32, i32* %9
%35 = add nsw i32 %34, 1
store i32 %35, i32* %9
br label %39
36: ; preds = %17
%37 = load i32, i32* %10
%38 = add nsw i32 %37, 1
store i32 %38, i32* %10
br label %39
39: ; preds = %36, %33, %30, %27, %24
br label %40
40: ; preds = %39
%41 = load i32, i32* %4
%42 = add nsw i32 %41, 1
store i32 %42, i32* %4
br label %13
43: ; preds = %13
%44 = load i32, i32* %6
%45 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.3, i64 0, i64 0), i32 %44)
%46 = load i32, i32* %7
%47 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.4, i64 0, i64 0), i32 %46)
%48 = load i32, i32* %8
%49 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.5, i64 0, i64 0), i32 %48)
%50 = load i32, i32* %9
%51 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.6, i64 0, i64 0), i32 %50)
%52 = load i32, i32* %10
%53 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.7, i64 0, i64 0), i32 %52)
ret i32 0
}

LLVM IR (-O2):
@.str = [9 x i8] c"Enter n:\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [16 x i8] c"Enter grade %d:\00"
@.str.3 = [28 x i8] c"The number of A(90~100):%d\0A\00"
@.str.4 = [27 x i8] c"The number of B(80~89):%d\0A\00"
@.str.5 = [27 x i8] c"The number of C(70~79):%d\0A\00"
@.str.6 = [27 x i8] c"The number of D(60~69):%d\0A\00"
@.str.7 = [26 x i8] c"The number of E(0~59):%d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = bitcast i32* %1 to i8*
%4 = bitcast i32* %2 to i8*
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0))
%6 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%7 = load i32, i32* %2
%8 = icmp slt i32 %7, 1
br i1 %8, label %39, label %9
9: ; preds = %0, %30
%10 = phi i32 [ %35, %30 ], [ 0, %0 ]
%11 = phi i32 [ %34, %30 ], [ 0, %0 ]
%12 = phi i32 [ %33, %30 ], [ 0, %0 ]
%13 = phi i32 [ %32, %30 ], [ 0, %0 ]
%14 = phi i32 [ %31, %30 ], [ 0, %0 ]
%15 = phi i32 [ %36, %30 ], [ 1, %0 ]
%16 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0), i32 %15)
%17 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%18 = load i32, i32* %1
%19 = sdiv i32 %18, 10
switch i32 %19, label %28 [
i32 10, label %20
i32 9, label %20
i32 8, label %22
i32 7, label %24
i32 6, label %26
]
20: ; preds = %9, %9
%21 = add nsw i32 %14, 1
br label %30
22: ; preds = %9
%23 = add nsw i32 %13, 1
br label %30
24: ; preds = %9
%25 = add nsw i32 %12, 1
br label %30
26: ; preds = %9
%27 = add nsw i32 %11, 1
br label %30
28: ; preds = %9
%29 = add nsw i32 %10, 1
br label %30
30: ; preds = %20, %22, %24, %26, %28
%31 = phi i32 [ %14, %28 ], [ %14, %26 ], [ %14, %24 ], [ %14, %22 ], [ %21, %20 ]
%32 = phi i32 [ %13, %28 ], [ %13, %26 ], [ %13, %24 ], [ %23, %22 ], [ %13, %20 ]
%33 = phi i32 [ %12, %28 ], [ %12, %26 ], [ %25, %24 ], [ %12, %22 ], [ %12, %20 ]
%34 = phi i32 [ %11, %28 ], [ %27, %26 ], [ %11, %24 ], [ %11, %22 ], [ %11, %20 ]
%35 = phi i32 [ %29, %28 ], [ %10, %26 ], [ %10, %24 ], [ %10, %22 ], [ %10, %20 ]
%36 = add nuw nsw i32 %15, 1
%37 = load i32, i32* %2
%38 = icmp slt i32 %15, %37
br i1 %38, label %9, label %39
39: ; preds = %30, %0
%40 = phi i32 [ 0, %0 ], [ %31, %30 ]
%41 = phi i32 [ 0, %0 ], [ %32, %30 ]
%42 = phi i32 [ 0, %0 ], [ %33, %30 ]
%43 = phi i32 [ 0, %0 ], [ %34, %30 ]
%44 = phi i32 [ 0, %0 ], [ %35, %30 ]
%45 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @.str.3, i64 0, i64 0), i32 %40)
%46 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str.4, i64 0, i64 0), i32 %41)
%47 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str.5, i64 0, i64 0), i32 %42)
%48 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str.6, i64 0, i64 0), i32 %43)
%49 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.7, i64 0, i64 0), i32 %44)
ret i32 0
}