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


x86 assembly (clang, -O0):
<conf_parse_unsigned_long>:
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_unsigned_internal@plt>
mov    %eax,-0x24(%rbp)
cmpl   $0x0,-0x24(%rbp)
jne    117a <conf_parse_unsigned_long+0x6a>
mov    -0x20(%rbp),%rax
mov    0x2e83(%rip),%rcx
cmp    (%rcx),%rax
jbe    1169 <conf_parse_unsigned_long+0x59>
xor    %eax,%eax
mov    0x2e89(%rip),%rcx
sub    (%rcx),%eax
mov    %eax,-0x24(%rbp)
jmp    1175 <conf_parse_unsigned_long+0x65>
mov    -0x20(%rbp),%rax
mov    %eax,%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
jmp    117a <conf_parse_unsigned_long+0x6a>
mov    -0x24(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<conf_parse_unsigned_long>:
push   %rbx
sub    $0x10,%rsp
mov    %rdx,%rbx
lea    0x8(%rsp),%rdx
call   1030 <conf_parse_unsigned_internal@plt>
test   %eax,%eax
jne    1148 <conf_parse_unsigned_long+0x38>
mov    0x8(%rsp),%rax
mov    0x2e9e(%rip),%rcx
cmp    (%rcx),%rax
jbe    1144 <conf_parse_unsigned_long+0x34>
mov    0x2eaa(%rip),%rcx
xor    %eax,%eax
sub    (%rcx),%eax
jmp    1148 <conf_parse_unsigned_long+0x38>
mov    %eax,(%rbx)
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@ULONG_MAX = global i64 0
@ERANGE = global i32 0
define i32 @conf_parse_unsigned_long(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_unsigned_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 %27, label %14
14: ; preds = %3
%15 = load i64, i64* %7
%16 = load i64, i64* @ULONG_MAX
%17 = icmp ugt i64 %15, %16
br i1 %17, label %18, label %21
18: ; preds = %14
%19 = load i32, i32* @ERANGE
%20 = sub nsw i32 0, %19
store i32 %20, i32* %8
br label %26
21: ; preds = %14
%22 = load i64, i64* %7
%23 = trunc i64 %22 to i32
%24 = load i8*, i8** %6
%25 = bitcast i8* %24 to i32*
store i32 %23, i32* %25
br label %26
26: ; preds = %21, %18
br label %27
27: ; preds = %26, %3
%28 = load i32, i32* %8
ret i32 %28
}

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