#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 atoi(char *);
int /*<<< orphan*/ strcmp(char *, char *);
void parse_cmd_line(int argc, char **argv, int *xtnum, int *filter,
                    int *c_arg) {
  *filter = 0;
  *xtnum = -1;
  *c_arg = argc - 1;
  if (!strcmp(argv[argc - 1], "-"))
    *filter = 1;
  if (!strcmp(argv[1], "-x")) {
    *xtnum = atoi(argv[2]);
    *c_arg = 3;
  } else {
    *c_arg = 1;
  }
  return;
}


x86 assembly (clang, -O0):
<parse_cmd_line>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
mov    -0x20(%rbp),%rax
movl   $0x0,(%rax)
mov    -0x18(%rbp),%rax
movl   $0xffffffff,(%rax)
mov    -0x4(%rbp),%ecx
sub    $0x1,%ecx
mov    -0x28(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x10(%rbp),%rax
mov    -0x4(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,8),%rdi
lea    0xe8d(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%eax
jne    118b <parse_cmd_line+0x6b>
mov    -0x20(%rbp),%rax
movl   $0x1,(%rax)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe68(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%eax
jne    11cc <parse_cmd_line+0xac>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   1040 <atoi@plt>
mov    %eax,%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x28(%rbp),%rax
movl   $0x3,(%rax)
jmp    11d6 <parse_cmd_line+0xb6>
mov    -0x28(%rbp),%rax
movl   $0x1,(%rax)
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<parse_cmd_line>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %r8,%r15
mov    %rcx,%r12
mov    %rdx,%r14
mov    %rsi,%rbx
movl   $0x0,(%rcx)
movl   $0xffffffff,(%rdx)
lea    -0x1(%rdi),%eax
mov    %eax,(%r8)
movslq %edi,%rax
mov    -0x8(%rsi,%rax,8),%rdi
lea    0xeab(%rip),%rsi
call   1030 <strcmp@plt>
test   %eax,%eax
jne    1166 <parse_cmd_line+0x46>
movl   $0x1,(%r12)
mov    0x8(%rbx),%rdi
lea    0xe91(%rip),%rsi
call   1030 <strcmp@plt>
mov    $0x1,%ecx
test   %eax,%eax
jne    1190 <parse_cmd_line+0x70>
mov    0x10(%rbx),%rdi
call   1040 <atoi@plt>
mov    %eax,(%r14)
mov    $0x3,%ecx
mov    %ecx,(%r15)
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [2 x i8] c"-\00"
@.str.1 = [3 x i8] c"-x\00"
define void @parse_cmd_line(i32 %0, i8** %1, i32* %2, i32* %3, i32* %4) {
%6 = alloca i32
%7 = alloca i8**
%8 = alloca i32*
%9 = alloca i32*
%10 = alloca i32*
store i32 %0, i32* %6
store i8** %1, i8*** %7
store i32* %2, i32** %8
store i32* %3, i32** %9
store i32* %4, i32** %10
%11 = load i32*, i32** %9
store i32 0, i32* %11
%12 = load i32*, i32** %8
store i32 -1, i32* %12
%13 = load i32, i32* %6
%14 = sub nsw i32 %13, 1
%15 = load i32*, i32** %10
store i32 %14, i32* %15
%16 = load i8**, i8*** %7
%17 = load i32, i32* %6
%18 = sub nsw i32 %17, 1
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds i8*, i8** %16, i64 %19
%21 = load i8*, i8** %20
%22 = call i32 @strcmp(i8* %21, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%23 = icmp ne i32 %22, 0
br i1 %23, label %26, label %24
24: ; preds = %5
%25 = load i32*, i32** %9
store i32 1, i32* %25
br label %26
26: ; preds = %24, %5
%27 = load i8**, i8*** %7
%28 = getelementptr inbounds i8*, i8** %27, i64 1
%29 = load i8*, i8** %28
%30 = call i32 @strcmp(i8* %29, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%31 = icmp ne i32 %30, 0
br i1 %31, label %39, label %32
32: ; preds = %26
%33 = load i8**, i8*** %7
%34 = getelementptr inbounds i8*, i8** %33, i64 2
%35 = load i8*, i8** %34
%36 = call i32 @atoi(i8* %35)
%37 = load i32*, i32** %8
store i32 %36, i32* %37
%38 = load i32*, i32** %10
store i32 3, i32* %38
br label %41
39: ; preds = %26
%40 = load i32*, i32** %10
store i32 1, i32* %40
br label %41
41: ; preds = %39, %32
ret void
}

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