#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*/ getchar();
int /*<<< orphan*/ printf(char *, unsigned int, unsigned int);
int /*<<< orphan*/ scanf(char const *, unsigned int *);
int /*<<< orphan*/ sprintf(char *, char *, char const *, char const *);
unsigned int get_value(const char *conv_specifier, unsigned int min,
                       unsigned int size) {
  unsigned int value;
  char fmt[100];
  sprintf(fmt, "Wrong value. Must be %s - %s\n", conv_specifier,
          conv_specifier);
  while (1) {
    if (!scanf(conv_specifier, &value)) {
      getchar();
      continue;
    }
    if ((value >= min) && (value < (min + size)))
      break;
    else {
      printf(fmt, min, (min + size - 1));
    }
  }
  return value;
}


x86 assembly (clang, -O0):
<get_value>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
lea    -0x80(%rbp),%rdi
mov    -0x8(%rbp),%rdx
mov    -0x8(%rbp),%rcx
lea    0xe98(%rip),%rsi
call   1060 <sprintf@plt>
mov    -0x8(%rbp),%rdi
lea    -0x14(%rbp),%rsi
call   1050 <scanf@plt>
cmp    $0x0,%eax
jne    118f <get_value+0x4f>
mov    $0x0,%al
call   1040 <getchar@plt>
jmp    116d <get_value+0x2d>
mov    -0x14(%rbp),%eax
cmp    -0xc(%rbp),%eax
jb     11b1 <get_value+0x71>
mov    -0x14(%rbp),%eax
mov    -0xc(%rbp),%ecx
add    -0x10(%rbp),%ecx
cmp    %ecx,%eax
jae    11b1 <get_value+0x71>
jmp    11cb <get_value+0x8b>
lea    -0x80(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0xc(%rbp),%edx
add    -0x10(%rbp),%edx
sub    $0x1,%edx
call   1030 <printf@plt>
jmp    116d <get_value+0x2d>
mov    -0x14(%rbp),%eax
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_value>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x78,%rsp
mov    %edx,%ebp
mov    %esi,%ebx
mov    %rdi,%r14
lea    0xea4(%rip),%rsi
lea    0x10(%rsp),%r15
mov    %r15,%rdi
mov    %r14,%rdx
mov    %r14,%rcx
call   1060 <sprintf@plt>
mov    %ebp,%r13d
add    %ebx,%r13d
add    %ebx,%ebp
add    $0xffffffff,%ebp
lea    0xc(%rsp),%r12
jmp    119c <get_value+0x5c>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %r15,%rdi
mov    %ebx,%esi
mov    %ebp,%edx
call   1030 <printf@plt>
mov    %r14,%rdi
mov    %r12,%rsi
call   1050 <scanf@plt>
test   %eax,%eax
je     11c0 <get_value+0x80>
mov    0xc(%rsp),%eax
cmp    %ebx,%eax
jb     1190 <get_value+0x50>
cmp    %r13d,%eax
jae    1190 <get_value+0x50>
jmp    11c9 <get_value+0x89>
nopw   0x0(%rax,%rax,1)
xor    %eax,%eax
call   1040 <getchar@plt>
jmp    119c <get_value+0x5c>
add    $0x78,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [30 x i8] c"Wrong value. Must be %s - %s\0A\00"
define i32 @get_value(i8* %0, i32 %1, i32 %2) {
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca [100 x i8]
store i8* %0, i8** %4
store i32 %1, i32* %5
store i32 %2, i32* %6
%9 = getelementptr inbounds [100 x i8], [100 x i8]* %8, i64 0, i64 0
%10 = load i8*, i8** %4
%11 = load i8*, i8** %4
%12 = call i32 @sprintf(i8* %9, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0), i8* %10, i8* %11)
br label %13
13: ; preds = %3, %17, %38
%14 = load i8*, i8** %4
%15 = call i32 @scanf(i8* %14, i32* %7)
%16 = icmp ne i32 %15, 0
br i1 %16, label %19, label %17
17: ; preds = %13
%18 = call i32 (...) @getchar()
br label %13
19: ; preds = %13
%20 = load i32, i32* %7
%21 = load i32, i32* %5
%22 = icmp uge i32 %20, %21
br i1 %22, label %23, label %30
23: ; preds = %19
%24 = load i32, i32* %7
%25 = load i32, i32* %5
%26 = load i32, i32* %6
%27 = add i32 %25, %26
%28 = icmp ult i32 %24, %27
br i1 %28, label %29, label %30
29: ; preds = %23
br label %39
30: ; preds = %23, %19
%31 = getelementptr inbounds [100 x i8], [100 x i8]* %8, i64 0, i64 0
%32 = load i32, i32* %5
%33 = load i32, i32* %5
%34 = load i32, i32* %6
%35 = add i32 %33, %34
%36 = sub i32 %35, 1
%37 = call i32 @printf(i8* %31, i32 %32, i32 %36)
br label %38
38: ; preds = %30
br label %13
39: ; preds = %29
%40 = load i32, i32* %7
ret i32 %40
}

LLVM IR (-O2):
@.str = [30 x i8] c"Wrong value. Must be %s - %s\0A\00"
define i32 @get_value(i8* %0, i32 %1, i32 %2) {
%4 = alloca i32
%5 = alloca [100 x i8]
%6 = bitcast i32* %4 to i8*
%7 = getelementptr inbounds [100 x i8], [100 x i8]* %5, i64 0, i64 0
%8 = call i32 @sprintf(i8* %7, i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0), i8* %0, i8* %0)
%9 = add i32 %2, %1
%10 = add i32 %9, -1
br label %11
11: ; preds = %16, %3
%12 = call i32 @scanf(i8* %0, i32* %4)
%13 = icmp eq i32 %12, 0
br i1 %13, label %14, label %17
14: ; preds = %11
%15 = call i32 (...) @getchar()
br label %16
16: ; preds = %14, %22
br label %11
17: ; preds = %11
%18 = load i32, i32* %4
%19 = icmp uge i32 %18, %1
%20 = icmp ult i32 %18, %9
%21 = and i1 %19, %20
br i1 %21, label %24, label %22
22: ; preds = %17
%23 = call i32 @printf(i8* %7, i32 %1, i32 %10)
br label %16
24: ; preds = %17
ret i32 %18
}