#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 abs(int);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
char getchar();
int /*<<< orphan*/ isalpha(char);
int /*<<< orphan*/ printf(char *, ...);
int rand();
int /*<<< orphan*/ scanf(char *, int *);
int /*<<< orphan*/ srand(int /*<<< orphan*/);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
char tolower(char);
int main() {
  int goal, guess, c, wins, loses;
  char yesno;
  float d;
  srand(time(NULL));
  wins = 0;
  loses = 0;
  printf(
      "Seeing Stars\n------------\n"
      "This is a number guessing game with a twist. After every guess you\n"
      "will be given a number of stars to tell you how close you are to the\n"
      "number you are trying to guess. The more stars you see, the closer\n"
      "you are.\n"
      "You only have %d guesses, so think quick.\n\n",
      10);
  do {
    goal = rand() % 100 + 1;
    guess = 0;
    printf("\nI'm thinking of a number between 1 and %d.", 100);
    for (c = 0; c < 10 && guess != goal; c++) {
      printf("\nWhat is your guess? ");
      scanf("%d", &guess);
      for (d = 100; (int)d > abs(guess - goal); d /= 2)
        printf("**");
    }
    if (guess != goal) {
      printf("\nSorry, thats %d guesses. My number was %d.\n", 10, goal);
      loses++;
    } else {
      printf("******\nBingo! You got my number.\n");
      wins++;
    }
    printf("Do you want to play again? (y/n) ");
    while (!isalpha(yesno = getchar()))
      ;
  } while (tolower(yesno) != 'n');
  printf("\nWell then, you won %d out of %d games, or %d%%.\n", wins,
         wins + loses, wins * 100 / (wins + loses));
  exit(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   1070 <time@plt>
mov    %eax,%edi
call   1050 <srand@plt>
movl   $0x0,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
lea    0xe34(%rip),%rdi
mov    $0xa,%esi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x0,%al
call   10c0 <rand@plt>
mov    $0x64,%ecx
cltd
idiv   %ecx
add    $0x1,%edx
mov    %edx,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
lea    0xf1f(%rip),%rdi
mov    $0x64,%esi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x10(%rbp)
xor    %eax,%eax
cmpl   $0xa,-0x10(%rbp)
mov    %al,-0x21(%rbp)
jge    1231 <main+0x91>
mov    -0xc(%rbp),%eax
cmp    -0x8(%rbp),%eax
setne  %al
mov    %al,-0x21(%rbp)
mov    -0x21(%rbp),%al
test   $0x1,%al
jne    1241 <main+0xa1>
jmp    12c8 <main+0x128>
lea    0xf06(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xf0e(%rip),%rdi
lea    -0xc(%rbp),%rsi
call   10a0 <scanf@plt>
movss  0xd99(%rip),%xmm0
movss  %xmm0,-0x20(%rbp)
cvttss2si -0x20(%rbp),%eax
mov    %eax,-0x28(%rbp)
mov    -0xc(%rbp),%edi
sub    -0x8(%rbp),%edi
call   1030 <abs@plt>
mov    %eax,%ecx
mov    -0x28(%rbp),%eax
cmp    %ecx,%eax
jle    12b5 <main+0x115>
lea    0xed4(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movss  -0x20(%rbp),%xmm0
movss  0xd5d(%rip),%xmm1
divss  %xmm1,%xmm0
movss  %xmm0,-0x20(%rbp)
jmp    126c <main+0xcc>
jmp    12ba <main+0x11a>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1216 <main+0x76>
mov    -0xc(%rbp),%eax
cmp    -0x8(%rbp),%eax
je     12f8 <main+0x158>
mov    -0x8(%rbp),%edx
lea    0xe8c(%rip),%rdi
mov    $0xa,%esi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    130f <main+0x16f>
lea    0xe98(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
lea    0xea3(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x0,%al
call   1060 <getchar@plt>
mov    %al,-0x19(%rbp)
movsbl %al,%edi
call   1090 <isalpha@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    1344 <main+0x1a4>
jmp    1349 <main+0x1a9>
jmp    131d <main+0x17d>
jmp    134e <main+0x1ae>
movsbl -0x19(%rbp),%edi
call   1080 <tolower@plt>
movsbl %al,%eax
cmp    $0x6e,%eax
jne    11e0 <main+0x40>
mov    -0x14(%rbp),%esi
mov    -0x14(%rbp),%eax
add    -0x18(%rbp),%eax
mov    %eax,-0x2c(%rbp)
imul   $0x64,-0x14(%rbp),%eax
mov    -0x14(%rbp),%ecx
add    -0x18(%rbp),%ecx
cltd
idiv   %ecx
mov    -0x2c(%rbp),%edx
mov    %eax,%ecx
lea    0xe53(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %edi,%edi
call   10b0 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
xor    %edi,%edi
call   1070 <time@plt>
mov    %eax,%edi
call   1050 <srand@plt>
lea    0xe45(%rip),%rdi
mov    $0xa,%esi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xf78(%rip),%rbp
lea    0xf87(%rip),%r15
lea    0x8(%rsp),%r14
lea    0xf7e(%rip),%r12
movl   $0x0,0x14(%rsp)
movl   $0x0,0x10(%rsp)
nopl   0x0(%rax)
xor    %eax,%eax
call   10c0 <rand@plt>
cltq
imul   $0x51eb851f,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
sar    $0x25,%rcx
add    %edx,%ecx
imul   $0x64,%ecx,%ecx
neg    %ecx
lea    (%rax,%rcx,1),%r13d
add    $0x1,%r13d
movl   $0x0,0x8(%rsp)
lea    0xee9(%rip),%rdi
mov    $0x64,%esi
xor    %eax,%eax
call   1040 <printf@plt>
cmp    %r13d,0x8(%rsp)
je     1320 <main+0x180>
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %rbp,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r15,%rdi
mov    %r14,%rsi
call   10a0 <scanf@plt>
mov    0x8(%rsp),%eax
mov    %eax,%ecx
sub    %r13d,%ecx
mov    %ecx,%edx
neg    %edx
cmovs  %ecx,%edx
cmp    $0x63,%edx
ja     12e6 <main+0x146>
movss  0xd6e(%rip),%xmm0
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
movss  %xmm0,0xc(%rsp)
mov    %r12,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
movss  0xd4c(%rip),%xmm0
movss  0xc(%rsp),%xmm1
mulss  %xmm0,%xmm1
movss  %xmm1,0xc(%rsp)
movss  0xc(%rsp),%xmm0
cvttss2si %xmm0,%ecx
mov    0x8(%rsp),%eax
mov    %eax,%edx
sub    %r13d,%edx
mov    %edx,%esi
neg    %esi
cmovs  %edx,%esi
cmp    %ecx,%esi
jl     12a0 <main+0x100>
cmp    $0x8,%ebx
ja     12f7 <main+0x157>
add    $0x1,%ebx
cmp    %r13d,%eax
jne    1260 <main+0xc0>
cmp    %r13d,%eax
je     1320 <main+0x180>
lea    0xe67(%rip),%rdi
mov    $0xa,%esi
mov    %r13d,%edx
xor    %eax,%eax
call   1040 <printf@plt>
addl   $0x1,0x10(%rsp)
jmp    1331 <main+0x191>
nopl   0x0(%rax)
lea    0xec4(%rip),%rdi
call   1030 <puts@plt>
addl   $0x1,0x14(%rsp)
lea    0xe5f(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
nop
xor    %eax,%eax
call   1060 <getchar@plt>
movsbl %al,%ebx
mov    %ebx,%edi
call   1090 <isalpha@plt>
test   %eax,%eax
je     1340 <main+0x1a0>
mov    %ebx,%edi
call   1080 <tolower@plt>
cmp    $0x6e,%al
jne    1200 <main+0x60>
mov    0x14(%rsp),%esi
mov    0x10(%rsp),%ecx
add    %esi,%ecx
imul   $0x64,%esi,%eax
cltd
idiv   %ecx
lea    0xe3e(%rip),%rdi
mov    %ecx,%edx
mov    %eax,%ecx
xor    %eax,%eax
call   1040 <printf@plt>
xor    %edi,%edi
call   10b0 <exit@plt>

LLVM IR (-O0):
@.str = [282 x i8] c"Seeing Stars\0A------------\0AThis is a number guessing game with a twist. After every guess you\0Awill be given a number of stars to tell you how close you are to the\0Anumber you are trying to guess. The more stars you see, the closer\0Ayou are.\0AYou only have %d guesses, so think quick.\0A\0A\00"
@.str.1 = [44 x i8] c"\0AI'm thinking of a number between 1 and %d.\00"
@.str.2 = [22 x i8] c"\0AWhat is your guess? \00"
@.str.3 = [3 x i8] c"%d\00"
@.str.4 = [3 x i8] c"**\00"
@.str.5 = [45 x i8] c"\0ASorry, thats %d guesses. My number was %d.\0A\00"
@.str.6 = [34 x i8] c"******\0ABingo! You got my number.\0A\00"
@.str.7 = [34 x i8] c"Do you want to play again? (y/n) \00"
@.str.8 = [50 x i8] c"\0AWell then, you won %d out of %d games, or %d%%.\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i8
%8 = alloca float
store i32 0, i32* %1
%9 = call i32 @time(i32* null)
%10 = call i32 @srand(i32 %9)
store i32 0, i32* %5
store i32 0, i32* %6
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([282 x i8], [282 x i8]* @.str, i64 0, i64 0), i32 10)
br label %12
12: ; preds = %68, %0
%13 = call i32 (...) @rand()
%14 = srem i32 %13, 100
%15 = add nsw i32 %14, 1
store i32 %15, i32* %2
store i32 0, i32* %3
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.1, i64 0, i64 0), i32 100)
store i32 0, i32* %4
br label %17
17: ; preds = %43, %12
%18 = load i32, i32* %4
%19 = icmp slt i32 %18, 10
br i1 %19, label %20, label %24
20: ; preds = %17
%21 = load i32, i32* %3
%22 = load i32, i32* %2
%23 = icmp ne i32 %21, %22
br label %24
24: ; preds = %20, %17
%25 = phi i1 [ false, %17 ], [ %23, %20 ]
br i1 %25, label %26, label %46
26: ; preds = %24
%27 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0))
%28 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32* %3)
store float 1.000000e+02, float* %8
br label %29
29: ; preds = %39, %26
%30 = load float, float* %8
%31 = fptosi float %30 to i32
%32 = load i32, i32* %3
%33 = load i32, i32* %2
%34 = sub nsw i32 %32, %33
%35 = call i32 @abs(i32 %34)
%36 = icmp sgt i32 %31, %35
br i1 %36, label %37, label %42
37: ; preds = %29
%38 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
br label %39
39: ; preds = %37
%40 = load float, float* %8
%41 = fdiv float %40, 2.000000e+00
store float %41, float* %8
br label %29
42: ; preds = %29
br label %43
43: ; preds = %42
%44 = load i32, i32* %4
%45 = add nsw i32 %44, 1
store i32 %45, i32* %4
br label %17
46: ; preds = %24
%47 = load i32, i32* %3
%48 = load i32, i32* %2
%49 = icmp ne i32 %47, %48
br i1 %49, label %50, label %55
50: ; preds = %46
%51 = load i32, i32* %2
%52 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.5, i64 0, i64 0), i32 10, i32 %51)
%53 = load i32, i32* %6
%54 = add nsw i32 %53, 1
store i32 %54, i32* %6
br label %59
55: ; preds = %46
%56 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.6, i64 0, i64 0))
%57 = load i32, i32* %5
%58 = add nsw i32 %57, 1
store i32 %58, i32* %5
br label %59
59: ; preds = %55, %50
%60 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.7, i64 0, i64 0))
br label %61
61: ; preds = %66, %59
%62 = call signext i8 (...) @getchar()
store i8 %62, i8* %7
%63 = call i32 @isalpha(i8 signext %62)
%64 = icmp ne i32 %63, 0
%65 = xor i1 %64, true
br i1 %65, label %66, label %67
66: ; preds = %61
br label %61
67: ; preds = %61
br label %68
68: ; preds = %67
%69 = load i8, i8* %7
%70 = call signext i8 @tolower(i8 signext %69)
%71 = sext i8 %70 to i32
%72 = icmp ne i32 %71, 110
br i1 %72, label %12, label %73
73: ; preds = %68
%74 = load i32, i32* %5
%75 = load i32, i32* %5
%76 = load i32, i32* %6
%77 = add nsw i32 %75, %76
%78 = load i32, i32* %5
%79 = mul nsw i32 %78, 100
%80 = load i32, i32* %5
%81 = load i32, i32* %6
%82 = add nsw i32 %80, %81
%83 = sdiv i32 %79, %82
%84 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str.8, i64 0, i64 0), i32 %74, i32 %77, i32 %83)
%85 = call i32 @exit(i32 0)
unreachable
}

