#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*/ fscanf(int /*<<< orphan*/, char *, int *);
char getchar();
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ stdin;
int getGuesses(void) {
  int guesses = -1;
  printf("How many guesses? : ");
  fscanf(stdin, "%d", &guesses);
  while (guesses <= 0) {
    while (getchar() != '\n')
      ;
    printf("Please enter a valid number of guesses: ");
    fscanf(stdin, "%d", &guesses);
  }
  while (getchar() != '\n')
    ;
  return guesses;
}


x86 assembly (clang, -O0):
<getGuesses>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0xffffffff,-0x4(%rbp)
lea    0xeba(%rip),%rdi
call   1030 <printf@plt>
mov    0x2e96(%rip),%rax
mov    (%rax),%edi
lea    0xeba(%rip),%rsi
lea    -0x4(%rbp),%rdx
call   1040 <fscanf@plt>
cmpl   $0x0,-0x4(%rbp)
jg     11b5 <getGuesses+0x85>
jmp    1173 <getGuesses+0x43>
mov    $0x0,%al
call   1050 <getchar@plt>
movsbl %al,%eax
cmp    $0xa,%eax
je     118b <getGuesses+0x5b>
jmp    1173 <getGuesses+0x43>
lea    0xe86(%rip),%rdi
call   1030 <printf@plt>
mov    0x2e4a(%rip),%rax
mov    (%rax),%edi
lea    0xe6e(%rip),%rsi
lea    -0x4(%rbp),%rdx
call   1040 <fscanf@plt>
jmp    1164 <getGuesses+0x34>
jmp    11ba <getGuesses+0x8a>
mov    $0x0,%al
call   1050 <getchar@plt>
movsbl %al,%eax
cmp    $0xa,%eax
je     11d2 <getGuesses+0xa2>
jmp    11ba <getGuesses+0x8a>
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getGuesses>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
movl   $0xffffffff,0x4(%rsp)
ff
lea    0xeb9(%rip),%rdi
call   1030 <printf@plt>
mov    0x2e95(%rip),%r12
mov    (%r12),%edi
lea    0xeb7(%rip),%rsi
lea    0x4(%rsp),%rdx
call   1040 <fscanf@plt>
cmpl   $0x0,0x4(%rsp)
jg     11c0 <getGuesses+0x90>
lea    0xea2(%rip),%r14
lea    0xe98(%rip),%r15
lea    0x4(%rsp),%rbx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
xor    %eax,%eax
call   1050 <getchar@plt>
cmp    $0xa,%al
jne    1190 <getGuesses+0x60>
mov    %r14,%rdi
call   1030 <printf@plt>
mov    (%r12),%edi
mov    %r15,%rsi
mov    %rbx,%rdx
call   1040 <fscanf@plt>
cmpl   $0x0,0x4(%rsp)
jle    1190 <getGuesses+0x60>
nopl   0x0(%rax)
xor    %eax,%eax
call   1050 <getchar@plt>
cmp    $0xa,%al
jne    11c0 <getGuesses+0x90>
mov    0x4(%rsp),%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [21 x i8] c"How many guesses? : \00"
@stdin = global i32 0
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [41 x i8] c"Please enter a valid number of guesses: \00"
define i32 @getGuesses() {
%1 = alloca i32
store i32 -1, i32* %1
%2 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0))
%3 = load i32, i32* @stdin
%4 = call i32 @fscanf(i32 %3, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
br label %5
5: ; preds = %14, %0
%6 = load i32, i32* %1
%7 = icmp sle i32 %6, 0
br i1 %7, label %8, label %18
8: ; preds = %5
br label %9
9: ; preds = %13, %8
%10 = call signext i8 (...) @getchar()
%11 = sext i8 %10 to i32
%12 = icmp ne i32 %11, 10
br i1 %12, label %13, label %14
13: ; preds = %9
br label %9
14: ; preds = %9
%15 = call i32 @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.2, i64 0, i64 0))
%16 = load i32, i32* @stdin
%17 = call i32 @fscanf(i32 %16, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
br label %5
18: ; preds = %5
br label %19
19: ; preds = %23, %18
%20 = call signext i8 (...) @getchar()
%21 = sext i8 %20 to i32
%22 = icmp ne i32 %21, 10
br i1 %22, label %23, label %24
23: ; preds = %19
br label %19
24: ; preds = %19
%25 = load i32, i32* %1
ret i32 %25
}

LLVM IR (-O2):
@.str = [21 x i8] c"How many guesses? : \00"
@stdin = global i32 0
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [41 x i8] c"Please enter a valid number of guesses: \00"
define i32 @getGuesses() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
store i32 -1, i32* %1
%3 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0))
%4 = load i32, i32* @stdin
%5 = call i32 @fscanf(i32 %4, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%6 = load i32, i32* %1
%7 = icmp slt i32 %6, 1
br i1 %7, label %8, label %18
8: ; preds = %0, %11
%9 = call signext i8 (...) @getchar()
%10 = icmp eq i8 %9, 10
br i1 %10, label %12, label %11
11: ; preds = %8, %12
br label %8
12: ; preds = %8
%13 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([41 x i8], [41 x i8]* @.str.2, i64 0, i64 0))
%14 = load i32, i32* @stdin
%15 = call i32 @fscanf(i32 %14, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%16 = load i32, i32* %1
%17 = icmp slt i32 %16, 1
br i1 %17, label %11, label %18
18: ; preds = %12, %0
br label %19
19: ; preds = %18, %19
%20 = call signext i8 (...) @getchar()
%21 = icmp eq i8 %20, 10
br i1 %21, label %22, label %19
22: ; preds = %19
%23 = load i32, i32* %1
ret i32 %23
}