#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*/ *fgets(char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, ...);
int sscanf(char *, char *, int *);
int /*<<< orphan*/ stdin;
int get_int(const char prompt[], int min, int max) {
  char in[512];
  int integer;
  int loop = 1;
  printf("%s ", prompt);
  while (fgets(in, 512, stdin) != NULL || loop == 1) {
    if (sscanf(in, "%d", &integer) == 1) {
      if ((integer >= min) && (integer <= max)) {
        printf("%d", integer);
        printf(" is the int you entered.\n");
        loop = 0;
        return integer;
      }
      printf("not within bounds... try again: ");
    } else {
      return -1;
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<get_int>:
push   %rbp
mov    %rsp,%rbp
sub    $0x230,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    %edx,-0x18(%rbp)
movl   $0x1,-0x228(%rbp)
mov    -0x10(%rbp),%rsi
lea    0xea6(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x220(%rbp),%rdi
mov    0x2e79(%rip),%rax
mov    (%rax),%edx
mov    $0x200,%esi
call   1040 <fgets@plt>
mov    %rax,%rcx
mov    $0x1,%al
cmp    $0x0,%rcx
mov    %al,-0x229(%rbp)
jne    11a0 <get_int+0x70>
cmpl   $0x1,-0x228(%rbp)
sete   %al
mov    %al,-0x229(%rbp)
mov    -0x229(%rbp),%al
test   $0x1,%al
jne    11b3 <get_int+0x83>
jmp    1252 <get_int+0x122>
lea    -0x220(%rbp),%rdi
lea    0xe43(%rip),%rsi
lea    -0x224(%rbp),%rdx
call   1050 <sscanf@plt>
cmp    $0x1,%eax
jne    1241 <get_int+0x111>
mov    -0x224(%rbp),%eax
cmp    -0x14(%rbp),%eax
jl     122e <get_int+0xfe>
mov    -0x224(%rbp),%eax
cmp    -0x18(%rbp),%eax
jg     122e <get_int+0xfe>
mov    -0x224(%rbp),%esi
lea    0xe03(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xdf8(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x228(%rbp)
mov    -0x224(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    1259 <get_int+0x129>
lea    0xdec(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    124d <get_int+0x11d>
movl   $0xffffffff,-0x4(%rbp)
jmp    1259 <get_int+0x129>
jmp    1161 <get_int+0x31>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x230,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_int>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x218,%rsp
mov    %edx,0xc(%rsp)
mov    %esi,%ebp
mov    %rdi,%rsi
lea    0xe9f(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x2e79(%rip),%r15
mov    (%r15),%edx
lea    0x10(%rsp),%rbx
mov    %rbx,%rdi
mov    $0x200,%esi
call   1050 <fgets@plt>
lea    0xe79(%rip),%rsi
lea    0x8(%rsp),%rdx
mov    %rbx,%rdi
call   1060 <sscanf@plt>
mov    $0xffffffff,%ecx
cmp    $0x1,%eax
jne    1220 <get_int+0xe0>
lea    0xe5e(%rip),%r12
lea    0x10(%rsp),%rbx
lea    0xe4f(%rip),%r13
lea    0x8(%rsp),%r14
jmp    11ed <get_int+0xad>
nopl   0x0(%rax)
mov    %r12,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    (%r15),%edx
mov    %rbx,%rdi
mov    $0x200,%esi
call   1050 <fgets@plt>
mov    %rbx,%rdi
mov    %r13,%rsi
mov    %r14,%rdx
call   1060 <sscanf@plt>
cmp    $0x1,%eax
jne    121b <get_int+0xdb>
mov    0x8(%rsp),%esi
cmp    %ebp,%esi
jl     11c0 <get_int+0x80>
cmp    0xc(%rsp),%esi
jg     11c0 <get_int+0x80>
lea    0xe02(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe18(%rip),%rdi
call   1030 <puts@plt>
mov    0x8(%rsp),%ecx
jmp    1220 <get_int+0xe0>
mov    $0xffffffff,%ecx
mov    %ecx,%eax
add    $0x218,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [4 x i8] c"%s \00"
@stdin = global i32 0
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [26 x i8] c" is the int you entered.\0A\00"
@.str.3 = [33 x i8] c"not within bounds... try again: \00"
define i32 @get_int(i8* %0, i32 %1, i32 %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i32
%8 = alloca [512 x i8]
%9 = alloca i32
%10 = alloca i32
store i8* %0, i8** %5
store i32 %1, i32* %6
store i32 %2, i32* %7
store i32 1, i32* %10
%11 = load i8*, i8** %5
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %11)
br label %13
13: ; preds = %43, %3
%14 = getelementptr inbounds [512 x i8], [512 x i8]* %8, i64 0, i64 0
%15 = load i32, i32* @stdin
%16 = call i32* @fgets(i8* %14, i32 512, i32 %15)
%17 = icmp ne i32* %16, null
br i1 %17, label %21, label %18
18: ; preds = %13
%19 = load i32, i32* %10
%20 = icmp eq i32 %19, 1
br label %21
21: ; preds = %18, %13
%22 = phi i1 [ true, %13 ], [ %20, %18 ]
br i1 %22, label %23, label %44
23: ; preds = %21
%24 = getelementptr inbounds [512 x i8], [512 x i8]* %8, i64 0, i64 0
%25 = call i32 @sscanf(i8* %24, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %9)
%26 = icmp eq i32 %25, 1
br i1 %26, label %27, label %42
27: ; preds = %23
%28 = load i32, i32* %9
%29 = load i32, i32* %6
%30 = icmp sge i32 %28, %29
br i1 %30, label %31, label %40
31: ; preds = %27
%32 = load i32, i32* %9
%33 = load i32, i32* %7
%34 = icmp sle i32 %32, %33
br i1 %34, label %35, label %40
35: ; preds = %31
%36 = load i32, i32* %9
%37 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 %36)
%38 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0))
store i32 0, i32* %10
%39 = load i32, i32* %9
store i32 %39, i32* %4
br label %45
40: ; preds = %31, %27
%41 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.3, i64 0, i64 0))
br label %43
42: ; preds = %23
store i32 -1, i32* %4
br label %45
43: ; preds = %40
br label %13
44: ; preds = %21
store i32 0, i32* %4
br label %45
45: ; preds = %44, %42, %35
%46 = load i32, i32* %4
ret i32 %46
}

LLVM IR (-O2):
@.str = [4 x i8] c"%s \00"
@stdin = global i32 0
@.str.1 = [3 x i8] c"%d\00"
@.str.3 = [33 x i8] c"not within bounds... try again: \00"
@str = [25 x i8] c" is the int you entered.\00"
define i32 @get_int(i8* %0, i32 %1, i32 %2) {
%4 = alloca [512 x i8]
%5 = alloca i32
%6 = getelementptr inbounds [512 x i8], [512 x i8]* %4, i64 0, i64 0
%7 = bitcast i32* %5 to i8*
%8 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %0)
%9 = load i32, i32* @stdin
%10 = call i32* @fgets(i8* %6, i32 512, i32 %9)
%11 = call i32 @sscanf(i8* %6, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %5)
%12 = icmp eq i32 %11, 1
br i1 %12, label %13, label %28
13: ; preds = %3, %22
%14 = load i32, i32* %5
%15 = icmp slt i32 %14, %1
%16 = icmp sgt i32 %14, %2
%17 = or i1 %15, %16
br i1 %17, label %22, label %18
18: ; preds = %13
%19 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 %14)
%20 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @str, i64 0, i64 0))
%21 = load i32, i32* %5
br label %28
22: ; preds = %13
%23 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @.str.3, i64 0, i64 0))
%24 = load i32, i32* @stdin
%25 = call i32* @fgets(i8* %6, i32 512, i32 %24)
%26 = call i32 @sscanf(i8* %6, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %5)
%27 = icmp eq i32 %26, 1
br i1 %27, label %13, label %28
28: ; preds = %22, %3, %18
%29 = phi i32 [ %21, %18 ], [ -1, %3 ], [ -1, %22 ]
ret i32 %29
}