#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*/ puts(char *);
int /*<<< orphan*/ scanf(char *, unsigned int *);
unsigned int get_rng_input(unsigned int rng_ceil) {
  unsigned int rng_input;
  puts("Enter an input from your RNG: ");
  scanf("%d", &rng_input);
  while (rng_input > rng_ceil) {
    puts("That's higher than your RNG is supposed to be able to generate! Try "
         "again: ");
    scanf("%d", &rng_input);
  }
  return rng_input;
}


x86 assembly (clang, -O0):
<get_rng_input>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
lea    0xece(%rip),%rdi
call   1030 <puts@plt>
lea    0xee1(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
mov    -0x8(%rbp),%eax
cmp    -0x4(%rbp),%eax
jbe    1174 <get_rng_input+0x54>
lea    0xec8(%rip),%rdi
call   1030 <puts@plt>
lea    0xeb9(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
jmp    1147 <get_rng_input+0x27>
mov    -0x8(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_rng_input>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %edi,%ebx
lea    0xecf(%rip),%rdi
call   1030 <puts@plt>
lea    0xee2(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1040 <scanf@plt>
mov    0x4(%rsp),%eax
cmp    %ebx,%eax
jbe    118b <get_rng_input+0x6b>
lea    0xecc(%rip),%r14
lea    0xec2(%rip),%r15
lea    0x4(%rsp),%r12
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %r14,%rdi
call   1030 <puts@plt>
mov    %r15,%rdi
mov    %r12,%rsi
call   1040 <scanf@plt>
mov    0x4(%rsp),%eax
cmp    %ebx,%eax
ja     1170 <get_rng_input+0x50>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [31 x i8] c"Enter an input from your RNG: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [76 x i8] c"That's higher than your RNG is supposed to be able to generate! Try again: \00"
define i32 @get_rng_input(i32 %0) {
%2 = alloca i32
%3 = alloca i32
store i32 %0, i32* %2
%4 = call i32 @puts(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0))
%5 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %3)
br label %6
6: ; preds = %10, %1
%7 = load i32, i32* %3
%8 = load i32, i32* %2
%9 = icmp ugt i32 %7, %8
br i1 %9, label %10, label %13
10: ; preds = %6
%11 = call i32 @puts(i8* getelementptr inbounds ([76 x i8], [76 x i8]* @.str.2, i64 0, i64 0))
%12 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %3)
br label %6
13: ; preds = %6
%14 = load i32, i32* %3
ret i32 %14
}

LLVM IR (-O2):
@.str = [31 x i8] c"Enter an input from your RNG: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [76 x i8] c"That's higher than your RNG is supposed to be able to generate! Try again: \00"
define i32 @get_rng_input(i32 %0) {
%2 = alloca i32
%3 = bitcast i32* %2 to i8*
%4 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0))
%5 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%6 = load i32, i32* %2
%7 = icmp ugt i32 %6, %0
br i1 %7, label %8, label %13
8: ; preds = %1, %8
%9 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([76 x i8], [76 x i8]* @.str.2, i64 0, i64 0))
%10 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%11 = load i32, i32* %2
%12 = icmp ugt i32 %11, %0
br i1 %12, label %8, label %13
13: ; preds = %8, %1
%14 = phi i32 [ %6, %1 ], [ %11, %8 ]
ret i32 %14
}