#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 */
typedef scalar_t__ clock_t;

/* Variables and functions */
int CLOCKS_PER_SEC;
scalar_t__ clock();
int /*<<< orphan*/ printf(char *, ...);
int rand();
int /*<<< orphan*/ scanf(char *, int *);
int /*<<< orphan*/ srand(int /*<<< orphan*/);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
int main(void) {
  int a, b, c;
  int x;
  clock_t start, end;
  double req_time;
  srand(time(NULL));
  a = 100 + rand() % 900;
  b = 100 + rand() % 900;
  c = 100 + rand() % 900;
  printf("%d\n", a + b + c);
  printf("%d + %d + %d equals :  ", a, b, c);
  start = clock();
  while (1) {
    scanf("%d", &x);
    if (x == a + b + c)
      break;
    printf("\a Wrong answer!!\nPlease input again: ");
  }
  end = clock();
  req_time = 10000 * (double)(end - start) / CLOCKS_PER_SEC;
  printf("Used %.1f secounds.\n", req_time);
  if (req_time > 30.0)
    printf("Use too much time.\n");
  else if (req_time > 17.0)
    printf("Just so so.\n");
  else
    printf("Well done.\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   1060 <time@plt>
mov    %eax,%edi
call   1050 <srand@plt>
mov    $0x0,%al
call   1080 <rand@plt>
mov    $0x384,%ecx
cltd
idiv   %ecx
add    $0x64,%edx
mov    %edx,-0x8(%rbp)
mov    $0x0,%al
call   1080 <rand@plt>
mov    $0x384,%ecx
cltd
idiv   %ecx
add    $0x64,%edx
mov    %edx,-0xc(%rbp)
mov    $0x0,%al
call   1080 <rand@plt>
mov    $0x384,%ecx
cltd
idiv   %ecx
add    $0x64,%edx
mov    %edx,-0x10(%rbp)
mov    -0x8(%rbp),%esi
add    -0xc(%rbp),%esi
add    -0x10(%rbp),%esi
lea    0xe4a(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x8(%rbp),%esi
mov    -0xc(%rbp),%edx
mov    -0x10(%rbp),%ecx
lea    0xe37(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x0,%al
call   1030 <clock@plt>
mov    %rax,-0x20(%rbp)
lea    0xe36(%rip),%rdi
lea    -0x14(%rbp),%rsi
call   1070 <scanf@plt>
mov    -0x14(%rbp),%eax
mov    -0x8(%rbp),%ecx
add    -0xc(%rbp),%ecx
add    -0x10(%rbp),%ecx
cmp    %ecx,%eax
jne    1220 <main+0xc0>
jmp    1233 <main+0xd3>
lea    0xe10(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    11f7 <main+0x97>
mov    $0x0,%al
call   1030 <clock@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
sub    -0x20(%rbp),%rax
cvtsi2sd %rax,%xmm1
movsd  0xdb5(%rip),%xmm0
mulsd  %xmm1,%xmm0
mov    0x2d8a(%rip),%rax
cvtsi2sdl (%rax),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x30(%rbp),%xmm0
lea    0xde6(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
movsd  -0x30(%rbp),%xmm0
movsd  0xd75(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    12a8 <main+0x148>
lea    0xdd6(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    12e5 <main+0x185>
movsd  -0x30(%rbp),%xmm0
movsd  0xd5b(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    12d2 <main+0x172>
lea    0xdc0(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    12e0 <main+0x180>
lea    0xdba(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    12e5 <main+0x185>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x10,%rsp
xor    %edi,%edi
call   1070 <time@plt>
mov    %eax,%edi
call   1060 <srand@plt>
xor    %eax,%eax
call   1090 <rand@plt>
cltq
imul   $0xffffffff91a2b3c5,%rax,%rcx
shr    $0x20,%rcx
add    %eax,%ecx
mov    %ecx,%edx
shr    $0x1f,%edx
sar    $0x9,%ecx
add    %edx,%ecx
imul   $0x384,%ecx,%ecx
neg    %ecx
lea    (%rax,%rcx,1),%r14d
add    $0x64,%r14d
xor    %eax,%eax
call   1090 <rand@plt>
cltq
imul   $0xffffffff91a2b3c5,%rax,%rcx
shr    $0x20,%rcx
add    %eax,%ecx
mov    %ecx,%edx
shr    $0x1f,%edx
sar    $0x9,%ecx
add    %edx,%ecx
imul   $0x384,%ecx,%ecx
neg    %ecx
lea    (%rax,%rcx,1),%r15d
add    $0x64,%r15d
xor    %eax,%eax
call   1090 <rand@plt>
cltq
imul   $0xffffffff91a2b3c5,%rax,%rcx
shr    $0x20,%rcx
add    %eax,%ecx
mov    %ecx,%edx
shr    $0x1f,%edx
sar    $0x9,%ecx
add    %edx,%ecx
imul   $0x384,%ecx,%ecx
neg    %ecx
lea    (%rax,%rcx,1),%ebx
add    $0x64,%ebx
lea    (%r15,%r14,1),%ebp
add    %ebx,%ebp
lea    0xdf3(%rip),%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xde7(%rip),%rdi
mov    %r14d,%esi
mov    %r15d,%edx
mov    %ebx,%ecx
xor    %eax,%eax
call   1050 <printf@plt>
xor    %eax,%eax
call   1040 <clock@plt>
mov    %rax,%r14
lea    0xddf(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1080 <scanf@plt>
cmp    %ebp,0x4(%rsp)
je     129b <main+0x12b>
lea    0xdcb(%rip),%r15
lea    0xdc1(%rip),%r12
lea    0x4(%rsp),%rbx
nopl   0x0(%rax,%rax,1)
mov    %r15,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %r12,%rdi
mov    %rbx,%rsi
call   1080 <scanf@plt>
cmp    %ebp,0x4(%rsp)
jne    1280 <main+0x110>
xor    %eax,%eax
call   1040 <clock@plt>
sub    %r14,%rax
cvtsi2sd %rax,%xmm0
mulsd  0xd4e(%rip),%xmm0
mov    0x2d2f(%rip),%rax
cvtsi2sdl (%rax),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,0x8(%rsp)
lea    0xd8f(%rip),%rdi
mov    $0x1,%al
call   1050 <printf@plt>
movsd  0x8(%rsp),%xmm0
ucomisd 0xd25(%rip),%xmm0
lea    0xd93(%rip),%rax
lea    0xd81(%rip),%rcx
cmova  %rax,%rcx
ucomisd 0xd13(%rip),%xmm0
lea    0xd85(%rip),%rdi
cmovbe %rcx,%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [4 x i8] c"%d\0A\00"
@.str.1 = [24 x i8] c"%d + %d + %d equals : \00"
@.str.2 = [3 x i8] c"%d\00"
@.str.3 = [38 x i8] c"\07 Wrong answer!!\0APlease input again: \00"
@CLOCKS_PER_SEC = global i32 0
@.str.4 = [21 x i8] c"Used %.1f secounds.\0A\00"
@.str.5 = [20 x i8] c"Use too much time.\0A\00"
@.str.6 = [13 x i8] c"Just so so.\0A\00"
@.str.7 = [12 x i8] c"Well done.\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i64
%7 = alloca i64
%8 = alloca double
store i32 0, i32* %1
%9 = call i32 @time(i32* null)
%10 = call i32 @srand(i32 %9)
%11 = call i32 (...) @rand()
%12 = srem i32 %11, 900
%13 = add nsw i32 100, %12
store i32 %13, i32* %2
%14 = call i32 (...) @rand()
%15 = srem i32 %14, 900
%16 = add nsw i32 100, %15
store i32 %16, i32* %3
%17 = call i32 (...) @rand()
%18 = srem i32 %17, 900
%19 = add nsw i32 100, %18
store i32 %19, i32* %4
%20 = load i32, i32* %2
%21 = load i32, i32* %3
%22 = add nsw i32 %20, %21
%23 = load i32, i32* %4
%24 = add nsw i32 %22, %23
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %24)
%26 = load i32, i32* %2
%27 = load i32, i32* %3
%28 = load i32, i32* %4
%29 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0), i32 %26, i32 %27, i32 %28)
%30 = call i64 (...) @clock()
store i64 %30, i64* %6
br label %31
31: ; preds = %0, %41
%32 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %5)
%33 = load i32, i32* %5
%34 = load i32, i32* %2
%35 = load i32, i32* %3
%36 = add nsw i32 %34, %35
%37 = load i32, i32* %4
%38 = add nsw i32 %36, %37
%39 = icmp eq i32 %33, %38
br i1 %39, label %40, label %41
40: ; preds = %31
br label %43
41: ; preds = %31
%42 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.3, i64 0, i64 0))
br label %31
43: ; preds = %40
%44 = call i64 (...) @clock()
store i64 %44, i64* %7
%45 = load i64, i64* %7
%46 = load i64, i64* %6
%47 = sub nsw i64 %45, %46
%48 = sitofp i64 %47 to double
%49 = fmul double 1.000000e+04, %48
%50 = load i32, i32* @CLOCKS_PER_SEC
%51 = sitofp i32 %50 to double
%52 = fdiv double %49, %51
store double %52, double* %8
%53 = load double, double* %8
%54 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.4, i64 0, i64 0), double %53)
%55 = load double, double* %8
%56 = fcmp ogt double %55, 3.000000e+01
br i1 %56, label %57, label %59
57: ; preds = %43
%58 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.5, i64 0, i64 0))
br label %67
59: ; preds = %43
%60 = load double, double* %8
%61 = fcmp ogt double %60, 1.700000e+01
br i1 %61, label %62, label %64
62: ; preds = %59
%63 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.6, i64 0, i64 0))
br label %66
64: ; preds = %59
%65 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.7, i64 0, i64 0))
br label %66
66: ; preds = %64, %62
br label %67
67: ; preds = %66, %57
ret i32 0
}

