#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 scalar_t__ time_t;

/* Variables and functions */
scalar_t__ errno;
char *proto_get_ascii(char **);
long long strtoll(char *, char **, int);
int proto_get_time(char **s, time_t *val) {
  long long tmp;
  char *cp, *end;
  cp = proto_get_ascii(s);
  if (cp == NULL)
    return (-1);
  errno = 0;
  tmp = strtoll(cp, &end, 10);
  if (errno || *end != '\0')
    return (-1);
  *val = (time_t)tmp;
  return (0);
}


x86 assembly (clang, -O0):
<proto_get_time>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <proto_get_ascii@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    1154 <proto_get_time+0x34>
movl   $0xffffffff,-0x4(%rbp)
jmp    11b7 <proto_get_time+0x97>
mov    0x2e85(%rip),%rax
movq   $0x0,(%rax)
mov    -0x28(%rbp),%rdi
lea    -0x30(%rbp),%rsi
mov    $0xa,%edx
call   1040 <strtoll@plt>
mov    %rax,-0x20(%rbp)
mov    0x2e61(%rip),%rax
cmpq   $0x0,(%rax)
jne    1199 <proto_get_time+0x79>
mov    -0x30(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     11a5 <proto_get_time+0x85>
movl   $0xffffffff,-0x4(%rbp)
jmp    11b7 <proto_get_time+0x97>
mov    -0x20(%rbp),%rcx
mov    -0x18(%rbp),%rax
mov    %rcx,(%rax)
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<proto_get_time>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %rsi,%r14
call   1030 <proto_get_ascii@plt>
mov    $0xffffffff,%ebx
test   %rax,%rax
je     1170 <proto_get_time+0x50>
mov    0x2e9e(%rip),%r15
movq   $0x0,(%r15)
lea    0x8(%rsp),%rsi
mov    %rax,%rdi
mov    $0xa,%edx
call   1040 <strtoll@plt>
cmpq   $0x0,(%r15)
jne    1170 <proto_get_time+0x50>
mov    0x8(%rsp),%rcx
cmpb   $0x0,(%rcx)
jne    1170 <proto_get_time+0x50>
mov    %rax,(%r14)
xor    %ebx,%ebx
mov    %ebx,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
@errno = global i64 0
define i32 @proto_get_time(i8** %0, i64* nocapture writeonly %1) {
%3 = alloca i8*
%4 = bitcast i8** %3 to i8*
%5 = tail call i8* @proto_get_ascii(i8** %0)
%6 = icmp eq i8* %5, null
br i1 %6, label %16, label %7
7: ; preds = %2
store i64 0, i64* @errno
%8 = call i64 @strtoll(i8* %5, i8** %3, i32 10)
%9 = load i64, i64* @errno
%10 = icmp eq i64 %9, 0
br i1 %10, label %11, label %16
11: ; preds = %7
%12 = load i8*, i8** %3
%13 = load i8, i8* %12
%14 = icmp eq i8 %13, 0
br i1 %14, label %15, label %16
15: ; preds = %11
store i64 %8, i64* %1
br label %16
16: ; preds = %7, %11, %2, %15
%17 = phi i32 [ 0, %15 ], [ -1, %2 ], [ -1, %11 ], [ -1, %7 ]
ret i32 %17
}