#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 */
scalar_t__ strcmp(char *, char *);
int parse_command_line(int argc, char **argv, char **pkey_text, int *pforward,
                       int *pargind, int *poutcat) {
  char *dirkey;
  *pargind = 2;
  *poutcat = 0;
  if (argc >= 2) {
    if (strcmp(argv[1], "cat") == 0) {
      *poutcat = 1;
      *pargind = 3;
    }
  }
  if ((argc - *pargind) < 1)
    return 0;
  dirkey = argv[*pargind - 1];
  *pkey_text = &dirkey[1];
  if (dirkey[0] == '+')
    *pforward = 1;
  else if (dirkey[0] == '-')
    *pforward = 0;
  else
    return 0;
  return 1;
}


x86 assembly (clang, -O0):
<parse_command_line>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
mov    %r9,-0x30(%rbp)
mov    -0x28(%rbp),%rax
movl   $0x2,(%rax)
mov    -0x30(%rbp),%rax
movl   $0x0,(%rax)
cmpl   $0x2,-0x8(%rbp)
jl     1184 <parse_command_line+0x74>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xea4(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
jne    117f <parse_command_line+0x6f>
mov    -0x30(%rbp),%rax
movl   $0x1,(%rax)
mov    -0x28(%rbp),%rax
movl   $0x3,(%rax)
jmp    1184 <parse_command_line+0x74>
mov    -0x8(%rbp),%eax
mov    -0x28(%rbp),%rcx
sub    (%rcx),%eax
cmp    $0x1,%eax
jge    11a2 <parse_command_line+0x92>
movl   $0x0,-0x4(%rbp)
jmp    121f <parse_command_line+0x10f>
mov    -0x10(%rbp),%rax
mov    -0x28(%rbp),%rcx
mov    (%rcx),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,8),%rax
mov    %rax,-0x38(%rbp)
mov    -0x38(%rbp),%rcx
add    $0x1,%rcx
mov    -0x18(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x38(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2b,%eax
jne    11e8 <parse_command_line+0xd8>
mov    -0x20(%rbp),%rax
movl   $0x1,(%rax)
jmp    1218 <parse_command_line+0x108>
mov    -0x38(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2d,%eax
jne    1207 <parse_command_line+0xf7>
mov    -0x20(%rbp),%rax
movl   $0x0,(%rax)
jmp    1213 <parse_command_line+0x103>
movl   $0x0,-0x4(%rbp)
jmp    121f <parse_command_line+0x10f>
jmp    1218 <parse_command_line+0x108>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<parse_command_line>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %r8,%rbx
mov    %rcx,%r14
mov    %rdx,%r15
mov    %rsi,%r12
mov    %edi,%ebp
movl   $0x2,(%r8)
movl   $0x0,(%r9)
cmp    $0x2,%edi
jl     1163 <parse_command_line+0x53>
mov    %r9,%r13
mov    0x8(%r12),%rdi
lea    0xeb5(%rip),%rsi
call   1030 <strcmp@plt>
test   %rax,%rax
jne    1163 <parse_command_line+0x53>
movl   $0x1,0x0(%r13)
movl   $0x3,(%rbx)
movslq (%rbx),%rcx
xor    %eax,%eax
cmp    %ebp,%ecx
jge    1193 <parse_command_line+0x83>
mov    -0x8(%r12,%rcx,8),%rcx
lea    0x1(%rcx),%rdx
mov    %rdx,(%r15)
mov    (%rcx),%cl
mov    $0x1,%edx
cmp    $0x2b,%cl
je     118b <parse_command_line+0x7b>
cmp    $0x2d,%cl
jne    1193 <parse_command_line+0x83>
xor    %edx,%edx
mov    %edx,(%r14)
mov    $0x1,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [4 x i8] c"cat\00"
define i32 @parse_command_line(i32 %0, i8** %1, i8** %2, i32* %3, i32* %4, i32* %5) {
%7 = alloca i32
%8 = alloca i32
%9 = alloca i8**
%10 = alloca i8**
%11 = alloca i32*
%12 = alloca i32*
%13 = alloca i32*
%14 = alloca i8*
store i32 %0, i32* %8
store i8** %1, i8*** %9
store i8** %2, i8*** %10
store i32* %3, i32** %11
store i32* %4, i32** %12
store i32* %5, i32** %13
%15 = load i32*, i32** %12
store i32 2, i32* %15
%16 = load i32*, i32** %13
store i32 0, i32* %16
%17 = load i32, i32* %8
%18 = icmp sge i32 %17, 2
br i1 %18, label %19, label %29
19: ; preds = %6
%20 = load i8**, i8*** %9
%21 = getelementptr inbounds i8*, i8** %20, i64 1
%22 = load i8*, i8** %21
%23 = call i64 @strcmp(i8* %22, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%24 = icmp eq i64 %23, 0
br i1 %24, label %25, label %28
25: ; preds = %19
%26 = load i32*, i32** %13
store i32 1, i32* %26
%27 = load i32*, i32** %12
store i32 3, i32* %27
br label %28
28: ; preds = %25, %19
br label %29
29: ; preds = %28, %6
%30 = load i32, i32* %8
%31 = load i32*, i32** %12
%32 = load i32, i32* %31
%33 = sub nsw i32 %30, %32
%34 = icmp slt i32 %33, 1
br i1 %34, label %35, label %36
35: ; preds = %29
store i32 0, i32* %7
br label %65
36: ; preds = %29
%37 = load i8**, i8*** %9
%38 = load i32*, i32** %12
%39 = load i32, i32* %38
%40 = sub nsw i32 %39, 1
%41 = sext i32 %40 to i64
%42 = getelementptr inbounds i8*, i8** %37, i64 %41
%43 = load i8*, i8** %42
store i8* %43, i8** %14
%44 = load i8*, i8** %14
%45 = getelementptr inbounds i8, i8* %44, i64 1
%46 = load i8**, i8*** %10
store i8* %45, i8** %46
%47 = load i8*, i8** %14
%48 = getelementptr inbounds i8, i8* %47, i64 0
%49 = load i8, i8* %48
%50 = sext i8 %49 to i32
%51 = icmp eq i32 %50, 43
br i1 %51, label %52, label %54
52: ; preds = %36
%53 = load i32*, i32** %11
store i32 1, i32* %53
br label %64
54: ; preds = %36
%55 = load i8*, i8** %14
%56 = getelementptr inbounds i8, i8* %55, i64 0
%57 = load i8, i8* %56
%58 = sext i8 %57 to i32
%59 = icmp eq i32 %58, 45
br i1 %59, label %60, label %62
60: ; preds = %54
%61 = load i32*, i32** %11
store i32 0, i32* %61
br label %63
62: ; preds = %54
store i32 0, i32* %7
br label %65
63: ; preds = %60
br label %64
64: ; preds = %63, %52
store i32 1, i32* %7
br label %65
65: ; preds = %64, %62, %35
%66 = load i32, i32* %7
ret i32 %66
}

LLVM IR (-O2):
@.str = [4 x i8] c"cat\00"
define i32 @parse_command_line(i32 %0, i8** nocapture %1, i8** nocapture writeonly %2, i32* nocapture writeonly %3, i32* nocapture %4, i32* nocapture writeonly %5) {
store i32 2, i32* %4
store i32 0, i32* %5
%7 = icmp sgt i32 %0, 1
br i1 %7, label %8, label %14
8: ; preds = %6
%9 = getelementptr inbounds i8*, i8** %1, i64 1
%10 = load i8*, i8** %9
%11 = tail call i64 @strcmp(i8* %10, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%12 = icmp eq i64 %11, 0
br i1 %12, label %13, label %14
13: ; preds = %8
store i32 1, i32* %5
store i32 3, i32* %4
br label %14
14: ; preds = %8, %13, %6
%15 = load i32, i32* %4
%16 = icmp slt i32 %15, %0
br i1 %16, label %17, label %27
17: ; preds = %14
%18 = add nsw i32 %15, -1
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds i8*, i8** %1, i64 %19
%21 = load i8*, i8** %20
%22 = getelementptr inbounds i8, i8* %21, i64 1
store i8* %22, i8** %2
%23 = load i8, i8* %21
switch i8 %23, label %27 [
i8 43, label %25
i8 45, label %24
]
24: ; preds = %17
br label %25
25: ; preds = %17, %24
%26 = phi i32 [ 0, %24 ], [ 1, %17 ]
store i32 %26, i32* %3
br label %27
27: ; preds = %17, %14, %25
%28 = phi i32 [ 1, %25 ], [ 0, %14 ], [ 0, %17 ]
ret i32 %28
}