#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 */
long long SIZE_MAX;
int /*<<< orphan*/ strict_strtoll(char const *, int, long long *);
bool parse_size(const char *s, int base, size_t *result) {
  long long x;
  if (!strict_strtoll(s, base, &x) || x < 0 || x > SIZE_MAX)
    return false;
  *result = x;
  return true;
}


x86 assembly (clang, -O0):
<parse_size>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    %rdx,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
lea    -0x28(%rbp),%rdx
call   1030 <strict_strtoll@plt>
cmp    $0x0,%eax
je     115b <parse_size+0x4b>
cmpq   $0x0,-0x28(%rbp)
jl     115b <parse_size+0x4b>
mov    -0x28(%rbp),%rax
mov    0x2e86(%rip),%rcx
cmp    (%rcx),%rax
jle    1167 <parse_size+0x57>
movl   $0x0,-0x4(%rbp)
jmp    1179 <parse_size+0x69>
mov    -0x28(%rbp),%rcx
mov    -0x20(%rbp),%rax
mov    %rcx,(%rax)
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<parse_size>:
push   %rbx
sub    $0x10,%rsp
mov    %rdx,%rbx
lea    0x8(%rsp),%rdx
call   1030 <strict_strtoll@plt>
mov    %eax,%ecx
xor    %eax,%eax
test   %ecx,%ecx
je     1148 <parse_size+0x38>
mov    0x8(%rsp),%rcx
test   %rcx,%rcx
js     1148 <parse_size+0x38>
mov    0x2e9d(%rip),%rdx
cmp    (%rdx),%rcx
jg     1148 <parse_size+0x38>
mov    %rcx,(%rbx)
mov    $0x1,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@SIZE_MAX = global i64 0
define i32 @parse_size(i8* %0, i32 %1, i64* %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i64*
%8 = alloca i64
store i8* %0, i8** %5
store i32 %1, i32* %6
store i64* %2, i64** %7
%9 = load i8*, i8** %5
%10 = load i32, i32* %6
%11 = call i32 @strict_strtoll(i8* %9, i32 %10, i64* %8)
%12 = icmp ne i32 %11, 0
br i1 %12, label %13, label %20
13: ; preds = %3
%14 = load i64, i64* %8
%15 = icmp slt i64 %14, 0
br i1 %15, label %20, label %16
16: ; preds = %13
%17 = load i64, i64* %8
%18 = load i64, i64* @SIZE_MAX
%19 = icmp sgt i64 %17, %18
br i1 %19, label %20, label %21
20: ; preds = %16, %13, %3
store i32 0, i32* %4
br label %24
21: ; preds = %16
%22 = load i64, i64* %8
%23 = load i64*, i64** %7
store i64 %22, i64* %23
store i32 1, i32* %4
br label %24
24: ; preds = %21, %20
%25 = load i32, i32* %4
ret i32 %25
}

LLVM IR (-O2):
@SIZE_MAX = global i64 0
define i32 @parse_size(i8* %0, i32 %1, i64* nocapture writeonly %2) {
%4 = alloca i64
%5 = bitcast i64* %4 to i8*
%6 = call i32 @strict_strtoll(i8* %0, i32 %1, i64* %4)
%7 = icmp eq i32 %6, 0
%8 = load i64, i64* %4
%9 = icmp slt i64 %8, 0
%10 = select i1 %7, i1 true, i1 %9
%11 = load i64, i64* @SIZE_MAX
%12 = icmp sgt i64 %8, %11
%13 = select i1 %10, i1 true, i1 %12
br i1 %13, label %15, label %14
14: ; preds = %3
store i64 %8, i64* %2
br label %15
15: ; preds = %3, %14
%16 = phi i32 [ 1, %14 ], [ 0, %3 ]
ret i32 %16
}