#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*/ flush_stream();
int /*<<< orphan*/ printf(char *, ...);
int scanf(char *, int *);
int main(void) {
  int input, ret;
  const char *prompt = "Input please: ";
  printf("Enter the number between 0 and 10 and I will tell you your grade!\n");
  while (1) {
    printf("%s", prompt);
    ret = scanf("%d", &input);
    if (ret == 0) {
      printf(
          "Sorry, invalid character data, your input must be from 0 to 10.\n");
      flush_stream();
      continue;
    }
    if (ret > 0) {
      if (input < 0 || input > 10) {
        printf("Sorry, invalid character data, your input must be from 0 to "
               "10.\n");
        flush_stream();
        continue;
      }
      switch (input) {
      case 0:
      case 1:
      case 2:
      case 3:
      case 4:
      case 5:
        printf("Your grade is F. \n");
        break;
      case 6:
        printf("Your grade is D. \n");
        break;
      }
    }
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeba(%rip),%rax
mov    %rax,-0x18(%rbp)
lea    0xebe(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%rsi
lea    0xeef(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xee4(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1050 <scanf@plt>
mov    %eax,-0xc(%rbp)
cmpl   $0x0,-0xc(%rbp)
jne    11a1 <main+0x71>
lea    0xeca(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0x0,%al
call   1040 <flush_stream@plt>
jmp    1158 <main+0x28>
cmpl   $0x0,-0xc(%rbp)
jle    1224 <main+0xf4>
cmpl   $0x0,-0x8(%rbp)
jl     11bf <main+0x8f>
cmpl   $0xa,-0x8(%rbp)
jle    11d9 <main+0xa9>
lea    0xe92(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0x0,%al
call   1040 <flush_stream@plt>
jmp    1158 <main+0x28>
mov    -0x8(%rbp),%eax
mov    %eax,-0x1c(%rbp)
sub    $0x6,%eax
jb     11fe <main+0xce>
jmp    11ed <main+0xbd>
mov    -0x1c(%rbp),%eax
sub    $0x6,%eax
je     1211 <main+0xe1>
jmp    121f <main+0xef>
lea    0xe94(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    121f <main+0xef>
lea    0xe94(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1224 <main+0xf4>
jmp    1158 <main+0x28>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
lea    0xec3(%rip),%rdi
call   1030 <puts@plt>
lea    0xeb1(%rip),%r14
lea    0xe9b(%rip),%r15
lea    0xea6(%rip),%r12
lea    0x4(%rsp),%rbx
lea    0xf03(%rip),%r13
lea    0xeea(%rip),%rbp
jmp    119f <main+0x5f>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %r13,%rdi
call   1030 <puts@plt>
xor    %eax,%eax
call   1050 <flush_stream@plt>
mov    %r14,%rdi
mov    %r15,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r12,%rdi
mov    %rbx,%rsi
call   1060 <scanf@plt>
test   %eax,%eax
je     1190 <main+0x50>
jle    119f <main+0x5f>
mov    0x4(%rsp),%eax
cmp    $0xb,%eax
jae    1190 <main+0x50>
cmp    $0x6,%eax
jae    11d5 <main+0x95>
mov    %rbp,%rdi
call   1030 <puts@plt>
jmp    119f <main+0x5f>
jne    119f <main+0x5f>
lea    0xe79(%rip),%rdi
call   1030 <puts@plt>
jmp    119f <main+0x5f>

LLVM IR (-O0):
@.str = [15 x i8] c"Input please: \00"
@.str.1 = [67 x i8] c"Enter the number between 0 and 10 and I will tell you your grade!\0A\00"
@.str.2 = [3 x i8] c"%s\00"
@.str.3 = [3 x i8] c"%d\00"
@.str.4 = [65 x i8] c"Sorry, invalid character data, your input must be from 0 to 10.\0A\00"
@.str.5 = [19 x i8] c"Your grade is F. \0A\00"
@.str.6 = [19 x i8] c"Your grade is D. \0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i8*
store i32 0, i32* %1
store i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i8** %4
%5 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([67 x i8], [67 x i8]* @.str.1, i64 0, i64 0))
br label %6
6: ; preds = %0, %12, %24, %34
%7 = load i8*, i8** %4
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %7)
%9 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32* %2)
store i32 %9, i32* %3
%10 = load i32, i32* %3
%11 = icmp eq i32 %10, 0
br i1 %11, label %12, label %15
12: ; preds = %6
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([65 x i8], [65 x i8]* @.str.4, i64 0, i64 0))
%14 = call i32 (...) @flush_stream()
br label %6
15: ; preds = %6
%16 = load i32, i32* %3
%17 = icmp sgt i32 %16, 0
br i1 %17, label %18, label %34
18: ; preds = %15
%19 = load i32, i32* %2
%20 = icmp slt i32 %19, 0
br i1 %20, label %24, label %21
21: ; preds = %18
%22 = load i32, i32* %2
%23 = icmp sgt i32 %22, 10
br i1 %23, label %24, label %27
24: ; preds = %21, %18
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([65 x i8], [65 x i8]* @.str.4, i64 0, i64 0))
%26 = call i32 (...) @flush_stream()
br label %6
27: ; preds = %21
%28 = load i32, i32* %2
switch i32 %28, label %33 [
i32 0, label %29
i32 1, label %29
i32 2, label %29
i32 3, label %29
i32 4, label %29
i32 5, label %29
i32 6, label %31
]
29: ; preds = %27, %27, %27, %27, %27, %27
%30 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.5, i64 0, i64 0))
br label %33
31: ; preds = %27
%32 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.6, i64 0, i64 0))
br label %33
33: ; preds = %27, %31, %29
br label %34
34: ; preds = %33, %15
br label %6
}

LLVM IR (-O2):
@.str = [15 x i8] c"Input please: \00"
@.str.2 = [3 x i8] c"%s\00"
@.str.3 = [3 x i8] c"%d\00"
@str = [66 x i8] c"Enter the number between 0 and 10 and I will tell you your grade!\00"
@str.7 = [18 x i8] c"Your grade is D. \00"
@str.8 = [18 x i8] c"Your grade is F. \00"
@str.10 = [64 x i8] c"Sorry, invalid character data, your input must be from 0 to 10.\00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([66 x i8], [66 x i8]* @str, i64 0, i64 0))
br label %4
4: ; preds = %13, %0
%5 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0))
%6 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32* %1)
%7 = icmp eq i32 %6, 0
br i1 %7, label %8, label %11
8: ; preds = %4
%9 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([64 x i8], [64 x i8]* @str.10, i64 0, i64 0))
%10 = call i32 (...) @flush_stream()
br label %13
11: ; preds = %4
%12 = icmp sgt i32 %6, 0
br i1 %12, label %14, label %13
13: ; preds = %11, %20, %23, %21, %8, %17
br label %4
14: ; preds = %11
%15 = load i32, i32* %1
%16 = icmp ugt i32 %15, 10
br i1 %16, label %17, label %20
17: ; preds = %14
%18 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([64 x i8], [64 x i8]* @str.10, i64 0, i64 0))
%19 = call i32 (...) @flush_stream()
br label %13
20: ; preds = %14
switch i32 %15, label %13 [
i32 0, label %21
i32 1, label %21
i32 2, label %21
i32 3, label %21
i32 4, label %21
i32 5, label %21
i32 6, label %23
]
21: ; preds = %20, %20, %20, %20, %20, %20
%22 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @str.8, i64 0, i64 0))
br label %13
23: ; preds = %20
%24 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @str.7, i64 0, i64 0))
br label %13
}