#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 */
char getchar();
scalar_t__ scanf(char *, int *);
int input(int a, int b) {
  int n;
  while (scanf("%d", &n) == 0 || n < a || n > b) {
    while (getchar() != '\n')
      ;
  }
  return n;
}


x86 assembly (clang, -O0):
<input>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
lea    0xecb(%rip),%rdi
lea    -0xc(%rbp),%rsi
call   1040 <scanf@plt>
mov    %rax,%rcx
mov    $0x1,%al
cmp    $0x0,%rcx
mov    %al,-0xd(%rbp)
je     116d <input+0x4d>
mov    -0xc(%rbp),%ecx
mov    $0x1,%al
cmp    -0x4(%rbp),%ecx
mov    %al,-0xd(%rbp)
jl     116d <input+0x4d>
mov    -0xc(%rbp),%eax
cmp    -0x8(%rbp),%eax
setg   %al
mov    %al,-0xd(%rbp)
mov    -0xd(%rbp),%al
test   $0x1,%al
jne    117d <input+0x5d>
jmp    119f <input+0x7f>
jmp    1182 <input+0x62>
mov    $0x0,%al
call   1030 <getchar@plt>
movsbl %al,%eax
cmp    $0xa,%eax
je     119a <input+0x7a>
jmp    1182 <input+0x62>
jmp    112e <input+0xe>
mov    -0xc(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<input>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %esi,%r14d
mov    %edi,%ebp
lea    0xecd(%rip),%r15
lea    0x4(%rsp),%rbx
nopl   0x0(%rax,%rax,1)
mov    %r15,%rdi
mov    %rbx,%rsi
call   1040 <scanf@plt>
test   %rax,%rax
je     1160 <input+0x40>
mov    0x4(%rsp),%eax
cmp    %ebp,%eax
jl     1160 <input+0x40>
cmp    %r14d,%eax
jle    116d <input+0x4d>
nopl   (%rax)
xor    %eax,%eax
call   1030 <getchar@plt>
cmp    $0xa,%al
jne    1160 <input+0x40>
jmp    1140 <input+0x20>
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%d\00"
define i32 @input(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i32 %0, i32* %3
store i32 %1, i32* %4
br label %6
6: ; preds = %25, %2
%7 = call i64 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %5)
%8 = icmp eq i64 %7, 0
br i1 %8, label %17, label %9
9: ; preds = %6
%10 = load i32, i32* %5
%11 = load i32, i32* %3
%12 = icmp slt i32 %10, %11
br i1 %12, label %17, label %13
13: ; preds = %9
%14 = load i32, i32* %5
%15 = load i32, i32* %4
%16 = icmp sgt i32 %14, %15
br label %17
17: ; preds = %13, %9, %6
%18 = phi i1 [ true, %9 ], [ true, %6 ], [ %16, %13 ]
br i1 %18, label %19, label %26
19: ; preds = %17
br label %20
20: ; preds = %24, %19
%21 = call signext i8 (...) @getchar()
%22 = sext i8 %21 to i32
%23 = icmp ne i32 %22, 10
br i1 %23, label %24, label %25
24: ; preds = %20
br label %20
25: ; preds = %20
br label %6
26: ; preds = %17
%27 = load i32, i32* %5
ret i32 %27
}

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
define i32 @input(i32 %0, i32 %1) {
%3 = alloca i32
%4 = bitcast i32* %3 to i8*
br label %5
5: ; preds = %14, %2
%6 = call i64 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %3)
%7 = icmp eq i64 %6, 0
br i1 %7, label %13, label %8
8: ; preds = %5
%9 = load i32, i32* %3
%10 = icmp slt i32 %9, %0
%11 = icmp sgt i32 %9, %1
%12 = or i1 %10, %11
br i1 %12, label %13, label %17
13: ; preds = %5, %8
br label %14
14: ; preds = %13, %14
%15 = call signext i8 (...) @getchar()
%16 = icmp eq i8 %15, 10
br i1 %16, label %5, label %14
17: ; preds = %8
ret i32 %9
}