#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 */
scalar_t__ ERANGE;
scalar_t__ errno;
scalar_t__ isspace(char);
int /*<<< orphan*/ memcpy(char *, char const *, size_t);
long long strtoll(char *, char **, int);
int getLongLongFromObject(const char *_o, size_t len, long long *target) {
  long long value;
  char *eptr;
  if (_o == NULL) {
    value = 0;
  } else {
    if (len > 38) {
      return -1;
    }
    char o[40];
    memcpy(o, _o, len);
    o[len] = 0;
    errno = 0;
    value = strtoll(o, &eptr, 10);
    if (isspace(((char *)o)[0]) || eptr[0] != '\0' || errno == ERANGE) {
      return -1;
    }
  }
  if (target)
    *target = value;
  return 0;
}


x86 assembly (clang, -O0):
<getLongLongFromObject>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    115c <getLongLongFromObject+0x2c>
movq   $0x0,-0x28(%rbp)
jmp    11ff <getLongLongFromObject+0xcf>
cmpq   $0x26,-0x18(%rbp)
jbe    1173 <getLongLongFromObject+0x43>
movl   $0xffffffff,-0x4(%rbp)
jmp    121c <getLongLongFromObject+0xec>
lea    -0x60(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
call   1050 <memcpy@plt>
mov    -0x18(%rbp),%rax
movb   $0x0,-0x60(%rbp,%rax,1)
mov    0x2e44(%rip),%rax
movq   $0x0,(%rax)
lea    -0x60(%rbp),%rdi
lea    -0x30(%rbp),%rsi
mov    $0xa,%edx
call   1040 <strtoll@plt>
mov    %rax,-0x28(%rbp)
movsbl -0x60(%rbp),%edi
call   1030 <isspace@plt>
cmp    $0x0,%rax
jne    11ee <getLongLongFromObject+0xbe>
mov    -0x30(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
jne    11ee <getLongLongFromObject+0xbe>
mov    0x2dfd(%rip),%rax
mov    (%rax),%rax
mov    0x2e03(%rip),%rcx
cmp    (%rcx),%rax
jne    11fa <getLongLongFromObject+0xca>
movl   $0xffffffff,-0x4(%rbp)
jmp    121c <getLongLongFromObject+0xec>
jmp    11ff <getLongLongFromObject+0xcf>
cmpq   $0x0,-0x20(%rbp)
je     1215 <getLongLongFromObject+0xe5>
mov    -0x28(%rbp),%rcx
mov    -0x20(%rbp),%rax
mov    %rcx,(%rax)
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getLongLongFromObject>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x38,%rsp
mov    %rdx,%r14
xor    %r15d,%r15d
test   %rdi,%rdi
je     11b6 <getLongLongFromObject+0x86>
mov    %rsi,%rbx
mov    $0xffffffff,%ebp
cmp    $0x26,%rsi
ja     11c0 <getLongLongFromObject+0x90>
mov    %rdi,%rsi
lea    0x10(%rsp),%r15
mov    %r15,%rdi
mov    %rbx,%rdx
call   1050 <memcpy@plt>
movb   $0x0,0x10(%rsp,%rbx,1)
mov    0x2e66(%rip),%rbx
movq   $0x0,(%rbx)
lea    0x8(%rsp),%rsi
mov    %r15,%rdi
mov    $0xa,%edx
call   1040 <strtoll@plt>
mov    %rax,%r15
movsbl 0x10(%rsp),%edi
call   1030 <isspace@plt>
test   %rax,%rax
jne    11c0 <getLongLongFromObject+0x90>
mov    0x8(%rsp),%rax
cmpb   $0x0,(%rax)
jne    11c0 <getLongLongFromObject+0x90>
mov    (%rbx),%rax
mov    0x2e37(%rip),%rcx
cmp    (%rcx),%rax
je     11c0 <getLongLongFromObject+0x90>
test   %r14,%r14
je     11be <getLongLongFromObject+0x8e>
mov    %r15,(%r14)
xor    %ebp,%ebp
mov    %ebp,%eax
add    $0x38,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@errno = global i64 0
@ERANGE = global i64 0
define i32 @getLongLongFromObject(i8* %0, i64 %1, i64* %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i64
%7 = alloca i64*
%8 = alloca i64
%9 = alloca i8*
%10 = alloca [40 x i8]
store i8* %0, i8** %5
store i64 %1, i64* %6
store i64* %2, i64** %7
%11 = load i8*, i8** %5
%12 = icmp eq i8* %11, null
br i1 %12, label %13, label %14
13: ; preds = %3
store i64 0, i64* %8
br label %44
14: ; preds = %3
%15 = load i64, i64* %6
%16 = icmp ugt i64 %15, 38
br i1 %16, label %17, label %18
17: ; preds = %14
store i32 -1, i32* %4
br label %51
18: ; preds = %14
%19 = getelementptr inbounds [40 x i8], [40 x i8]* %10, i64 0, i64 0
%20 = load i8*, i8** %5
%21 = load i64, i64* %6
%22 = call i32 @memcpy(i8* %19, i8* %20, i64 %21)
%23 = load i64, i64* %6
%24 = getelementptr inbounds [40 x i8], [40 x i8]* %10, i64 0, i64 %23
store i8 0, i8* %24
store i64 0, i64* @errno
%25 = getelementptr inbounds [40 x i8], [40 x i8]* %10, i64 0, i64 0
%26 = call i64 @strtoll(i8* %25, i8** %9, i32 10)
store i64 %26, i64* %8
%27 = getelementptr inbounds [40 x i8], [40 x i8]* %10, i64 0, i64 0
%28 = getelementptr inbounds i8, i8* %27, i64 0
%29 = load i8, i8* %28
%30 = call i64 @isspace(i8 signext %29)
%31 = icmp ne i64 %30, 0
br i1 %31, label %42, label %32
32: ; preds = %18
%33 = load i8*, i8** %9
%34 = getelementptr inbounds i8, i8* %33, i64 0
%35 = load i8, i8* %34
%36 = sext i8 %35 to i32
%37 = icmp ne i32 %36, 0
br i1 %37, label %42, label %38
38: ; preds = %32
%39 = load i64, i64* @errno
%40 = load i64, i64* @ERANGE
%41 = icmp eq i64 %39, %40
br i1 %41, label %42, label %43
42: ; preds = %38, %32, %18
store i32 -1, i32* %4
br label %51
43: ; preds = %38
br label %44
44: ; preds = %43, %13
%45 = load i64*, i64** %7
%46 = icmp ne i64* %45, null
br i1 %46, label %47, label %50
47: ; preds = %44
%48 = load i64, i64* %8
%49 = load i64*, i64** %7
store i64 %48, i64* %49
br label %50
50: ; preds = %47, %44
store i32 0, i32* %4
br label %51
51: ; preds = %50, %42, %17
%52 = load i32, i32* %4
ret i32 %52
}

LLVM IR (-O2):
@errno = global i64 0
@ERANGE = global i64 0
define i32 @getLongLongFromObject(i8* %0, i64 %1, i64* writeonly %2) {
%4 = alloca i8*
%5 = alloca [40 x i8]
%6 = bitcast i8** %4 to i8*
%7 = icmp eq i8* %0, null
br i1 %7, label %28, label %8
8: ; preds = %3
%9 = icmp ugt i64 %1, 38
br i1 %9, label %32, label %10
10: ; preds = %8
%11 = getelementptr inbounds [40 x i8], [40 x i8]* %5, i64 0, i64 0
%12 = call i32 @memcpy(i8* %11, i8* %0, i64 %1)
%13 = getelementptr inbounds [40 x i8], [40 x i8]* %5, i64 0, i64 %1
store i8 0, i8* %13
store i64 0, i64* @errno
%14 = call i64 @strtoll(i8* %11, i8** %4, i32 10)
%15 = load i8, i8* %11
%16 = call i64 @isspace(i8 signext %15)
%17 = icmp eq i64 %16, 0
br i1 %17, label %18, label %26
18: ; preds = %10
%19 = load i8*, i8** %4
%20 = load i8, i8* %19
%21 = icmp eq i8 %20, 0
br i1 %21, label %22, label %26
22: ; preds = %18
%23 = load i64, i64* @errno
%24 = load i64, i64* @ERANGE
%25 = icmp eq i64 %23, %24
br i1 %25, label %26, label %27
26: ; preds = %10, %18, %22
br label %32
27: ; preds = %22
br label %28
28: ; preds = %27, %3
%29 = phi i64 [ 0, %3 ], [ %14, %27 ]
%30 = icmp eq i64* %2, null
br i1 %30, label %32, label %31
31: ; preds = %28
store i64 %29, i64* %2
br label %32
32: ; preds = %28, %31, %26, %8
%33 = phi i32 [ -1, %26 ], [ -1, %8 ], [ 0, %31 ], [ 0, %28 ]
ret i32 %33
}