#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 */
scalar_t__ ERANGE;
int /*<<< orphan*/ assert(int);
scalar_t__ errno;
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *, int, int);
int /*<<< orphan*/ opt_err(char *);
int /*<<< orphan*/ opt_err_pfx();
int /*<<< orphan*/ opt_err_sfx();
char *opt_name();
int /*<<< orphan*/ stderr;
long strtol(char *, char **, int);
int opt_store_int_lim(char *arg, void *data) {
  char *end;
  long val;
  int *p = data;
  assert(arg && data);
  errno = 0;
  val = strtol(arg, &end, 10);
  if (end == arg || end[0])
    opt_err("the value of %s must be an integer");
  if (errno == ERANGE || val < p[1] || val > p[2]) {
    opt_err_pfx();
    fprintf(stderr, "the value of %s must be in the range %d to %d", opt_name(),
            p[1], p[2]);
    opt_err_sfx();
  }
  p[0] = val;
  return 0;
}


x86 assembly (clang, -O0):
<opt_store_int_lim>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x28(%rbp)
xor    %eax,%eax
cmpq   $0x0,-0x8(%rbp)
mov    %al,-0x29(%rbp)
je     11a3 <opt_store_int_lim+0x33>
cmpq   $0x0,-0x10(%rbp)
setne  %al
mov    %al,-0x29(%rbp)
mov    -0x29(%rbp),%al
and    $0x1,%al
movzbl %al,%edi
call   1060 <assert@plt>
mov    0x2e19(%rip),%rax
movq   $0x0,(%rax)
mov    -0x8(%rbp),%rdi
lea    -0x18(%rbp),%rsi
mov    $0xa,%edx
call   1080 <strtol@plt>
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rax
cmp    -0x8(%rbp),%rax
je     11f2 <opt_store_int_lim+0x82>
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     11fe <opt_store_int_lim+0x8e>
lea    0xe07(%rip),%rdi
call   1090 <opt_err@plt>
mov    0x2dcb(%rip),%rax
mov    (%rax),%rax
mov    0x2dd9(%rip),%rcx
cmp    (%rcx),%rax
je     1242 <opt_store_int_lim+0xd2>
mov    -0x20(%rbp),%rax
mov    -0x28(%rbp),%rcx
movslq 0x4(%rcx),%rcx
cmp    %rcx,%rax
jl     1242 <opt_store_int_lim+0xd2>
mov    -0x20(%rbp),%rax
mov    -0x28(%rbp),%rcx
movslq 0x8(%rcx),%rcx
cmp    %rcx,%rax
jle    1284 <opt_store_int_lim+0x114>
mov    $0x0,%al
call   1050 <opt_err_pfx@plt>
mov    0x2d88(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x30(%rbp)
mov    $0x0,%al
call   1030 <opt_name@plt>
mov    -0x30(%rbp),%edi
mov    %rax,%rdx
mov    -0x28(%rbp),%rax
mov    0x4(%rax),%ecx
mov    -0x28(%rbp),%rax
mov    0x8(%rax),%r8d
lea    0xdab(%rip),%rsi
call   1070 <fprintf@plt>
mov    $0x0,%al
call   1040 <opt_err_sfx@plt>
mov    -0x20(%rbp),%rax
mov    %eax,%ecx
mov    -0x28(%rbp),%rax
mov    %ecx,(%rax)
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<opt_store_int_lim>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r15
mov    %rdi,%rbx
test   %rdi,%rdi
setne  %al
test   %rsi,%rsi
setne  %cl
and    %al,%cl
movzbl %cl,%edi
call   1060 <assert@plt>
mov    0x2e35(%rip),%r12
movq   $0x0,(%r12)
mov    %rsp,%rsi
mov    %rbx,%rdi
mov    $0xa,%edx
call   1080 <strtol@plt>
mov    %rax,%r14
mov    (%rsp),%rax
cmp    %rbx,%rax
je     11c4 <opt_store_int_lim+0x54>
cmpb   $0x0,(%rax)
je     11d0 <opt_store_int_lim+0x60>
lea    0xe35(%rip),%rdi
call   1090 <opt_err@plt>
mov    (%r12),%rax
mov    0x2e0d(%rip),%rcx
cmp    (%rcx),%rax
je     11f2 <opt_store_int_lim+0x82>
movslq 0x4(%r15),%rax
cmp    %rax,%r14
jl     11f2 <opt_store_int_lim+0x82>
movslq 0x8(%r15),%rax
cmp    %rax,%r14
jle    1229 <opt_store_int_lim+0xb9>
xor    %eax,%eax
call   1050 <opt_err_pfx@plt>
mov    0x2dd8(%rip),%rax
mov    (%rax),%ebx
xor    %eax,%eax
call   1030 <opt_name@plt>
mov    0x4(%r15),%ecx
mov    0x8(%r15),%r8d
lea    0xe0b(%rip),%rsi
mov    %ebx,%edi
mov    %rax,%rdx
call   1070 <fprintf@plt>
xor    %eax,%eax
call   1040 <opt_err_sfx@plt>
mov    %r14d,(%r15)
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@errno = global i64 0
@.str = [35 x i8] c"the value of %s must be an integer\00"
@ERANGE = global i64 0
@stderr = global i32 0
@.str.1 = [46 x i8] c"the value of %s must be in the range %d to %d\00"
define i32 @opt_store_int_lim(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i64
%7 = alloca i32*
store i8* %0, i8** %3
store i8* %1, i8** %4
%8 = load i8*, i8** %4
%9 = bitcast i8* %8 to i32*
store i32* %9, i32** %7
%10 = load i8*, i8** %3
%11 = icmp ne i8* %10, null
br i1 %11, label %12, label %15
12: ; preds = %2
%13 = load i8*, i8** %4
%14 = icmp ne i8* %13, null
br label %15
15: ; preds = %12, %2
%16 = phi i1 [ false, %2 ], [ %14, %12 ]
%17 = zext i1 %16 to i32
%18 = call i32 @assert(i32 %17)
store i64 0, i64* @errno
%19 = load i8*, i8** %3
%20 = call i64 @strtol(i8* %19, i8** %5, i32 10)
store i64 %20, i64* %6
%21 = load i8*, i8** %5
%22 = load i8*, i8** %3
%23 = icmp eq i8* %21, %22
br i1 %23, label %30, label %24
24: ; preds = %15
%25 = load i8*, i8** %5
%26 = getelementptr inbounds i8, i8* %25, i64 0
%27 = load i8, i8* %26
%28 = sext i8 %27 to i32
%29 = icmp ne i32 %28, 0
br i1 %29, label %30, label %32
30: ; preds = %24, %15
%31 = call i32 @opt_err(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str, i64 0, i64 0))
br label %32
32: ; preds = %30, %24
%33 = load i64, i64* @errno
%34 = load i64, i64* @ERANGE
%35 = icmp eq i64 %33, %34
br i1 %35, label %50, label %36
36: ; preds = %32
%37 = load i64, i64* %6
%38 = load i32*, i32** %7
%39 = getelementptr inbounds i32, i32* %38, i64 1
%40 = load i32, i32* %39
%41 = sext i32 %40 to i64
%42 = icmp slt i64 %37, %41
br i1 %42, label %50, label %43
43: ; preds = %36
%44 = load i64, i64* %6
%45 = load i32*, i32** %7
%46 = getelementptr inbounds i32, i32* %45, i64 2
%47 = load i32, i32* %46
%48 = sext i32 %47 to i64
%49 = icmp sgt i64 %44, %48
br i1 %49, label %50, label %62
50: ; preds = %43, %36, %32
%51 = call i32 (...) @opt_err_pfx()
%52 = load i32, i32* @stderr
%53 = call i8* (...) @opt_name()
%54 = load i32*, i32** %7
%55 = getelementptr inbounds i32, i32* %54, i64 1
%56 = load i32, i32* %55
%57 = load i32*, i32** %7
%58 = getelementptr inbounds i32, i32* %57, i64 2
%59 = load i32, i32* %58
%60 = call i32 @fprintf(i32 %52, i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.1, i64 0, i64 0), i8* %53, i32 %56, i32 %59)
%61 = call i32 (...) @opt_err_sfx()
br label %62
62: ; preds = %50, %43
%63 = load i64, i64* %6
%64 = trunc i64 %63 to i32
%65 = load i32*, i32** %7
%66 = getelementptr inbounds i32, i32* %65, i64 0
store i32 %64, i32* %66
ret i32 0
}

