#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);
int strlen(char const *);
int is_int(const char *str) {
  int i;
  int str_len = strlen(str);
  if (str_len < 1)
    return 0;
  if (str[0] == 0)
    return 0;
  for (i = 0; i < str_len; ++i) {
    if (!isdigit(str[i]))
      return 0;
  }
  return 1;
}


x86 assembly (clang, -O0):
<is_int>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0x1,-0x18(%rbp)
jge    114e <is_int+0x2e>
movl   $0x0,-0x4(%rbp)
jmp    11bd <is_int+0x9d>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
jne    116a <is_int+0x4a>
movl   $0x0,-0x4(%rbp)
jmp    11bd <is_int+0x9d>
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x18(%rbp),%eax
jge    11b6 <is_int+0x96>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
movsbl (%rax,%rcx,1),%edi
call   1030 <isdigit@plt>
cmp    $0x0,%eax
jne    11a3 <is_int+0x83>
movl   $0x0,-0x4(%rbp)
jmp    11bd <is_int+0x9d>
jmp    11a8 <is_int+0x88>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1171 <is_int+0x51>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<is_int>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rdi,%rbx
call   1040 <strlen@plt>
xor    %r14d,%r14d
test   %eax,%eax
jle    117e <is_int+0x5e>
mov    %eax,%ebp
mov    (%rbx),%al
test   %al,%al
je     117e <is_int+0x5e>
movsbl %al,%edi
call   1030 <isdigit@plt>
test   %eax,%eax
je     117e <is_int+0x5e>
mov    %ebp,%r15d
mov    $0x1,%ebp
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
cmp    %rbp,%r15
je     1178 <is_int+0x58>
movsbl (%rbx,%rbp,1),%edi
call   1030 <isdigit@plt>
add    $0x1,%rbp
test   %eax,%eax
jne    1160 <is_int+0x40>
jmp    117e <is_int+0x5e>
mov    $0x1,%r14d
mov    %r14d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

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

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