#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_elfcmd(int, char **);
int /*<<< orphan*/ printf_2(int, char *);
int parse_arg(int num_args, char **arg_ptr) {
  char *cur_cmd;
  if (arg_ptr[0][0] == '-' && num_args) {
    switch (arg_ptr[0][1]) {
    case 'd':
      printf_2(-2,
               "USING -d IS DEPRECATED, USE -es INSTEAD. FIXING COMMAND\r\n");
      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;
    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    11f5 <parse_arg+0xc5>
cmpl   $0x0,-0x8(%rbp)
je     11f5 <parse_arg+0xc5>
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
movsbl 0x1(%rax),%eax
mov    %eax,-0x1c(%rbp)
sub    $0x62,%eax
je     11d5 <parse_arg+0xa5>
jmp    1178 <parse_arg+0x48>
mov    -0x1c(%rbp),%eax
sub    $0x64,%eax
je     119a <parse_arg+0x6a>
jmp    1189 <parse_arg+0x59>
mov    -0x1c(%rbp),%eax
sub    $0x65,%eax
je     11c1 <parse_arg+0x91>
jmp    11e9 <parse_arg+0xb9>
mov    $0xfffffffe,%edi
lea    0xe5a(%rip),%rsi
call   1030 <printf_2@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   1050 <argparse_elfcmd@plt>
mov    %eax,-0x4(%rbp)
jmp    11fc <parse_arg+0xcc>
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
call   1040 <argparse_binimagecmd@plt>
mov    %eax,-0x4(%rbp)
jmp    11fc <parse_arg+0xcc>
movl   $0x0,-0x4(%rbp)
jmp    11fc <parse_arg+0xcc>
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
test   %edi,%edi
je     1186 <parse_arg+0x56>
mov    %rsi,%rbx
mov    (%rsi),%rax
cmpb   $0x2d,(%rax)
jne    1186 <parse_arg+0x56>
mov    %edi,%ebp
movsbl 0x1(%rax),%eax
cmp    $0x62,%eax
je     118f <parse_arg+0x5f>
cmp    $0x65,%eax
je     1176 <parse_arg+0x46>
cmp    $0x64,%eax
jne    1186 <parse_arg+0x56>
lea    0xea2(%rip),%rsi
mov    $0xfffffffe,%edi
call   1030 <printf_2@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    1050 <argparse_elfcmd@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret
mov    %ebp,%edi
mov    %rbx,%rsi
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1040 <argparse_binimagecmd@plt>

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

LLVM IR (-O2):
@.str = [58 x i8] c"USING -d IS DEPRECATED, USE -es INSTEAD. FIXING COMMAND\0D\0A\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 %22
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 %22 [
i32 100, label %12
i32 101, label %18
i32 98, label %20
]
12: ; preds = %8
%13 = tail call i32 @printf_2(i32 -2, i8* getelementptr inbounds ([58 x i8], [58 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 %22
20: ; preds = %8
%21 = tail call i32 @argparse_binimagecmd(i32 %0, i8** %1)
br label %22
22: ; preds = %2, %8, %20, %18
%23 = phi i32 [ %21, %20 ], [ %19, %18 ], [ 0, %8 ], [ 0, %2 ]
ret i32 %23
}