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

/* Variables and functions */
scalar_t__ ERANGE;
scalar_t__ errno;
int /*<<< orphan*/ strtoll(char const *, char **, int /*<<< orphan*/);
int /*<<< orphan*/ warn(char *, char const *, unsigned int);
int64_t signed64_value(const char *value, const char *filename,
                       unsigned linenum, int *error) {
  char *endptr;
  uint64_t ret;
  errno = 0;
  ret = strtoll(value, &endptr, 0);
  if (errno == ERANGE) {
    warn("Value out of range %s:%d", filename, linenum);
    *error = -1;
  }
  if (endptr == value) {
    warn("Bad integer value at %s:%d", filename, linenum);
    *error = -1;
  }
  return ret;
}


x86 assembly (clang, -O0):
<signed64_value>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %rcx,-0x20(%rbp)
mov    0x2e9a(%rip),%rax
movq   $0x0,(%rax)
mov    -0x8(%rbp),%rdi
lea    -0x28(%rbp),%rsi
xor    %edx,%edx
call   1040 <strtoll@plt>
mov    %eax,-0x2c(%rbp)
mov    0x2e7a(%rip),%rax
mov    (%rax),%rax
mov    0x2e80(%rip),%rcx
cmp    (%rcx),%rax
jne    118e <signed64_value+0x6e>
mov    -0x10(%rbp),%rsi
mov    -0x14(%rbp),%edx
lea    0xe81(%rip),%rdi
call   1030 <warn@plt>
mov    -0x20(%rbp),%rax
movl   $0xffffffff,(%rax)
mov    -0x28(%rbp),%rax
cmp    -0x8(%rbp),%rax
jne    11b9 <signed64_value+0x99>
mov    -0x10(%rbp),%rsi
mov    -0x14(%rbp),%edx
lea    0xe6f(%rip),%rdi
call   1030 <warn@plt>
mov    -0x20(%rbp),%rax
movl   $0xffffffff,(%rax)
mov    -0x2c(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<signed64_value>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rcx,%r14
mov    %edx,%r15d
mov    %rsi,%r12
mov    %rdi,%rbx
mov    0x2e9a(%rip),%rbp
movq   $0x0,0x0(%rbp)
mov    %rsp,%rsi
xor    %edx,%edx
call   1040 <strtoll@plt>
mov    %eax,%r13d
mov    0x0(%rbp),%rax
mov    0x2e8a(%rip),%rcx
cmp    (%rcx),%rax
jne    117c <signed64_value+0x5c>
lea    0xe96(%rip),%rdi
mov    %r12,%rsi
mov    %r15d,%edx
call   1030 <warn@plt>
movl   $0xffffffff,(%r14)
cmp    %rbx,(%rsp)
jne    119b <signed64_value+0x7b>
lea    0xe90(%rip),%rdi
mov    %r12,%rsi
mov    %r15d,%edx
call   1030 <warn@plt>
movl   $0xffffffff,(%r14)
mov    %r13d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@errno = global i64 0
@ERANGE = global i64 0
@.str = [25 x i8] c"Value out of range %s:%d\00"
@.str.1 = [27 x i8] c"Bad integer value at %s:%d\00"
define i32 @signed64_value(i8* %0, i8* %1, i32 %2, i32* %3) {
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i32*
%9 = alloca i8*
%10 = alloca i32
store i8* %0, i8** %5
store i8* %1, i8** %6
store i32 %2, i32* %7
store i32* %3, i32** %8
store i64 0, i64* @errno
%11 = load i8*, i8** %5
%12 = call i32 @strtoll(i8* %11, i8** %9, i32 0)
store i32 %12, i32* %10
%13 = load i64, i64* @errno
%14 = load i64, i64* @ERANGE
%15 = icmp eq i64 %13, %14
br i1 %15, label %16, label %21
16: ; preds = %4
%17 = load i8*, i8** %6
%18 = load i32, i32* %7
%19 = call i32 @warn(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i8* %17, i32 %18)
%20 = load i32*, i32** %8
store i32 -1, i32* %20
br label %21
21: ; preds = %16, %4
%22 = load i8*, i8** %9
%23 = load i8*, i8** %5
%24 = icmp eq i8* %22, %23
br i1 %24, label %25, label %30
25: ; preds = %21
%26 = load i8*, i8** %6
%27 = load i32, i32* %7
%28 = call i32 @warn(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.1, i64 0, i64 0), i8* %26, i32 %27)
%29 = load i32*, i32** %8
store i32 -1, i32* %29
br label %30
30: ; preds = %25, %21
%31 = load i32, i32* %10
ret i32 %31
}

LLVM IR (-O2):
@errno = global i64 0
@ERANGE = global i64 0
@.str = [25 x i8] c"Value out of range %s:%d\00"
@.str.1 = [27 x i8] c"Bad integer value at %s:%d\00"
define i32 @signed64_value(i8* %0, i8* %1, i32 %2, i32* nocapture writeonly %3) {
%5 = alloca i8*
%6 = bitcast i8** %5 to i8*
store i64 0, i64* @errno
%7 = call i32 @strtoll(i8* %0, i8** %5, i32 0)
%8 = load i64, i64* @errno
%9 = load i64, i64* @ERANGE
%10 = icmp eq i64 %8, %9
br i1 %10, label %11, label %13
11: ; preds = %4
%12 = tail call i32 @warn(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i8* %1, i32 %2)
store i32 -1, i32* %3
br label %13
13: ; preds = %11, %4
%14 = load i8*, i8** %5
%15 = icmp eq i8* %14, %0
br i1 %15, label %16, label %18
16: ; preds = %13
%17 = tail call i32 @warn(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.1, i64 0, i64 0), i8* %1, i32 %2)
store i32 -1, i32* %3
br label %18
18: ; preds = %16, %13
ret i32 %7
}