#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 */
long get_long();
int /*<<< orphan*/ printf(char *, int);
int /*<<< orphan*/ puts(char *);
long get_choice() {
  while (1) {
    printf("Choose a number (1-%d)\n", 36);
    long choice = get_long();
    if (1 <= choice && choice <= 36) {
      return choice;
    } else {
      puts("Please enter a valid choice.");
    }
  }
}


x86 assembly (clang, -O0):
<get_choice>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
lea    0xec1(%rip),%rdi
mov    $0x24,%esi
call   1050 <printf@plt>
mov    $0x0,%al
call   1040 <get_long@plt>
mov    %rax,-0x8(%rbp)
mov    $0x1,%eax
cmp    -0x8(%rbp),%rax
jg     1178 <get_choice+0x48>
cmpq   $0x24,-0x8(%rbp)
jg     1178 <get_choice+0x48>
mov    -0x8(%rbp),%rax
add    $0x10,%rsp
pop    %rbp
ret
lea    0xe99(%rip),%rdi
call   1030 <puts@plt>
jmp    1138 <get_choice+0x8>

x86 assembly (clang, -O2):
<get_choice>:
push   %r14
push   %rbx
push   %rax
lea    0xec5(%rip),%rdi
mov    $0x24,%esi
call   1050 <printf@plt>
xor    %eax,%eax
call   1040 <get_long@plt>
mov    %rax,%rcx
add    $0xffffffffffffffff,%rcx
cmp    $0x24,%rcx
jb     1196 <get_choice+0x66>
lea    0xeb8(%rip),%r14
lea    0xe99(%rip),%rbx
nopw   0x0(%rax,%rax,1)
mov    %r14,%rdi
call   1030 <puts@plt>
mov    %rbx,%rdi
mov    $0x24,%esi
call   1050 <printf@plt>
xor    %eax,%eax
call   1040 <get_long@plt>
lea    -0x1(%rax),%rcx
cmp    $0x23,%rcx
ja     1170 <get_choice+0x40>
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [24 x i8] c"Choose a number (1-%d)\0A\00"
@.str.1 = [29 x i8] c"Please enter a valid choice.\00"
define i64 @get_choice() {
%1 = alloca i64
br label %2
2: ; preds = %0, %14
%3 = call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), i32 36)
%4 = call i64 (...) @get_long()
store i64 %4, i64* %1
%5 = load i64, i64* %1
%6 = icmp sle i64 1, %5
br i1 %6, label %7, label %12
7: ; preds = %2
%8 = load i64, i64* %1
%9 = icmp sle i64 %8, 36
br i1 %9, label %10, label %12
10: ; preds = %7
%11 = load i64, i64* %1
ret i64 %11
12: ; preds = %7, %2
%13 = call i32 @puts(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.1, i64 0, i64 0))
br label %14
14: ; preds = %12
br label %2
}

LLVM IR (-O2):
@.str = [24 x i8] c"Choose a number (1-%d)\0A\00"
@.str.1 = [29 x i8] c"Please enter a valid choice.\00"
define i64 @get_choice() {
%1 = tail call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), i32 36)
%2 = tail call i64 (...) @get_long()
%3 = add i64 %2, -1
%4 = icmp ult i64 %3, 36
br i1 %4, label %11, label %5
5: ; preds = %0, %5
%6 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @.str.1, i64 0, i64 0))
%7 = tail call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), i32 36)
%8 = tail call i64 (...) @get_long()
%9 = add i64 %8, -1
%10 = icmp ult i64 %9, 36
br i1 %10, label %11, label %5
11: ; preds = %5, %0
%12 = phi i64 [ %2, %0 ], [ %8, %5 ]
ret i64 %12
}