#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 */
long strtol(char *, char **, int);
int isint(int *r, char *s) {
  char **endptr;
  char *p;
  long int l;
  if (s[0] == 0) {
    return (0);
  }
  endptr = &p;
  l = strtol(s, endptr, 10);
  if (**endptr != 0) {
    return (0);
  }
  *r = (int)l;
  return (-1);
}


x86 assembly (clang, -O0):
<isint>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
jne    113c <isint+0x2c>
movl   $0x0,-0x4(%rbp)
jmp    118c <isint+0x7c>
lea    -0x28(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%rsi
mov    $0xa,%edx
call   1030 <strtol@plt>
mov    %rax,-0x30(%rbp)
mov    -0x20(%rbp),%rax
mov    (%rax),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     1179 <isint+0x69>
movl   $0x0,-0x4(%rbp)
jmp    118c <isint+0x7c>
mov    -0x30(%rbp),%rax
mov    %eax,%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,(%rax)
movl   $0xffffffff,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<isint>:
push   %r14
push   %rbx
push   %rax
xor    %ebx,%ebx
cmpb   $0x0,(%rsi)
je     1142 <isint+0x32>
mov    %rdi,%r14
mov    %rsp,%rax
mov    %rsi,%rdi
mov    %rax,%rsi
mov    $0xa,%edx
call   1030 <strtol@plt>
mov    (%rsp),%rcx
cmpb   $0x0,(%rcx)
jne    1142 <isint+0x32>
mov    %eax,(%r14)
mov    $0xffffffff,%ebx
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

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

LLVM IR (-O2):
define i32 @isint(i32* nocapture writeonly %0, i8* %1) {
%3 = alloca i8*
%4 = bitcast i8** %3 to i8*
%5 = load i8, i8* %1
%6 = icmp eq i8 %5, 0
br i1 %6, label %14, label %7
7: ; preds = %2
%8 = call i64 @strtol(i8* %1, i8** %3, i32 10)
%9 = load i8*, i8** %3
%10 = load i8, i8* %9
%11 = icmp eq i8 %10, 0
br i1 %11, label %12, label %14
12: ; preds = %7
%13 = trunc i64 %8 to i32
store i32 %13, i32* %0
br label %14
14: ; preds = %7, %2, %12
%15 = phi i32 [ -1, %12 ], [ 0, %2 ], [ 0, %7 ]
ret i32 %15
}