#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*/ isdigit(char const);
bool is_integer(const char *str) {
  if (*str == '-')
    str++;
  if (*str == '\0')
    return false;
  while (*str) {
    if (!isdigit(*str))
      return false;
    str++;
  }
  return true;
}


x86 assembly (clang, -O0):
<is_integer>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2d,%eax
jne    1138 <is_integer+0x28>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
jne    1154 <is_integer+0x44>
movl   $0x0,-0x4(%rbp)
jmp    119f <is_integer+0x8f>
jmp    1159 <is_integer+0x49>
mov    -0x10(%rbp),%rax
cmpb   $0x0,(%rax)
je     1198 <is_integer+0x88>
mov    -0x10(%rbp),%rax
movsbl (%rax),%edi
call   1030 <isdigit@plt>
cmp    $0x0,%eax
jne    1187 <is_integer+0x77>
movl   $0x0,-0x4(%rbp)
jmp    119f <is_integer+0x8f>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    1159 <is_integer+0x49>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<is_integer>:
push   %rbp
push   %rbx
push   %rax
xor    %ecx,%ecx
cmpb   $0x2d,(%rdi)
sete   %cl
mov    (%rdi,%rcx,1),%al
xor    %ebp,%ebp
test   %al,%al
je     114c <is_integer+0x3c>
lea    (%rcx,%rdi,1),%rbx
add    $0x1,%rbx
nopl   0x0(%rax)
movsbl %al,%edi
call   1030 <isdigit@plt>
test   %eax,%eax
je     114c <is_integer+0x3c>
movzbl (%rbx),%eax
add    $0x1,%rbx
test   %al,%al
jne    1130 <is_integer+0x20>
mov    $0x1,%ebp
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
define i32 @is_integer(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
store i8* %0, i8** %3
%4 = load i8*, i8** %3
%5 = load i8, i8* %4
%6 = sext i8 %5 to i32
%7 = icmp eq i32 %6, 45
br i1 %7, label %8, label %11
8: ; preds = %1
%9 = load i8*, i8** %3
%10 = getelementptr inbounds i8, i8* %9, i32 1
store i8* %10, i8** %3
br label %11
11: ; preds = %8, %1
%12 = load i8*, i8** %3
%13 = load i8, i8* %12
%14 = sext i8 %13 to i32
%15 = icmp eq i32 %14, 0
br i1 %15, label %16, label %17
16: ; preds = %11
store i32 0, i32* %2
br label %32
17: ; preds = %11
br label %18
18: ; preds = %28, %17
%19 = load i8*, i8** %3
%20 = load i8, i8* %19
%21 = icmp ne i8 %20, 0
br i1 %21, label %22, label %31
22: ; preds = %18
%23 = load i8*, i8** %3
%24 = load i8, i8* %23
%25 = call i32 @isdigit(i8 signext %24)
%26 = icmp ne i32 %25, 0
br i1 %26, label %28, label %27
27: ; preds = %22
store i32 0, i32* %2
br label %32
28: ; preds = %22
%29 = load i8*, i8** %3
%30 = getelementptr inbounds i8, i8* %29, i32 1
store i8* %30, i8** %3
br label %18
31: ; preds = %18
store i32 1, i32* %2
br label %32
32: ; preds = %31, %27, %16
%33 = load i32, i32* %2
ret i32 %33
}

LLVM IR (-O2):
define i32 @is_integer(i8* nocapture %0) {
%2 = load i8, i8* %0
%3 = icmp eq i8 %2, 45
%4 = zext i1 %3 to i64
%5 = getelementptr i8, i8* %0, i64 %4
%6 = load i8, i8* %5
%7 = icmp eq i8 %6, 0
br i1 %7, label %17, label %8
8: ; preds = %1, %13
%9 = phi i8* [ %14, %13 ], [ %5, %1 ]
%10 = phi i8 [ %15, %13 ], [ %6, %1 ]
%11 = tail call i32 @isdigit(i8 signext %10)
%12 = icmp eq i32 %11, 0
br i1 %12, label %17, label %13
13: ; preds = %8
%14 = getelementptr inbounds i8, i8* %9, i64 1
%15 = load i8, i8* %14
%16 = icmp eq i8 %15, 0
br i1 %16, label %17, label %8
17: ; preds = %8, %13, %1
%18 = phi i32 [ 0, %1 ], [ 0, %8 ], [ 1, %13 ]
ret i32 %18
}