#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 */
int /*<<< orphan*/ invalid_arg(char const *, char const *);
long long strtoll(char const *, char **, int);
void int_arg(size_t *var, const char *option, const char *value) {
  char *endptr = NULL;
  long long int out = strtoll(value, &endptr, 10);
  if ((*value && !*endptr) && out >= 0)
    *var = out;
  else
    invalid_arg(option, value);
}


x86 assembly (clang, -O0):
<int_arg>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
movq   $0x0,-0x20(%rbp)
mov    -0x18(%rbp),%rdi
lea    -0x20(%rbp),%rsi
mov    $0xa,%edx
call   1040 <strtoll@plt>
mov    %rax,-0x28(%rbp)
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     118a <int_arg+0x6a>
mov    -0x20(%rbp),%rax
cmpb   $0x0,(%rax)
jne    118a <int_arg+0x6a>
cmpq   $0x0,-0x28(%rbp)
jl     118a <int_arg+0x6a>
mov    -0x28(%rbp),%rcx
mov    -0x8(%rbp),%rax
mov    %rcx,(%rax)
jmp    1197 <int_arg+0x77>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1030 <invalid_arg@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<int_arg>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %rdx,%rbx
mov    %rsi,%r15
mov    %rdi,%r14
movq   $0x0,0x8(%rsp)
lea    0x8(%rsp),%rsi
mov    %rdx,%rdi
mov    $0xa,%edx
call   1040 <strtoll@plt>
cmpb   $0x0,(%rbx)
je     116e <int_arg+0x4e>
mov    0x8(%rsp),%rcx
cmpb   $0x0,(%rcx)
jne    116e <int_arg+0x4e>
test   %rax,%rax
js     116e <int_arg+0x4e>
mov    %rax,(%r14)
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret
mov    %r15,%rdi
mov    %rbx,%rsi
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
jmp    1030 <invalid_arg@plt>

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

LLVM IR (-O2):
define void @int_arg(i64* nocapture writeonly %0, i8* %1, i8* %2) {
%4 = alloca i8*
%5 = bitcast i8** %4 to i8*
store i8* null, i8** %4
%6 = call i64 @strtoll(i8* %2, i8** %4, i32 10)
%7 = load i8, i8* %2
%8 = icmp eq i8 %7, 0
br i1 %8, label %16, label %9
9: ; preds = %3
%10 = load i8*, i8** %4
%11 = load i8, i8* %10
%12 = icmp eq i8 %11, 0
%13 = icmp sgt i64 %6, -1
%14 = select i1 %12, i1 %13, i1 false
br i1 %14, label %15, label %16
15: ; preds = %9
store i64 %6, i64* %0
br label %18
16: ; preds = %9, %3
%17 = tail call i32 @invalid_arg(i8* %1, i8* %2)
br label %18
18: ; preds = %16, %15
ret void
}