#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*/ EXIT_FAILURE;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ usage(char *, char *, ...);
void check_int(long val, int min, int max, int err, char *string, char *endptr,
               char *progname) {
  if (val < min || val > max) {
    usage(progname, "\nError: The value has to be between 0x%x and 0x%x\n", min,
          max);
    exit(EXIT_FAILURE);
  }
  if (endptr == string || *endptr != '\0') {
    usage(progname, "\nError: An integer is required\n");
    exit(EXIT_FAILURE);
  }
  if ((err) && (!val)) {
    perror("strtol");
    exit(EXIT_FAILURE);
  }
}


x86 assembly (clang, -O0):
<check_int>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    0x10(%rbp),%rax
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    %ecx,-0x14(%rbp)
mov    %r8,-0x20(%rbp)
mov    %r9,-0x28(%rbp)
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
cmp    %rcx,%rax
jl     1173 <check_int+0x43>
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
cmp    %rcx,%rax
jle    1199 <check_int+0x69>
mov    0x10(%rbp),%rdi
mov    -0xc(%rbp),%edx
mov    -0x10(%rbp),%ecx
lea    0xe7c(%rip),%rsi
mov    $0x0,%al
call   1030 <usage@plt>
mov    0x2e4e(%rip),%rax
mov    (%rax),%edi
call   1050 <exit@plt>
mov    -0x28(%rbp),%rax
cmp    -0x20(%rbp),%rax
je     11b7 <check_int+0x87>
mov    -0x28(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     11d7 <check_int+0xa7>
mov    0x10(%rbp),%rdi
lea    0xe71(%rip),%rsi
mov    $0x0,%al
call   1030 <usage@plt>
mov    0x2e10(%rip),%rax
mov    (%rax),%edi
call   1050 <exit@plt>
cmpl   $0x0,-0x14(%rbp)
je     1206 <check_int+0xd6>
cmpq   $0x0,-0x8(%rbp)
jne    1206 <check_int+0xd6>
lea    0xe60(%rip),%rdi
call   1040 <perror@plt>
mov    0x2de1(%rip),%rax
mov    (%rax),%edi
call   1050 <exit@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<check_int>:
push   %rax
mov    %edx,%r10d
mov    %esi,%eax
mov    %rdi,%rdx
mov    0x10(%rsp),%rdi
movslq %esi,%rsi
cmp    %rdx,%rsi
jg     1174 <check_int+0x44>
movslq %r10d,%rsi
cmp    %rdx,%rsi
jl     1174 <check_int+0x44>
cmp    %r8,%r9
je     1164 <check_int+0x34>
cmpb   $0x0,(%r9)
jne    1164 <check_int+0x34>
test   %rdx,%rdx
jne    1162 <check_int+0x32>
test   %ecx,%ecx
jne    1189 <check_int+0x59>
pop    %rax
ret
lea    0xec8(%rip),%rsi
xor    %eax,%eax
call   1030 <usage@plt>
jmp    1195 <check_int+0x65>
lea    0xe85(%rip),%rsi
mov    %eax,%edx
mov    %r10d,%ecx
xor    %eax,%eax
call   1030 <usage@plt>
jmp    1195 <check_int+0x65>
lea    0xec3(%rip),%rdi
call   1040 <perror@plt>
mov    0x2e44(%rip),%rax
mov    (%rax),%edi
call   1050 <exit@plt>

LLVM IR (-O0):
@.str = [51 x i8] c"\0AError: The value has to be between 0x%x and 0x%x\0A\00"
@EXIT_FAILURE = global i32 0
@.str.1 = [32 x i8] c"\0AError: An integer is required\0A\00"
@.str.2 = [7 x i8] c"strtol\00"
define void @check_int(i64 %0, i32 %1, i32 %2, i32 %3, i8* %4, i8* %5, i8* %6) {
%8 = alloca i64
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i8*
%13 = alloca i8*
%14 = alloca i8*
store i64 %0, i64* %8
store i32 %1, i32* %9
store i32 %2, i32* %10
store i32 %3, i32* %11
store i8* %4, i8** %12
store i8* %5, i8** %13
store i8* %6, i8** %14
%15 = load i64, i64* %8
%16 = load i32, i32* %9
%17 = sext i32 %16 to i64
%18 = icmp slt i64 %15, %17
br i1 %18, label %24, label %19
19: ; preds = %7
%20 = load i64, i64* %8
%21 = load i32, i32* %10
%22 = sext i32 %21 to i64
%23 = icmp sgt i64 %20, %22
br i1 %23, label %24, label %31
24: ; preds = %19, %7
%25 = load i8*, i8** %14
%26 = load i32, i32* %9
%27 = load i32, i32* %10
%28 = call i32 (i8*, i8*, ...) @usage(i8* %25, i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str, i64 0, i64 0), i32 %26, i32 %27)
%29 = load i32, i32* @EXIT_FAILURE
%30 = call i32 @exit(i32 %29)
unreachable
31: ; preds = %19
%32 = load i8*, i8** %13
%33 = load i8*, i8** %12
%34 = icmp eq i8* %32, %33
br i1 %34, label %40, label %35
35: ; preds = %31
%36 = load i8*, i8** %13
%37 = load i8, i8* %36
%38 = sext i8 %37 to i32
%39 = icmp ne i32 %38, 0
br i1 %39, label %40, label %45
40: ; preds = %35, %31
%41 = load i8*, i8** %14
%42 = call i32 (i8*, i8*, ...) @usage(i8* %41, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.1, i64 0, i64 0))
%43 = load i32, i32* @EXIT_FAILURE
%44 = call i32 @exit(i32 %43)
unreachable
45: ; preds = %35
%46 = load i32, i32* %11
%47 = icmp ne i32 %46, 0
br i1 %47, label %48, label %55
48: ; preds = %45
%49 = load i64, i64* %8
%50 = icmp ne i64 %49, 0
br i1 %50, label %55, label %51
51: ; preds = %48
%52 = call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0))
%53 = load i32, i32* @EXIT_FAILURE
%54 = call i32 @exit(i32 %53)
unreachable
55: ; preds = %48, %45
ret void
}

