#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*/ fprintf(int /*<<< orphan*/, char *, char *);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ strncpy(char *, char *, int);
int /*<<< orphan*/ usage(char *);
bool parse_cli(char *string_out, int argv, char *argc[]) {
  if (argv == 2) {
    strncpy(string_out, argc[1], 128);
    return true;
  } else {
    fprintf(stderr, "ERROR: '%s' must have a string as argument.. Exiting\n",
            argc[0]);
    usage(argc[0]);
    return false;
  }
}


x86 assembly (clang, -O0):
<parse_cli>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    %rdx,-0x20(%rbp)
cmpl   $0x2,-0x14(%rbp)
jne    116f <parse_cli+0x3f>
mov    -0x10(%rbp),%rdi
mov    -0x20(%rbp),%rax
mov    0x8(%rax),%rsi
mov    $0x80,%edx
call   1030 <strncpy@plt>
movl   $0x1,-0x4(%rbp)
jmp    119e <parse_cli+0x6e>
mov    0x2e6a(%rip),%rax
mov    (%rax),%edi
mov    -0x20(%rbp),%rax
mov    (%rax),%rdx
lea    0xe7a(%rip),%rsi
call   1040 <fprintf@plt>
mov    -0x20(%rbp),%rax
mov    (%rax),%rdi
call   1050 <usage@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<parse_cli>:
push   %rbx
mov    %rdx,%rbx
cmp    $0x2,%esi
jne    114e <parse_cli+0x1e>
mov    0x8(%rbx),%rsi
mov    $0x80,%edx
call   1030 <strncpy@plt>
mov    $0x1,%eax
pop    %rbx
ret
mov    0x2e8b(%rip),%rax
mov    (%rax),%edi
mov    (%rbx),%rdx
lea    0xe9f(%rip),%rsi
call   1040 <fprintf@plt>
mov    (%rbx),%rdi
call   1050 <usage@plt>
xor    %eax,%eax
pop    %rbx
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [54 x i8] c"ERROR: '%s' must have a string as argument.. Exiting\0A\00"
define i32 @parse_cli(i8* %0, i32 %1, i8** %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i8**
store i8* %0, i8** %5
store i32 %1, i32* %6
store i8** %2, i8*** %7
%8 = load i32, i32* %6
%9 = icmp eq i32 %8, 2
br i1 %9, label %10, label %16
10: ; preds = %3
%11 = load i8*, i8** %5
%12 = load i8**, i8*** %7
%13 = getelementptr inbounds i8*, i8** %12, i64 1
%14 = load i8*, i8** %13
%15 = call i32 @strncpy(i8* %11, i8* %14, i32 128)
store i32 1, i32* %4
br label %26
16: ; preds = %3
%17 = load i32, i32* @stderr
%18 = load i8**, i8*** %7
%19 = getelementptr inbounds i8*, i8** %18, i64 0
%20 = load i8*, i8** %19
%21 = call i32 @fprintf(i32 %17, i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str, i64 0, i64 0), i8* %20)
%22 = load i8**, i8*** %7
%23 = getelementptr inbounds i8*, i8** %22, i64 0
%24 = load i8*, i8** %23
%25 = call i32 @usage(i8* %24)
store i32 0, i32* %4
br label %26
26: ; preds = %16, %10
%27 = load i32, i32* %4
ret i32 %27
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [54 x i8] c"ERROR: '%s' must have a string as argument.. Exiting\0A\00"
define i32 @parse_cli(i8* %0, i32 %1, i8** nocapture %2) {
%4 = icmp eq i32 %1, 2
br i1 %4, label %5, label %9
5: ; preds = %3
%6 = getelementptr inbounds i8*, i8** %2, i64 1
%7 = load i8*, i8** %6
%8 = tail call i32 @strncpy(i8* %0, i8* %7, i32 128)
br label %15
9: ; preds = %3
%10 = load i32, i32* @stderr
%11 = load i8*, i8** %2
%12 = tail call i32 @fprintf(i32 %10, i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str, i64 0, i64 0), i8* %11)
%13 = load i8*, i8** %2
%14 = tail call i32 @usage(i8* %13)
br label %15
15: ; preds = %9, %5
%16 = phi i32 [ 1, %5 ], [ 0, %9 ]
ret i32 %16
}