#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*/ clearInputBuffer();
int /*<<< orphan*/ printf(char *, int);
int /*<<< orphan*/ scanf(char *, int *);
int getIntegerLesserThan(int max) {
  int number = 0;
  do {
    scanf("%d", &number);
    if (number > max || number <= 0)
      printf("Please enter a number between 1 & %d\n", max);
    clearInputBuffer();
  } while (number > max || number <= 0);
  return number;
}


x86 assembly (clang, -O0):
<getIntegerLesserThan>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
lea    0xeb7(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
mov    -0x8(%rbp),%eax
cmp    -0x4(%rbp),%eax
jg     1168 <getIntegerLesserThan+0x38>
cmpl   $0x0,-0x8(%rbp)
jg     1177 <getIntegerLesserThan+0x47>
mov    -0x4(%rbp),%esi
lea    0xe91(%rip),%rdi
call   1030 <printf@plt>
mov    $0x0,%al
call   1050 <clearInputBuffer@plt>
mov    -0x8(%rbp),%ecx
mov    $0x1,%al
cmp    -0x4(%rbp),%ecx
mov    %al,-0x9(%rbp)
jg     1199 <getIntegerLesserThan+0x69>
cmpl   $0x0,-0x8(%rbp)
setle  %al
mov    %al,-0x9(%rbp)
mov    -0x9(%rbp),%al
test   $0x1,%al
jne    1142 <getIntegerLesserThan+0x12>
mov    -0x8(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getIntegerLesserThan>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %edi,%ebx
movl   $0x0,0x4(%rsp)
lea    0xeb7(%rip),%r14
lea    0x4(%rsp),%r15
lea    0xeae(%rip),%r12
cs nopw 0x0(%rax,%rax,1)
nop
mov    %r14,%rdi
mov    %r15,%rsi
call   1040 <scanf@plt>
mov    0x4(%rsp),%eax
cmp    %ebx,%eax
jg     1177 <getIntegerLesserThan+0x47>
test   %eax,%eax
jg     1181 <getIntegerLesserThan+0x51>
mov    %r12,%rdi
mov    %ebx,%esi
call   1030 <printf@plt>
xor    %eax,%eax
call   1050 <clearInputBuffer@plt>
mov    0x4(%rsp),%eax
cmp    %ebx,%eax
jg     1160 <getIntegerLesserThan+0x30>
test   %eax,%eax
jle    1160 <getIntegerLesserThan+0x30>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%d\00"
@.str.1 = [38 x i8] c"Please enter a number between 1 & %d\0A\00"
define i32 @getIntegerLesserThan(i32 %0) {
%2 = alloca i32
%3 = alloca i32
store i32 %0, i32* %2
store i32 0, i32* %3
br label %4
4: ; preds = %24, %1
%5 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %3)
%6 = load i32, i32* %3
%7 = load i32, i32* %2
%8 = icmp sgt i32 %6, %7
br i1 %8, label %12, label %9
9: ; preds = %4
%10 = load i32, i32* %3
%11 = icmp sle i32 %10, 0
br i1 %11, label %12, label %15
12: ; preds = %9, %4
%13 = load i32, i32* %2
%14 = call i32 @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.1, i64 0, i64 0), i32 %13)
br label %15
15: ; preds = %12, %9
%16 = call i32 (...) @clearInputBuffer()
br label %17
17: ; preds = %15
%18 = load i32, i32* %3
%19 = load i32, i32* %2
%20 = icmp sgt i32 %18, %19
br i1 %20, label %24, label %21
21: ; preds = %17
%22 = load i32, i32* %3
%23 = icmp sle i32 %22, 0
br label %24
24: ; preds = %21, %17
%25 = phi i1 [ true, %17 ], [ %23, %21 ]
br i1 %25, label %4, label %26
26: ; preds = %24
%27 = load i32, i32* %3
ret i32 %27
}

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
@.str.1 = [38 x i8] c"Please enter a number between 1 & %d\0A\00"
define i32 @getIntegerLesserThan(i32 %0) {
%2 = alloca i32
%3 = bitcast i32* %2 to i8*
store i32 0, i32* %2
br label %4
4: ; preds = %12, %1
%5 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %2)
%6 = load i32, i32* %2
%7 = icmp sgt i32 %6, %0
%8 = icmp slt i32 %6, 1
%9 = or i1 %7, %8
br i1 %9, label %10, label %12
10: ; preds = %4
%11 = call i32 @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.1, i64 0, i64 0), i32 %0)
br label %12
12: ; preds = %4, %10
%13 = call i32 (...) @clearInputBuffer()
%14 = load i32, i32* %2
%15 = icmp sgt i32 %14, %0
%16 = icmp slt i32 %14, 1
%17 = or i1 %15, %16
br i1 %17, label %4, label %18
18: ; preds = %12
ret i32 %14
}