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


x86 assembly (clang, -O0):
<cmd_add>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
lea    -0x8(%rbp),%rdi
lea    0xea9(%rip),%rsi
call   1050 <parse_flags@plt>
mov    %eax,-0xc(%rbp)
cmpl   $0xffffffff,-0xc(%rbp)
jne    116e <cmd_add+0x2e>
jmp    11a9 <cmd_add+0x69>
cmpq   $0x0,-0x8(%rbp)
jne    118a <cmd_add+0x4a>
lea    0xe85(%rip),%rdi
call   1030 <error_msg@plt>
jmp    11a9 <cmd_add+0x69>
mov    -0xc(%rbp),%edi
call   1060 <flag_to_view@plt>
mov    %eax,%edi
mov    -0x8(%rbp),%rsi
cmpl   $0x51,-0xc(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%edx
call   1040 <view_add@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<cmd_add>:
push   %rbx
sub    $0x10,%rsp
mov    %rdi,0x8(%rsp)
lea    0xeaf(%rip),%rsi
lea    0x8(%rsp),%rdi
call   1050 <parse_flags@plt>
cmp    $0xffffffff,%eax
je     1193 <cmd_add+0x53>
cmpq   $0x0,0x8(%rsp)
je     1187 <cmd_add+0x47>
mov    %eax,%ebx
mov    %eax,%edi
call   1060 <flag_to_view@plt>
mov    0x8(%rsp),%rsi
xor    %edx,%edx
cmp    $0x51,%ebx
sete   %dl
mov    %eax,%edi
call   1040 <view_add@plt>
jmp    1193 <cmd_add+0x53>
lea    0xe77(%rip),%rdi
call   1030 <error_msg@plt>
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [5 x i8] c"lpqQ\00"
@.str.1 = [22 x i8] c"not enough arguments\0A\00"
define void @cmd_add(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
store i8* %0, i8** %2
%4 = call i32 @parse_flags(i8** %2, i8* getelementptr inbounds ([5 x i8], [5 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 %21
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 %21
13: ; preds = %8
%14 = load i32, i32* %3
%15 = call i32 @flag_to_view(i32 %14)
%16 = load i8*, i8** %2
%17 = load i32, i32* %3
%18 = icmp eq i32 %17, 81
%19 = zext i1 %18 to i32
%20 = call i32 @view_add(i32 %15, i8* %16, i32 %19)
br label %21
21: ; preds = %13, %11, %7
ret void
}

LLVM IR (-O2):
@.str = [5 x i8] c"lpqQ\00"
@.str.1 = [22 x i8] c"not enough arguments\0A\00"
define void @cmd_add(i8* %0) {
%2 = alloca i8*
store i8* %0, i8** %2
%3 = call i32 @parse_flags(i8** %2, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%4 = icmp eq i32 %3, -1
br i1 %4, label %16, 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 %16
10: ; preds = %5
%11 = call i32 @flag_to_view(i32 %3)
%12 = load i8*, i8** %2
%13 = icmp eq i32 %3, 81
%14 = zext i1 %13 to i32
%15 = call i32 @view_add(i32 %11, i8* %12, i32 %14)
br label %16
16: ; preds = %1, %10, %8
ret void
}