#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 */
scalar_t__ isspace(char const);
const char *strtoul_pre(const char *string, int *negate, int *base) {
  while (isspace(*string))
    string++;
  *negate = 0;
  if (*string == '-') {
    string++;
    *negate = 1;
  } else if (*string == '+') {
    string++;
  }
  if (*base == 0) {
    *base = 10;
    if (*string == '0') {
      string++;
      *base = 8;
      if ((*string & ~0x20) == 'X') {
        string++;
        *base = 16;
      }
    }
  }
  return string;
}


x86 assembly (clang, -O0):
<strtoul_pre>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x8(%rbp),%rax
movsbl (%rax),%edi
call   1030 <isspace@plt>
cmp    $0x0,%rax
je     114b <strtoul_pre+0x3b>
mov    -0x8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
jmp    1124 <strtoul_pre+0x14>
mov    -0x10(%rbp),%rax
movl   $0x0,(%rax)
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2d,%eax
jne    1180 <strtoul_pre+0x70>
mov    -0x8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
mov    -0x10(%rbp),%rax
movl   $0x1,(%rax)
jmp    11a1 <strtoul_pre+0x91>
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2b,%eax
jne    119c <strtoul_pre+0x8c>
mov    -0x8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
jmp    11a1 <strtoul_pre+0x91>
mov    -0x18(%rbp),%rax
cmpl   $0x0,(%rax)
jne    1211 <strtoul_pre+0x101>
mov    -0x18(%rbp),%rax
movl   $0xa,(%rax)
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x30,%eax
jne    120c <strtoul_pre+0xfc>
mov    -0x8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
mov    -0x18(%rbp),%rax
movl   $0x8,(%rax)
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
and    $0xffffffdf,%eax
cmp    $0x58,%eax
jne    1207 <strtoul_pre+0xf7>
mov    -0x8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
mov    -0x18(%rbp),%rax
movl   $0x10,(%rax)
jmp    120c <strtoul_pre+0xfc>
jmp    1211 <strtoul_pre+0x101>
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<strtoul_pre>:
push   %r15
push   %r14
push   %rbx
mov    %rdx,%r14
mov    %rsi,%r15
mov    %rdi,%rbx
xchg   %ax,%ax
movsbl (%rbx),%edi
call   1030 <isspace@plt>
add    $0x1,%rbx
test   %rax,%rax
jne    1120 <strtoul_pre+0x10>
movl   $0x0,(%r15)
mov    -0x1(%rbx),%al
cmp    $0x2b,%al
je     114a <strtoul_pre+0x3a>
cmp    $0x2d,%al
jne    1152 <strtoul_pre+0x42>
movl   $0x1,(%r15)
cmpl   $0x0,(%r14)
jne    1189 <strtoul_pre+0x79>
jmp    115c <strtoul_pre+0x4c>
add    $0xffffffffffffffff,%rbx
cmpl   $0x0,(%r14)
jne    1189 <strtoul_pre+0x79>
movl   $0xa,(%r14)
cmpb   $0x30,(%rbx)
jne    1189 <strtoul_pre+0x79>
movl   $0x8,(%r14)
mov    0x1(%rbx),%al
and    $0xdf,%al
cmp    $0x58,%al
jne    1185 <strtoul_pre+0x75>
add    $0x2,%rbx
movl   $0x10,(%r14)
jmp    1189 <strtoul_pre+0x79>
add    $0x1,%rbx
mov    %rbx,%rax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define i8* @strtoul_pre(i8* %0, i32* %1, i32* %2) {
%4 = alloca i8*
%5 = alloca i32*
%6 = alloca i32*
store i8* %0, i8** %4
store i32* %1, i32** %5
store i32* %2, i32** %6
br label %7
7: ; preds = %12, %3
%8 = load i8*, i8** %4
%9 = load i8, i8* %8
%10 = call i64 @isspace(i8 signext %9)
%11 = icmp ne i64 %10, 0
br i1 %11, label %12, label %15
12: ; preds = %7
%13 = load i8*, i8** %4
%14 = getelementptr inbounds i8, i8* %13, i32 1
store i8* %14, i8** %4
br label %7
15: ; preds = %7
%16 = load i32*, i32** %5
store i32 0, i32* %16
%17 = load i8*, i8** %4
%18 = load i8, i8* %17
%19 = sext i8 %18 to i32
%20 = icmp eq i32 %19, 45
br i1 %20, label %21, label %25
21: ; preds = %15
%22 = load i8*, i8** %4
%23 = getelementptr inbounds i8, i8* %22, i32 1
store i8* %23, i8** %4
%24 = load i32*, i32** %5
store i32 1, i32* %24
br label %34
25: ; preds = %15
%26 = load i8*, i8** %4
%27 = load i8, i8* %26
%28 = sext i8 %27 to i32
%29 = icmp eq i32 %28, 43
br i1 %29, label %30, label %33
30: ; preds = %25
%31 = load i8*, i8** %4
%32 = getelementptr inbounds i8, i8* %31, i32 1
store i8* %32, i8** %4
br label %33
33: ; preds = %30, %25
br label %34
34: ; preds = %33, %21
%35 = load i32*, i32** %6
%36 = load i32, i32* %35
%37 = icmp eq i32 %36, 0
br i1 %37, label %38, label %59
38: ; preds = %34
%39 = load i32*, i32** %6
store i32 10, i32* %39
%40 = load i8*, i8** %4
%41 = load i8, i8* %40
%42 = sext i8 %41 to i32
%43 = icmp eq i32 %42, 48
br i1 %43, label %44, label %58
44: ; preds = %38
%45 = load i8*, i8** %4
%46 = getelementptr inbounds i8, i8* %45, i32 1
store i8* %46, i8** %4
%47 = load i32*, i32** %6
store i32 8, i32* %47
%48 = load i8*, i8** %4
%49 = load i8, i8* %48
%50 = sext i8 %49 to i32
%51 = and i32 %50, -33
%52 = icmp eq i32 %51, 88
br i1 %52, label %53, label %57
53: ; preds = %44
%54 = load i8*, i8** %4
%55 = getelementptr inbounds i8, i8* %54, i32 1
store i8* %55, i8** %4
%56 = load i32*, i32** %6
store i32 16, i32* %56
br label %57
57: ; preds = %53, %44
br label %58
58: ; preds = %57, %38
br label %59
59: ; preds = %58, %34
%60 = load i8*, i8** %4
ret i8* %60
}

