#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__ errno;
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ stderr;
void *strtol(char const *, int /*<<< orphan*/ *, int /*<<< orphan*/);
int /*<<< orphan*/ usage(char *);
bool parse_cli(size_t *alloc_size, unsigned char *alignment, int argv,
               char *argc[]) {
  if (argv == 3) {
    *alloc_size = strtol((const char *)argc[1], NULL, 0);
    if (errno) {
      perror("ERROR getting 'alloc-size-in-bytes'");
      return false;
    }
    *alignment = strtol((const char *)argc[2], NULL, 0);
    if (errno) {
      perror("ERROR getting 'alignment'");
      return false;
    }
    return true;
  } else {
    fprintf(stderr, "ERROR: '%s' must have 2 numbers as argument.. Exiting\n",
            argc[0]);
    usage(argc[0]);
    return false;
  }
}


x86 assembly (clang, -O0):
<parse_cli>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %edx,-0x1c(%rbp)
mov    %rcx,-0x28(%rbp)
cmpl   $0x3,-0x1c(%rbp)
jne    11f7 <parse_cli+0xb7>
mov    -0x28(%rbp),%rax
mov    0x8(%rax),%rdi
xor    %eax,%eax
mov    %eax,%esi
xor    %edx,%edx
call   1040 <strtol@plt>
mov    %rax,%rcx
mov    -0x10(%rbp),%rax
mov    %rcx,(%rax)
mov    0x2e53(%rip),%rax
cmpq   $0x0,(%rax)
je     11a7 <parse_cli+0x67>
lea    0xe6a(%rip),%rdi
call   1060 <perror@plt>
movl   $0x0,-0x4(%rbp)
jmp    1226 <parse_cli+0xe6>
mov    -0x28(%rbp),%rax
mov    0x10(%rax),%rdi
xor    %eax,%eax
mov    %eax,%esi
xor    %edx,%edx
call   1040 <strtol@plt>
mov    %al,%cl
mov    -0x18(%rbp),%rax
mov    %cl,(%rax)
mov    0x2e0f(%rip),%rax
cmpq   $0x0,(%rax)
je     11eb <parse_cli+0xab>
lea    0xe4a(%rip),%rdi
call   1060 <perror@plt>
movl   $0x0,-0x4(%rbp)
jmp    1226 <parse_cli+0xe6>
movl   $0x1,-0x4(%rbp)
jmp    1226 <parse_cli+0xe6>
mov    0x2de2(%rip),%rax
mov    (%rax),%edi
mov    -0x28(%rbp),%rax
mov    (%rax),%rdx
lea    0xe30(%rip),%rsi
call   1030 <fprintf@plt>
mov    -0x28(%rbp),%rax
mov    (%rax),%rdi
call   1050 <usage@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<parse_cli>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rcx,%rbx
cmp    $0x3,%edx
jne    11a3 <parse_cli+0x63>
mov    %rsi,%r14
mov    %rdi,%r12
mov    0x8(%rbx),%rdi
xor    %r15d,%r15d
xor    %esi,%esi
xor    %edx,%edx
call   1040 <strtol@plt>
mov    %rax,(%r12)
mov    0x2e67(%rip),%r12
cmpq   $0x0,(%r12)
jne    11d5 <parse_cli+0x95>
mov    0x10(%rbx),%rdi
xor    %esi,%esi
xor    %edx,%edx
call   1040 <strtol@plt>
mov    %al,(%r14)
mov    $0x1,%r15d
cmpq   $0x0,(%r12)
je     11c6 <parse_cli+0x86>
lea    0xe88(%rip),%rdi
call   1060 <perror@plt>
jmp    11c3 <parse_cli+0x83>
mov    0x2e36(%rip),%rax
mov    (%rax),%edi
mov    (%rbx),%rdx
lea    0xe88(%rip),%rsi
call   1030 <fprintf@plt>
mov    (%rbx),%rdi
call   1050 <usage@plt>
xor    %r15d,%r15d
mov    %r15d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret
lea    0xe24(%rip),%rdi
call   1060 <perror@plt>
jmp    11c6 <parse_cli+0x86>

