#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*/ error_msg(char *);
int /*<<< orphan*/ flag_to_view(int);
int parse_flags(char const **, char *);
int /*<<< orphan*/ view_load(int /*<<< orphan*/, char *);
void cmd_load(char *arg) {
  int flag = parse_flags((const char **)&arg, "lp");
  if (flag == -1)
    return;
  if (arg == NULL) {
    error_msg("not enough arguments\n");
    return;
  }
  view_load(flag_to_view(flag), arg);
}


x86 assembly (clang, -O0):
<cmd_load>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
lea    -0x8(%rbp),%rdi
lea    0xea9(%rip),%rsi
call   1040 <parse_flags@plt>
mov    %eax,-0xc(%rbp)
cmpl   $0xffffffff,-0xc(%rbp)
jne    116e <cmd_load+0x2e>
jmp    119d <cmd_load+0x5d>
cmpq   $0x0,-0x8(%rbp)
jne    118a <cmd_load+0x4a>
lea    0xe83(%rip),%rdi
call   1030 <error_msg@plt>
jmp    119d <cmd_load+0x5d>
mov    -0xc(%rbp),%edi
call   1060 <flag_to_view@plt>
mov    %eax,%edi
mov    -0x8(%rbp),%rsi
call   1050 <view_load@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<cmd_load>:
push   %rax
mov    %rdi,(%rsp)
lea    0xeb4(%rip),%rsi
mov    %rsp,%rdi
call   1040 <parse_flags@plt>
cmp    $0xffffffff,%eax
je     1172 <cmd_load+0x32>
cmpq   $0x0,(%rsp)
je     1174 <cmd_load+0x34>
mov    %eax,%edi
call   1060 <flag_to_view@plt>
mov    (%rsp),%rsi
mov    %eax,%edi
call   1050 <view_load@plt>
pop    %rax
ret
lea    0xe88(%rip),%rdi
call   1030 <error_msg@plt>
pop    %rax
ret

LLVM IR (-O0):
@.str = [3 x i8] c"lp\00"
@.str.1 = [22 x i8] c"not enough arguments\0A\00"
define void @cmd_load(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
store i8* %0, i8** %2
%4 = call i32 @parse_flags(i8** %2, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
store i32 %4, i32* %3
%5 = load i32, i32* %3
%6 = icmp eq i32 %5, -1
br i1 %6, label %7, label %8
7: ; preds = %1
br label %18
8: ; preds = %1
%9 = load i8*, i8** %2
%10 = icmp eq i8* %9, null
br i1 %10, label %11, label %13
11: ; preds = %8
%12 = call i32 @error_msg(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0))
br label %18
13: ; preds = %8
%14 = load i32, i32* %3
%15 = call i32 @flag_to_view(i32 %14)
%16 = load i8*, i8** %2
%17 = call i32 @view_load(i32 %15, i8* %16)
br label %18
18: ; preds = %13, %11, %7
ret void
}

LLVM IR (-O2):
@.str = [3 x i8] c"lp\00"
@.str.1 = [22 x i8] c"not enough arguments\0A\00"
define void @cmd_load(i8* %0) {
%2 = alloca i8*
store i8* %0, i8** %2
%3 = call i32 @parse_flags(i8** %2, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%4 = icmp eq i32 %3, -1
br i1 %4, label %14, label %5
5: ; preds = %1
%6 = load i8*, i8** %2
%7 = icmp eq i8* %6, null
br i1 %7, label %8, label %10
8: ; preds = %5
%9 = call i32 @error_msg(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0))
br label %14
10: ; preds = %5
%11 = call i32 @flag_to_view(i32 %3)
%12 = load i8*, i8** %2
%13 = call i32 @view_load(i32 %11, i8* %12)
br label %14
14: ; preds = %1, %10, %8
ret void
}