#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 strtonum(char *, int, int, char const **);
int main(void) {
  const char *errstr;
  if (strtonum("1", 0, 2, &errstr) != 1)
    return 1;
  if (errstr != NULL)
    return 2;
  if (strtonum("1x", 0, 2, &errstr) != 0)
    return 3;
  if (errstr == NULL)
    return 4;
  if (strtonum("2", 0, 1, &errstr) != 0)
    return 5;
  if (errstr == NULL)
    return 6;
  if (strtonum("0", 1, 2, &errstr) != 0)
    return 7;
  if (errstr == NULL)
    return 8;
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeda(%rip),%rdi
xor    %esi,%esi
mov    $0x2,%edx
lea    -0x10(%rbp),%rcx
call   1030 <strtonum@plt>
cmp    $0x1,%eax
je     114b <main+0x3b>
movl   $0x1,-0x4(%rbp)
jmp    1235 <main+0x125>
cmpq   $0x0,-0x10(%rbp)
je     1162 <main+0x52>
movl   $0x2,-0x4(%rbp)
jmp    1235 <main+0x125>
lea    0xe99(%rip),%rdi
xor    %esi,%esi
mov    $0x2,%edx
lea    -0x10(%rbp),%rcx
call   1030 <strtonum@plt>
cmp    $0x0,%eax
je     118e <main+0x7e>
movl   $0x3,-0x4(%rbp)
jmp    1235 <main+0x125>
cmpq   $0x0,-0x10(%rbp)
jne    11a5 <main+0x95>
movl   $0x4,-0x4(%rbp)
jmp    1235 <main+0x125>
lea    0xe59(%rip),%rdi
xor    %esi,%esi
mov    $0x1,%edx
lea    -0x10(%rbp),%rcx
call   1030 <strtonum@plt>
cmp    $0x0,%eax
je     11d1 <main+0xc1>
movl   $0x5,-0x4(%rbp)
jmp    1235 <main+0x125>
cmpq   $0x0,-0x10(%rbp)
jne    11e8 <main+0xd8>
movl   $0x6,-0x4(%rbp)
jmp    1235 <main+0x125>
lea    0xe18(%rip),%rdi
mov    $0x1,%esi
mov    $0x2,%edx
lea    -0x10(%rbp),%rcx
call   1030 <strtonum@plt>
cmp    $0x0,%eax
je     1217 <main+0x107>
movl   $0x7,-0x4(%rbp)
jmp    1235 <main+0x125>
cmpq   $0x0,-0x10(%rbp)
jne    122e <main+0x11e>
movl   $0x8,-0x4(%rbp)
jmp    1235 <main+0x125>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
lea    0xee8(%rip),%rdi
mov    %rsp,%rcx
xor    %esi,%esi
mov    $0x2,%edx
call   1030 <strtonum@plt>
mov    %eax,%ecx
mov    $0x1,%eax
cmp    $0x1,%ecx
jne    113f <main+0x2f>
cmpq   $0x0,(%rsp)
mov    $0x2,%eax
je     1141 <main+0x31>
pop    %rcx
ret
lea    0xeba(%rip),%rdi
mov    %rsp,%rcx
xor    %esi,%esi
mov    $0x2,%edx
call   1030 <strtonum@plt>
mov    %eax,%ecx
mov    $0x3,%eax
test   %ecx,%ecx
jne    113f <main+0x2f>
cmpq   $0x0,(%rsp)
je     11c4 <main+0xb4>
lea    0xe95(%rip),%rdi
mov    %rsp,%rcx
xor    %esi,%esi
mov    $0x1,%edx
call   1030 <strtonum@plt>
mov    %eax,%ecx
mov    $0x5,%eax
test   %ecx,%ecx
jne    113f <main+0x2f>
cmpq   $0x0,(%rsp)
je     11cb <main+0xbb>
lea    0xe6f(%rip),%rdi
mov    %rsp,%rcx
mov    $0x1,%esi
mov    $0x2,%edx
call   1030 <strtonum@plt>
mov    %eax,%ecx
mov    $0x7,%eax
test   %ecx,%ecx
jne    113f <main+0x2f>
xor    %eax,%eax
cmpq   $0x0,(%rsp)
sete   %al
shl    $0x3,%eax
pop    %rcx
ret
mov    $0x4,%eax
pop    %rcx
ret
mov    $0x6,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [2 x i8] c"1\00"
@.str.1 = [3 x i8] c"1x\00"
@.str.2 = [2 x i8] c"2\00"
@.str.3 = [2 x i8] c"0\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i8*
store i32 0, i32* %1
%3 = call i32 @strtonum(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i32 0, i32 2, i8** %2)
%4 = icmp ne i32 %3, 1
br i1 %4, label %5, label %6
5: ; preds = %0
store i32 1, i32* %1
br label %35
6: ; preds = %0
%7 = load i8*, i8** %2
%8 = icmp ne i8* %7, null
br i1 %8, label %9, label %10
9: ; preds = %6
store i32 2, i32* %1
br label %35
10: ; preds = %6
%11 = call i32 @strtonum(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 0, i32 2, i8** %2)
%12 = icmp ne i32 %11, 0
br i1 %12, label %13, label %14
13: ; preds = %10
store i32 3, i32* %1
br label %35
14: ; preds = %10
%15 = load i8*, i8** %2
%16 = icmp eq i8* %15, null
br i1 %16, label %17, label %18
17: ; preds = %14
store i32 4, i32* %1
br label %35
18: ; preds = %14
%19 = call i32 @strtonum(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0), i32 0, i32 1, i8** %2)
%20 = icmp ne i32 %19, 0
br i1 %20, label %21, label %22
21: ; preds = %18
store i32 5, i32* %1
br label %35
22: ; preds = %18
%23 = load i8*, i8** %2
%24 = icmp eq i8* %23, null
br i1 %24, label %25, label %26
25: ; preds = %22
store i32 6, i32* %1
br label %35
26: ; preds = %22
%27 = call i32 @strtonum(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0), i32 1, i32 2, i8** %2)
%28 = icmp ne i32 %27, 0
br i1 %28, label %29, label %30
29: ; preds = %26
store i32 7, i32* %1
br label %35
30: ; preds = %26
%31 = load i8*, i8** %2
%32 = icmp eq i8* %31, null
br i1 %32, label %33, label %34
33: ; preds = %30
store i32 8, i32* %1
br label %35
34: ; preds = %30
store i32 0, i32* %1
br label %35
35: ; preds = %34, %33, %29, %25, %21, %17, %13, %9, %5
%36 = load i32, i32* %1
ret i32 %36
}

