#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;
int /*<<< orphan*/ assert(int /*<<< orphan*/);
scalar_t__ errno;
long long strtoll(char *, int /*<<< orphan*/ *, int);
int parse_ll(char *tok, long long *seq) {
  assert(tok != NULL);
  assert(seq != NULL);
  *seq = strtoll(tok, NULL, 10);
  if (*seq < 0 || errno == ERANGE) {
    return -1;
  }
  return 0;
}


x86 assembly (clang, -O0):
<parse_ll>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
cmpq   $0x0,-0x10(%rbp)
setne  %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
cmpq   $0x0,-0x18(%rbp)
setne  %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
mov    -0x10(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
mov    $0xa,%edx
call   1030 <strtoll@plt>
mov    %rax,%rcx
mov    -0x18(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x18(%rbp),%rax
cmpq   $0x0,(%rax)
jl     1198 <parse_ll+0x78>
mov    0x2e53(%rip),%rax
mov    (%rax),%rax
mov    0x2e59(%rip),%rcx
cmp    (%rcx),%rax
jne    11a4 <parse_ll+0x84>
movl   $0xffffffff,-0x4(%rbp)
jmp    11ab <parse_ll+0x8b>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<parse_ll>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%rbx
xor    %edi,%edi
test   %rbx,%rbx
setne  %dil
call   1040 <assert@plt>
xor    %edi,%edi
test   %r14,%r14
setne  %dil
call   1040 <assert@plt>
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0xa,%edx
call   1030 <strtoll@plt>
mov    %rax,(%r14)
test   %rax,%rax
sets   %al
mov    0x2e73(%rip),%rcx
mov    (%rcx),%rcx
mov    0x2e79(%rip),%rdx
cmp    (%rdx),%rcx
sete   %cl
or     %al,%cl
movzbl %cl,%eax
neg    %eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

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

LLVM IR (-O2):
@errno = global i64 0
@ERANGE = global i64 0
define i32 @parse_ll(i8* %0, i64* writeonly %1) {
%3 = icmp ne i8* %0, null
%4 = zext i1 %3 to i32
%5 = tail call i32 @assert(i32 %4)
%6 = icmp ne i64* %1, null
%7 = zext i1 %6 to i32
%8 = tail call i32 @assert(i32 %7)
%9 = tail call i64 @strtoll(i8* nocapture %0, i32* null, i32 10)
store i64 %9, i64* %1
%10 = icmp slt i64 %9, 0
%11 = load i64, i64* @errno
%12 = load i64, i64* @ERANGE
%13 = icmp eq i64 %11, %12
%14 = select i1 %10, i1 true, i1 %13
%15 = sext i1 %14 to i32
ret i32 %15
}