#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*/ key_unbind(char *, char *, int);
int parse_flags(char const **, char *);
char *strchr(char *, char);
void cmd_unbind(char *arg) {
  int flag = parse_flags((const char **)&arg, "f");
  char *key;
  if (flag == -1)
    return;
  if (arg == NULL)
    goto err;
  key = strchr(arg, ' ');
  if (key == NULL)
    goto err;
  *key++ = 0;
  while (*key == ' ')
    key++;
  if (*key == 0)
    goto err;
  key_unbind(arg, key, flag == 'f');
  return;
err:
  error_msg("expecting 2 arguments (context and key)\n");
}


x86 assembly (clang, -O0):
<cmd_unbind>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%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_unbind+0x2e>
jmp    1212 <cmd_unbind+0xd2>
cmpq   $0x0,-0x8(%rbp)
jne    117e <cmd_unbind+0x3e>
jmp    1206 <cmd_unbind+0xc6>
mov    -0x8(%rbp),%rdi
mov    $0x20,%esi
call   1040 <strchr@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    11a0 <cmd_unbind+0x60>
jmp    1206 <cmd_unbind+0xc6>
mov    -0x18(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x18(%rbp)
movb   $0x0,(%rax)
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x20,%eax
jne    11d3 <cmd_unbind+0x93>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    11b2 <cmd_unbind+0x72>
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
jne    11e8 <cmd_unbind+0xa8>
jmp    1206 <cmd_unbind+0xc6>
mov    -0x8(%rbp),%rdi
mov    -0x18(%rbp),%rsi
cmpl   $0x66,-0xc(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%edx
call   1060 <key_unbind@plt>
jmp    1212 <cmd_unbind+0xd2>
lea    0xdf5(%rip),%rdi
call   1030 <error_msg@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<cmd_unbind>:
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     119d <cmd_unbind+0x5d>
mov    0x8(%rsp),%rdi
test   %rdi,%rdi
je     1191 <cmd_unbind+0x51>
mov    %eax,%ebx
mov    $0x20,%esi
call   1040 <strchr@plt>
test   %rax,%rax
je     1191 <cmd_unbind+0x51>
movb   $0x0,(%rax)
xchg   %ax,%ax
movzbl 0x1(%rax),%ecx
add    $0x1,%rax
cmp    $0x20,%cl
je     1180 <cmd_unbind+0x40>
test   %cl,%cl
jne    11a3 <cmd_unbind+0x63>
lea    0xe6a(%rip),%rdi
call   1030 <error_msg@plt>
add    $0x10,%rsp
pop    %rbx
ret
mov    0x8(%rsp),%rdi
xor    %edx,%edx
cmp    $0x66,%ebx
sete   %dl
mov    %rax,%rsi
call   1060 <key_unbind@plt>
jmp    119d <cmd_unbind+0x5d>

LLVM IR (-O0):
@.str = [2 x i8] c"f\00"
@.str.1 = [41 x i8] c"expecting 2 arguments (context and key)\0A\00"
define void @cmd_unbind(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
%4 = alloca i8*
store i8* %0, i8** %2
%5 = call i32 @parse_flags(i8** %2, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32 %5, i32* %3
%6 = load i32, i32* %3
%7 = icmp eq i32 %6, -1
br i1 %7, label %8, label %9
8: ; preds = %1
br label %45
9: ; preds = %1
%10 = load i8*, i8** %2
%11 = icmp eq i8* %10, null
br i1 %11, label %12, label %13
12: ; preds = %9
br label %43
13: ; preds = %9
%14 = load i8*, i8** %2
%15 = call i8* @strchr(i8* %14, i8 signext 32)
store i8* %15, i8** %4
%16 = load i8*, i8** %4
%17 = icmp eq i8* %16, null
br i1 %17, label %18, label %19
18: ; preds = %13
br label %43
19: ; preds = %13
%20 = load i8*, i8** %4
%21 = getelementptr inbounds i8, i8* %20, i32 1
store i8* %21, i8** %4
store i8 0, i8* %20
br label %22
22: ; preds = %27, %19
%23 = load i8*, i8** %4
%24 = load i8, i8* %23
%25 = sext i8 %24 to i32
%26 = icmp eq i32 %25, 32
br i1 %26, label %27, label %30
27: ; preds = %22
%28 = load i8*, i8** %4
%29 = getelementptr inbounds i8, i8* %28, i32 1
store i8* %29, i8** %4
br label %22
30: ; preds = %22
%31 = load i8*, i8** %4
%32 = load i8, i8* %31
%33 = sext i8 %32 to i32
%34 = icmp eq i32 %33, 0
br i1 %34, label %35, label %36
35: ; preds = %30
br label %43
36: ; preds = %30
%37 = load i8*, i8** %2
%38 = load i8*, i8** %4
%39 = load i32, i32* %3
%40 = icmp eq i32 %39, 102
%41 = zext i1 %40 to i32
%42 = call i32 @key_unbind(i8* %37, i8* %38, i32 %41)
br label %45
43: ; preds = %35, %18, %12
%44 = call i32 @error_msg(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.1, i64 0, i64 0))
br label %45
45: ; preds = %43, %36, %8
ret void
}

LLVM IR (-O2):
@.str = [2 x i8] c"f\00"
@.str.1 = [41 x i8] c"expecting 2 arguments (context and key)\0A\00"
define void @cmd_unbind(i8* %0) {
%2 = alloca i8*
store i8* %0, i8** %2
%3 = call i32 @parse_flags(i8** %2, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%4 = icmp eq i32 %3, -1
br i1 %4, label %23, label %5
5: ; preds = %1
%6 = load i8*, i8** %2
%7 = icmp eq i8* %6, null
br i1 %7, label %21, label %8
8: ; preds = %5
%9 = call i8* @strchr(i8* %6, i8 signext 32)
%10 = icmp eq i8* %9, null
br i1 %10, label %21, label %11
11: ; preds = %8
store i8 0, i8* %9
br label %12
12: ; preds = %12, %11
%13 = phi i8* [ %9, %11 ], [ %14, %12 ]
%14 = getelementptr inbounds i8, i8* %13, i64 1
%15 = load i8, i8* %14
switch i8 %15, label %16 [
i8 32, label %12
i8 0, label %21
]
16: ; preds = %12
%17 = load i8*, i8** %2
%18 = icmp eq i32 %3, 102
%19 = zext i1 %18 to i32
%20 = call i32 @key_unbind(i8* %17, i8* %14, i32 %19)
br label %23
21: ; preds = %12, %8, %5
%22 = call i32 @error_msg(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.1, i64 0, i64 0))
br label %23
23: ; preds = %1, %21, %16
ret void
}