#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 *, float *);
int main() {
  float score;
  char grade;
input_score:
  printf("input a score[0--100]:");
  scanf("%f", &score);
  if (score < 0 || score > 100) {
    printf("error input. ");
    goto input_score;
  }
  switch ((int)(score / 10)) {
  case 10:
  case 9:
    grade = 'A';
    break;
  case 8:
    grade = 'B';
    break;
  case 7:
    grade = 'C';
    break;
  case 6:
    grade = 'D';
    break;
  case 5:
  case 4:
  case 3:
  case 2:
  case 1:
  case 0:
    grade = 'E';
    break;
  }
  printf("score=%.2f, grade=%c\n", score, grade);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xefe(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xf07(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
xorps  %xmm0,%xmm0
ucomiss -0x8(%rbp),%xmm0
ja     1170 <main+0x50>
movss  -0x8(%rbp),%xmm0
movss  0xe99(%rip),%xmm1
ucomiss %xmm1,%xmm0
jbe    1183 <main+0x63>
lea    0xed7(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    112f <main+0xf>
movss  -0x8(%rbp),%xmm0
movss  0xe74(%rip),%xmm1
divss  %xmm1,%xmm0
cvttss2si %xmm0,%eax
mov    %eax,%ecx
mov    %rcx,-0x18(%rbp)
sub    $0xa,%eax
ja     11e3 <main+0xc3>
mov    -0x18(%rbp),%rax
lea    0xe56(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
movb   $0x41,-0x9(%rbp)
jmp    11e3 <main+0xc3>
movb   $0x42,-0x9(%rbp)
jmp    11e3 <main+0xc3>
movb   $0x43,-0x9(%rbp)
jmp    11e3 <main+0xc3>
movb   $0x44,-0x9(%rbp)
jmp    11e3 <main+0xc3>
movb   $0x45,-0x9(%rbp)
movss  -0x8(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsbl -0x9(%rbp),%esi
lea    0xe65(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
lea    0xedd(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xee6(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1040 <scanf@plt>
movss  0x4(%rsp),%xmm0
xorps  %xmm1,%xmm1
ucomiss %xmm0,%xmm1
ja     115e <main+0x3e>
ucomiss 0xea4(%rip),%xmm0
jbe    11b6 <main+0x96>
lea    0xec1(%rip),%r14
lea    0xea0(%rip),%r15
lea    0xeb0(%rip),%r12
lea    0x4(%rsp),%rbx
nopl   0x0(%rax,%rax,1)
mov    %r14,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    %r15,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    %r12,%rdi
mov    %rbx,%rsi
call   1040 <scanf@plt>
movss  0x4(%rsp),%xmm0
xorps  %xmm1,%xmm1
ucomiss %xmm0,%xmm1
ja     1180 <main+0x60>
ucomiss 0xe4c(%rip),%xmm0
ja     1180 <main+0x60>
movaps %xmm0,%xmm1
divss  0xe43(%rip),%xmm1
cvttss2si %xmm1,%eax
xor    %esi,%esi
cmp    $0xa,%eax
ja     11d8 <main+0xb8>
cltq
lea    0xe77(%rip),%rcx
mov    (%rcx,%rax,4),%esi
cvtss2sd %xmm0,%xmm0
lea    0xe51(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [23 x i8] c"input a score[0--100]:\00"
@.str.1 = [3 x i8] c"%f\00"
@.str.2 = [14 x i8] c"error input. \00"
@.str.3 = [22 x i8] c"score=%.2f, grade=%c\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca float
%3 = alloca i8
store i32 0, i32* %1
br label %4
4: ; preds = %12, %0
%5 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 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), float* %2)
%7 = load float, float* %2
%8 = fcmp olt float %7, 0.000000e+00
br i1 %8, label %12, label %9
9: ; preds = %4
%10 = load float, float* %2
%11 = fcmp ogt float %10, 1.000000e+02
br i1 %11, label %12, label %14
12: ; preds = %9, %4
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0))
br label %4
14: ; preds = %9
%15 = load float, float* %2
%16 = fdiv float %15, 1.000000e+01
%17 = fptosi float %16 to i32
switch i32 %17, label %23 [
i32 10, label %18
i32 9, label %18
i32 8, label %19
i32 7, label %20
i32 6, label %21
i32 5, label %22
i32 4, label %22
i32 3, label %22
i32 2, label %22
i32 1, label %22
i32 0, label %22
]
18: ; preds = %14, %14
store i8 65, i8* %3
br label %23
19: ; preds = %14
store i8 66, i8* %3
br label %23
20: ; preds = %14
store i8 67, i8* %3
br label %23
21: ; preds = %14
store i8 68, i8* %3
br label %23
22: ; preds = %14, %14, %14, %14, %14, %14
store i8 69, i8* %3
br label %23
23: ; preds = %14, %22, %21, %20, %19, %18
%24 = load float, float* %2
%25 = fpext float %24 to double
%26 = load i8, i8* %3
%27 = sext i8 %26 to i32
%28 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.3, i64 0, i64 0), double %25, i32 %27)
ret i32 0
}

LLVM IR (-O2):
@.str = [23 x i8] c"input a score[0--100]:\00"
@.str.1 = [3 x i8] c"%f\00"
@.str.2 = [14 x i8] c"error input. \00"
@.str.3 = [22 x i8] c"score=%.2f, grade=%c\0A\00"
@switch.table.main = [11 x i32] [i32 69, i32 69, i32 69, i32 69, i32 69, i32 69, i32 68, i32 67, i32 66, i32 65, i32 65]
define i32 @main() {
%1 = alloca float
%2 = bitcast float* %1 to i8*
%3 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0))
%4 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), float* %1)
%5 = load float, float* %1
%6 = fcmp olt float %5, 0.000000e+00
%7 = fcmp ogt float %5, 1.000000e+02
%8 = or i1 %6, %7
br i1 %8, label %9, label %17
9: ; preds = %0, %9
%10 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0))
%11 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 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), float* %1)
%13 = load float, float* %1
%14 = fcmp olt float %13, 0.000000e+00
%15 = fcmp ogt float %13, 1.000000e+02
%16 = or i1 %14, %15
br i1 %16, label %9, label %17
17: ; preds = %9, %0
%18 = phi float [ %5, %0 ], [ %13, %9 ]
%19 = fdiv float %18, 1.000000e+01
%20 = fptosi float %19 to i32
%21 = icmp ult i32 %20, 11
br i1 %21, label %22, label %26
22: ; preds = %17
%23 = sext i32 %20 to i64
%24 = getelementptr inbounds [11 x i32], [11 x i32]* @switch.table.main, i64 0, i64 %23
%25 = load i32, i32* %24
br label %26
26: ; preds = %22, %17
%27 = phi i32 [ 0, %17 ], [ %25, %22 ]
%28 = fpext float %18 to double
%29 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.3, i64 0, i64 0), double %28, i32 %27)
ret i32 0
}