#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__ isspace(char const);
unsigned long long strtoull(char const *, char **, int);
long long int strtoll(const char *nptr, char **endptr, int base) {
  long long int ret = 0;
  unsigned long long int uret;
  int signe = 1;
  const char *bckp = nptr;
  while (isspace(*(bckp)))
    bckp++;
  if (*bckp == '+') {
    signe = 1;
    bckp++;
  } else if (*bckp == '-') {
    signe = -1;
    bckp++;
  }
  uret = strtoull(nptr, endptr, base);
  ret = signe * (long long int)uret;
  return ret;
}


x86 assembly (clang, -O0):
<strtoll>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
movq   $0x0,-0x20(%rbp)
movl   $0x1,-0x2c(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    -0x38(%rbp),%rax
movsbl (%rax),%edi
call   1030 <isspace@plt>
cmp    $0x0,%rax
je     1171 <strtoll+0x51>
mov    -0x38(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x38(%rbp)
jmp    114a <strtoll+0x2a>
mov    -0x38(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2b,%eax
jne    1199 <strtoll+0x79>
movl   $0x1,-0x2c(%rbp)
mov    -0x38(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x38(%rbp)
jmp    11c1 <strtoll+0xa1>
mov    -0x38(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2d,%eax
jne    11bc <strtoll+0x9c>
movl   $0xffffffff,-0x2c(%rbp)
mov    -0x38(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x38(%rbp)
jmp    11c1 <strtoll+0xa1>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x14(%rbp),%edx
call   1040 <strtoull@plt>
mov    %rax,-0x28(%rbp)
movslq -0x2c(%rbp),%rax
imul   -0x28(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<strtoll>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %edx,%r14d
mov    %rsi,%r15
mov    %rdi,%rbx
mov    %rdi,%rbp
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
movsbl 0x0(%rbp),%edi
call   1030 <isspace@plt>
add    $0x1,%rbp
test   %rax,%rax
jne    1140 <strtoll+0x20>
mov    -0x1(%rbp),%bpl
mov    %rbx,%rdi
mov    %r15,%rsi
mov    %r14d,%edx
call   1040 <strtoull@plt>
mov    %rax,%rcx
neg    %rcx
cmp    $0x2d,%bpl
cmove  %rcx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
define i64 @strtoll(i8* %0, i8** nocapture %1, i32 %2) {
br label %4
4: ; preds = %4, %3
%5 = phi i8* [ %0, %3 ], [ %9, %4 ]
%6 = load i8, i8* %5
%7 = tail call i64 @isspace(i8 signext %6)
%8 = icmp eq i64 %7, 0
%9 = getelementptr inbounds i8, i8* %5, i64 1
br i1 %8, label %10, label %4
10: ; preds = %4
%11 = load i8, i8* %5
%12 = icmp eq i8 %11, 45
%13 = tail call i64 @strtoull(i8* %0, i8** %1, i32 %2)
%14 = sub nsw i64 0, %13
%15 = select i1 %12, i64 %14, i64 %13
ret i64 %15
}