#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 argparse_binimagecmd(int, char **);
int argparse_commcmd(int, char **);
int argparse_elfcmd(int, char **);
int /*<<< orphan*/ infohelper_output(int, char *);
int parse_arg(int num_args, char **arg_ptr) {
  if (arg_ptr[0][0] == '-' && num_args) {
    switch (arg_ptr[0][1]) {
    case 'd':
      infohelper_output(
          1, "USING -d IS DEPRECATED, USE -es INSTEAD. FIXING COMMAND");
      arg_ptr[0][1] = 'e';
      arg_ptr[0][2] = 's';
    case 'e':
      return argparse_elfcmd(num_args, arg_ptr);
      break;
    case 'b':
      return argparse_binimagecmd(num_args, arg_ptr);
      break;
    case 'c':
      return argparse_commcmd(num_args, arg_ptr);
      break;
    case 'v':
      return 1;
      break;
    default:
      return 0;
      break;
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<parse_arg>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
movsbl (%rax),%eax
cmp    $0x2d,%eax
jne    1218 <parse_arg+0xd8>
cmpl   $0x0,-0x8(%rbp)
je     1218 <parse_arg+0xd8>
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
movsbl 0x1(%rax),%eax
add    $0xffffff9e,%eax
mov    %eax,%ecx
mov    %rcx,-0x18(%rbp)
sub    $0x14,%eax
ja     120c <parse_arg+0xcc>
mov    -0x18(%rbp),%rax
lea    0xe6c(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    $0x1,%edi
lea    0xeab(%rip),%rsi
call   1040 <infohelper_output@plt>
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
movb   $0x65,0x1(%rax)
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
movb   $0x73,0x2(%rax)
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
call   1060 <argparse_elfcmd@plt>
mov    %eax,-0x4(%rbp)
jmp    121f <parse_arg+0xdf>
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
call   1050 <argparse_binimagecmd@plt>
mov    %eax,-0x4(%rbp)
jmp    121f <parse_arg+0xdf>
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
call   1030 <argparse_commcmd@plt>
mov    %eax,-0x4(%rbp)
jmp    121f <parse_arg+0xdf>
movl   $0x1,-0x4(%rbp)
jmp    121f <parse_arg+0xdf>
movl   $0x0,-0x4(%rbp)
jmp    121f <parse_arg+0xdf>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<parse_arg>:
push   %rbp
push   %rbx
push   %rax
xor    %eax,%eax
test   %edi,%edi
je     11c8 <parse_arg+0x88>
mov    %rsi,%rbx
mov    (%rsi),%rcx
cmpb   $0x2d,(%rcx)
jne    11c8 <parse_arg+0x88>
movsbl 0x1(%rcx),%ecx
add    $0xffffff9e,%ecx
cmp    $0x14,%ecx
ja     11c6 <parse_arg+0x86>
mov    %edi,%ebp
mov    $0x1,%eax
lea    0xe92(%rip),%rdx
movslq (%rdx,%rcx,4),%rcx
add    %rdx,%rcx
jmp    *%rcx
mov    %ebp,%edi
mov    %rbx,%rsi
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1050 <argparse_binimagecmd@plt>
mov    %ebp,%edi
mov    %rbx,%rsi
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1030 <argparse_commcmd@plt>
lea    0xeb6(%rip),%rsi
mov    $0x1,%edi
call   1040 <infohelper_output@plt>
mov    (%rbx),%rax
movb   $0x65,0x1(%rax)
mov    (%rbx),%rax
movb   $0x73,0x2(%rax)
mov    %ebp,%edi
mov    %rbx,%rsi
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1060 <argparse_elfcmd@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [56 x i8] c"USING -d IS DEPRECATED, USE -es INSTEAD. FIXING COMMAND\00"
define i32 @parse_arg(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
store i32 %0, i32* %4
store i8** %1, i8*** %5
%6 = load i8**, i8*** %5
%7 = getelementptr inbounds i8*, i8** %6, i64 0
%8 = load i8*, i8** %7
%9 = getelementptr inbounds i8, i8* %8, i64 0
%10 = load i8, i8* %9
%11 = sext i8 %10 to i32
%12 = icmp eq i32 %11, 45
br i1 %12, label %13, label %47
13: ; preds = %2
%14 = load i32, i32* %4
%15 = icmp ne i32 %14, 0
br i1 %15, label %16, label %47
16: ; preds = %13
%17 = load i8**, i8*** %5
%18 = getelementptr inbounds i8*, i8** %17, i64 0
%19 = load i8*, i8** %18
%20 = getelementptr inbounds i8, i8* %19, i64 1
%21 = load i8, i8* %20
%22 = sext i8 %21 to i32
switch i32 %22, label %46 [
i32 100, label %23
i32 101, label %33
i32 98, label %37
i32 99, label %41
i32 118, label %45
]
23: ; preds = %16
%24 = call i32 @infohelper_output(i32 1, i8* getelementptr inbounds ([56 x i8], [56 x i8]* @.str, i64 0, i64 0))
%25 = load i8**, i8*** %5
%26 = getelementptr inbounds i8*, i8** %25, i64 0
%27 = load i8*, i8** %26
%28 = getelementptr inbounds i8, i8* %27, i64 1
store i8 101, i8* %28
%29 = load i8**, i8*** %5
%30 = getelementptr inbounds i8*, i8** %29, i64 0
%31 = load i8*, i8** %30
%32 = getelementptr inbounds i8, i8* %31, i64 2
store i8 115, i8* %32
br label %33
33: ; preds = %16, %23
%34 = load i32, i32* %4
%35 = load i8**, i8*** %5
%36 = call i32 @argparse_elfcmd(i32 %34, i8** %35)
store i32 %36, i32* %3
br label %48
37: ; preds = %16
%38 = load i32, i32* %4
%39 = load i8**, i8*** %5
%40 = call i32 @argparse_binimagecmd(i32 %38, i8** %39)
store i32 %40, i32* %3
br label %48
41: ; preds = %16
%42 = load i32, i32* %4
%43 = load i8**, i8*** %5
%44 = call i32 @argparse_commcmd(i32 %42, i8** %43)
store i32 %44, i32* %3
br label %48
45: ; preds = %16
store i32 1, i32* %3
br label %48
46: ; preds = %16
store i32 0, i32* %3
br label %48
47: ; preds = %13, %2
store i32 0, i32* %3
br label %48
48: ; preds = %47, %46, %45, %41, %37, %33
%49 = load i32, i32* %3
ret i32 %49
}

LLVM IR (-O2):
@.str = [56 x i8] c"USING -d IS DEPRECATED, USE -es INSTEAD. FIXING COMMAND\00"
define i32 @parse_arg(i32 %0, i8** %1) {
%3 = load i8*, i8** %1
%4 = load i8, i8* %3
%5 = icmp eq i8 %4, 45
%6 = icmp ne i32 %0, 0
%7 = and i1 %6, %5
br i1 %7, label %8, label %25
8: ; preds = %2
%9 = getelementptr inbounds i8, i8* %3, i64 1
%10 = load i8, i8* %9
%11 = sext i8 %10 to i32
switch i32 %11, label %24 [
i32 100, label %12
i32 101, label %18
i32 98, label %20
i32 99, label %22
i32 118, label %25
]
12: ; preds = %8
%13 = tail call i32 @infohelper_output(i32 1, i8* getelementptr inbounds ([56 x i8], [56 x i8]* @.str, i64 0, i64 0))
%14 = load i8*, i8** %1
%15 = getelementptr inbounds i8, i8* %14, i64 1
store i8 101, i8* %15
%16 = load i8*, i8** %1
%17 = getelementptr inbounds i8, i8* %16, i64 2
store i8 115, i8* %17
br label %18
18: ; preds = %8, %12
%19 = tail call i32 @argparse_elfcmd(i32 %0, i8** %1)
br label %25
20: ; preds = %8
%21 = tail call i32 @argparse_binimagecmd(i32 %0, i8** %1)
br label %25
22: ; preds = %8
%23 = tail call i32 @argparse_commcmd(i32 %0, i8** %1)
br label %25
24: ; preds = %8
br label %25
25: ; preds = %2, %8, %24, %22, %20, %18
%26 = phi i32 [ 0, %24 ], [ %23, %22 ], [ %21, %20 ], [ %19, %18 ], [ 1, %8 ], [ 0, %2 ]
ret i32 %26
}