#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 LONG_MAX;
long LONG_MIN;
int /*<<< orphan*/ error(char *);
long strtol(char const *, char **, int);
long getInt(const char *arg) {
  long narg;
  char *endptr;
  narg = strtol(arg, &endptr, 10);
  if (endptr == arg || narg == LONG_MIN || narg == LONG_MAX) {
    error("%s is not an int");
  }
  return narg;
}


x86 assembly (clang, -O0):
<getInt>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
lea    -0x18(%rbp),%rsi
mov    $0xa,%edx
call   1030 <strtol@plt>
mov    %rax,-0x10(%rbp)
mov    -0x18(%rbp),%rax
cmp    -0x8(%rbp),%rax
je     1178 <getInt+0x58>
mov    -0x10(%rbp),%rax
mov    0x2e8d(%rip),%rcx
cmp    (%rcx),%rax
je     1178 <getInt+0x58>
mov    -0x10(%rbp),%rax
mov    0x2e69(%rip),%rcx
cmp    (%rcx),%rax
jne    1184 <getInt+0x64>
lea    0xe81(%rip),%rdi
call   1040 <error@plt>
mov    -0x10(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getInt>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%rbx
mov    %rsp,%rsi
mov    $0xa,%edx
call   1030 <strtol@plt>
mov    %rax,%r14
cmp    %rbx,(%rsp)
je     1155 <getInt+0x35>
mov    0x2ea4(%rip),%rax
cmp    (%rax),%r14
je     1155 <getInt+0x35>
mov    0x2e88(%rip),%rax
cmp    (%rax),%r14
jne    1161 <getInt+0x41>
lea    0xea4(%rip),%rdi
call   1040 <error@plt>
mov    %r14,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@LONG_MIN = global i64 0
@LONG_MAX = global i64 0
@.str = [17 x i8] c"%s is not an int\00"
define i64 @getInt(i8* %0) {
%2 = alloca i8*
%3 = alloca i64
%4 = alloca i8*
store i8* %0, i8** %2
%5 = load i8*, i8** %2
%6 = call i64 @strtol(i8* %5, i8** %4, i32 10)
store i64 %6, i64* %3
%7 = load i8*, i8** %4
%8 = load i8*, i8** %2
%9 = icmp eq i8* %7, %8
br i1 %9, label %18, label %10
10: ; preds = %1
%11 = load i64, i64* %3
%12 = load i64, i64* @LONG_MIN
%13 = icmp eq i64 %11, %12
br i1 %13, label %18, label %14
14: ; preds = %10
%15 = load i64, i64* %3
%16 = load i64, i64* @LONG_MAX
%17 = icmp eq i64 %15, %16
br i1 %17, label %18, label %20
18: ; preds = %14, %10, %1
%19 = call i32 @error(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0))
br label %20
20: ; preds = %18, %14
%21 = load i64, i64* %3
ret i64 %21
}

LLVM IR (-O2):
@LONG_MIN = global i64 0
@LONG_MAX = global i64 0
@.str = [17 x i8] c"%s is not an int\00"
define i64 @getInt(i8* %0) {
%2 = alloca i8*
%3 = bitcast i8** %2 to i8*
%4 = call i64 @strtol(i8* %0, i8** %2, i32 10)
%5 = load i8*, i8** %2
%6 = icmp eq i8* %5, %0
%7 = load i64, i64* @LONG_MIN
%8 = icmp eq i64 %4, %7
%9 = select i1 %6, i1 true, i1 %8
%10 = load i64, i64* @LONG_MAX
%11 = icmp eq i64 %4, %10
%12 = select i1 %9, i1 true, i1 %11
br i1 %12, label %13, label %15
13: ; preds = %1
%14 = tail call i32 @error(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0))
br label %15
15: ; preds = %1, %13
ret i64 %4
}