#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 /*<<< orphan*/);
int parse_long(int argc, char *argv[], long *data) {
  char *p, *endp;
  if (argc < 1 || !data)
    return -1;
  p = argv[0];
  *data = strtol(p, &endp, 0);
  if (endp == p)
    return 0;
  return 1;
}


x86 assembly (clang, -O0):
<parse_long>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
cmpl   $0x1,-0x8(%rbp)
jl     1138 <parse_long+0x28>
cmpq   $0x0,-0x18(%rbp)
jne    1144 <parse_long+0x34>
movl   $0xffffffff,-0x4(%rbp)
jmp    1189 <parse_long+0x79>
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
lea    -0x28(%rbp),%rsi
xor    %edx,%edx
call   1030 <strtol@plt>
mov    %rax,%rcx
mov    -0x18(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x28(%rbp),%rax
cmp    -0x20(%rbp),%rax
jne    1182 <parse_long+0x72>
movl   $0x0,-0x4(%rbp)
jmp    1189 <parse_long+0x79>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<parse_long>:
push   %r14
push   %rbx
push   %rax
mov    $0xffffffff,%eax
test   %edi,%edi
jle    1141 <parse_long+0x31>
mov    %rdx,%rbx
test   %rdx,%rdx
je     1141 <parse_long+0x31>
mov    (%rsi),%r14
mov    %rsp,%rsi
mov    %r14,%rdi
xor    %edx,%edx
call   1030 <strtol@plt>
mov    %rax,(%rbx)
xor    %eax,%eax
cmp    %r14,(%rsp)
setne  %al
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

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

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