LLVM IR (-O2):
@.str = [4 x i8] c"%d\0A\00"
@.str.1 = [24 x i8] c"%d + %d + %d equals : \00"
@.str.2 = [3 x i8] c"%d\00"
@.str.3 = [38 x i8] c"\07 Wrong answer!!\0APlease input again: \00"
@CLOCKS_PER_SEC = global i32 0
@.str.4 = [21 x i8] c"Used %.1f secounds.\0A\00"
@str = [11 x i8] c"Well done.\00"
@str.8 = [12 x i8] c"Just so so.\00"
@str.9 = [19 x i8] c"Use too much time.\00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = tail call i32 @time(i32* null)
%4 = tail call i32 @srand(i32 %3)
%5 = tail call i32 (...) @rand()
%6 = srem i32 %5, 900
%7 = add nsw i32 %6, 100
%8 = tail call i32 (...) @rand()
%9 = srem i32 %8, 900
%10 = add nsw i32 %9, 100
%11 = tail call i32 (...) @rand()
%12 = srem i32 %11, 900
%13 = add nsw i32 %12, 100
%14 = add nsw i32 %10, %7
%15 = add nsw i32 %14, %13
%16 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %15)
%17 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0), i32 %7, i32 %10, i32 %13)
%18 = tail call i64 (...) @clock()
%19 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %1)
%20 = load i32, i32* %1
%21 = icmp eq i32 %20, %15
br i1 %21, label %27, label %22
22: ; preds = %0, %22
%23 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([38 x i8], [38 x i8]* @.str.3, i64 0, i64 0))
%24 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %1)
%25 = load i32, i32* %1
%26 = icmp eq i32 %25, %15
br i1 %26, label %27, label %22
27: ; preds = %22, %0
%28 = call i64 (...) @clock()
%29 = sub nsw i64 %28, %18
%30 = sitofp i64 %29 to double
%31 = fmul double %30, 1.000000e+04
%32 = load i32, i32* @CLOCKS_PER_SEC
%33 = sitofp i32 %32 to double
%34 = fdiv double %31, %33
%35 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.4, i64 0, i64 0), double %34)
%36 = fcmp ogt double %34, 3.000000e+01
%37 = fcmp ogt double %34, 1.700000e+01
%38 = select i1 %37, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @str.8, i64 0, i64 0), i8* getelementptr inbounds ([11 x i8], [11 x i8]* @str, i64 0, i64 0)
%39 = select i1 %36, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @str.9, i64 0, i64 0), i8* %38
%40 = call i32 @puts(i8* dereferenceable(1) %39)
ret i32 0
}