#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 input_level() {
  int ret = -1;
  int level = -1;
  int level_flag = 0;
  while (level < 0) {
    printf("Input level!([lowest]1-9[fastest]):");
    level_flag = scanf(" %d", &level);
    scanf("%*[^\n]");
    scanf("%*c");
    if (level_flag == 0) {
      printf("Input level is illeagl!Please input again!\n");
      level = -1;
      continue;
    } else if (level == 1) {
      if ((0 < level) && (level < 10)) {
        break;
      } else {
        printf("Input level is not useful!Please input again!\n");
        level = -1;
        continue;
      }
    }
  }
  ret = level;
  return ret;
}


x86 assembly (clang, -O0):
<input_level>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0xffffffff,-0x4(%rbp)
movl   $0xffffffff,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
cmpl   $0x0,-0x8(%rbp)
jge    11ec <input_level+0xcc>
lea    0xeb2(%rip),%rdi
call   1030 <printf@plt>
lea    0xeca(%rip),%rdi
lea    -0x8(%rbp),%rsi
mov    $0x0,%al
call   1040 <scanf@plt>
mov    %eax,-0xc(%rbp)
lea    0xeb9(%rip),%rdi
mov    $0x0,%al
call   1040 <scanf@plt>
lea    0xeb2(%rip),%rdi
mov    $0x0,%al
call   1040 <scanf@plt>
cmpl   $0x0,-0xc(%rbp)
jne    11a6 <input_level+0x86>
lea    0xe9e(%rip),%rdi
call   1030 <printf@plt>
movl   $0xffffffff,-0x8(%rbp)
jmp    113d <input_level+0x1d>
cmpl   $0x1,-0x8(%rbp)
jne    11e2 <input_level+0xc2>
xor    %eax,%eax
cmp    -0x8(%rbp),%eax
jge    11ca <input_level+0xaa>
cmpl   $0xa,-0x8(%rbp)
jge    11ca <input_level+0xaa>
jmp    11ec <input_level+0xcc>
lea    0xe8e(%rip),%rdi
call   1030 <printf@plt>
movl   $0xffffffff,-0x8(%rbp)
jmp    113d <input_level+0x1d>
jmp    11e7 <input_level+0xc7>
jmp    113d <input_level+0x1d>
mov    -0x8(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<input_level>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
lea    0xebe(%rip),%r14
lea    0xedb(%rip),%r15
lea    0x4(%rsp),%r12
lea    0xed3(%rip),%r13
lea    0xed3(%rip),%rbx
movl   $0xffffffff,0x4(%rsp)
ff
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %r14,%rdi
call   1040 <printf@plt>
mov    %r15,%rdi
mov    %r12,%rsi
xor    %eax,%eax
call   1050 <scanf@plt>
mov    %eax,%ebp
mov    %r13,%rdi
xor    %eax,%eax
call   1050 <scanf@plt>
mov    %rbx,%rdi
xor    %eax,%eax
call   1050 <scanf@plt>
test   %ebp,%ebp
je     11b0 <input_level+0x80>
mov    0x4(%rsp),%eax
test   %eax,%eax
js     1170 <input_level+0x40>
jmp    11be <input_level+0x8e>
nopl   0x0(%rax)
lea    0xe7c(%rip),%rdi
call   1030 <puts@plt>
jmp    115c <input_level+0x2c>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [36 x i8] c"Input level!([lowest]1-9[fastest]):\00"
@.str.1 = [4 x i8] c" %d\00"
@.str.2 = [7 x i8] c"%*[^\0A]\00"
@.str.3 = [4 x i8] c"%*c\00"
@.str.4 = [44 x i8] c"Input level is illeagl!Please input again!\0A\00"
@.str.5 = [47 x i8] c"Input level is not useful!Please input again!\0A\00"
define i32 @input_level() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
store i32 -1, i32* %1
store i32 -1, i32* %2
store i32 0, i32* %3
br label %4
4: ; preds = %29, %26, %14, %0
%5 = load i32, i32* %2
%6 = icmp slt i32 %5, 0
br i1 %6, label %7, label %30
7: ; preds = %4
%8 = call i32 @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str, i64 0, i64 0))
%9 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32* %2)
store i32 %9, i32* %3
%10 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0))
%11 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0))
%12 = load i32, i32* %3
%13 = icmp eq i32 %12, 0
br i1 %13, label %14, label %16
14: ; preds = %7
%15 = call i32 @printf(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.4, i64 0, i64 0))
store i32 -1, i32* %2
br label %4
16: ; preds = %7
%17 = load i32, i32* %2
%18 = icmp eq i32 %17, 1
br i1 %18, label %19, label %28
19: ; preds = %16
%20 = load i32, i32* %2
%21 = icmp slt i32 0, %20
br i1 %21, label %22, label %26
22: ; preds = %19
%23 = load i32, i32* %2
%24 = icmp slt i32 %23, 10
br i1 %24, label %25, label %26
25: ; preds = %22
br label %30
26: ; preds = %22, %19
%27 = call i32 @printf(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.5, i64 0, i64 0))
store i32 -1, i32* %2
br label %4
28: ; preds = %16
br label %29
29: ; preds = %28
br label %4
30: ; preds = %25, %4
%31 = load i32, i32* %2
store i32 %31, i32* %1
%32 = load i32, i32* %1
ret i32 %32
}

LLVM IR (-O2):
@.str = [36 x i8] c"Input level!([lowest]1-9[fastest]):\00"
@.str.1 = [4 x i8] c" %d\00"
@.str.2 = [7 x i8] c"%*[^\0A]\00"
@.str.3 = [4 x i8] c"%*c\00"
@str = [43 x i8] c"Input level is illeagl!Please input again!\00"
define i32 @input_level() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
br label %3
3: ; preds = %10, %0
store i32 -1, i32* %1
br label %4
4: ; preds = %3, %12
%5 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([36 x i8], [36 x i8]* @.str, i64 0, i64 0))
%6 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%7 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0))
%8 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0))
%9 = icmp eq i32 %6, 0
br i1 %9, label %10, label %12
10: ; preds = %4
%11 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([43 x i8], [43 x i8]* @str, i64 0, i64 0))
br label %3
12: ; preds = %4
%13 = load i32, i32* %1
%14 = icmp slt i32 %13, 0
br i1 %14, label %4, label %15
15: ; preds = %12
ret i32 %13
}