LLVM IR (-O2):
@errno = global i64 0
@.str = [35 x i8] c"the value of %s must be an integer\00"
@ERANGE = global i64 0
@stderr = global i32 0
@.str.1 = [46 x i8] c"the value of %s must be in the range %d to %d\00"
define i32 @opt_store_int_lim(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = bitcast i8** %3 to i8*
%5 = icmp ne i8* %0, null
%6 = icmp ne i8* %1, null
%7 = and i1 %5, %6
%8 = zext i1 %7 to i32
%9 = tail call i32 @assert(i32 %8)
store i64 0, i64* @errno
%10 = call i64 @strtol(i8* %0, i8** %3, i32 10)
%11 = load i8*, i8** %3
%12 = icmp eq i8* %11, %0
br i1 %12, label %16, label %13
13: ; preds = %2
%14 = load i8, i8* %11
%15 = icmp eq i8 %14, 0
br i1 %15, label %18, label %16
16: ; preds = %13, %2
%17 = tail call i32 @opt_err(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str, i64 0, i64 0))
br label %18
18: ; preds = %16, %13
%19 = load i64, i64* @errno
%20 = load i64, i64* @ERANGE
%21 = icmp eq i64 %19, %20
br i1 %21, label %34, label %22
22: ; preds = %18
%23 = getelementptr inbounds i8, i8* %1, i64 4
%24 = bitcast i8* %23 to i32*
%25 = load i32, i32* %24
%26 = sext i32 %25 to i64
%27 = icmp slt i64 %10, %26
br i1 %27, label %34, label %28
28: ; preds = %22
%29 = getelementptr inbounds i8, i8* %1, i64 8
%30 = bitcast i8* %29 to i32*
%31 = load i32, i32* %30
%32 = sext i32 %31 to i64
%33 = icmp sgt i64 %10, %32
br i1 %33, label %34, label %46
34: ; preds = %18, %28, %22
%35 = tail call i32 (...) @opt_err_pfx()
%36 = load i32, i32* @stderr
%37 = tail call i8* (...) @opt_name()
%38 = getelementptr inbounds i8, i8* %1, i64 4
%39 = bitcast i8* %38 to i32*
%40 = load i32, i32* %39
%41 = getelementptr inbounds i8, i8* %1, i64 8
%42 = bitcast i8* %41 to i32*
%43 = load i32, i32* %42
%44 = tail call i32 @fprintf(i32 %36, i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.1, i64 0, i64 0), i8* %37, i32 %40, i32 %43)
%45 = tail call i32 (...) @opt_err_sfx()
br label %46
46: ; preds = %34, %28
%47 = bitcast i8* %1 to i32*
%48 = trunc i64 %10 to i32
store i32 %48, i32* %47
ret i32 0
}