#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 strlen(char *);
char *trim(char *);
int isint(char string[]) {
  char *newstring = trim(string);
  int i = 0, len = strlen(newstring) - 1;
  do {
    if (newstring[i] < 48 || newstring[i] > 57)
      return 0;
  } while (i++ < len);
  return 1;
}


x86 assembly (clang, -O0):
<isint>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <trim@plt>
mov    %rax,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x18(%rbp),%rdi
call   1030 <strlen@plt>
sub    $0x1,%eax
mov    %eax,-0x20(%rbp)
mov    -0x18(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x30,%eax
jl     1179 <isint+0x59>
mov    -0x18(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x39,%eax
jle    1185 <isint+0x65>
movl   $0x0,-0x4(%rbp)
jmp    11a5 <isint+0x85>
jmp    118a <isint+0x6a>
mov    -0x1c(%rbp),%eax
mov    %eax,%ecx
add    $0x1,%ecx
mov    %ecx,-0x1c(%rbp)
cmp    -0x20(%rbp),%eax
jl     114f <isint+0x2f>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<isint>:
push   %r14
push   %rbx
push   %rax
call   1040 <trim@plt>
mov    %rax,%r14
mov    %rax,%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
add    $0xffffffff,%ecx
xor    %eax,%eax
test   %ecx,%ecx
cmovle %eax,%ecx
add    $0x1,%ecx
xor    %edx,%edx
cs nopw 0x0(%rax,%rax,1)
nop
movzbl (%r14,%rdx,1),%ebx
add    $0xc6,%bl
cmp    $0xf6,%bl
jb     116b <isint+0x4b>
add    $0x1,%rdx
cmp    %rdx,%rcx
jne    1150 <isint+0x30>
mov    $0x1,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

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

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