#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__ ERANGE;
long INT_MAX;
long INT_MIN;
scalar_t__ errno;
scalar_t__ strlen(char const *);
scalar_t__ strspn(char const *, char *);
long strtol(char const *, int /*<<< orphan*/ *, int);
int is_integer(const char *number) {
  long int n;
  if (!number)
    return (0);
  if (strspn(number, "-0123456789 ") != strlen(number))
    return (0);
  errno = 0;
  n = strtol(number, NULL, 10);
  if (errno != ERANGE && n >= INT_MIN && n <= INT_MAX)
    return (1);
  else
    return (0);
}


x86 assembly (clang, -O0):
<is_integer>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    1153 <is_integer+0x23>
movl   $0x0,-0x4(%rbp)
jmp    1205 <is_integer+0xd5>
mov    -0x10(%rbp),%rdi
lea    0xea2(%rip),%rsi
call   1040 <strspn@plt>
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    %rax,%rcx
mov    -0x20(%rbp),%rax
cmp    %rcx,%rax
je     118c <is_integer+0x5c>
movl   $0x0,-0x4(%rbp)
jmp    1205 <is_integer+0xd5>
mov    0x2e35(%rip),%rax
movq   $0x0,(%rax)
mov    -0x10(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
mov    $0xa,%edx
call   1050 <strtol@plt>
mov    %rax,-0x18(%rbp)
mov    0x2e11(%rip),%rax
mov    (%rax),%rax
mov    0x2e17(%rip),%rcx
cmp    (%rcx),%rax
je     11fe <is_integer+0xce>
mov    -0x18(%rbp),%rax
mov    0x2e0b(%rip),%rcx
cmp    (%rcx),%rax
jl     11fe <is_integer+0xce>
mov    -0x18(%rbp),%rax
mov    0x2dff(%rip),%rcx
cmp    (%rcx),%rax
jg     11fe <is_integer+0xce>
movl   $0x1,-0x4(%rbp)
jmp    1205 <is_integer+0xd5>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<is_integer>:
push   %rbp
push   %r14
push   %rbx
xor    %ebp,%ebp
test   %rdi,%rdi
je     11aa <is_integer+0x7a>
mov    %rdi,%rbx
lea    0xebb(%rip),%rsi
call   1040 <strspn@plt>
mov    %rax,%r14
mov    %rbx,%rdi
call   1030 <strlen@plt>
cmp    %rax,%r14
jne    11aa <is_integer+0x7a>
mov    0x2e67(%rip),%rbp
movq   $0x0,0x0(%rbp)
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0xa,%edx
call   1050 <strtol@plt>
mov    0x0(%rbp),%rcx
mov    0x2e55(%rip),%rdx
cmp    (%rdx),%rcx
setne  %cl
mov    0x2e50(%rip),%rdx
cmp    (%rdx),%rax
setge  %dl
and    %cl,%dl
mov    0x2e49(%rip),%rcx
cmp    (%rcx),%rax
setle  %al
and    %dl,%al
movzbl %al,%ebp
mov    %ebp,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [13 x i8] c"-0123456789 \00"
@errno = global i64 0
@ERANGE = global i64 0
@INT_MIN = global i64 0
@INT_MAX = global i64 0
define i32 @is_integer(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i64
store i8* %0, i8** %3
%5 = load i8*, i8** %3
%6 = icmp ne i8* %5, null
br i1 %6, label %8, label %7
7: ; preds = %1
store i32 0, i32* %2
br label %31
8: ; preds = %1
%9 = load i8*, i8** %3
%10 = call i64 @strspn(i8* %9, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0))
%11 = load i8*, i8** %3
%12 = call i64 @strlen(i8* %11)
%13 = icmp ne i64 %10, %12
br i1 %13, label %14, label %15
14: ; preds = %8
store i32 0, i32* %2
br label %31
15: ; preds = %8
store i64 0, i64* @errno
%16 = load i8*, i8** %3
%17 = call i64 @strtol(i8* %16, i32* null, i32 10)
store i64 %17, i64* %4
%18 = load i64, i64* @errno
%19 = load i64, i64* @ERANGE
%20 = icmp ne i64 %18, %19
br i1 %20, label %21, label %30
21: ; preds = %15
%22 = load i64, i64* %4
%23 = load i64, i64* @INT_MIN
%24 = icmp sge i64 %22, %23
br i1 %24, label %25, label %30
25: ; preds = %21
%26 = load i64, i64* %4
%27 = load i64, i64* @INT_MAX
%28 = icmp sle i64 %26, %27
br i1 %28, label %29, label %30
29: ; preds = %25
store i32 1, i32* %2
br label %31
30: ; preds = %25, %21, %15
store i32 0, i32* %2
br label %31
31: ; preds = %30, %29, %14, %7
%32 = load i32, i32* %2
ret i32 %32
}

LLVM IR (-O2):
@.str = [13 x i8] c"-0123456789 \00"
@errno = global i64 0
@ERANGE = global i64 0
@INT_MIN = global i64 0
@INT_MAX = global i64 0
define i32 @is_integer(i8* %0) {
%2 = icmp eq i8* %0, null
br i1 %2, label %19, label %3
3: ; preds = %1
%4 = tail call i64 @strspn(i8* %0, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0))
%5 = tail call i64 @strlen(i8* %0)
%6 = icmp eq i64 %4, %5
br i1 %6, label %7, label %19
7: ; preds = %3
store i64 0, i64* @errno
%8 = tail call i64 @strtol(i8* nocapture %0, i32* null, i32 10)
%9 = load i64, i64* @errno
%10 = load i64, i64* @ERANGE
%11 = icmp ne i64 %9, %10
%12 = load i64, i64* @INT_MIN
%13 = icmp sge i64 %8, %12
%14 = select i1 %11, i1 %13, i1 false
%15 = load i64, i64* @INT_MAX
%16 = icmp sle i64 %8, %15
%17 = select i1 %14, i1 %16, i1 false
%18 = zext i1 %17 to i32
br label %19
19: ; preds = %7, %3, %1
%20 = phi i32 [ 0, %1 ], [ 0, %3 ], [ %18, %7 ]
ret i32 %20
}