#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*/ errExit(char *);
scalar_t__ errno;
long strtol(char *, char **, int);
long int getLong(char string[]) {
  char *firstCharNotNumber;
  long int result;
  errno = 0;
  result = strtol(string, &firstCharNotNumber, 10);
  if (errno != 0)
    errExit("strtol");
  if (*firstCharNotNumber != '\0')
    errExit("strtol: Expected base 10 number, got something else");
  return result;
}


x86 assembly (clang, -O0):
<getLong>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    0x2ead(%rip),%rax
movq   $0x0,(%rax)
mov    -0x8(%rbp),%rdi
lea    -0x10(%rbp),%rsi
mov    $0xa,%edx
call   1040 <strtol@plt>
mov    %rax,-0x18(%rbp)
mov    0x2e89(%rip),%rax
cmpq   $0x0,(%rax)
je     116d <getLong+0x4d>
lea    0xe98(%rip),%rdi
call   1030 <errExit@plt>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     1189 <getLong+0x69>
lea    0xe83(%rip),%rdi
call   1030 <errExit@plt>
mov    -0x18(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getLong>:
push   %r14
push   %rbx
push   %rax
mov    0x2eb5(%rip),%r14
movq   $0x0,(%r14)
mov    %rsp,%rsi
mov    $0xa,%edx
call   1040 <strtol@plt>
mov    %rax,%rbx
cmpq   $0x0,(%r14)
je     1154 <getLong+0x34>
lea    0xeb1(%rip),%rdi
call   1030 <errExit@plt>
mov    (%rsp),%rax
cmpb   $0x0,(%rax)
je     1169 <getLong+0x49>
lea    0xea3(%rip),%rdi
call   1030 <errExit@plt>
mov    %rbx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@errno = global i64 0
@.str = [7 x i8] c"strtol\00"
@.str.1 = [52 x i8] c"strtol: Expected base 10 number, got something else\00"
define i64 @getLong(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i64
store i8* %0, i8** %2
store i64 0, i64* @errno
%5 = load i8*, i8** %2
%6 = call i64 @strtol(i8* %5, i8** %3, i32 10)
store i64 %6, i64* %4
%7 = load i64, i64* @errno
%8 = icmp ne i64 %7, 0
br i1 %8, label %9, label %11
9: ; preds = %1
%10 = call i32 @errExit(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
br label %11
11: ; preds = %9, %1
%12 = load i8*, i8** %3
%13 = load i8, i8* %12
%14 = sext i8 %13 to i32
%15 = icmp ne i32 %14, 0
br i1 %15, label %16, label %18
16: ; preds = %11
%17 = call i32 @errExit(i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str.1, i64 0, i64 0))
br label %18
18: ; preds = %16, %11
%19 = load i64, i64* %4
ret i64 %19
}

LLVM IR (-O2):
@errno = global i64 0
@.str = [7 x i8] c"strtol\00"
@.str.1 = [52 x i8] c"strtol: Expected base 10 number, got something else\00"
define i64 @getLong(i8* %0) {
%2 = alloca i8*
%3 = bitcast i8** %2 to i8*
store i64 0, i64* @errno
%4 = call i64 @strtol(i8* %0, i8** %2, i32 10)
%5 = load i64, i64* @errno
%6 = icmp eq i64 %5, 0
br i1 %6, label %9, label %7
7: ; preds = %1
%8 = tail call i32 @errExit(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
br label %9
9: ; preds = %7, %1
%10 = load i8*, i8** %2
%11 = load i8, i8* %10
%12 = icmp eq i8 %11, 0
br i1 %12, label %15, label %13
13: ; preds = %9
%14 = tail call i32 @errExit(i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str.1, i64 0, i64 0))
br label %15
15: ; preds = %13, %9
ret i64 %4
}