#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;
long LONG_MAX;
scalar_t__ errno;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char const *,
                           char const *, long, int /*<<< orphan*/);
char *proc_string(char const *, char const *);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ strerror(scalar_t__);
long strtol(char const *, char **, int);
unsigned long proc_ulong(const char *filename, const char *line) {
  const char *s = proc_string(filename, line);
  long retval;
  char *end;
  errno = 0;
  retval = strtol(s, &end, 10);
  if (retval < 0 || retval >= LONG_MAX || (end && *end)) {
    fprintf(stderr, "\"%s\":\"%s\": %ld, %s\n", filename, line, retval,
            strerror(errno));
    exit(EXIT_FAILURE);
  }
  return retval;
}


x86 assembly (clang, -O0):
<proc_ulong>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1030 <proc_string@plt>
mov    %rax,-0x18(%rbp)
mov    0x2e58(%rip),%rax
movq   $0x0,(%rax)
mov    -0x18(%rbp),%rdi
lea    -0x28(%rbp),%rsi
mov    $0xa,%edx
call   1050 <strtol@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jl     11cf <proc_ulong+0x7f>
mov    -0x20(%rbp),%rax
mov    0x2e2d(%rip),%rcx
cmp    (%rcx),%rax
jge    11cf <proc_ulong+0x7f>
cmpq   $0x0,-0x28(%rbp)
je     122e <proc_ulong+0xde>
mov    -0x28(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     122e <proc_ulong+0xde>
mov    0x2e0a(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x44(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x40(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    0x2dd6(%rip),%rax
mov    (%rax),%rdi
call   1070 <strerror@plt>
mov    -0x44(%rbp),%edi
mov    -0x40(%rbp),%rdx
mov    -0x38(%rbp),%rcx
mov    -0x30(%rbp),%r8
mov    %eax,%r9d
lea    0xde5(%rip),%rsi
call   1040 <fprintf@plt>
mov    0x2da1(%rip),%rax
mov    (%rax),%edi
call   1060 <exit@plt>
mov    -0x20(%rbp),%rax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<proc_ulong>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x10,%rsp
mov    %rsi,%r14
mov    %rdi,%r15
call   1030 <proc_string@plt>
mov    0x2e62(%rip),%rbp
movq   $0x0,0x0(%rbp)
lea    0x8(%rsp),%rsi
mov    %rax,%rdi
mov    $0xa,%edx
call   1050 <strtol@plt>
mov    %rax,%rbx
test   %rax,%rax
js     11bb <proc_ulong+0x6b>
mov    0x2e41(%rip),%rax
cmp    (%rax),%rbx
jge    11bb <proc_ulong+0x6b>
mov    0x8(%rsp),%rax
test   %rax,%rax
je     11ab <proc_ulong+0x5b>
cmpb   $0x0,(%rax)
jne    11bb <proc_ulong+0x6b>
mov    %rbx,%rax
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2e1e(%rip),%rax
mov    (%rax),%r12d
mov    0x0(%rbp),%rdi
call   1070 <strerror@plt>
lea    0xe2b(%rip),%rsi
mov    %r12d,%edi
mov    %r15,%rdx
mov    %r14,%rcx
mov    %rbx,%r8
mov    %eax,%r9d
call   1040 <fprintf@plt>
mov    0x2dd8(%rip),%rax
mov    (%rax),%edi
call   1060 <exit@plt>

LLVM IR (-O0):
@errno = global i64 0
@LONG_MAX = global i64 0
@stderr = global i32 0
@.str = [20 x i8] c"\22%s\22:\22%s\22: %ld, %s\0A\00"
@EXIT_FAILURE = global i32 0
define i64 @proc_ulong(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i64
%7 = alloca i8*
store i8* %0, i8** %3
store i8* %1, i8** %4
%8 = load i8*, i8** %3
%9 = load i8*, i8** %4
%10 = call i8* @proc_string(i8* %8, i8* %9)
store i8* %10, i8** %5
store i64 0, i64* @errno
%11 = load i8*, i8** %5
%12 = call i64 @strtol(i8* %11, i8** %7, i32 10)
store i64 %12, i64* %6
%13 = load i64, i64* %6
%14 = icmp slt i64 %13, 0
br i1 %14, label %27, label %15
15: ; preds = %2
%16 = load i64, i64* %6
%17 = load i64, i64* @LONG_MAX
%18 = icmp sge i64 %16, %17
br i1 %18, label %27, label %19
19: ; preds = %15
%20 = load i8*, i8** %7
%21 = icmp ne i8* %20, null
br i1 %21, label %22, label %37
22: ; preds = %19
%23 = load i8*, i8** %7
%24 = load i8, i8* %23
%25 = sext i8 %24 to i32
%26 = icmp ne i32 %25, 0
br i1 %26, label %27, label %37
27: ; preds = %22, %15, %2
%28 = load i32, i32* @stderr
%29 = load i8*, i8** %3
%30 = load i8*, i8** %4
%31 = load i64, i64* %6
%32 = load i64, i64* @errno
%33 = call i32 @strerror(i64 %32)
%34 = call i32 @fprintf(i32 %28, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i8* %29, i8* %30, i64 %31, i32 %33)
%35 = load i32, i32* @EXIT_FAILURE
%36 = call i32 @exit(i32 %35)
unreachable
37: ; preds = %22, %19
%38 = load i64, i64* %6
ret i64 %38
}

LLVM IR (-O2):
@errno = global i64 0
@LONG_MAX = global i64 0
@stderr = global i32 0
@.str = [20 x i8] c"\22%s\22:\22%s\22: %ld, %s\0A\00"
@EXIT_FAILURE = global i32 0
define i64 @proc_ulong(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = tail call i8* @proc_string(i8* %0, i8* %1)
%5 = bitcast i8** %3 to i8*
store i64 0, i64* @errno
%6 = call i64 @strtol(i8* %4, i8** %3, i32 10)
%7 = icmp sgt i64 %6, -1
%8 = load i64, i64* @LONG_MAX
%9 = icmp slt i64 %6, %8
%10 = select i1 %7, i1 %9, i1 false
br i1 %10, label %11, label %17
11: ; preds = %2
%12 = load i8*, i8** %3
%13 = icmp eq i8* %12, null
br i1 %13, label %24, label %14
14: ; preds = %11
%15 = load i8, i8* %12
%16 = icmp eq i8 %15, 0
br i1 %16, label %24, label %17
17: ; preds = %14, %2
%18 = load i32, i32* @stderr
%19 = load i64, i64* @errno
%20 = tail call i32 @strerror(i64 %19)
%21 = tail call i32 @fprintf(i32 %18, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i8* %0, i8* %1, i64 %6, i32 %20)
%22 = load i32, i32* @EXIT_FAILURE
%23 = tail call i32 @exit(i32 %22)
unreachable
24: ; preds = %14, %11
ret i64 %6
}