#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);
scalar_t__ strlen(char *);
bool is_int_p(char *d) {
  for (int i = 0; i <= (int)strlen(d) - 1; i++) {
    if (i == 0 && d[i] == '-')
      continue;
    if (!(isdigit(d[i]))) {
      return false;
    }
  }
  return true;
}


x86 assembly (clang, -O0):
<is_int_p>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <strlen@plt>
mov    %rax,%rcx
mov    -0x18(%rbp),%eax
sub    $0x1,%ecx
cmp    %ecx,%eax
jg     11b0 <is_int_p+0x90>
cmpl   $0x0,-0x14(%rbp)
jne    1177 <is_int_p+0x57>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x2d,%eax
jne    1177 <is_int_p+0x57>
jmp    11a2 <is_int_p+0x82>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
movsbl (%rax,%rcx,1),%edi
call   1030 <isdigit@plt>
cmp    $0x0,%eax
jne    119d <is_int_p+0x7d>
movl   $0x0,-0x4(%rbp)
jmp    11b7 <is_int_p+0x97>
jmp    11a2 <is_int_p+0x82>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1133 <is_int_p+0x13>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<is_int_p>:
push   %rbp
push   %r14
push   %rbx
mov    %rdi,%rbx
call   1040 <strlen@plt>
mov    $0x1,%r14d
test   %eax,%eax
jle    116f <is_int_p+0x4f>
xor    %ebp,%ebp
jmp    1160 <is_int_p+0x40>
nopw   0x0(%rax,%rax,1)
movsbl (%rbx,%rbp,1),%edi
call   1030 <isdigit@plt>
test   %eax,%eax
je     116c <is_int_p+0x4c>
add    $0x1,%rbp
mov    %rbx,%rdi
call   1040 <strlen@plt>
cltq
cmp    %rax,%rbp
jge    116f <is_int_p+0x4f>
test   %rbp,%rbp
jne    1140 <is_int_p+0x20>
cmpb   $0x2d,(%rbx)
jne    1140 <is_int_p+0x20>
jmp    114d <is_int_p+0x2d>
xor    %r14d,%r14d
mov    %r14d,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

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

LLVM IR (-O2):
define i32 @is_int_p(i8* nocapture %0) {
%2 = tail call i64 @strlen(i8* dereferenceable(1) %0)
%3 = trunc i64 %2 to i32
%4 = icmp sgt i32 %3, 0
br i1 %4, label %5, label %22
5: ; preds = %1, %16
%6 = phi i64 [ %17, %16 ], [ 0, %1 ]
%7 = icmp eq i64 %6, 0
br i1 %7, label %8, label %11
8: ; preds = %5
%9 = load i8, i8* %0
%10 = icmp eq i8 %9, 45
br i1 %10, label %16, label %11
11: ; preds = %8, %5
%12 = getelementptr inbounds i8, i8* %0, i64 %6
%13 = load i8, i8* %12
%14 = tail call i32 @isdigit(i8 signext %13)
%15 = icmp eq i32 %14, 0
br i1 %15, label %22, label %16
16: ; preds = %11, %8
%17 = add nuw nsw i64 %6, 1
%18 = tail call i64 @strlen(i8* dereferenceable(1) %0)
%19 = shl i64 %18, 32
%20 = ashr exact i64 %19, 32
%21 = icmp slt i64 %17, %20
br i1 %21, label %5, label %22
22: ; preds = %16, %11, %1
%23 = phi i32 [ 1, %1 ], [ 0, %11 ], [ 1, %16 ]
ret i32 %23
}