LLVM IR (-O2):
@.str = [282 x i8] c"Seeing Stars\0A------------\0AThis is a number guessing game with a twist. After every guess you\0Awill be given a number of stars to tell you how close you are to the\0Anumber you are trying to guess. The more stars you see, the closer\0Ayou are.\0AYou only have %d guesses, so think quick.\0A\0A\00"
@.str.1 = [44 x i8] c"\0AI'm thinking of a number between 1 and %d.\00"
@.str.2 = [22 x i8] c"\0AWhat is your guess? \00"
@.str.3 = [3 x i8] c"%d\00"
@.str.4 = [3 x i8] c"**\00"
@.str.5 = [45 x i8] c"\0ASorry, thats %d guesses. My number was %d.\0A\00"
@.str.7 = [34 x i8] c"Do you want to play again? (y/n) \00"
@.str.8 = [50 x i8] c"\0AWell then, you won %d out of %d games, or %d%%.\0A\00"
@str = [33 x i8] c"******\0ABingo! You got my number.\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 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([282 x i8], [282 x i8]* @.str, i64 0, i64 0), i32 10)
br label %6
6: ; preds = %53, %0
%7 = phi i32 [ 0, %0 ], [ %46, %53 ]
%8 = phi i32 [ 0, %0 ], [ %47, %53 ]
%9 = call i32 (...) @rand()
%10 = srem i32 %9, 100
%11 = add nsw i32 %10, 1
store i32 0, i32* %1
%12 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([44 x i8], [44 x i8]* @.str.1, i64 0, i64 0), i32 100)
%13 = load i32, i32* %1
%14 = icmp eq i32 %13, %11
br i1 %14, label %42, label %15
15: ; preds = %6, %32
%16 = phi i32 [ %34, %32 ], [ 0, %6 ]
%17 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0))
%18 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32* %1)
%19 = load i32, i32* %1
%20 = sub nsw i32 %19, %11
%21 = call i32 @llvm.abs.i32(i32 %20, i1 true)
%22 = icmp ult i32 %21, 100
br i1 %22, label %23, label %32
23: ; preds = %15, %23
%24 = phi float [ %26, %23 ], [ 1.000000e+02, %15 ]
%25 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
%26 = fmul float %24, 5.000000e-01
%27 = fptosi float %26 to i32
%28 = load i32, i32* %1
%29 = sub nsw i32 %28, %11
%30 = call i32 @llvm.abs.i32(i32 %29, i1 true)
%31 = icmp slt i32 %30, %27
br i1 %31, label %23, label %32
32: ; preds = %23, %15
%33 = phi i32 [ %19, %15 ], [ %28, %23 ]
%34 = add nuw nsw i32 %16, 1
%35 = icmp ult i32 %16, 9
%36 = icmp ne i32 %33, %11
%37 = select i1 %35, i1 %36, i1 false
br i1 %37, label %15, label %38
38: ; preds = %32
br i1 %36, label %39, label %42
39: ; preds = %38
%40 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([45 x i8], [45 x i8]* @.str.5, i64 0, i64 0), i32 10, i32 %11)
%41 = add nsw i32 %8, 1
br label %45
42: ; preds = %6, %38
%43 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @str, i64 0, i64 0))
%44 = add nsw i32 %7, 1
br label %45
45: ; preds = %42, %39
%46 = phi i32 [ %7, %39 ], [ %44, %42 ]
%47 = phi i32 [ %41, %39 ], [ %8, %42 ]
%48 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @.str.7, i64 0, i64 0))
br label %49
49: ; preds = %49, %45
%50 = call signext i8 (...) @getchar()
%51 = call i32 @isalpha(i8 signext %50)
%52 = icmp eq i32 %51, 0
br i1 %52, label %49, label %53
53: ; preds = %49
%54 = call signext i8 @tolower(i8 signext %50)
%55 = icmp eq i8 %54, 110
br i1 %55, label %56, label %6
56: ; preds = %53
%57 = add nsw i32 %47, %46
%58 = mul nsw i32 %46, 100
%59 = sdiv i32 %58, %57
%60 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([50 x i8], [50 x i8]* @.str.8, i64 0, i64 0), i32 %46, i32 %57, i32 %59)
%61 = call i32 @exit(i32 0)
unreachable
}