LLVM IR (-O2):
define i8* @strtoul_pre(i8* %0, i32* nocapture writeonly %1, i32* nocapture %2) {
br label %4
4: ; preds = %4, %3
%5 = phi i8* [ %0, %3 ], [ %9, %4 ]
%6 = load i8, i8* %5
%7 = tail call i64 @isspace(i8 signext %6)
%8 = icmp eq i64 %7, 0
%9 = getelementptr inbounds i8, i8* %5, i64 1
br i1 %8, label %10, label %4
10: ; preds = %4
store i32 0, i32* %1
%11 = load i8, i8* %5
switch i8 %11, label %14 [
i8 45, label %12
i8 43, label %13
]
12: ; preds = %10
store i32 1, i32* %1
br label %14
13: ; preds = %10
br label %14
14: ; preds = %10, %13, %12
%15 = phi i8* [ %9, %12 ], [ %9, %13 ], [ %5, %10 ]
%16 = load i32, i32* %2
%17 = icmp eq i32 %16, 0
br i1 %17, label %18, label %28
18: ; preds = %14
store i32 10, i32* %2
%19 = load i8, i8* %15
%20 = icmp eq i8 %19, 48
br i1 %20, label %21, label %28
21: ; preds = %18
%22 = getelementptr inbounds i8, i8* %15, i64 1
store i32 8, i32* %2
%23 = load i8, i8* %22
%24 = and i8 %23, -33
%25 = icmp eq i8 %24, 88
br i1 %25, label %26, label %28
26: ; preds = %21
%27 = getelementptr inbounds i8, i8* %15, i64 2
store i32 16, i32* %2
br label %28
28: ; preds = %18, %26, %21, %14
%29 = phi i8* [ %27, %26 ], [ %22, %21 ], [ %15, %18 ], [ %15, %14 ]
ret i8* %29
}