#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 scanf(char *, ...);
int main(void) {
  int grade = 0;
  do {
    printf("输入成绩:");
    if (scanf("%d", &grade) != 1) {
      printf("输入无效!");
      scanf("%*[^\n]");
      scanf("%*c");
      continue;
      printf("hehe");
    } else {
      if (grade < 0 || 100 < grade) {
        printf("成绩不在合法范围内!\n");
        scanf("%*[^\n]");
        scanf("%*c");
        grade = 0;
        continue;
      }
      printf("成绩是:%d\n", grade);
    }
  } while (grade < 60 && grade >= 0);
  printf("恭喜你,考试通过!\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
lea    0xec3(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xec3(%rip),%rdi
lea    -0x8(%rbp),%rsi
mov    $0x0,%al
call   1040 <scanf@plt>
cmp    $0x1,%eax
je     118e <main+0x6e>
lea    0xeab(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xeab(%rip),%rdi
mov    $0x0,%al
call   1040 <scanf@plt>
lea    0xea4(%rip),%rdi
mov    $0x0,%al
call   1040 <scanf@plt>
jmp    11f2 <main+0xd2>
cmpl   $0x0,-0x8(%rbp)
jl     11a6 <main+0x86>
mov    $0x64,%eax
cmp    -0x8(%rbp),%eax
jge    11dc <main+0xbc>
lea    0xe7d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe64(%rip),%rdi
mov    $0x0,%al
call   1040 <scanf@plt>
lea    0xe5d(%rip),%rdi
mov    $0x0,%al
call   1040 <scanf@plt>
movl   $0x0,-0x8(%rbp)
jmp    11f2 <main+0xd2>
mov    -0x8(%rbp),%esi
lea    0xe62(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11f2 <main+0xd2>
xor    %eax,%eax
cmpl   $0x3c,-0x8(%rbp)
mov    %al,-0x9(%rbp)
jge    120b <main+0xeb>
cmpl   $0x0,-0x8(%rbp)
setge  %al
mov    %al,-0x9(%rbp)
mov    -0x9(%rbp),%al
test   $0x1,%al
jne    1136 <main+0x16>
lea    0xe39(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
movl   $0x0,0x4(%rsp)
lea    0xeb6(%rip),%r14
lea    0xebd(%rip),%r15
lea    0x4(%rsp),%rbx
lea    0xec2(%rip),%r13
lea    0xec2(%rip),%rbp
jmp    119d <main+0x6d>
cs nopw 0x0(%rax,%rax,1)
lea    0xe9a(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r13,%rdi
xor    %eax,%eax
call   1050 <scanf@plt>
mov    %rbp,%rdi
xor    %eax,%eax
call   1050 <scanf@plt>
mov    0x4(%rsp),%r12d
cmp    $0x3c,%r12d
jae    1210 <main+0xe0>
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1050 <scanf@plt>
cmp    $0x1,%eax
jne    1170 <main+0x40>
mov    0x4(%rsp),%esi
cmp    $0x65,%esi
jb     1200 <main+0xd0>
lea    0xe87(%rip),%rdi
call   1030 <puts@plt>
xor    %r12d,%r12d
mov    %r13,%rdi
xor    %eax,%eax
call   1050 <scanf@plt>
mov    %rbp,%rdi
xor    %eax,%eax
call   1050 <scanf@plt>
movl   $0x0,0x4(%rsp)
cmp    $0x3c,%r12d
jb     119d <main+0x6d>
jmp    1210 <main+0xe0>
cs nopw 0x0(%rax,%rax,1)
nop
lea    0xe23(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    1192 <main+0x62>
lea    0xe21(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [14 x i8] c"\E8\BE\93\E5\85\A5\E6\88\90\E7\BB\A9:\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [14 x i8] c"\E8\BE\93\E5\85\A5\E6\97\A0\E6\95\88!\00"
@.str.3 = [7 x i8] c"%*[^\0A]\00"
@.str.4 = [4 x i8] c"%*c\00"
@.str.5 = [30 x i8] c"\E6\88\90\E7\BB\A9\E4\B8\8D\E5\9C\A8\E5\90\88\E6\B3\95\E8\8C\83\E5\9B\B4\E5\86\85!\0A\00"
@.str.6 = [14 x i8] c"\E6\88\90\E7\BB\A9\E6\98\AF:%d\0A\00"
@.str.7 = [25 x i8] c"\E6\81\AD\E5\96\9C\E4\BD\A0,\E8\80\83\E8\AF\95\E9\80\9A\E8\BF\87!\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %2
br label %3
3: ; preds = %31, %0
%4 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0))
%5 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%6 = icmp ne i32 %5, 1
br i1 %6, label %7, label %11
7: ; preds = %3
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0))
%9 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0))
%10 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0))
br label %25
11: ; preds = %3
%12 = load i32, i32* %2
%13 = icmp slt i32 %12, 0
br i1 %13, label %17, label %14
14: ; preds = %11
%15 = load i32, i32* %2
%16 = icmp slt i32 100, %15
br i1 %16, label %17, label %21
17: ; preds = %14, %11
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.5, i64 0, i64 0))
%19 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0))
%20 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0))
store i32 0, i32* %2
br label %25
21: ; preds = %14
%22 = load i32, i32* %2
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.6, i64 0, i64 0), i32 %22)
br label %24
24: ; preds = %21
br label %25
25: ; preds = %24, %17, %7
%26 = load i32, i32* %2
%27 = icmp slt i32 %26, 60
br i1 %27, label %28, label %31
28: ; preds = %25
%29 = load i32, i32* %2
%30 = icmp sge i32 %29, 0
br label %31
31: ; preds = %28, %25
%32 = phi i1 [ false, %25 ], [ %30, %28 ]
br i1 %32, label %3, label %33
33: ; preds = %31
%34 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.7, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@.str = [14 x i8] c"\E8\BE\93\E5\85\A5\E6\88\90\E7\BB\A9:\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [14 x i8] c"\E8\BE\93\E5\85\A5\E6\97\A0\E6\95\88!\00"
@.str.3 = [7 x i8] c"%*[^\0A]\00"
@.str.4 = [4 x i8] c"%*c\00"
@.str.6 = [14 x i8] c"\E6\88\90\E7\BB\A9\E6\98\AF:%d\0A\00"
@str = [24 x i8] c"\E6\81\AD\E5\96\9C\E4\BD\A0,\E8\80\83\E8\AF\95\E9\80\9A\E8\BF\87!\00"
@str.8 = [29 x i8] c"\E6\88\90\E7\BB\A9\E4\B8\8D\E5\9C\A8\E5\90\88\E6\B3\95\E8\8C\83\E5\9B\B4\E5\86\85!\00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
store i32 0, i32* %1
br label %3
3: ; preds = %22, %0
%4 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0))
%5 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%6 = icmp eq i32 %5, 1
br i1 %6, label %11, label %7
7: ; preds = %3
%8 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0))
%9 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0))
%10 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0))
br label %20
11: ; preds = %3
%12 = load i32, i32* %1
%13 = icmp ugt i32 %12, 100
br i1 %13, label %14, label %18
14: ; preds = %11
%15 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @str.8, i64 0, i64 0))
%16 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0))
%17 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0))
store i32 0, i32* %1
br label %22
18: ; preds = %11
%19 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.6, i64 0, i64 0), i32 %12)
br label %20
20: ; preds = %7, %18
%21 = load i32, i32* %1
br label %22
22: ; preds = %20, %14
%23 = phi i32 [ %21, %20 ], [ 0, %14 ]
%24 = icmp ult i32 %23, 60
br i1 %24, label %3, label %25
25: ; preds = %22
%26 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @str, i64 0, i64 0))
ret i32 0
}