LLVM IR (-O2):
@.str = [2 x i8] c"1\00"
@.str.1 = [3 x i8] c"1x\00"
@.str.2 = [2 x i8] c"2\00"
@.str.3 = [2 x i8] c"0\00"
define i32 @main() {
%1 = alloca i8*
%2 = bitcast i8** %1 to i8*
%3 = call i32 @strtonum(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i32 0, i32 2, i8** %1)
%4 = icmp eq i32 %3, 1
br i1 %4, label %5, label %27
5: ; preds = %0
%6 = load i8*, i8** %1
%7 = icmp eq i8* %6, null
br i1 %7, label %8, label %27
8: ; preds = %5
%9 = call i32 @strtonum(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 0, i32 2, i8** %1)
%10 = icmp eq i32 %9, 0
br i1 %10, label %11, label %27
11: ; preds = %8
%12 = load i8*, i8** %1
%13 = icmp eq i8* %12, null
br i1 %13, label %27, label %14
14: ; preds = %11
%15 = call i32 @strtonum(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0), i32 0, i32 1, i8** %1)
%16 = icmp eq i32 %15, 0
br i1 %16, label %17, label %27
17: ; preds = %14
%18 = load i8*, i8** %1
%19 = icmp eq i8* %18, null
br i1 %19, label %27, label %20
20: ; preds = %17
%21 = call i32 @strtonum(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0), i32 1, i32 2, i8** %1)
%22 = icmp eq i32 %21, 0
br i1 %22, label %23, label %27
23: ; preds = %20
%24 = load i8*, i8** %1
%25 = icmp eq i8* %24, null
%26 = select i1 %25, i32 8, i32 0
br label %27
27: ; preds = %23, %20, %17, %14, %11, %8, %5, %0
%28 = phi i32 [ 1, %0 ], [ 2, %5 ], [ 3, %8 ], [ 4, %11 ], [ 5, %14 ], [ 6, %17 ], [ 7, %20 ], [ %26, %23 ]
ret i32 %28
}