#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 sscanf(char const *, char *, long *, char *);
int strlen(char const *);
int isint(const register char *string, long int *result) {
  int i;
  char junk = '\0';
  for (i = 0; i < strlen(string); i++)
    if (!isdigit(string[i]))
      return 0;
  if ((sscanf(string, "%ld%c", result, &junk) == 1) || junk != '\0')
    return 1;
  else
    return 0;
}


x86 assembly (clang, -O0):
<isint>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
movb   $0x0,-0x1d(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
mov    %eax,-0x24(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,%ecx
mov    -0x24(%rbp),%eax
cmp    %ecx,%eax
jge    11a0 <isint+0x70>
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movsbl (%rax,%rcx,1),%edi
call   1030 <isdigit@plt>
cmp    $0x0,%eax
jne    118d <isint+0x5d>
movl   $0x0,-0x4(%rbp)
jmp    11e1 <isint+0xb1>
jmp    1192 <isint+0x62>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    114b <isint+0x1b>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rdx
lea    0xe51(%rip),%rsi
lea    -0x1d(%rbp),%rcx
call   1050 <sscanf@plt>
cmp    $0x1,%eax
je     11ce <isint+0x9e>
movsbl -0x1d(%rbp),%eax
cmp    $0x0,%eax
je     11da <isint+0xaa>
movl   $0x1,-0x4(%rbp)
jmp    11e1 <isint+0xb1>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<isint>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%r12
movb   $0x0,0x7(%rsp)
call   1040 <strlen@plt>
test   %eax,%eax
jle    1181 <isint+0x51>
xor    %r15d,%r15d
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
movsbl (%r12,%rbx,1),%edi
call   1030 <isdigit@plt>
test   %eax,%eax
je     11ac <isint+0x7c>
add    $0x1,%rbx
mov    %r12,%rdi
call   1040 <strlen@plt>
cltq
cmp    %rax,%rbx
jl     1160 <isint+0x30>
lea    0xe78(%rip),%rsi
lea    0x7(%rsp),%rcx
mov    %r12,%rdi
mov    %r14,%rdx
call   1050 <sscanf@plt>
cmp    $0x1,%eax
sete   %al
cmpb   $0x0,0x7(%rsp)
setne  %cl
or     %al,%cl
movzbl %cl,%r15d
mov    %r15d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
@.str = [6 x i8] c"%ld%c\00"
define i32 @isint(i8* %0, i64* %1) {
%3 = alloca i8
store i8 0, i8* %3
%4 = tail call i32 @strlen(i8* %0)
%5 = icmp sgt i32 %4, 0
br i1 %5, label %10, label %17
6: ; preds = %10
%7 = tail call i32 @strlen(i8* %0)
%8 = sext i32 %7 to i64
%9 = icmp slt i64 %16, %8
br i1 %9, label %10, label %17
10: ; preds = %2, %6
%11 = phi i64 [ %16, %6 ], [ 0, %2 ]
%12 = getelementptr inbounds i8, i8* %0, i64 %11
%13 = load i8, i8* %12
%14 = tail call i32 @isdigit(i8 signext %13)
%15 = icmp eq i32 %14, 0
%16 = add nuw nsw i64 %11, 1
br i1 %15, label %24, label %6
17: ; preds = %6, %2
%18 = call i32 @sscanf(i8* %0, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i64* %1, i8* %3)
%19 = icmp eq i32 %18, 1
%20 = load i8, i8* %3
%21 = icmp ne i8 %20, 0
%22 = select i1 %19, i1 true, i1 %21
%23 = zext i1 %22 to i32
br label %24
24: ; preds = %10, %17
%25 = phi i32 [ %23, %17 ], [ 0, %10 ]
ret i32 %25
}