#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_clear(int /*<<< orphan*/);
void cmd_clear(char *arg) {
  int flag = parse_flags((const char **)&arg, "lpq");
  if (flag == -1)
    return;
  if (arg) {
    error_msg("too many arguments\n");
    return;
  }
  view_clear(flag_to_view(flag));
}


x86 assembly (clang, -O0):
<cmd_clear>:
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_clear+0x2e>
jmp    1199 <cmd_clear+0x59>
cmpq   $0x0,-0x8(%rbp)
je     118a <cmd_clear+0x4a>
lea    0xe84(%rip),%rdi
call   1030 <error_msg@plt>
jmp    1199 <cmd_clear+0x59>
mov    -0xc(%rbp),%edi
call   1060 <flag_to_view@plt>
mov    %eax,%edi
call   1050 <view_clear@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<cmd_clear>:
push   %rax
mov    %rdi,(%rsp)
lea    0xeb4(%rip),%rsi
mov    %rsp,%rdi
call   1040 <parse_flags@plt>
cmp    $0xffffffff,%eax
je     117c <cmd_clear+0x3c>
cmpq   $0x0,(%rsp)
je     116e <cmd_clear+0x2e>
lea    0xe9d(%rip),%rdi
call   1030 <error_msg@plt>
pop    %rax
ret
mov    %eax,%edi
call   1060 <flag_to_view@plt>
mov    %eax,%edi
call   1050 <view_clear@plt>
pop    %rax
ret

LLVM IR (-O0):
@.str = [4 x i8] c"lpq\00"
@.str.1 = [20 x i8] c"too many arguments\0A\00"
define void @cmd_clear(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
store i8* %0, i8** %2
%4 = call i32 @parse_flags(i8** %2, i8* getelementptr inbounds ([4 x i8], [4 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 %17
8: ; preds = %1
%9 = load i8*, i8** %2
%10 = icmp ne i8* %9, null
br i1 %10, label %11, label %13
11: ; preds = %8
%12 = call i32 @error_msg(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0))
br label %17
13: ; preds = %8
%14 = load i32, i32* %3
%15 = call i32 @flag_to_view(i32 %14)
%16 = call i32 @view_clear(i32 %15)
br label %17
17: ; preds = %13, %11, %7
ret void
}

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