LLVM IR (-O0):
@errno = global i64 0
@.str = [36 x i8] c"ERROR getting 'alloc-size-in-bytes'\00"
@.str.1 = [26 x i8] c"ERROR getting 'alignment'\00"
@stderr = global i32 0
@.str.2 = [55 x i8] c"ERROR: '%s' must have 2 numbers as argument.. Exiting\0A\00"
define i32 @parse_cli(i64* %0, i8* %1, i32 %2, i8** %3) {
%5 = alloca i32
%6 = alloca i64*
%7 = alloca i8*
%8 = alloca i32
%9 = alloca i8**
store i64* %0, i64** %6
store i8* %1, i8** %7
store i32 %2, i32* %8
store i8** %3, i8*** %9
%10 = load i32, i32* %8
%11 = icmp eq i32 %10, 3
br i1 %11, label %12, label %35
12: ; preds = %4
%13 = load i8**, i8*** %9
%14 = getelementptr inbounds i8*, i8** %13, i64 1
%15 = load i8*, i8** %14
%16 = call i8* @strtol(i8* %15, i32* null, i32 0)
%17 = ptrtoint i8* %16 to i64
%18 = load i64*, i64** %6
store i64 %17, i64* %18
%19 = load i64, i64* @errno
%20 = icmp ne i64 %19, 0
br i1 %20, label %21, label %23
21: ; preds = %12
%22 = call i32 @perror(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %5
br label %45
23: ; preds = %12
%24 = load i8**, i8*** %9
%25 = getelementptr inbounds i8*, i8** %24, i64 2
%26 = load i8*, i8** %25
%27 = call i8* @strtol(i8* %26, i32* null, i32 0)
%28 = ptrtoint i8* %27 to i8
%29 = load i8*, i8** %7
store i8 %28, i8* %29
%30 = load i64, i64* @errno
%31 = icmp ne i64 %30, 0
br i1 %31, label %32, label %34
32: ; preds = %23
%33 = call i32 @perror(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.1, i64 0, i64 0))
store i32 0, i32* %5
br label %45
34: ; preds = %23
store i32 1, i32* %5
br label %45
35: ; preds = %4
%36 = load i32, i32* @stderr
%37 = load i8**, i8*** %9
%38 = getelementptr inbounds i8*, i8** %37, i64 0
%39 = load i8*, i8** %38
%40 = call i32 @fprintf(i32 %36, i8* getelementptr inbounds ([55 x i8], [55 x i8]* @.str.2, i64 0, i64 0), i8* %39)
%41 = load i8**, i8*** %9
%42 = getelementptr inbounds i8*, i8** %41, i64 0
%43 = load i8*, i8** %42
%44 = call i32 @usage(i8* %43)
store i32 0, i32* %5
br label %45
45: ; preds = %35, %34, %32, %21
%46 = load i32, i32* %5
ret i32 %46
}

LLVM IR (-O2):
@errno = global i64 0
@.str = [36 x i8] c"ERROR getting 'alloc-size-in-bytes'\00"
@.str.1 = [26 x i8] c"ERROR getting 'alignment'\00"
@stderr = global i32 0
@.str.2 = [55 x i8] c"ERROR: '%s' must have 2 numbers as argument.. Exiting\0A\00"
define i32 @parse_cli(i64* nocapture writeonly %0, i8* nocapture writeonly %1, i32 %2, i8** nocapture %3) {
%5 = icmp eq i32 %2, 3
br i1 %5, label %6, label %25
6: ; preds = %4
%7 = getelementptr inbounds i8*, i8** %3, i64 1
%8 = load i8*, i8** %7
%9 = tail call i8* @strtol(i8* nocapture %8, i32* null, i32 0)
%10 = ptrtoint i8* %9 to i64
store i64 %10, i64* %0
%11 = load i64, i64* @errno
%12 = icmp eq i64 %11, 0
br i1 %12, label %15, label %13
13: ; preds = %6
%14 = tail call i32 @perror(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str, i64 0, i64 0))
br label %31
15: ; preds = %6
%16 = getelementptr inbounds i8*, i8** %3, i64 2
%17 = load i8*, i8** %16
%18 = tail call i8* @strtol(i8* nocapture %17, i32* null, i32 0)
%19 = ptrtoint i8* %18 to i64
%20 = trunc i64 %19 to i8
store i8 %20, i8* %1
%21 = load i64, i64* @errno
%22 = icmp eq i64 %21, 0
br i1 %22, label %31, label %23
23: ; preds = %15
%24 = tail call i32 @perror(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.1, i64 0, i64 0))
br label %31
25: ; preds = %4
%26 = load i32, i32* @stderr
%27 = load i8*, i8** %3
%28 = tail call i32 @fprintf(i32 %26, i8* getelementptr inbounds ([55 x i8], [55 x i8]* @.str.2, i64 0, i64 0), i8* %27)
%29 = load i8*, i8** %3
%30 = tail call i32 @usage(i8* %29)
br label %31
31: ; preds = %15, %25, %23, %13
%32 = phi i32 [ 0, %13 ], [ 0, %23 ], [ 0, %25 ], [ 1, %15 ]
ret i32 %32
}