#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 EOF;
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ gets(char *);
int sscanf(char *, char *, int *);
int /*<<< orphan*/ stdout;
int getint(char *instr, int minx, int maxx, int def) {
  int ret, status;
  char line[1024];
  while (1) {
    fprintf(stdout, "%s (%d..%d)    [%d]: ", instr, (int)minx, (int)maxx,
            (int)def);
    gets(line);
    status = sscanf(line, "%d", &ret);
    if (status == EOF)
      return def;
    if (ret > maxx) {
      fprintf(stdout, "ERROR: Max. value=%d\n\n", (int)maxx);
      continue;
    }
    if (ret < minx) {
      fprintf(stdout, "ERROR: Min. value=%d\n\n", (int)minx);
      continue;
    }
    break;
  }
  return ret;
}


x86 assembly (clang, -O0):
<getint>:
push   %rbp
mov    %rsp,%rbp
sub    $0x430,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    %edx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
mov    0x2e89(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rdx
mov    -0x14(%rbp),%ecx
mov    -0x18(%rbp),%r8d
mov    -0x1c(%rbp),%r9d
lea    0xe99(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
lea    -0x430(%rbp),%rdi
call   1040 <gets@plt>
lea    -0x430(%rbp),%rdi
lea    0xe8e(%rip),%rsi
lea    -0x20(%rbp),%rdx
call   1050 <sscanf@plt>
mov    %eax,-0x24(%rbp)
mov    -0x24(%rbp),%eax
mov    0x2e4a(%rip),%rcx
cmp    (%rcx),%eax
jne    11b1 <getint+0x81>
mov    -0x1c(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    1212 <getint+0xe2>
mov    -0x20(%rbp),%eax
cmp    -0x18(%rbp),%eax
jle    11dc <getint+0xac>
mov    0x2e14(%rip),%rax
mov    (%rax),%edi
mov    -0x18(%rbp),%edx
lea    0xe49(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
jmp    1148 <getint+0x18>
mov    -0x20(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    1207 <getint+0xd7>
mov    0x2de9(%rip),%rax
mov    (%rax),%edi
mov    -0x14(%rbp),%edx
lea    0xe35(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
jmp    1148 <getint+0x18>
jmp    120c <getint+0xdc>
mov    -0x20(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x430,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getint>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x418,%rsp
mov    %ecx,%r14d
mov    %edx,%ebp
mov    %esi,%ebx
mov    %rdi,%r15
mov    0x2e86(%rip),%r13
mov    0x0(%r13),%edi
lea    0xea3(%rip),%rsi
mov    %r15,%rdx
mov    %ebx,%ecx
mov    %ebp,%r8d
mov    %r14d,%r9d
xor    %eax,%eax
call   1030 <fprintf@plt>
lea    0x10(%rsp),%r12
mov    %r12,%rdi
call   1040 <gets@plt>
lea    0xe93(%rip),%rsi
lea    0xc(%rsp),%rdx
mov    %r12,%rdi
call   1050 <sscanf@plt>
mov    0x2e51(%rip),%rcx
cmp    (%rcx),%eax
jne    11b0 <getint+0x80>
mov    %r14d,%eax
add    $0x418,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0x10(%rsp),%r12
jmp    1218 <getint+0xe8>
nopw   0x0(%rax,%rax,1)
mov    0x0(%r13),%edi
lea    0xe4e(%rip),%rsi
mov    %ebp,%edx
xor    %eax,%eax
call   1030 <fprintf@plt>
mov    0x0(%r13),%edi
lea    0xe21(%rip),%rsi
mov    %r15,%rdx
mov    %ebx,%ecx
mov    %ebp,%r8d
mov    %r14d,%r9d
xor    %eax,%eax
call   1030 <fprintf@plt>
mov    %r12,%rdi
call   1040 <gets@plt>
mov    %r12,%rdi
lea    0xe13(%rip),%rsi
lea    0xc(%rsp),%rdx
call   1050 <sscanf@plt>
mov    0x2dd4(%rip),%rcx
cmp    (%rcx),%eax
je     119b <getint+0x6b>
mov    0xc(%rsp),%eax
cmp    %ebp,%eax
jg     11c0 <getint+0x90>
cmp    %ebx,%eax
jge    119e <getint+0x6e>
mov    0x0(%r13),%edi
lea    0xdfd(%rip),%rsi
mov    %ebx,%edx
jmp    11cd <getint+0x9d>

LLVM IR (-O0):
@stdout = global i32 0
@.str = [22 x i8] c"%s (%d..%d) [%d]: \00"
@.str.1 = [3 x i8] c"%d\00"
@EOF = global i32 0
@.str.2 = [23 x i8] c"ERROR: Max. value=%d\0A\0A\00"
@.str.3 = [23 x i8] c"ERROR: Min. value=%d\0A\0A\00"
define i32 @getint(i8* %0, i32 %1, i32 %2, i32 %3) {
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca [1024 x i8]
store i8* %0, i8** %6
store i32 %1, i32* %7
store i32 %2, i32* %8
store i32 %3, i32* %9
br label %13
13: ; preds = %4, %33, %41
%14 = load i32, i32* @stdout
%15 = load i8*, i8** %6
%16 = load i32, i32* %7
%17 = load i32, i32* %8
%18 = load i32, i32* %9
%19 = call i32 (i32, i8*, ...) @fprintf(i32 %14, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i8* %15, i32 %16, i32 %17, i32 %18)
%20 = getelementptr inbounds [1024 x i8], [1024 x i8]* %12, i64 0, i64 0
%21 = call i32 @gets(i8* %20)
%22 = getelementptr inbounds [1024 x i8], [1024 x i8]* %12, i64 0, i64 0
%23 = call i32 @sscanf(i8* %22, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %10)
store i32 %23, i32* %11
%24 = load i32, i32* %11
%25 = load i32, i32* @EOF
%26 = icmp eq i32 %24, %25
br i1 %26, label %27, label %29
27: ; preds = %13
%28 = load i32, i32* %9
store i32 %28, i32* %5
br label %48
29: ; preds = %13
%30 = load i32, i32* %10
%31 = load i32, i32* %8
%32 = icmp sgt i32 %30, %31
br i1 %32, label %33, label %37
33: ; preds = %29
%34 = load i32, i32* @stdout
%35 = load i32, i32* %8
%36 = call i32 (i32, i8*, ...) @fprintf(i32 %34, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0), i32 %35)
br label %13
37: ; preds = %29
%38 = load i32, i32* %10
%39 = load i32, i32* %7
%40 = icmp slt i32 %38, %39
br i1 %40, label %41, label %45
41: ; preds = %37
%42 = load i32, i32* @stdout
%43 = load i32, i32* %7
%44 = call i32 (i32, i8*, ...) @fprintf(i32 %42, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.3, i64 0, i64 0), i32 %43)
br label %13
45: ; preds = %37
br label %46
46: ; preds = %45
%47 = load i32, i32* %10
store i32 %47, i32* %5
br label %48
48: ; preds = %46, %27
%49 = load i32, i32* %5
ret i32 %49
}

LLVM IR (-O2):
@stdout = global i32 0
@.str = [22 x i8] c"%s (%d..%d) [%d]: \00"
@.str.1 = [3 x i8] c"%d\00"
@EOF = global i32 0
@.str.2 = [23 x i8] c"ERROR: Max. value=%d\0A\0A\00"
@.str.3 = [23 x i8] c"ERROR: Min. value=%d\0A\0A\00"
define i32 @getint(i8* %0, i32 %1, i32 %2, i32 %3) {
%5 = alloca i32
%6 = alloca [1024 x i8]
%7 = bitcast i32* %5 to i8*
%8 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%9 = load i32, i32* @stdout
%10 = call i32 (i32, i8*, ...) @fprintf(i32 %9, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i8* %0, i32 %1, i32 %2, i32 %3)
%11 = call i32 @gets(i8* %8)
%12 = call i32 @sscanf(i8* %8, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %5)
%13 = load i32, i32* @EOF
%14 = icmp eq i32 %12, %13
br i1 %14, label %33, label %15
15: ; preds = %4, %21
%16 = load i32, i32* %5
%17 = icmp sgt i32 %16, %2
br i1 %17, label %18, label %28
18: ; preds = %15
%19 = load i32, i32* @stdout
%20 = call i32 (i32, i8*, ...) @fprintf(i32 %19, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0), i32 %2)
br label %21
21: ; preds = %18, %30
%22 = load i32, i32* @stdout
%23 = call i32 (i32, i8*, ...) @fprintf(i32 %22, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i8* %0, i32 %1, i32 %2, i32 %3)
%24 = call i32 @gets(i8* %8)
%25 = call i32 @sscanf(i8* %8, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %5)
%26 = load i32, i32* @EOF
%27 = icmp eq i32 %25, %26
br i1 %27, label %33, label %15
28: ; preds = %15
%29 = icmp slt i32 %16, %1
br i1 %29, label %30, label %33
30: ; preds = %28
%31 = load i32, i32* @stdout
%32 = call i32 (i32, i8*, ...) @fprintf(i32 %31, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.3, i64 0, i64 0), i32 %1)
br label %21
33: ; preds = %21, %28, %4
%34 = phi i32 [ %3, %4 ], [ %16, %28 ], [ %3, %21 ]
ret i32 %34
}