#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__ uint64_t;

/* Variables and functions */
int /*<<< orphan*/ ERANGE;
scalar_t__ INT64_MAX;
int /*<<< orphan*/ errno;
scalar_t__ parse_size_p(char const *, scalar_t__ *);
scalar_t__ strcasecmp(char *, char const *);
int parse_offset(const char *str, uint64_t *size) {
  uint64_t sz = 0;
  if (strcasecmp("max", str) == 0) {
    if (size)
      *size = INT64_MAX;
    return 1;
  } else if (parse_size_p(str, &sz)) {
    if (sz <= INT64_MAX) {
      if (size)
        *size = sz;
      return 1;
    }
    errno = ERANGE;
  }
  return 0;
}


x86 assembly (clang, -O0):
<parse_offset>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
movq   $0x0,-0x20(%rbp)
mov    -0x10(%rbp),%rsi
lea    0xebd(%rip),%rdi
call   1030 <strcasecmp@plt>
cmp    $0x0,%rax
jne    117a <parse_offset+0x5a>
cmpq   $0x0,-0x18(%rbp)
je     116e <parse_offset+0x4e>
mov    0x2e84(%rip),%rax
mov    (%rax),%rcx
mov    -0x18(%rbp),%rax
mov    %rcx,(%rax)
movl   $0x1,-0x4(%rbp)
jmp    11e5 <parse_offset+0xc5>
mov    -0x10(%rbp),%rdi
lea    -0x20(%rbp),%rsi
call   1040 <parse_size_p@plt>
cmp    $0x0,%rax
je     11d9 <parse_offset+0xb9>
mov    -0x20(%rbp),%rax
mov    0x2e4c(%rip),%rcx
cmp    (%rcx),%rax
jg     11c7 <parse_offset+0xa7>
cmpq   $0x0,-0x18(%rbp)
je     11bb <parse_offset+0x9b>
mov    -0x20(%rbp),%rcx
mov    -0x18(%rbp),%rax
mov    %rcx,(%rax)
movl   $0x1,-0x4(%rbp)
jmp    11e5 <parse_offset+0xc5>
mov    0x2e12(%rip),%rax
mov    (%rax),%ecx
mov    0x2df9(%rip),%rax
mov    %ecx,(%rax)
jmp    11de <parse_offset+0xbe>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<parse_offset>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%rbx
movq   $0x0,(%rsp)
lea    0xec7(%rip),%rdi
mov    %rbx,%rsi
call   1030 <strcasecmp@plt>
test   %rax,%rax
je     117f <parse_offset+0x5f>
mov    %rsp,%rsi
mov    %rbx,%rdi
call   1040 <parse_size_p@plt>
mov    %rax,%rcx
xor    %eax,%eax
test   %rcx,%rcx
je     11a2 <parse_offset+0x82>
mov    (%rsp),%rcx
mov    0x2e82(%rip),%rdx
cmp    (%rdx),%rcx
jle    1195 <parse_offset+0x75>
mov    0x2e6e(%rip),%rcx
mov    (%rcx),%ecx
mov    0x2e55(%rip),%rdx
mov    %ecx,(%rdx)
jmp    11a2 <parse_offset+0x82>
mov    $0x1,%eax
test   %r14,%r14
je     11a2 <parse_offset+0x82>
mov    0x2e58(%rip),%rcx
mov    (%rcx),%rcx
jmp    119f <parse_offset+0x7f>
mov    $0x1,%eax
test   %r14,%r14
je     11a2 <parse_offset+0x82>
mov    %rcx,(%r14)
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [4 x i8] c"max\00"
@INT64_MAX = global i64 0
@ERANGE = global i32 0
@errno = global i32 0
define i32 @parse_offset(i8* %0, i64* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i64*
%6 = alloca i64
store i8* %0, i8** %4
store i64* %1, i64** %5
store i64 0, i64* %6
%7 = load i8*, i8** %4
%8 = call i64 @strcasecmp(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %7)
%9 = icmp eq i64 %8, 0
br i1 %9, label %10, label %17
10: ; preds = %2
%11 = load i64*, i64** %5
%12 = icmp ne i64* %11, null
br i1 %12, label %13, label %16
13: ; preds = %10
%14 = load i64, i64* @INT64_MAX
%15 = load i64*, i64** %5
store i64 %14, i64* %15
br label %16
16: ; preds = %13, %10
store i32 1, i32* %3
br label %36
17: ; preds = %2
%18 = load i8*, i8** %4
%19 = call i64 @parse_size_p(i8* %18, i64* %6)
%20 = icmp ne i64 %19, 0
br i1 %20, label %21, label %34
21: ; preds = %17
%22 = load i64, i64* %6
%23 = load i64, i64* @INT64_MAX
%24 = icmp sle i64 %22, %23
br i1 %24, label %25, label %32
25: ; preds = %21
%26 = load i64*, i64** %5
%27 = icmp ne i64* %26, null
br i1 %27, label %28, label %31
28: ; preds = %25
%29 = load i64, i64* %6
%30 = load i64*, i64** %5
store i64 %29, i64* %30
br label %31
31: ; preds = %28, %25
store i32 1, i32* %3
br label %36
32: ; preds = %21
%33 = load i32, i32* @ERANGE
store i32 %33, i32* @errno
br label %34
34: ; preds = %32, %17
br label %35
35: ; preds = %34
store i32 0, i32* %3
br label %36
36: ; preds = %35, %31, %16
%37 = load i32, i32* %3
ret i32 %37
}

LLVM IR (-O2):
@.str = [4 x i8] c"max\00"
@INT64_MAX = global i64 0
@ERANGE = global i32 0
@errno = global i32 0
define i32 @parse_offset(i8* %0, i64* writeonly %1) {
%3 = alloca i64
%4 = bitcast i64* %3 to i8*
store i64 0, i64* %3
%5 = tail call i64 @strcasecmp(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %0)
%6 = icmp eq i64 %5, 0
br i1 %6, label %7, label %11
7: ; preds = %2
%8 = icmp eq i64* %1, null
br i1 %8, label %23, label %9
9: ; preds = %7
%10 = load i64, i64* @INT64_MAX
store i64 %10, i64* %1
br label %23
11: ; preds = %2
%12 = call i64 @parse_size_p(i8* %0, i64* %3)
%13 = icmp eq i64 %12, 0
br i1 %13, label %23, label %14
14: ; preds = %11
%15 = load i64, i64* %3
%16 = load i64, i64* @INT64_MAX
%17 = icmp sgt i64 %15, %16
br i1 %17, label %21, label %18
18: ; preds = %14
%19 = icmp eq i64* %1, null
br i1 %19, label %23, label %20
20: ; preds = %18
store i64 %15, i64* %1
br label %23
21: ; preds = %14
%22 = load i32, i32* @ERANGE
store i32 %22, i32* @errno
br label %23
23: ; preds = %21, %11, %18, %20, %7, %9
%24 = phi i32 [ 1, %9 ], [ 1, %7 ], [ 1, %20 ], [ 1, %18 ], [ 0, %11 ], [ 0, %21 ]
ret i32 %24
}