#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__ time_t;

/* Variables and functions */
int /*<<< orphan*/ fflush(int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, ...);
int rand();
int /*<<< orphan*/ scanf(char *, ...);
int /*<<< orphan*/ srand(unsigned int);
int /*<<< orphan*/ stdin;
int /*<<< orphan*/ time(scalar_t__ *);
char toupper(char);
int main() {
  time_t sek;
  char run;
  unsigned int number;
  unsigned int guess;
  unsigned int attempts;
  do {
    time(&sek);
    srand((unsigned)sek);
    number = rand() % 15 + 1;
    attempts = 0;
    while (attempts < 3) {
      ++attempts;
      printf("Your guess: ");
      scanf("%d", &guess);
      fflush(stdin);
      if (guess == number) {
        printf("Congratiolation, it\'s correct!\n");
        break;
      } else if (attempts == 3)
        printf("Bad luck! Number was: %d\n", number);
      else if (guess > number)
        printf("Your guess is too big.\n");
      else if (guess < number)
        printf("Your guess is too small.\n");
    }
    printf("Another run? (Y/N): ");
    scanf("%c", &run);
    fflush(stdin);
    run = toupper(run);
  } while (run == 'Y');
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x10(%rbp),%rdi
call   1060 <time@plt>
mov    -0x10(%rbp),%rax
mov    %eax,%edi
call   1050 <srand@plt>
mov    $0x0,%al
call   1090 <rand@plt>
mov    $0xf,%ecx
cltd
idiv   %ecx
add    $0x1,%edx
mov    %edx,-0x18(%rbp)
movl   $0x0,-0x20(%rbp)
cmpl   $0x3,-0x20(%rbp)
jae    127c <main+0x10c>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
lea    0xe37(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe36(%rip),%rdi
lea    -0x1c(%rbp),%rsi
mov    $0x0,%al
call   1080 <scanf@plt>
mov    0x2dff(%rip),%rax
mov    (%rax),%edi
call   1070 <fflush@plt>
mov    -0x1c(%rbp),%eax
cmp    -0x18(%rbp),%eax
jne    120f <main+0x9f>
lea    0xe0d(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    127c <main+0x10c>
cmpl   $0x3,-0x20(%rbp)
jne    122f <main+0xbf>
mov    -0x18(%rbp),%esi
lea    0xe0d(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1272 <main+0x102>
mov    -0x1c(%rbp),%eax
cmp    -0x18(%rbp),%eax
jbe    124e <main+0xde>
lea    0xe08(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    126d <main+0xfd>
mov    -0x1c(%rbp),%eax
cmp    -0x18(%rbp),%eax
jae    1268 <main+0xf8>
lea    0xe01(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    126d <main+0xfd>
jmp    1272 <main+0x102>
jmp    1277 <main+0x107>
jmp    11af <main+0x3f>
lea    0xdf9(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe00(%rip),%rdi
lea    -0x11(%rbp),%rsi
mov    $0x0,%al
call   1080 <scanf@plt>
mov    0x2d45(%rip),%rax
mov    (%rax),%edi
call   1070 <fflush@plt>
movsbl -0x11(%rbp),%edi
call   1030 <toupper@plt>
mov    %al,-0x11(%rbp)
movsbl -0x11(%rbp),%eax
cmp    $0x59,%eax
je     117f <main+0xf>
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
lea    0xe6b(%rip),%r15
lea    0xe71(%rip),%r12
lea    0xc(%rsp),%rbx
mov    0x2e40(%rip),%r13
lea    0xb(%rsp),%r14
jmp    11fa <main+0x7a>
nop
lea    0xebb(%rip),%rdi
call   1040 <puts@plt>
lea    0xe67(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xe6e(%rip),%rdi
mov    %r14,%rsi
xor    %eax,%eax
call   1090 <scanf@plt>
mov    0x0(%r13),%edi
call   1080 <fflush@plt>
movsbl 0xb(%rsp),%edi
call   1030 <toupper@plt>
mov    %al,0xb(%rsp)
cmp    $0x59,%al
jne    1300 <main+0x180>
lea    0x10(%rsp),%rdi
call   1070 <time@plt>
mov    0x10(%rsp),%edi
call   1060 <srand@plt>
xor    %eax,%eax
call   10a0 <rand@plt>
cltq
imul   $0xffffffff88888889,%rax,%rcx
shr    $0x20,%rcx
add    %eax,%ecx
mov    %ecx,%edx
shr    $0x1f,%edx
sar    $0x3,%ecx
add    %edx,%ecx
lea    (%rcx,%rcx,4),%ecx
lea    (%rcx,%rcx,2),%ecx
neg    %ecx
lea    (%rax,%rcx,1),%ebp
add    $0x1,%ebp
mov    %r15,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %r12,%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1090 <scanf@plt>
mov    0x0(%r13),%edi
call   1080 <fflush@plt>
mov    0xc(%rsp),%eax
cmp    %ebp,%eax
je     11b0 <main+0x30>
lea    0xded(%rip),%rdi
ja     1279 <main+0xf9>
lea    0xdcb(%rip),%rdi
jae    127e <main+0xfe>
call   1040 <puts@plt>
mov    %r15,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %r12,%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1090 <scanf@plt>
mov    0x0(%r13),%edi
call   1080 <fflush@plt>
mov    0xc(%rsp),%eax
cmp    %ebp,%eax
je     11b0 <main+0x30>
lea    0xdaa(%rip),%rdi
ja     12bc <main+0x13c>
lea    0xd88(%rip),%rdi
jae    12c1 <main+0x141>
call   1040 <puts@plt>
mov    %r15,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %r12,%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1090 <scanf@plt>
mov    0x0(%r13),%edi
call   1080 <fflush@plt>
cmp    %ebp,0xc(%rsp)
je     11b0 <main+0x30>
lea    0xd1e(%rip),%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1050 <printf@plt>
jmp    11bc <main+0x3c>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [13 x i8] c"Your guess: \00"
@.str.1 = [3 x i8] c"%d\00"
@stdin = global i32 0
@.str.2 = [32 x i8] c"Congratiolation, it's correct!\0A\00"
@.str.3 = [26 x i8] c"Bad luck! Number was: %d\0A\00"
@.str.4 = [24 x i8] c"Your guess is too big.\0A\00"
@.str.5 = [26 x i8] c"Your guess is too small.\0A\00"
@.str.6 = [21 x i8] c"Another run? (Y/N): \00"
@.str.7 = [3 x i8] c"%c\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i64
%3 = alloca i8
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store i32 0, i32* %1
br label %7
7: ; preds = %59, %0
%8 = call i32 @time(i64* %2)
%9 = load i64, i64* %2
%10 = trunc i64 %9 to i32
%11 = call i32 @srand(i32 %10)
%12 = call i32 (...) @rand()
%13 = srem i32 %12, 15
%14 = add nsw i32 %13, 1
store i32 %14, i32* %4
store i32 0, i32* %6
br label %15
15: ; preds = %51, %7
%16 = load i32, i32* %6
%17 = icmp ult i32 %16, 3
br i1 %17, label %18, label %52
18: ; preds = %15
%19 = load i32, i32* %6
%20 = add i32 %19, 1
store i32 %20, i32* %6
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0))
%22 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %5)
%23 = load i32, i32* @stdin
%24 = call i32 @fflush(i32 %23)
%25 = load i32, i32* %5
%26 = load i32, i32* %4
%27 = icmp eq i32 %25, %26
br i1 %27, label %28, label %30
28: ; preds = %18
%29 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.2, i64 0, i64 0))
br label %52
30: ; preds = %18
%31 = load i32, i32* %6
%32 = icmp eq i32 %31, 3
br i1 %32, label %33, label %36
33: ; preds = %30
%34 = load i32, i32* %4
%35 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.3, i64 0, i64 0), i32 %34)
br label %50
36: ; preds = %30
%37 = load i32, i32* %5
%38 = load i32, i32* %4
%39 = icmp ugt i32 %37, %38
br i1 %39, label %40, label %42
40: ; preds = %36
%41 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.4, i64 0, i64 0))
br label %49
42: ; preds = %36
%43 = load i32, i32* %5
%44 = load i32, i32* %4
%45 = icmp ult i32 %43, %44
br i1 %45, label %46, label %48
46: ; preds = %42
%47 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.5, i64 0, i64 0))
br label %48
48: ; preds = %46, %42
br label %49
49: ; preds = %48, %40
br label %50
50: ; preds = %49, %33
br label %51
51: ; preds = %50
br label %15
52: ; preds = %28, %15
%53 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.6, i64 0, i64 0))
%54 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0), i8* %3)
%55 = load i32, i32* @stdin
%56 = call i32 @fflush(i32 %55)
%57 = load i8, i8* %3
%58 = call signext i8 @toupper(i8 signext %57)
store i8 %58, i8* %3
br label %59
59: ; preds = %52
%60 = load i8, i8* %3
%61 = sext i8 %60 to i32
%62 = icmp eq i32 %61, 89
br i1 %62, label %7, label %63
63: ; preds = %59
%64 = load i32, i32* %1
ret i32 %64
}

