#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 read_number();
int /*<<< orphan*/ sprintf(char *, char *, ...);
int /*<<< orphan*/ writeln(char *);
int /*<<< orphan*/ writestr(char *);
long ask_for_number(int n1, int n2) {
  char s[50];
  int n;
  if (n1 != n2)
    sprintf(s, "Enter a number from %d to %d: ", n1, n2);
  else
    sprintf(s, "Enter a number: ");
  for (;;) {
    writestr(s);
    n = read_number();
    if (n1 == n2 || (n >= n1 && n <= n2))
      return n;
    writeln("");
  }
}


x86 assembly (clang, -O0):
<ask_for_number>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    -0x4(%rbp),%eax
cmp    -0x8(%rbp),%eax
je     1177 <ask_for_number+0x37>
lea    -0x40(%rbp),%rdi
mov    -0x4(%rbp),%edx
mov    -0x8(%rbp),%ecx
lea    0xe95(%rip),%rsi
mov    $0x0,%al
call   1060 <sprintf@plt>
jmp    1189 <ask_for_number+0x49>
lea    -0x40(%rbp),%rdi
lea    0xe9d(%rip),%rsi
mov    $0x0,%al
call   1060 <sprintf@plt>
jmp    118e <ask_for_number+0x4e>
lea    -0x40(%rbp),%rdi
call   1040 <writestr@plt>
mov    $0x0,%al
call   1050 <read_number@plt>
mov    %eax,-0x44(%rbp)
mov    -0x4(%rbp),%eax
cmp    -0x8(%rbp),%eax
je     11c5 <ask_for_number+0x85>
mov    -0x44(%rbp),%eax
cmp    -0x4(%rbp),%eax
jl     11cf <ask_for_number+0x8f>
mov    -0x44(%rbp),%eax
cmp    -0x8(%rbp),%eax
jg     11cf <ask_for_number+0x8f>
movslq -0x44(%rbp),%rax
add    $0x50,%rsp
pop    %rbp
ret
lea    0xe48(%rip),%rdi
call   1030 <writeln@plt>
jmp    118e <ask_for_number+0x4e>

x86 assembly (clang, -O2):
<ask_for_number>:
push   %rbp
push   %rbx
sub    $0x38,%rsp
mov    %esi,%ebx
mov    %edi,%ebp
cmp    %esi,%edi
jne    1160 <ask_for_number+0x20>
movups 0xeca(%rip),%xmm0
movaps %xmm0,(%rsp)
movb   $0x0,0x10(%rsp)
jmp    1175 <ask_for_number+0x35>
lea    0xe99(%rip),%rsi
mov    %rsp,%rdi
mov    %ebp,%edx
mov    %ebx,%ecx
xor    %eax,%eax
call   1060 <sprintf@plt>
mov    %rsp,%rdi
call   1040 <writestr@plt>
xor    %eax,%eax
call   1050 <read_number@plt>
cmp    %ebx,%ebp
jne    11ab <ask_for_number+0x6b>
jmp    11b3 <ask_for_number+0x73>
nopw   0x0(%rax,%rax,1)
lea    0xe87(%rip),%rdi
call   1030 <writeln@plt>
mov    %rsp,%rdi
call   1040 <writestr@plt>
xor    %eax,%eax
call   1050 <read_number@plt>
cmp    %ebp,%eax
jl     1190 <ask_for_number+0x50>
cmp    %ebx,%eax
jg     1190 <ask_for_number+0x50>
cltq
add    $0x38,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [31 x i8] c"Enter a number from %d to %d: \00"
@.str.1 = [17 x i8] c"Enter a number: \00"
@.str.2 = [1 x i8] zeroinitializer
define i64 @ask_for_number(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca [50 x i8]
%6 = alloca i32
store i32 %0, i32* %3
store i32 %1, i32* %4
%7 = load i32, i32* %3
%8 = load i32, i32* %4
%9 = icmp ne i32 %7, %8
br i1 %9, label %10, label %15
10: ; preds = %2
%11 = getelementptr inbounds [50 x i8], [50 x i8]* %5, i64 0, i64 0
%12 = load i32, i32* %3
%13 = load i32, i32* %4
%14 = call i32 (i8*, i8*, ...) @sprintf(i8* %11, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0), i32 %12, i32 %13)
br label %18
15: ; preds = %2
%16 = getelementptr inbounds [50 x i8], [50 x i8]* %5, i64 0, i64 0
%17 = call i32 (i8*, i8*, ...) @sprintf(i8* %16, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0))
br label %18
18: ; preds = %15, %10
br label %19
19: ; preds = %37, %18
%20 = getelementptr inbounds [50 x i8], [50 x i8]* %5, i64 0, i64 0
%21 = call i32 @writestr(i8* %20)
%22 = call i32 (...) @read_number()
store i32 %22, i32* %6
%23 = load i32, i32* %3
%24 = load i32, i32* %4
%25 = icmp eq i32 %23, %24
br i1 %25, label %34, label %26
26: ; preds = %19
%27 = load i32, i32* %6
%28 = load i32, i32* %3
%29 = icmp sge i32 %27, %28
br i1 %29, label %30, label %37
30: ; preds = %26
%31 = load i32, i32* %6
%32 = load i32, i32* %4
%33 = icmp sle i32 %31, %32
br i1 %33, label %34, label %37
34: ; preds = %30, %19
%35 = load i32, i32* %6
%36 = sext i32 %35 to i64
ret i64 %36
37: ; preds = %30, %26
%38 = call i32 @writeln(i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.2, i64 0, i64 0))
br label %19
}

LLVM IR (-O2):
@.str = [31 x i8] c"Enter a number from %d to %d: \00"
@.str.1 = [17 x i8] c"Enter a number: \00"
@.str.2 = [1 x i8] zeroinitializer
define i64 @ask_for_number(i32 %0, i32 %1) {
%3 = alloca [50 x i8]
%4 = getelementptr inbounds [50 x i8], [50 x i8]* %3, i64 0, i64 0
%5 = icmp eq i32 %0, %1
br i1 %5, label %8, label %6
6: ; preds = %2
%7 = call i32 (i8*, i8*, ...) @sprintf(i8* %4, i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0), i32 %0, i32 %1)
br label %9
8: ; preds = %2
br label %9
9: ; preds = %8, %6
%10 = call i32 @writestr(i8* %4)
%11 = call i32 (...) @read_number()
br i1 %5, label %16, label %12
12: ; preds = %9
%13 = icmp slt i32 %11, %0
%14 = icmp sgt i32 %11, %1
%15 = or i1 %13, %14
br i1 %15, label %19, label %16
16: ; preds = %19, %12, %9
%17 = phi i32 [ %11, %9 ], [ %11, %12 ], [ %22, %19 ]
%18 = sext i32 %17 to i64
ret i64 %18
19: ; preds = %12, %19
%20 = call i32 @writeln(i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.2, i64 0, i64 0))
%21 = call i32 @writestr(i8* %4)
%22 = call i32 (...) @read_number()
%23 = icmp slt i32 %22, %0
%24 = icmp sgt i32 %22, %1
%25 = or i1 %23, %24
br i1 %25, label %19, label %16
}