#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*/ die(char *);
int /*<<< orphan*/ print_usage(int /*<<< orphan*/);
int /*<<< orphan*/ print_version(int /*<<< orphan*/);
scalar_t__ strcmp(char *, char *);
char *parse_args(int argc, char **argv) {
  register unsigned int i;
  for (i = 1; i < argc; i++) {
    if (strcmp(argv[i], "-h") == 0 || strcmp(argv[i], "--help") == 0)
      print_usage(0);
    else if (strcmp(argv[i], "-v") == 0 || strcmp(argv[i], "--version") == 0)
      print_version(0);
    else
      return argv[i];
  }
  die("No input file specified.");
  return NULL;
}


x86 assembly (clang, -O0):
<parse_args>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0xc(%rbp)
mov    %rsi,-0x18(%rbp)
movl   $0x1,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0xc(%rbp),%eax
jae    122a <parse_args+0xea>
mov    -0x18(%rbp),%rax
mov    -0x1c(%rbp),%ecx
mov    (%rax,%rcx,8),%rdi
lea    0xe8c(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
je     11a4 <parse_args+0x64>
mov    -0x18(%rbp),%rax
mov    -0x1c(%rbp),%ecx
mov    (%rax,%rcx,8),%rdi
lea    0xe6e(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    11b0 <parse_args+0x70>
xor    %edi,%edi
call   1060 <print_usage@plt>
jmp    1217 <parse_args+0xd7>
mov    -0x18(%rbp),%rax
mov    -0x1c(%rbp),%ecx
mov    (%rax,%rcx,8),%rdi
lea    0xe48(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
je     11f2 <parse_args+0xb2>
mov    -0x18(%rbp),%rax
mov    -0x1c(%rbp),%ecx
mov    (%rax,%rcx,8),%rdi
lea    0xe2a(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    11fe <parse_args+0xbe>
xor    %edi,%edi
call   1030 <print_version@plt>
jmp    1212 <parse_args+0xd2>
mov    -0x18(%rbp),%rax
mov    -0x1c(%rbp),%ecx
mov    (%rax,%rcx,8),%rax
mov    %rax,-0x8(%rbp)
jmp    123e <parse_args+0xfe>
jmp    1217 <parse_args+0xd7>
jmp    121c <parse_args+0xdc>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1156 <parse_args+0x16>
lea    0xde6(%rip),%rdi
call   1050 <die@plt>
movq   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<parse_args>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
cmp    $0x2,%edi
jb     11e1 <parse_args+0xa1>
mov    %rsi,%rbx
mov    %edi,%ebp
mov    $0x1,%r13d
lea    0xe9a(%rip),%r14
lea    0xe96(%rip),%r15
lea    0xe96(%rip),%r12
jmp    1190 <parse_args+0x50>
cs nopw 0x0(%rax,%rax,1)
xor    %edi,%edi
call   1060 <print_usage@plt>
add    $0x1,%r13
cmp    %r13,%rbp
je     11e1 <parse_args+0xa1>
mov    (%rbx,%r13,8),%rdi
mov    %r14,%rsi
call   1040 <strcmp@plt>
test   %rax,%rax
je     1180 <parse_args+0x40>
mov    (%rbx,%r13,8),%rdi
mov    %r15,%rsi
call   1040 <strcmp@plt>
test   %rax,%rax
je     1180 <parse_args+0x40>
mov    (%rbx,%r13,8),%rdi
mov    %r12,%rsi
call   1040 <strcmp@plt>
test   %rax,%rax
je     11d8 <parse_args+0x98>
mov    (%rbx,%r13,8),%rdi
lea    0xe3f(%rip),%rsi
call   1040 <strcmp@plt>
test   %rax,%rax
jne    11fe <parse_args+0xbe>
xor    %edi,%edi
call   1030 <print_version@plt>
jmp    1187 <parse_args+0x47>
lea    0xe2f(%rip),%rdi
call   1050 <die@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    (%rbx,%r13,8),%rax
jmp    11ef <parse_args+0xaf>

LLVM IR (-O0):
@.str = [3 x i8] c"-h\00"
@.str.1 = [7 x i8] c"--help\00"
@.str.2 = [3 x i8] c"-v\00"
@.str.3 = [10 x i8] c"--version\00"
@.str.4 = [25 x i8] c"No input file specified.\00"
define i8* @parse_args(i32 %0, i8** %1) {
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 1, i32* %6
br label %7
7: ; preds = %55, %2
%8 = load i32, i32* %6
%9 = load i32, i32* %4
%10 = icmp ult i32 %8, %9
br i1 %10, label %11, label %58
11: ; preds = %7
%12 = load i8**, i8*** %5
%13 = load i32, i32* %6
%14 = zext i32 %13 to i64
%15 = getelementptr inbounds i8*, i8** %12, i64 %14
%16 = load i8*, i8** %15
%17 = call i64 @strcmp(i8* %16, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%18 = icmp eq i64 %17, 0
br i1 %18, label %27, label %19
19: ; preds = %11
%20 = load i8**, i8*** %5
%21 = load i32, i32* %6
%22 = zext i32 %21 to i64
%23 = getelementptr inbounds i8*, i8** %20, i64 %22
%24 = load i8*, i8** %23
%25 = call i64 @strcmp(i8* %24, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
%26 = icmp eq i64 %25, 0
br i1 %26, label %27, label %29
27: ; preds = %19, %11
%28 = call i32 @print_usage(i32 0)
br label %54
29: ; preds = %19
%30 = load i8**, i8*** %5
%31 = load i32, i32* %6
%32 = zext i32 %31 to i64
%33 = getelementptr inbounds i8*, i8** %30, i64 %32
%34 = load i8*, i8** %33
%35 = call i64 @strcmp(i8* %34, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%36 = icmp eq i64 %35, 0
br i1 %36, label %45, label %37
37: ; preds = %29
%38 = load i8**, i8*** %5
%39 = load i32, i32* %6
%40 = zext i32 %39 to i64
%41 = getelementptr inbounds i8*, i8** %38, i64 %40
%42 = load i8*, i8** %41
%43 = call i64 @strcmp(i8* %42, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0))
%44 = icmp eq i64 %43, 0
br i1 %44, label %45, label %47
45: ; preds = %37, %29
%46 = call i32 @print_version(i32 0)
br label %53
47: ; preds = %37
%48 = load i8**, i8*** %5
%49 = load i32, i32* %6
%50 = zext i32 %49 to i64
%51 = getelementptr inbounds i8*, i8** %48, i64 %50
%52 = load i8*, i8** %51
store i8* %52, i8** %3
br label %60
53: ; preds = %45
br label %54
54: ; preds = %53, %27
br label %55
55: ; preds = %54
%56 = load i32, i32* %6
%57 = add i32 %56, 1
store i32 %57, i32* %6
br label %7
58: ; preds = %7
%59 = call i32 @die(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.4, i64 0, i64 0))
store i8* null, i8** %3
br label %60
60: ; preds = %58, %47
%61 = load i8*, i8** %3
ret i8* %61
}

LLVM IR (-O2):
@.str = [3 x i8] c"-h\00"
@.str.1 = [7 x i8] c"--help\00"
@.str.2 = [3 x i8] c"-v\00"
@.str.3 = [10 x i8] c"--version\00"
@.str.4 = [25 x i8] c"No input file specified.\00"
define i8* @parse_args(i32 %0, i8** nocapture %1) {
%3 = icmp ugt i32 %0, 1
br i1 %3, label %4, label %33
4: ; preds = %2
%5 = zext i32 %0 to i64
br label %6
6: ; preds = %4, %30
%7 = phi i64 [ 1, %4 ], [ %31, %30 ]
%8 = getelementptr inbounds i8*, i8** %1, i64 %7
%9 = load i8*, i8** %8
%10 = tail call i64 @strcmp(i8* %9, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%11 = icmp eq i64 %10, 0
br i1 %11, label %16, label %12
12: ; preds = %6
%13 = load i8*, i8** %8
%14 = tail call i64 @strcmp(i8* %13, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
%15 = icmp eq i64 %14, 0
br i1 %15, label %16, label %18
16: ; preds = %12, %6
%17 = tail call i32 @print_usage(i32 0)
br label %30
18: ; preds = %12
%19 = load i8*, i8** %8
%20 = tail call i64 @strcmp(i8* %19, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%21 = icmp eq i64 %20, 0
br i1 %21, label %26, label %22
22: ; preds = %18
%23 = load i8*, i8** %8
%24 = tail call i64 @strcmp(i8* %23, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0))
%25 = icmp eq i64 %24, 0
br i1 %25, label %26, label %28
26: ; preds = %22, %18
%27 = tail call i32 @print_version(i32 0)
br label %30
28: ; preds = %22
%29 = load i8*, i8** %8
br label %35
30: ; preds = %16, %26
%31 = add nuw nsw i64 %7, 1
%32 = icmp eq i64 %31, %5
br i1 %32, label %33, label %6
33: ; preds = %30, %2
%34 = tail call i32 @die(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.4, i64 0, i64 0))
br label %35
35: ; preds = %33, %28
%36 = phi i8* [ %29, %28 ], [ null, %33 ]
ret i8* %36
}