#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 */
typedef int /*<<< orphan*/ buf;

/* Variables and functions */
scalar_t__ EINVAL;
scalar_t__ ERANGE;
scalar_t__ LLONG_MAX;
scalar_t__ errno;
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char const *, char *);
int /*<<< orphan*/ snprintf(char *, int, char *, unsigned long long);
int /*<<< orphan*/ stderr;
long long strtoll(char const *, char **, int);
int _strtoll(char const *progname) {
  char *p;
  char const spaces[] = "      ";
  long long ll;
  unsigned long long llu;
  char buf[32];
  errno = 0;
  strtoll(spaces, &p, 0);
  if (p != spaces || errno != ERANGE) {
    fprintf(stderr, "%s: %s: Conversion error (spaces)\n", progname, "strtol");
    return 1;
  }
  llu = (unsigned long long)LLONG_MAX + 1;
  snprintf(buf, sizeof(buf), "-%llu", llu);
  errno = 0;
  ll = strtoll(buf, &p, 10);
  if (errno != 0) {
    fprintf(stderr, "%s: %s: Conversion error (-LLONG_MAX - 1)\n", progname,
            "strtoll");
    return 1;
  }
  llu = (unsigned long)LLONG_MAX + 2;
  snprintf(buf, sizeof(buf), "-%llu", llu);
  errno = 0;
  strtoll(buf, &p, 10);
  if (errno != ERANGE) {
    fprintf(stderr, "%s: %s: Conversion error (-LLONG_MAX - 2)\n", progname,
            "strtoll");
    return 1;
  }
  ll = strtoll("invalid", &p, 0);
  if (ll != 0 || errno != EINVAL) {
    fprintf(stderr, "%s: %s: Conversion error (invalid input)\n", progname,
            "strtoll");
    return 1;
  }
  return 0;
}


