#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;
unsigned long ULONG_MAX;
scalar_t__ errno;
unsigned long strtoul(char const *, char **, int);
long long sleep_time_get(const char *restrict token) {
  char *endptr = NULL;
  errno = 0;
  unsigned result = 0;
  unsigned long tmp = 0UL;
  if (0UL == (tmp = strtoul(token, &endptr, 10)) && endptr == token) {
    return -1;
  }
  if (ULONG_MAX == tmp && ERANGE == errno) {
    return -1;
  }
  result = tmp;
  if ((unsigned long)result != tmp) {
    return -1;
  }
  return result;
}


x86 assembly (clang, -O0):
<sleep_time_get>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
mov    0x2ead(%rip),%rax
movq   $0x0,(%rax)
movl   $0x0,-0x1c(%rbp)
movq   $0x0,-0x28(%rbp)
mov    -0x10(%rbp),%rdi
lea    -0x18(%rbp),%rsi
mov    $0xa,%edx
call   1030 <strtoul@plt>
mov    %rax,%rcx
mov    %rcx,-0x28(%rbp)
xor    %eax,%eax
cmp    %rcx,%rax
jne    1180 <sleep_time_get+0x70>
mov    -0x18(%rbp),%rax
cmp    -0x10(%rbp),%rax
jne    1180 <sleep_time_get+0x70>
movq   $0xffffffffffffffff,-0x8(%rbp)
ff
jmp    11e3 <sleep_time_get+0xd3>
mov    0x2e41(%rip),%rax
mov    (%rax),%rax
cmp    -0x28(%rbp),%rax
jne    11bb <sleep_time_get+0xab>
mov    0x2e4d(%rip),%rax
mov    (%rax),%rax
mov    0x2e33(%rip),%rcx
cmp    (%rcx),%rax
jne    11bb <sleep_time_get+0xab>
movq   $0xffffffffffffffff,-0x8(%rbp)
ff
jmp    11e3 <sleep_time_get+0xd3>
mov    -0x28(%rbp),%rax
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x28(%rbp),%rax
je     11dc <sleep_time_get+0xcc>
movq   $0xffffffffffffffff,-0x8(%rbp)
ff
jmp    11e3 <sleep_time_get+0xd3>
mov    -0x1c(%rbp),%eax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sleep_time_get>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%rbx
movq   $0x0,(%rsp)
mov    0x2eb2(%rip),%r14
movq   $0x0,(%r14)
mov    %rsp,%rsi
mov    $0xa,%edx
call   1030 <strtoul@plt>
mov    %rax,%rcx
mov    $0xffffffffffffffff,%rax
test   %rcx,%rcx
jne    114f <sleep_time_get+0x3f>
cmp    %rbx,(%rsp)
je     1176 <sleep_time_get+0x66>
mov    0x2e72(%rip),%rdx
cmp    %rcx,(%rdx)
jne    116a <sleep_time_get+0x5a>
mov    0x2e86(%rip),%rdx
mov    (%rdx),%rdx
cmp    (%r14),%rdx
je     1176 <sleep_time_get+0x66>
mov    %rcx,%rdx
shr    $0x20,%rdx
jne    1176 <sleep_time_get+0x66>
mov    %rcx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@errno = global i64 0
@ULONG_MAX = global i64 0
@ERANGE = global i64 0
define i64 @sleep_time_get(i8* noalias %0) {
%2 = alloca i64
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i64
store i8* %0, i8** %3
store i8* null, i8** %4
store i64 0, i64* @errno
store i32 0, i32* %5
store i64 0, i64* %6
%7 = load i8*, i8** %3
%8 = call i64 @strtoul(i8* %7, i8** %4, i32 10)
store i64 %8, i64* %6
%9 = icmp eq i64 0, %8
br i1 %9, label %10, label %15
10: ; preds = %1
%11 = load i8*, i8** %4
%12 = load i8*, i8** %3
%13 = icmp eq i8* %11, %12
br i1 %13, label %14, label %15
14: ; preds = %10
store i64 -1, i64* %2
br label %35
15: ; preds = %10, %1
%16 = load i64, i64* @ULONG_MAX
%17 = load i64, i64* %6
%18 = icmp eq i64 %16, %17
br i1 %18, label %19, label %24
19: ; preds = %15
%20 = load i64, i64* @ERANGE
%21 = load i64, i64* @errno
%22 = icmp eq i64 %20, %21
br i1 %22, label %23, label %24
23: ; preds = %19
store i64 -1, i64* %2
br label %35
24: ; preds = %19, %15
%25 = load i64, i64* %6
%26 = trunc i64 %25 to i32
store i32 %26, i32* %5
%27 = load i32, i32* %5
%28 = zext i32 %27 to i64
%29 = load i64, i64* %6
%30 = icmp ne i64 %28, %29
br i1 %30, label %31, label %32
31: ; preds = %24
store i64 -1, i64* %2
br label %35
32: ; preds = %24
%33 = load i32, i32* %5
%34 = zext i32 %33 to i64
store i64 %34, i64* %2
br label %35
35: ; preds = %32, %31, %23, %14
%36 = load i64, i64* %2
ret i64 %36
}

LLVM IR (-O2):
@errno = global i64 0
@ULONG_MAX = global i64 0
@ERANGE = global i64 0
define i64 @sleep_time_get(i8* noalias %0) {
%2 = alloca i8*
%3 = bitcast i8** %2 to i8*
store i8* null, i8** %2
store i64 0, i64* @errno
%4 = call i64 @strtoul(i8* %0, i8** %2, i32 10)
%5 = icmp eq i64 %4, 0
%6 = load i8*, i8** %2
%7 = icmp eq i8* %6, %0
%8 = select i1 %5, i1 %7, i1 false
br i1 %8, label %21, label %9
9: ; preds = %1
%10 = load i64, i64* @ULONG_MAX
%11 = icmp eq i64 %10, %4
br i1 %11, label %12, label %18
12: ; preds = %9
%13 = load i64, i64* @ERANGE
%14 = load i64, i64* @errno
%15 = icmp ne i64 %13, %14
%16 = icmp ult i64 %4, 4294967296
%17 = select i1 %15, i1 %16, i1 false
br i1 %17, label %20, label %21
18: ; preds = %9
%19 = icmp ult i64 %4, 4294967296
br i1 %19, label %20, label %21
20: ; preds = %12, %18
br label %21
21: ; preds = %18, %12, %1, %20
%22 = phi i64 [ %4, %20 ], [ -1, %1 ], [ -1, %12 ], [ -1, %18 ]
ret i64 %22
}