#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 *, char const *);
int /*<<< orphan*/ isspace(char);
int /*<<< orphan*/ stderr;
unsigned long strtoul(char const *, char **, int /*<<< orphan*/);
void parse_long(const char *arg, unsigned long *value, const char *prefix,
                const char *varname) {
  char *endptr;
  *value = strtoul(arg, &endptr, 0);
  if (*endptr != '\0' && !isspace(*endptr)) {
    if (prefix != NULL && varname != NULL) {
      fprintf(stderr, "%s: invalid %s = %s\n", prefix, varname, arg);
      exit(255);
    }
    exit(255);
  }
}


x86 assembly (clang, -O0):
<parse_long>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    -0x8(%rbp),%rdi
lea    -0x28(%rbp),%rsi
xor    %edx,%edx
call   1050 <strtoul@plt>
mov    %rax,%rcx
mov    -0x10(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x28(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     11e1 <parse_long+0xa1>
mov    -0x28(%rbp),%rax
movsbl (%rax),%edi
call   1030 <isspace@plt>
cmp    $0x0,%eax
jne    11e1 <parse_long+0xa1>
cmpq   $0x0,-0x18(%rbp)
je     11d7 <parse_long+0x97>
cmpq   $0x0,-0x20(%rbp)
je     11d7 <parse_long+0x97>
mov    0x2e2d(%rip),%rax
mov    (%rax),%edi
mov    -0x18(%rbp),%rdx
mov    -0x20(%rbp),%rcx
mov    -0x8(%rbp),%r8
lea    0xe38(%rip),%rsi
call   1040 <fprintf@plt>
mov    $0xff,%edi
call   1060 <exit@plt>
mov    $0xff,%edi
call   1060 <exit@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<parse_long>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rcx,%r14
mov    %rdx,%r15
mov    %rsi,%rbx
mov    %rdi,%r12
mov    %rsp,%rsi
xor    %edx,%edx
call   1050 <strtoul@plt>
mov    %rax,(%rbx)
mov    (%rsp),%rax
mov    (%rax),%al
test   %al,%al
je     1177 <parse_long+0x37>
movsbl %al,%edi
call   1030 <isspace@plt>
test   %eax,%eax
je     1183 <parse_long+0x43>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret
test   %r15,%r15
je     11ab <parse_long+0x6b>
test   %r14,%r14
je     11ab <parse_long+0x6b>
mov    0x2e4c(%rip),%rax
mov    (%rax),%edi
lea    0xe63(%rip),%rsi
mov    %r15,%rdx
mov    %r14,%rcx
mov    %r12,%r8
call   1040 <fprintf@plt>
mov    $0xff,%edi
call   1060 <exit@plt>

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

LLVM IR (-O2):
@stderr = global i32 0
@.str = [21 x i8] c"%s: invalid %s = %s\0A\00"
define void @parse_long(i8* %0, i64* nocapture writeonly %1, i8* %2, i8* %3) {
%5 = alloca i8*
%6 = bitcast i8** %5 to i8*
%7 = call i64 @strtoul(i8* %0, i8** %5, i32 0)
store i64 %7, i64* %1
%8 = load i8*, i8** %5
%9 = load i8, i8* %8
%10 = icmp eq i8 %9, 0
br i1 %10, label %24, label %11
11: ; preds = %4
%12 = tail call i32 @isspace(i8 signext %9)
%13 = icmp eq i32 %12, 0
br i1 %13, label %14, label %24
14: ; preds = %11
%15 = icmp ne i8* %2, null
%16 = icmp ne i8* %3, null
%17 = and i1 %15, %16
br i1 %17, label %18, label %22
18: ; preds = %14
%19 = load i32, i32* @stderr
%20 = tail call i32 @fprintf(i32 %19, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i8* %2, i8* %3, i8* %0)
%21 = tail call i32 @exit(i32 255)
unreachable
22: ; preds = %14
%23 = tail call i32 @exit(i32 255)
unreachable
24: ; preds = %11, %4
ret void
}