#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 rand();
int /*<<< orphan*/ scanf(char *, int *);
int /*<<< orphan*/ srand(int /*<<< orphan*/);
int /*<<< orphan*/ time(int /*<<< orphan*/);
int main(int argc, const char *argv[]) {
  srand(time(0));
  int a = rand() % 100 + 1;
  int number;
  int count = 0;
  do {
    printf("请输入1-100的数：");
    scanf("%d", &number);
    count++;
    if (a > number) {
      printf("您输的数小了！\n");
    } else if (a < number) {
      printf("您输的数大了！\n");
    } else {
      printf("恭喜，您在第%d次猜对了！", count);
    }
  } while (a != number);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
xor    %edi,%edi
call   1050 <time@plt>
mov    %eax,%edi
call   1040 <srand@plt>
mov    $0x0,%al
call   1070 <rand@plt>
mov    $0x64,%ecx
cltd
idiv   %ecx
add    $0x1,%edx
mov    %edx,-0x14(%rbp)
movl   $0x0,-0x1c(%rbp)
lea    0xe69(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe73(%rip),%rdi
lea    -0x18(%rbp),%rsi
call   1060 <scanf@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x18(%rbp),%eax
jle    11d6 <main+0x86>
lea    0xe51(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    120b <main+0xbb>
mov    -0x14(%rbp),%eax
cmp    -0x18(%rbp),%eax
jge    11f5 <main+0xa5>
lea    0xe49(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1206 <main+0xb6>
mov    -0x1c(%rbp),%esi
lea    0xe4a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    120b <main+0xbb>
jmp    1210 <main+0xc0>
mov    -0x14(%rbp),%eax
cmp    -0x18(%rbp),%eax
jne    1190 <main+0x40>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
xor    %edi,%edi
call   1060 <time@plt>
mov    %eax,%edi
call   1050 <srand@plt>
xor    %eax,%eax
call   1080 <rand@plt>
cltq
imul   $0x51eb851f,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
sar    $0x25,%rcx
add    %edx,%ecx
imul   $0x64,%ecx,%ecx
mov    %eax,%ebp
sub    %ecx,%ebp
neg    %ecx
lea    (%rax,%rcx,1),%r13d
add    $0x1,%r13d
mov    $0x1,%ebx
lea    0xe4d(%rip),%r14
lea    0xe5e(%rip),%r15
lea    0x4(%rsp),%r12
jmp    11e6 <main+0x86>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
lea    0xe7e(%rip),%rdi
call   1030 <puts@plt>
add    $0x1,%ebx
cmp    0x4(%rsp),%r13d
je     1232 <main+0xd2>
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r15,%rdi
mov    %r12,%rsi
call   1070 <scanf@plt>
mov    0x4(%rsp),%eax
cmp    %eax,%ebp
jge    11d0 <main+0x70>
cmp    %eax,%r13d
jge    1220 <main+0xc0>
lea    0xe30(%rip),%rdi
jmp    11d7 <main+0x77>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
lea    0xdf4(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    11dc <main+0x7c>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [24 x i8] c"\E8\AF\B7\E8\BE\93\E5\85\A51-100\E7\9A\84\E6\95\B0\EF\BC\9A\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [23 x i8] c"\E6\82\A8\E8\BE\93\E7\9A\84\E6\95\B0\E5\B0\8F\E4\BA\86\EF\BC\81\0A\00"
@.str.3 = [23 x i8] c"\E6\82\A8\E8\BE\93\E7\9A\84\E6\95\B0\E5\A4\A7\E4\BA\86\EF\BC\81\0A\00"
@.str.4 = [36 x i8] c"\E6\81\AD\E5\96\9C\EF\BC\8C\E6\82\A8\E5\9C\A8\E7\AC\AC%d\E6\AC\A1\E7\8C\9C\E5\AF\B9\E4\BA\86\EF\BC\81\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%9 = call i32 @time(i32 0)
%10 = call i32 @srand(i32 %9)
%11 = call i32 (...) @rand()
%12 = srem i32 %11, 100
%13 = add nsw i32 %12, 1
store i32 %13, i32* %6
store i32 0, i32* %8
br label %14
14: ; preds = %35, %2
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0))
%16 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %7)
%17 = load i32, i32* %8
%18 = add nsw i32 %17, 1
store i32 %18, i32* %8
%19 = load i32, i32* %6
%20 = load i32, i32* %7
%21 = icmp sgt i32 %19, %20
br i1 %21, label %22, label %24
22: ; preds = %14
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0))
br label %34
24: ; preds = %14
%25 = load i32, i32* %6
%26 = load i32, i32* %7
%27 = icmp slt i32 %25, %26
br i1 %27, label %28, label %30
28: ; preds = %24
%29 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.3, i64 0, i64 0))
br label %33
30: ; preds = %24
%31 = load i32, i32* %8
%32 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.4, i64 0, i64 0), i32 %31)
br label %33
33: ; preds = %30, %28
br label %34
34: ; preds = %33, %22
br label %35
35: ; preds = %34
%36 = load i32, i32* %6
%37 = load i32, i32* %7
%38 = icmp ne i32 %36, %37
br i1 %38, label %14, label %39
39: ; preds = %35
ret i32 0
}

LLVM IR (-O2):
@.str = [24 x i8] c"\E8\AF\B7\E8\BE\93\E5\85\A51-100\E7\9A\84\E6\95\B0\EF\BC\9A\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.4 = [36 x i8] c"\E6\81\AD\E5\96\9C\EF\BC\8C\E6\82\A8\E5\9C\A8\E7\AC\AC%d\E6\AC\A1\E7\8C\9C\E5\AF\B9\E4\BA\86\EF\BC\81\00"
@str = [22 x i8] c"\E6\82\A8\E8\BE\93\E7\9A\84\E6\95\B0\E5\A4\A7\E4\BA\86\EF\BC\81\00"
@str.5 = [22 x i8] c"\E6\82\A8\E8\BE\93\E7\9A\84\E6\95\B0\E5\B0\8F\E4\BA\86\EF\BC\81\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca i32
%4 = tail call i32 @time(i32 0)
%5 = tail call i32 @srand(i32 %4)
%6 = tail call i32 (...) @rand()
%7 = srem i32 %6, 100
%8 = add nsw i32 %7, 1
%9 = bitcast i32* %3 to i8*
br label %10
10: ; preds = %25, %2
%11 = phi i32 [ 0, %2 ], [ %14, %25 ]
%12 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0))
%13 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %3)
%14 = add nuw nsw i32 %11, 1
%15 = load i32, i32* %3
%16 = icmp slt i32 %7, %15
br i1 %16, label %19, label %17
17: ; preds = %10
%18 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @str.5, i64 0, i64 0))
br label %25
19: ; preds = %10
%20 = icmp slt i32 %8, %15
br i1 %20, label %21, label %23
21: ; preds = %19
%22 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @str, i64 0, i64 0))
br label %25
23: ; preds = %19
%24 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([36 x i8], [36 x i8]* @.str.4, i64 0, i64 0), i32 %14)
br label %25
25: ; preds = %17, %23, %21
%26 = load i32, i32* %3
%27 = icmp eq i32 %8, %26
br i1 %27, label %28, label %10
28: ; preds = %25
ret i32 0
}