x86 assembly (clang, -O0):
<_strtoll>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x10(%rbp)
mov    0xebe(%rip),%eax
mov    %eax,-0x1f(%rbp)
mov    0xeb8(%rip),%ax
mov    %ax,-0x1b(%rbp)
mov    0xeb0(%rip),%al
mov    %al,-0x19(%rbp)
mov    0x2e68(%rip),%rax
movq   $0x0,(%rax)
lea    -0x1f(%rbp),%rdi
lea    -0x18(%rbp),%rsi
xor    %edx,%edx
call   1040 <strtoll@plt>
mov    -0x18(%rbp),%rax
lea    -0x1f(%rbp),%rcx
cmp    %rcx,%rax
jne    11a1 <_strtoll+0x71>
mov    0x2e3a(%rip),%rax
mov    (%rax),%rax
mov    0x2e50(%rip),%rcx
cmp    (%rcx),%rax
je     11cd <_strtoll+0x9d>
mov    0x2e28(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rdx
lea    0xe52(%rip),%rsi
lea    0xe6e(%rip),%rcx
call   1050 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1358 <_strtoll+0x228>
mov    0x2e0c(%rip),%rax
mov    (%rax),%rax
add    $0x1,%rax
mov    %rax,-0x30(%rbp)
lea    -0x50(%rbp),%rdi
mov    -0x30(%rbp),%rcx
mov    $0x20,%esi
lea    0xe3e(%rip),%rdx
call   1030 <snprintf@plt>
mov    0x2dc9(%rip),%rax
movq   $0x0,(%rax)
lea    -0x50(%rbp),%rdi
lea    -0x18(%rbp),%rsi
mov    $0xa,%edx
call   1040 <strtoll@plt>
mov    %rax,-0x28(%rbp)
mov    0x2da5(%rip),%rax
cmpq   $0x0,(%rax)
je     1259 <_strtoll+0x129>
mov    0x2d9c(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rdx
lea    0xdf6(%rip),%rsi
lea    0xe1a(%rip),%rcx
call   1050 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1358 <_strtoll+0x228>
mov    0x2d80(%rip),%rax
mov    (%rax),%rax
add    $0x2,%rax
mov    %rax,-0x30(%rbp)
lea    -0x50(%rbp),%rdi
mov    -0x30(%rbp),%rcx
mov    $0x20,%esi
lea    0xdb2(%rip),%rdx
call   1030 <snprintf@plt>
mov    0x2d3d(%rip),%rax
movq   $0x0,(%rax)
lea    -0x50(%rbp),%rdi
lea    -0x18(%rbp),%rsi
mov    $0xa,%edx
call   1040 <strtoll@plt>
mov    0x2d1d(%rip),%rax
mov    (%rax),%rax
mov    0x2d33(%rip),%rcx
cmp    (%rcx),%rax
je     12ea <_strtoll+0x1ba>
mov    0x2d0b(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rdx
lea    0xd98(%rip),%rsi
lea    0xd89(%rip),%rcx
call   1050 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1358 <_strtoll+0x228>
lea    0xda4(%rip),%rdi
lea    -0x18(%rbp),%rsi
xor    %edx,%edx
call   1040 <strtoll@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    1325 <_strtoll+0x1f5>
mov    0x2cb6(%rip),%rax
mov    (%rax),%rax
mov    0x2ca4(%rip),%rcx
cmp    (%rcx),%rax
je     1351 <_strtoll+0x221>
mov    0x2ca4(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rdx
lea    0xd64(%rip),%rsi
lea    0xd22(%rip),%rcx
call   1050 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1358 <_strtoll+0x228>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<_strtoll>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x30,%rsp
mov    %rdi,%rbx
movl   $0x202020,0xb(%rsp)
movl   $0x20202020,0x8(%rsp)
20
mov    0x2e72(%rip),%r14
movq   $0x0,(%r14)
lea    0x8(%rsp),%rbp
mov    %rsp,%rsi
mov    %rbp,%rdi
xor    %edx,%edx
call   1040 <strtoll@plt>
cmp    %rbp,(%rsp)
jne    11de <_strtoll+0xae>
mov    (%r14),%rax
mov    0x2e69(%rip),%r15
cmp    (%r15),%rax
jne    11de <_strtoll+0xae>
mov    0x2e55(%rip),%r12
mov    (%r12),%rcx
add    $0x1,%rcx
lea    0xe97(%rip),%rdx
lea    0x10(%rsp),%rbp
mov    %rbp,%rdi
mov    $0x20,%esi
call   1030 <snprintf@plt>
movq   $0x0,(%r14)
mov    %rsp,%rsi
mov    %rbp,%rdi
mov    $0xa,%edx
call   1040 <strtoll@plt>
cmpq   $0x0,(%r14)
je     1211 <_strtoll+0xe1>
mov    0x2e00(%rip),%rax
mov    (%rax),%edi
lea    0xe5e(%rip),%rsi
jmp    129a <_strtoll+0x16a>
mov    0x2deb(%rip),%rax
mov    (%rax),%edi
lea    0xe19(%rip),%rsi
lea    0xe35(%rip),%rcx
mov    %rbx,%rdx
call   1050 <fprintf@plt>
mov    $0x1,%ebp
mov    %ebp,%eax
add    $0x30,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret
mov    (%r12),%rcx
add    $0x2,%rcx
lea    0xe11(%rip),%rdx
lea    0x10(%rsp),%rbp
mov    %rbp,%rdi
mov    $0x20,%esi
call   1030 <snprintf@plt>
movq   $0x0,(%r14)
mov    %rsp,%rsi
mov    %rbp,%rdi
mov    $0xa,%edx
call   1040 <strtoll@plt>
mov    (%r14),%rax
cmp    (%r15),%rax
jne    128a <_strtoll+0x15a>
lea    0xe3d(%rip),%rdi
mov    %rsp,%rsi
xor    %ebp,%ebp
xor    %edx,%edx
call   1040 <strtoll@plt>
test   %rax,%rax
jne    1278 <_strtoll+0x148>
mov    (%r14),%rax
mov    0x2d4d(%rip),%rcx
cmp    (%rcx),%rax
je     1202 <_strtoll+0xd2>
mov    0x2d51(%rip),%rax
mov    (%rax),%edi
lea    0xe15(%rip),%rsi
jmp    129a <_strtoll+0x16a>
mov    0x2d3f(%rip),%rax
mov    (%rax),%edi
lea    0xdd0(%rip),%rsi
lea    0xdc1(%rip),%rcx
jmp    11f5 <_strtoll+0xc5>

LLVM IR (-O0):
@__const._strtoll.spaces = [7 x i8] c" \00"
@errno = global i64 0
@ERANGE = global i64 0
@stderr = global i32 0
@.str = [35 x i8] c"%s: %s: Conversion error (spaces)\0A\00"
@.str.1 = [7 x i8] c"strtol\00"
@LLONG_MAX = global i64 0
@.str.2 = [6 x i8] c"-%llu\00"
@.str.3 = [43 x i8] c"%s: %s: Conversion error (-LLONG_MAX - 1)\0A\00"
@.str.4 = [8 x i8] c"strtoll\00"
@.str.5 = [43 x i8] c"%s: %s: Conversion error (-LLONG_MAX - 2)\0A\00"
@.str.6 = [8 x i8] c"invalid\00"
@EINVAL = global i64 0
@.str.7 = [42 x i8] c"%s: %s: Conversion error (invalid input)\0A\00"
define i32 @_strtoll(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca [7 x i8]
%6 = alloca i64
%7 = alloca i64
%8 = alloca [32 x i8]
store i8* %0, i8** %3
%9 = bitcast [7 x i8]* %5 to i8*
store i64 0, i64* @errno
%10 = getelementptr inbounds [7 x i8], [7 x i8]* %5, i64 0, i64 0
%11 = call i64 @strtoll(i8* %10, i8** %4, i32 0)
%12 = load i8*, i8** %4
%13 = getelementptr inbounds [7 x i8], [7 x i8]* %5, i64 0, i64 0
%14 = icmp ne i8* %12, %13
br i1 %14, label %19, label %15
15: ; preds = %1
%16 = load i64, i64* @errno
%17 = load i64, i64* @ERANGE
%18 = icmp ne i64 %16, %17
br i1 %18, label %19, label %23
19: ; preds = %15, %1
%20 = load i32, i32* @stderr
%21 = load i8*, i8** %3
%22 = call i32 @fprintf(i32 %20, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str, i64 0, i64 0), i8* %21, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
store i32 1, i32* %2
br label %65
23: ; preds = %15
%24 = load i64, i64* @LLONG_MAX
%25 = add i64 %24, 1
store i64 %25, i64* %7
%26 = getelementptr inbounds [32 x i8], [32 x i8]* %8, i64 0, i64 0
%27 = load i64, i64* %7
%28 = call i32 @snprintf(i8* %26, i32 32, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i64 %27)
store i64 0, i64* @errno
%29 = getelementptr inbounds [32 x i8], [32 x i8]* %8, i64 0, i64 0
%30 = call i64 @strtoll(i8* %29, i8** %4, i32 10)
store i64 %30, i64* %6
%31 = load i64, i64* @errno
%32 = icmp ne i64 %31, 0
br i1 %32, label %33, label %37
33: ; preds = %23
%34 = load i32, i32* @stderr
%35 = load i8*, i8** %3
%36 = call i32 @fprintf(i32 %34, i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.3, i64 0, i64 0), i8* %35, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0))
store i32 1, i32* %2
br label %65
37: ; preds = %23
%38 = load i64, i64* @LLONG_MAX
%39 = add i64 %38, 2
store i64 %39, i64* %7
%40 = getelementptr inbounds [32 x i8], [32 x i8]* %8, i64 0, i64 0
%41 = load i64, i64* %7
%42 = call i32 @snprintf(i8* %40, i32 32, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i64 %41)
store i64 0, i64* @errno
%43 = getelementptr inbounds [32 x i8], [32 x i8]* %8, i64 0, i64 0
%44 = call i64 @strtoll(i8* %43, i8** %4, i32 10)
%45 = load i64, i64* @errno
%46 = load i64, i64* @ERANGE
%47 = icmp ne i64 %45, %46
br i1 %47, label %48, label %52
48: ; preds = %37
%49 = load i32, i32* @stderr
%50 = load i8*, i8** %3
%51 = call i32 @fprintf(i32 %49, i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.5, i64 0, i64 0), i8* %50, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0))
store i32 1, i32* %2
br label %65
52: ; preds = %37
%53 = call i64 @strtoll(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.6, i64 0, i64 0), i8** %4, i32 0)
store i64 %53, i64* %6
%54 = load i64, i64* %6
%55 = icmp ne i64 %54, 0
br i1 %55, label %60, label %56
56: ; preds = %52
%57 = load i64, i64* @errno
%58 = load i64, i64* @EINVAL
%59 = icmp ne i64 %57, %58
br i1 %59, label %60, label %64
60: ; preds = %56, %52
%61 = load i32, i32* @stderr
%62 = load i8*, i8** %3
%63 = call i32 @fprintf(i32 %61, i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.7, i64 0, i64 0), i8* %62, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0))
store i32 1, i32* %2
br label %65
64: ; preds = %56
store i32 0, i32* %2
br label %65
65: ; preds = %64, %60, %48, %33, %19
%66 = load i32, i32* %2
ret i32 %66
}

