#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 */
long INT_MAX;
long INT_MIN;
scalar_t__ errno;
long strtol(char const *, char **, int /*<<< orphan*/);
int /*<<< orphan*/ syntaxErr(char *, char const *);
char *parseInt(const char *cursor, int *integer) {
  char *end;
  long result;
  errno = 0;
  result = strtol(cursor, &end, 0);
  if (errno || end == cursor || result < INT_MIN || result > INT_MAX)
    syntaxErr("\"%s\" is not a valid integer", cursor);
  *integer = result;
  return end;
}


x86 assembly (clang, -O0):
<parseInt>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0x2e99(%rip),%rax
movq   $0x0,(%rax)
mov    -0x8(%rbp),%rdi
lea    -0x18(%rbp),%rsi
xor    %edx,%edx
call   1030 <strtol@plt>
mov    %rax,-0x20(%rbp)
mov    0x2e78(%rip),%rax
cmpq   $0x0,(%rax)
jne    1198 <parseInt+0x78>
mov    -0x18(%rbp),%rax
cmp    -0x8(%rbp),%rax
je     1198 <parseInt+0x78>
mov    -0x20(%rbp),%rax
mov    0x2e65(%rip),%rcx
cmp    (%rcx),%rax
jl     1198 <parseInt+0x78>
mov    -0x20(%rbp),%rax
mov    0x2e59(%rip),%rcx
cmp    (%rcx),%rax
jle    11a8 <parseInt+0x88>
mov    -0x8(%rbp),%rsi
lea    0xe5d(%rip),%rdi
call   1040 <syntaxErr@plt>
mov    -0x20(%rbp),%rax
mov    %eax,%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x18(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<parseInt>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%r15
mov    0x2e9b(%rip),%r12
movq   $0x0,(%r12)
mov    %rsp,%rsi
xor    %edx,%edx
call   1030 <strtol@plt>
mov    %rax,%rbx
cmpq   $0x0,(%r12)
mov    (%rsp),%r12
jne    1172 <parseInt+0x52>
cmp    %r15,%r12
je     1172 <parseInt+0x52>
mov    0x2e7f(%rip),%rax
cmp    (%rax),%rbx
jl     1172 <parseInt+0x52>
mov    0x2e7b(%rip),%rax
cmp    (%rax),%rbx
jle    1181 <parseInt+0x61>
lea    0xe87(%rip),%rdi
mov    %r15,%rsi
call   1040 <syntaxErr@plt>
mov    %ebx,(%r14)
mov    %r12,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@errno = global i64 0
@INT_MIN = global i64 0
@INT_MAX = global i64 0
@.str = [28 x i8] c"\22%s\22 is not a valid integer\00"
define i8* @parseInt(i8* %0, i32* %1) {
%3 = alloca i8*
%4 = alloca i32*
%5 = alloca i8*
%6 = alloca i64
store i8* %0, i8** %3
store i32* %1, i32** %4
store i64 0, i64* @errno
%7 = load i8*, i8** %3
%8 = call i64 @strtol(i8* %7, i8** %5, i32 0)
store i64 %8, i64* %6
%9 = load i64, i64* @errno
%10 = icmp ne i64 %9, 0
br i1 %10, label %23, label %11
11: ; preds = %2
%12 = load i8*, i8** %5
%13 = load i8*, i8** %3
%14 = icmp eq i8* %12, %13
br i1 %14, label %23, label %15
15: ; preds = %11
%16 = load i64, i64* %6
%17 = load i64, i64* @INT_MIN
%18 = icmp slt i64 %16, %17
br i1 %18, label %23, label %19
19: ; preds = %15
%20 = load i64, i64* %6
%21 = load i64, i64* @INT_MAX
%22 = icmp sgt i64 %20, %21
br i1 %22, label %23, label %26
23: ; preds = %19, %15, %11, %2
%24 = load i8*, i8** %3
%25 = call i32 @syntaxErr(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0), i8* %24)
br label %26
26: ; preds = %23, %19
%27 = load i64, i64* %6
%28 = trunc i64 %27 to i32
%29 = load i32*, i32** %4
store i32 %28, i32* %29
%30 = load i8*, i8** %5
ret i8* %30
}

LLVM IR (-O2):
@errno = global i64 0
@INT_MIN = global i64 0
@INT_MAX = global i64 0
@.str = [28 x i8] c"\22%s\22 is not a valid integer\00"
define i8* @parseInt(i8* %0, i32* nocapture writeonly %1) {
%3 = alloca i8*
%4 = bitcast i8** %3 to i8*
store i64 0, i64* @errno
%5 = call i64 @strtol(i8* %0, i8** %3, i32 0)
%6 = load i64, i64* @errno
%7 = icmp ne i64 %6, 0
%8 = load i8*, i8** %3
%9 = icmp eq i8* %8, %0
%10 = select i1 %7, i1 true, i1 %9
%11 = load i64, i64* @INT_MIN
%12 = icmp slt i64 %5, %11
%13 = select i1 %10, i1 true, i1 %12
%14 = load i64, i64* @INT_MAX
%15 = icmp sgt i64 %5, %14
%16 = select i1 %13, i1 true, i1 %15
br i1 %16, label %17, label %19
17: ; preds = %2
%18 = tail call i32 @syntaxErr(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0), i8* %0)
br label %19
19: ; preds = %2, %17
%20 = trunc i64 %5 to i32
store i32 %20, i32* %1
ret i8* %8
}