LLVM IR (-O2):
@.str = [51 x i8] c"\0AError: The value has to be between 0x%x and 0x%x\0A\00"
@EXIT_FAILURE = global i32 0
@.str.1 = [32 x i8] c"\0AError: An integer is required\0A\00"
@.str.2 = [7 x i8] c"strtol\00"
define void @check_int(i64 %0, i32 %1, i32 %2, i32 %3, i8* readnone %4, i8* %5, i8* %6) {
%8 = sext i32 %1 to i64
%9 = icmp sgt i64 %8, %0
%10 = sext i32 %2 to i64
%11 = icmp slt i64 %10, %0
%12 = or i1 %9, %11
br i1 %12, label %13, label %17
13: ; preds = %7
%14 = tail call i32 (i8*, i8*, ...) @usage(i8* %6, i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str, i64 0, i64 0), i32 %1, i32 %2)
%15 = load i32, i32* @EXIT_FAILURE
%16 = tail call i32 @exit(i32 %15)
unreachable
17: ; preds = %7
%18 = icmp eq i8* %5, %4
br i1 %18, label %22, label %19
19: ; preds = %17
%20 = load i8, i8* %5
%21 = icmp eq i8 %20, 0
br i1 %21, label %26, label %22
22: ; preds = %19, %17
%23 = tail call i32 (i8*, i8*, ...) @usage(i8* %6, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.1, i64 0, i64 0))
%24 = load i32, i32* @EXIT_FAILURE
%25 = tail call i32 @exit(i32 %24)
unreachable
26: ; preds = %19
%27 = icmp eq i32 %3, 0
%28 = icmp ne i64 %0, 0
%29 = or i1 %28, %27
br i1 %29, label %34, label %30
30: ; preds = %26
%31 = tail call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0))
%32 = load i32, i32* @EXIT_FAILURE
%33 = tail call i32 @exit(i32 %32)
unreachable
34: ; preds = %26
ret void
}