#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(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char const *,
                           char const *);
int /*<<< orphan*/ stderr;
unsigned long strtoul(char const *, char **, int);
unsigned long _parse_ul(const char *type, const char *str) {
  char *endptr;
  unsigned long ul = strtoul(str, &endptr, 10);
  if (endptr == str || *endptr != '\0') {
    fprintf(stderr, "resu: Unknown %s `%s'", type, str);
    exit(1);
  }
  return ul;
}


x86 assembly (clang, -O0):
<_parse_ul>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
lea    -0x18(%rbp),%rsi
mov    $0xa,%edx
call   1040 <strtoul@plt>
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rax
cmp    -0x10(%rbp),%rax
je     1174 <_parse_ul+0x44>
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     119b <_parse_ul+0x6b>
mov    0x2e65(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%rdx
mov    -0x10(%rbp),%rcx
lea    0xe74(%rip),%rsi
call   1030 <fprintf@plt>
mov    $0x1,%edi
call   1050 <exit@plt>
mov    -0x20(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<_parse_ul>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    %rdi,%r14
mov    %rsp,%rsi
mov    %rbx,%rdi
mov    $0xa,%edx
call   1040 <strtoul@plt>
mov    (%rsp),%rcx
cmp    %rbx,%rcx
je     1160 <_parse_ul+0x30>
cmpb   $0x0,(%rcx)
jne    1160 <_parse_ul+0x30>
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret
mov    0x2e79(%rip),%rax
mov    (%rax),%edi
lea    0xe90(%rip),%rsi
mov    %r14,%rdx
mov    %rbx,%rcx
call   1030 <fprintf@plt>
mov    $0x1,%edi
call   1050 <exit@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [22 x i8] c"resu: Unknown %s `%s'\00"
define i64 @_parse_ul(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i64
store i8* %0, i8** %3
store i8* %1, i8** %4
%7 = load i8*, i8** %4
%8 = call i64 @strtoul(i8* %7, i8** %5, i32 10)
store i64 %8, i64* %6
%9 = load i8*, i8** %5
%10 = load i8*, i8** %4
%11 = icmp eq i8* %9, %10
br i1 %11, label %17, label %12
12: ; preds = %2
%13 = load i8*, i8** %5
%14 = load i8, i8* %13
%15 = sext i8 %14 to i32
%16 = icmp ne i32 %15, 0
br i1 %16, label %17, label %23
17: ; preds = %12, %2
%18 = load i32, i32* @stderr
%19 = load i8*, i8** %3
%20 = load i8*, i8** %4
%21 = call i32 @fprintf(i32 %18, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i8* %19, i8* %20)
%22 = call i32 @exit(i32 1)
unreachable
23: ; preds = %12
%24 = load i64, i64* %6
ret i64 %24
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [22 x i8] c"resu: Unknown %s `%s'\00"
define i64 @_parse_ul(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = bitcast i8** %3 to i8*
%5 = call i64 @strtoul(i8* %1, i8** %3, i32 10)
%6 = load i8*, i8** %3
%7 = icmp eq i8* %6, %1
br i1 %7, label %11, label %8
8: ; preds = %2
%9 = load i8, i8* %6
%10 = icmp eq i8 %9, 0
br i1 %10, label %15, label %11
11: ; preds = %8, %2
%12 = load i32, i32* @stderr
%13 = tail call i32 @fprintf(i32 %12, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i8* %0, i8* %1)
%14 = tail call i32 @exit(i32 1)
unreachable
15: ; preds = %8
ret i64 %5
}