#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*/ exit(int);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ scanf(char *, int *);
int getBet() {
  int bet;
  do {
    printf("How much do you want to bet? (Enter a number 1 to 5, or 0 to quit "
           "the game): ");
    scanf(" %d", &bet);
    if (bet >= 1 && bet <= 5) {
      return (bet);
    } else if (bet == 0) {
      exit(1);
    } else {
      printf("\n\nPlease enter a bet from 1-5 or 0 to quit the game.\n");
    }
  } while ((bet < 0) || (bet > 5));
}


x86 assembly (clang, -O0):
<getBet>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
lea    0xec1(%rip),%rdi
call   1030 <printf@plt>
lea    0xf03(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
cmpl   $0x1,-0x8(%rbp)
jl     1173 <getBet+0x43>
cmpl   $0x5,-0x8(%rbp)
jg     1173 <getBet+0x43>
mov    -0x8(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    11c1 <getBet+0x91>
cmpl   $0x0,-0x8(%rbp)
jne    1187 <getBet+0x57>
mov    $0x1,%edi
call   1050 <exit@plt>
lea    0xec4(%rip),%rdi
call   1030 <printf@plt>
jmp    1198 <getBet+0x68>
jmp    119d <getBet+0x6d>
mov    $0x1,%al
cmpl   $0x0,-0x8(%rbp)
mov    %al,-0x9(%rbp)
jl     11b6 <getBet+0x86>
cmpl   $0x5,-0x8(%rbp)
setg   %al
mov    %al,-0x9(%rbp)
mov    -0x9(%rbp),%al
test   $0x1,%al
jne    1138 <getBet+0x8>
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getBet>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x10,%rsp
lea    0xeac(%rip),%r14
lea    0xef3(%rip),%r15
lea    0xc(%rsp),%r13
lea    0xeeb(%rip),%r12
nopw   0x0(%rax,%rax,1)
mov    %r14,%rdi
call   1040 <printf@plt>
mov    %r15,%rdi
mov    %r13,%rsi
call   1050 <scanf@plt>
mov    0xc(%rsp),%ebx
lea    -0x1(%rbx),%eax
cmp    $0x5,%eax
jb     11a2 <getBet+0x62>
test   %ebx,%ebx
je     11b2 <getBet+0x72>
mov    %r12,%rdi
call   1030 <puts@plt>
cmpl   $0x5,0xc(%rsp)
ja     1170 <getBet+0x30>
mov    %ebx,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret
mov    $0x1,%edi
call   1060 <exit@plt>

LLVM IR (-O0):
@.str = [78 x i8] c"How much do you want to bet? (Enter a number 1 to 5, or 0 to quit the game): \00"
@.str.1 = [4 x i8] c" %d\00"
@.str.2 = [54 x i8] c"\0A\0APlease enter a bet from 1-5 or 0 to quit the game.\0A\00"
define i32 @getBet() {
%1 = alloca i32
%2 = alloca i32
br label %3
3: ; preds = %28, %0
%4 = call i32 @printf(i8* getelementptr inbounds ([78 x i8], [78 x i8]* @.str, i64 0, i64 0))
%5 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%6 = load i32, i32* %2
%7 = icmp sge i32 %6, 1
br i1 %7, label %8, label %13
8: ; preds = %3
%9 = load i32, i32* %2
%10 = icmp sle i32 %9, 5
br i1 %10, label %11, label %13
11: ; preds = %8
%12 = load i32, i32* %2
store i32 %12, i32* %1
br label %30
13: ; preds = %8, %3
%14 = load i32, i32* %2
%15 = icmp eq i32 %14, 0
br i1 %15, label %16, label %18
16: ; preds = %13
%17 = call i32 @exit(i32 1)
unreachable
18: ; preds = %13
%19 = call i32 @printf(i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str.2, i64 0, i64 0))
br label %20
20: ; preds = %18
br label %21
21: ; preds = %20
br label %22
22: ; preds = %21
%23 = load i32, i32* %2
%24 = icmp slt i32 %23, 0
br i1 %24, label %28, label %25
25: ; preds = %22
%26 = load i32, i32* %2
%27 = icmp sgt i32 %26, 5
br label %28
28: ; preds = %25, %22
%29 = phi i1 [ true, %22 ], [ %27, %25 ]
br i1 %29, label %3, label %30
30: ; preds = %11, %28
%31 = load i32, i32* %1
ret i32 %31
}

LLVM IR (-O2):
@.str = [78 x i8] c"How much do you want to bet? (Enter a number 1 to 5, or 0 to quit the game): \00"
@.str.1 = [4 x i8] c" %d\00"
@str = [53 x i8] c"\0A\0APlease enter a bet from 1-5 or 0 to quit the game.\00"
define i32 @getBet() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
br label %3
3: ; preds = %13, %0
%4 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([78 x i8], [78 x i8]* @.str, i64 0, i64 0))
%5 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%6 = load i32, i32* %1
%7 = add i32 %6, -1
%8 = icmp ult i32 %7, 5
br i1 %8, label %17, label %9
9: ; preds = %3
%10 = icmp eq i32 %6, 0
br i1 %10, label %11, label %13
11: ; preds = %9
%12 = call i32 @exit(i32 1)
unreachable
13: ; preds = %9
%14 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([53 x i8], [53 x i8]* @str, i64 0, i64 0))
%15 = load i32, i32* %1
%16 = icmp ugt i32 %15, 5
br i1 %16, label %3, label %17
17: ; preds = %13, %3
ret i32 %6
}