#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 ERANGE;
long long INT_MAX;
long long INT_MIN;
int conf_parse_int_internal(char const *, char const *, long long *);
int conf_parse_int(const char *lvalue, const char *rvalue, void *data) {
  long long int result;
  int err;
  err = conf_parse_int_internal(lvalue, rvalue, &result);
  if (!err) {
    if (result > INT_MAX || result < INT_MIN) {
      err = -ERANGE;
    } else {
      *((int *)data) = result;
    }
  }
  return err;
}


x86 assembly (clang, -O0):
<conf_parse_int>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
lea    -0x20(%rbp),%rdx
call   1030 <conf_parse_int_internal@plt>
mov    %eax,-0x24(%rbp)
cmpl   $0x0,-0x24(%rbp)
jne    118e <conf_parse_int+0x7e>
mov    -0x20(%rbp),%rax
mov    0x2e9b(%rip),%rcx
cmp    (%rcx),%rax
jg     116a <conf_parse_int+0x5a>
mov    -0x20(%rbp),%rax
mov    0x2e7f(%rip),%rcx
cmp    (%rcx),%rax
jge    117d <conf_parse_int+0x6d>
xor    %eax,%eax
mov    0x2e65(%rip),%rcx
sub    (%rcx),%eax
mov    %eax,-0x24(%rbp)
jmp    1189 <conf_parse_int+0x79>
mov    -0x20(%rbp),%rax
mov    %eax,%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
jmp    118e <conf_parse_int+0x7e>
mov    -0x24(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<conf_parse_int>:
push   %rbx
sub    $0x10,%rsp
mov    %rdx,%rbx
lea    0x8(%rsp),%rdx
call   1030 <conf_parse_int_internal@plt>
test   %eax,%eax
jne    1154 <conf_parse_int+0x44>
mov    0x8(%rsp),%rax
mov    0x2eb6(%rip),%rcx
cmp    (%rcx),%rax
jg     1149 <conf_parse_int+0x39>
mov    0x2ea2(%rip),%rcx
cmp    (%rcx),%rax
jl     1149 <conf_parse_int+0x39>
mov    %eax,(%rbx)
xor    %eax,%eax
jmp    1154 <conf_parse_int+0x44>
mov    0x2e88(%rip),%rcx
xor    %eax,%eax
sub    (%rcx),%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@INT_MAX = global i64 0
@INT_MIN = global i64 0
@ERANGE = global i32 0
define i32 @conf_parse_int(i8* %0, i8* %1, i8* %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i64
%8 = alloca i32
store i8* %0, i8** %4
store i8* %1, i8** %5
store i8* %2, i8** %6
%9 = load i8*, i8** %4
%10 = load i8*, i8** %5
%11 = call i32 @conf_parse_int_internal(i8* %9, i8* %10, i64* %7)
store i32 %11, i32* %8
%12 = load i32, i32* %8
%13 = icmp ne i32 %12, 0
br i1 %13, label %31, label %14
14: ; preds = %3
%15 = load i64, i64* %7
%16 = load i64, i64* @INT_MAX
%17 = icmp sgt i64 %15, %16
br i1 %17, label %22, label %18
18: ; preds = %14
%19 = load i64, i64* %7
%20 = load i64, i64* @INT_MIN
%21 = icmp slt i64 %19, %20
br i1 %21, label %22, label %25
22: ; preds = %18, %14
%23 = load i32, i32* @ERANGE
%24 = sub nsw i32 0, %23
store i32 %24, i32* %8
br label %30
25: ; preds = %18
%26 = load i64, i64* %7
%27 = trunc i64 %26 to i32
%28 = load i8*, i8** %6
%29 = bitcast i8* %28 to i32*
store i32 %27, i32* %29
br label %30
30: ; preds = %25, %22
br label %31
31: ; preds = %30, %3
%32 = load i32, i32* %8
ret i32 %32
}

LLVM IR (-O2):
@INT_MAX = global i64 0
@INT_MIN = global i64 0
@ERANGE = global i32 0
define i32 @conf_parse_int(i8* %0, i8* %1, i8* nocapture writeonly %2) {
%4 = alloca i64
%5 = bitcast i64* %4 to i8*
%6 = call i32 @conf_parse_int_internal(i8* %0, i8* %1, i64* %4)
%7 = icmp eq i32 %6, 0
br i1 %7, label %8, label %21
8: ; preds = %3
%9 = load i64, i64* %4
%10 = load i64, i64* @INT_MAX
%11 = icmp sgt i64 %9, %10
%12 = load i64, i64* @INT_MIN
%13 = icmp slt i64 %9, %12
%14 = select i1 %11, i1 true, i1 %13
br i1 %14, label %15, label %18
15: ; preds = %8
%16 = load i32, i32* @ERANGE
%17 = sub nsw i32 0, %16
br label %21
18: ; preds = %8
%19 = trunc i64 %9 to i32
%20 = bitcast i8* %2 to i32*
store i32 %19, i32* %20
br label %21
21: ; preds = %15, %18, %3
%22 = phi i32 [ %6, %3 ], [ %17, %15 ], [ 0, %18 ]
ret i32 %22
}