#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*/ EXIT_FAILURE;
int /*<<< orphan*/ EXIT_SUCCESS;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int getopt(int, char *const *, char *);
int /*<<< orphan*/ print_usage();
int /*<<< orphan*/ print_version();
void parse_args(int argc, char *const *argv) {
  int opt;
  while ((opt = getopt(argc, argv, "v")) > 0) {
    switch (opt) {
    case '?':
      print_usage();
      exit(EXIT_FAILURE);
    case 'v':
      print_version();
      exit(EXIT_SUCCESS);
    }
  }
}


x86 assembly (clang, -O0):
<parse_args>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x4(%rbp),%edi
mov    -0x10(%rbp),%rsi
lea    0xea3(%rip),%rdx
call   1040 <getopt@plt>
mov    %eax,-0x14(%rbp)
cmp    $0x0,%eax
jle    11c2 <parse_args+0x82>
mov    -0x14(%rbp),%eax
mov    %eax,-0x18(%rbp)
sub    $0x3f,%eax
je     1193 <parse_args+0x53>
jmp    1182 <parse_args+0x42>
mov    -0x18(%rbp),%eax
sub    $0x76,%eax
je     11a8 <parse_args+0x68>
jmp    11bd <parse_args+0x7d>
mov    $0x0,%al
call   1060 <print_usage@plt>
mov    0x2e3f(%rip),%rax
mov    (%rax),%edi
call   1050 <exit@plt>
mov    $0x0,%al
call   1030 <print_version@plt>
mov    0x2e22(%rip),%rax
mov    (%rax),%edi
call   1050 <exit@plt>
jmp    114f <parse_args+0xf>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<parse_args>:
push   %rbp
push   %r14
push   %rbx
mov    %rsi,%rbx
mov    %edi,%ebp
lea    0xeb0(%rip),%r14
mov    %ebp,%edi
mov    %rbx,%rsi
mov    %r14,%rdx
call   1040 <getopt@plt>
test   %eax,%eax
jle    1180 <parse_args+0x40>
cmp    $0x76,%eax
je     1185 <parse_args+0x45>
cmp    $0x3f,%eax
jne    1150 <parse_args+0x10>
xor    %eax,%eax
call   1060 <print_usage@plt>
mov    0x2e67(%rip),%rax
mov    (%rax),%edi
call   1050 <exit@plt>
pop    %rbx
pop    %r14
pop    %rbp
ret
xor    %eax,%eax
call   1030 <print_version@plt>
mov    0x2e45(%rip),%rax
mov    (%rax),%edi
call   1050 <exit@plt>

LLVM IR (-O0):
@.str = [2 x i8] c"v\00"
@EXIT_FAILURE = global i32 0
@EXIT_SUCCESS = global i32 0
define void @parse_args(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i8**
%5 = alloca i32
store i32 %0, i32* %3
store i8** %1, i8*** %4
br label %6
6: ; preds = %21, %2
%7 = load i32, i32* %3
%8 = load i8**, i8*** %4
%9 = call i32 @getopt(i32 %7, i8** %8, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32 %9, i32* %5
%10 = icmp sgt i32 %9, 0
br i1 %10, label %11, label %22
11: ; preds = %6
%12 = load i32, i32* %5
switch i32 %12, label %21 [
i32 63, label %13
i32 118, label %17
]
13: ; preds = %11
%14 = call i32 (...) @print_usage()
%15 = load i32, i32* @EXIT_FAILURE
%16 = call i32 @exit(i32 %15)
unreachable
17: ; preds = %11
%18 = call i32 (...) @print_version()
%19 = load i32, i32* @EXIT_SUCCESS
%20 = call i32 @exit(i32 %19)
unreachable
21: ; preds = %11
br label %6
22: ; preds = %6
ret void
}

LLVM IR (-O2):
@.str = [2 x i8] c"v\00"
@EXIT_FAILURE = global i32 0
@EXIT_SUCCESS = global i32 0
define void @parse_args(i32 %0, i8** %1) {
br label %3
3: ; preds = %6, %2
%4 = tail call i32 @getopt(i32 %0, i8** %1, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%5 = icmp sgt i32 %4, 0
br i1 %5, label %6, label %15
6: ; preds = %3
switch i32 %4, label %3 [
i32 63, label %7
i32 118, label %11
]
7: ; preds = %6
%8 = tail call i32 (...) @print_usage()
%9 = load i32, i32* @EXIT_FAILURE
%10 = tail call i32 @exit(i32 %9)
unreachable
11: ; preds = %6
%12 = tail call i32 (...) @print_version()
%13 = load i32, i32* @EXIT_SUCCESS
%14 = tail call i32 @exit(i32 %13)
unreachable
15: ; preds = %3
ret void
}