LLVM IR (-O2):
@.str = [13 x i8] c"Your guess: \00"
@.str.1 = [3 x i8] c"%d\00"
@stdin = global i32 0
@.str.3 = [26 x i8] c"Bad luck! Number was: %d\0A\00"
@.str.6 = [21 x i8] c"Another run? (Y/N): \00"
@.str.7 = [3 x i8] c"%c\00"
@str = [25 x i8] c"Your guess is too small.\00"
@str.8 = [23 x i8] c"Your guess is too big.\00"
@str.9 = [31 x i8] c"Congratiolation, it's correct!\00"
define i32 @main() {
%1 = alloca i64
%2 = alloca i8
%3 = alloca i32
%4 = bitcast i64* %1 to i8*
%5 = bitcast i32* %3 to i8*
br label %6
6: ; preds = %52, %0
%7 = call i32 @time(i64* %1)
%8 = load i64, i64* %1
%9 = trunc i64 %8 to i32
%10 = call i32 @srand(i32 %9)
%11 = call i32 (...) @rand()
%12 = srem i32 %11, 15
%13 = add nsw i32 %12, 1
%14 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0))
%15 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %3)
%16 = load i32, i32* @stdin
%17 = call i32 @fflush(i32 %16)
%18 = load i32, i32* %3
%19 = icmp eq i32 %18, %13
br i1 %19, label %20, label %22
20: ; preds = %43, %29, %6
%21 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @str.9, i64 0, i64 0))
br label %52
22: ; preds = %6
%23 = icmp ugt i32 %18, %13
br i1 %23, label %26, label %24
24: ; preds = %22
%25 = icmp ult i32 %18, %13
br i1 %25, label %26, label %29
26: ; preds = %24, %22
%27 = phi i8* [ getelementptr inbounds ([23 x i8], [23 x i8]* @str.8, i64 0, i64 0), %22 ], [ getelementptr inbounds ([25 x i8], [25 x i8]* @str, i64 0, i64 0), %24 ]
%28 = call i32 @puts(i8* dereferenceable(1) %27)
br label %29
29: ; preds = %26, %24
%30 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0))
%31 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %3)
%32 = load i32, i32* @stdin
%33 = call i32 @fflush(i32 %32)
%34 = load i32, i32* %3
%35 = icmp eq i32 %34, %13
br i1 %35, label %20, label %36
36: ; preds = %29
%37 = icmp ugt i32 %34, %13
br i1 %37, label %40, label %38
38: ; preds = %36
%39 = icmp ult i32 %34, %13
br i1 %39, label %40, label %43
40: ; preds = %36, %38
%41 = phi i8* [ getelementptr inbounds ([25 x i8], [25 x i8]* @str, i64 0, i64 0), %38 ], [ getelementptr inbounds ([23 x i8], [23 x i8]* @str.8, i64 0, i64 0), %36 ]
%42 = call i32 @puts(i8* dereferenceable(1) %41)
br label %43
43: ; preds = %40, %38
%44 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0))
%45 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %3)
%46 = load i32, i32* @stdin
%47 = call i32 @fflush(i32 %46)
%48 = load i32, i32* %3
%49 = icmp eq i32 %48, %13
br i1 %49, label %20, label %50
50: ; preds = %43
%51 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.3, i64 0, i64 0), i32 %13)
br label %52
52: ; preds = %50, %20
%53 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.6, i64 0, i64 0))
%54 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0), i8* %2)
%55 = load i32, i32* @stdin
%56 = call i32 @fflush(i32 %55)
%57 = load i8, i8* %2
%58 = call signext i8 @toupper(i8 signext %57)
store i8 %58, i8* %2
%59 = icmp eq i8 %58, 89
br i1 %59, label %6, label %60
60: ; preds = %52
ret i32 0
}