LLVM IR (-O2):
@__const._strtoll.spaces = [7 x i8] c" \00"
@errno = global i64 0
@ERANGE = global i64 0
@stderr = global i32 0
@.str = [35 x i8] c"%s: %s: Conversion error (spaces)\0A\00"
@.str.1 = [7 x i8] c"strtol\00"
@LLONG_MAX = global i64 0
@.str.2 = [6 x i8] c"-%llu\00"
@.str.3 = [43 x i8] c"%s: %s: Conversion error (-LLONG_MAX - 1)\0A\00"
@.str.4 = [8 x i8] c"strtoll\00"
@.str.5 = [43 x i8] c"%s: %s: Conversion error (-LLONG_MAX - 2)\0A\00"
@.str.6 = [8 x i8] c"invalid\00"
@EINVAL = global i64 0
@.str.7 = [42 x i8] c"%s: %s: Conversion error (invalid input)\0A\00"
define i32 @_strtoll(i8* %0) {
%2 = alloca i8*
%3 = alloca [7 x i8]
%4 = alloca [32 x i8]
%5 = bitcast i8** %2 to i8*
%6 = getelementptr inbounds [7 x i8], [7 x i8]* %3, i64 0, i64 0
%7 = getelementptr inbounds [32 x i8], [32 x i8]* %4, i64 0, i64 0
store i64 0, i64* @errno
%8 = call i64 @strtoll(i8* %6, i8** %2, i32 0)
%9 = load i8*, i8** %2
%10 = icmp eq i8* %9, %6
br i1 %10, label %11, label %15
11: ; preds = %1
%12 = load i64, i64* @errno
%13 = load i64, i64* @ERANGE
%14 = icmp eq i64 %12, %13
br i1 %14, label %18, label %15
15: ; preds = %11, %1
%16 = load i32, i32* @stderr
%17 = call i32 @fprintf(i32 %16, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str, i64 0, i64 0), i8* %0, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
br label %49
18: ; preds = %11
%19 = load i64, i64* @LLONG_MAX
%20 = add i64 %19, 1
%21 = call i32 @snprintf(i8* %7, i32 32, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i64 %20)
store i64 0, i64* @errno
%22 = call i64 @strtoll(i8* %7, i8** %2, i32 10)
%23 = load i64, i64* @errno
%24 = icmp eq i64 %23, 0
br i1 %24, label %28, label %25
25: ; preds = %18
%26 = load i32, i32* @stderr
%27 = call i32 @fprintf(i32 %26, i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.3, i64 0, i64 0), i8* %0, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0))
br label %49
28: ; preds = %18
%29 = load i64, i64* @LLONG_MAX
%30 = add i64 %29, 2
%31 = call i32 @snprintf(i8* %7, i32 32, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i64 %30)
store i64 0, i64* @errno
%32 = call i64 @strtoll(i8* %7, i8** %2, i32 10)
%33 = load i64, i64* @errno
%34 = load i64, i64* @ERANGE
%35 = icmp eq i64 %33, %34
br i1 %35, label %39, label %36
36: ; preds = %28
%37 = load i32, i32* @stderr
%38 = call i32 @fprintf(i32 %37, i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.5, i64 0, i64 0), i8* %0, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0))
br label %49
39: ; preds = %28
%40 = call i64 @strtoll(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.6, i64 0, i64 0), i8** %2, i32 0)
%41 = icmp eq i64 %40, 0
br i1 %41, label %42, label %46
42: ; preds = %39
%43 = load i64, i64* @errno
%44 = load i64, i64* @EINVAL
%45 = icmp eq i64 %43, %44
br i1 %45, label %49, label %46
46: ; preds = %42, %39
%47 = load i32, i32* @stderr
%48 = call i32 @fprintf(i32 %47, i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.7, i64 0, i64 0), i8* %0, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0))
br label %49
49: ; preds = %42, %46, %36, %25, %15
%50 = phi i32 [ 1, %15 ], [ 1, %25 ], [ 1, %36 ], [ 1, %46 ], [ 0, %42 ]
ret i32 %50
}