#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;
long LONG_MAX;
long LONG_MIN;
scalar_t__ errno;
long strtol(char const *, char **, int);
long int utils_parse_number(const char *s) {
  long int n;
  errno = 0;
  n = strtol(s, (char **)0, 0x0A);
  if ((errno == ERANGE && (n == LONG_MAX || n == LONG_MIN)) ||
      (errno != 0 && n == 0))
    return -1;
  return n;
}


x86 assembly (clang, -O0):
<utils_parse_number>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    0x2ea5(%rip),%rax
movq   $0x0,(%rax)
mov    -0x10(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
mov    $0xa,%edx
call   1030 <strtol@plt>
mov    %rax,-0x18(%rbp)
mov    0x2e81(%rip),%rax
mov    (%rax),%rax
mov    0x2e8f(%rip),%rcx
cmp    (%rcx),%rax
jne    1182 <utils_parse_number+0x72>
mov    -0x18(%rbp),%rax
mov    0x2e6b(%rip),%rcx
cmp    (%rcx),%rax
je     119e <utils_parse_number+0x8e>
mov    -0x18(%rbp),%rax
mov    0x2e6f(%rip),%rcx
cmp    (%rcx),%rax
je     119e <utils_parse_number+0x8e>
mov    0x2e3f(%rip),%rax
cmpq   $0x0,(%rax)
je     11ab <utils_parse_number+0x9b>
cmpq   $0x0,-0x18(%rbp)
jne    11ab <utils_parse_number+0x9b>
movq   $0xffffffffffffffff,-0x8(%rbp)
ff
jmp    11b3 <utils_parse_number+0xa3>
mov    -0x18(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<utils_parse_number>:
push   %rbx
mov    0x2eb0(%rip),%rbx
movq   $0x0,(%rbx)
xor    %esi,%esi
mov    $0xa,%edx
call   1030 <strtol@plt>
mov    (%rbx),%rdx
mov    0x2eab(%rip),%rcx
cmp    (%rcx),%rdx
jne    1159 <utils_parse_number+0x49>
mov    0x2e8f(%rip),%rsi
mov    $0xffffffffffffffff,%rcx
cmp    (%rsi),%rax
je     116a <utils_parse_number+0x5a>
mov    0x2e94(%rip),%rsi
cmp    (%rsi),%rax
je     116a <utils_parse_number+0x5a>
cmp    $0x1,%rax
sbb    %rcx,%rcx
or     %rax,%rcx
test   %rdx,%rdx
cmove  %rax,%rcx
mov    %rcx,%rax
pop    %rbx
ret

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

LLVM IR (-O2):
@errno = global i64 0
@ERANGE = global i64 0
@LONG_MAX = global i64 0
@LONG_MIN = global i64 0
define i64 @utils_parse_number(i8* nocapture %0) {
store i64 0, i64* @errno
%2 = tail call i64 @strtol(i8* nocapture %0, i8** null, i32 10)
%3 = load i64, i64* @errno
%4 = load i64, i64* @ERANGE
%5 = icmp eq i64 %3, %4
br i1 %5, label %6, label %12
6: ; preds = %1
%7 = load i64, i64* @LONG_MAX
%8 = icmp eq i64 %2, %7
%9 = load i64, i64* @LONG_MIN
%10 = icmp eq i64 %2, %9
%11 = select i1 %8, i1 true, i1 %10
br i1 %11, label %17, label %12
12: ; preds = %6, %1
%13 = icmp ne i64 %3, 0
%14 = icmp eq i64 %2, 0
%15 = select i1 %13, i1 %14, i1 false
%16 = select i1 %15, i64 -1, i64 %2
br label %17
17: ; preds = %12, %6
%18 = phi i64 [ -1, %6 ], [ %16, %12 ]
ret i64 %18
}