#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 */
struct option {
  char *name;
  char val;
  int /*<<< orphan*/ *flag;
  int /*<<< orphan*/ const has_arg;
};

/* Variables and functions */
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
int getopt_long(int, char **, char *, struct option const *, int *);
#define no_argument 129
char *optarg;
#define required_argument 128
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ usage(char *);
int /*<<< orphan*/ version();
int parse_cmdline(int argc, char *argv[], char **filename,
                  char **output_filename) {
  static const struct option options[] = {
      {.name = "help", .has_arg = no_argument, .flag = NULL, .val = 0},
      {.name = "version", .has_arg = no_argument, .flag = NULL, .val = 0},
      {.name = "input", .has_arg = required_argument, .flag = NULL, .val = 'i'},
      {.name = "output",
       .has_arg = required_argument,
       .flag = NULL,
       .val = 'o'}};
  int ch, longidx;
  *filename = NULL;
  *output_filename = NULL;
  while ((ch = getopt_long(argc, argv, "i:o:", options, &longidx)) != -1) {
    switch (ch) {
    case '?':
    case ':':
      return 0;
    case 'i':
      *filename = optarg;
      break;
    case 'o':
      *output_filename = optarg;
      break;
    case 0:
      switch (longidx) {
      case 0:
        usage(argv[0]);
        return 0;
      case 1:
        version();
        return 0;
      }
      break;
    }
  }
  if (*filename == NULL) {
    fprintf(stderr,
            "%1$s: RIL file name is not specified. Try '%1$s --help'.\n",
            argv[0]);
    return 0;
  }
  if (*output_filename == NULL) {
    fprintf(stderr,
            "%1$s: output file name is not specified. Try '%1$s --help'.\n",
            argv[0]);
    return 0;
  }
  return 1;
}


x86 assembly (clang, -O0):
<parse_cmdline>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    -0x18(%rbp),%rax
movq   $0x0,(%rax)
mov    -0x20(%rbp),%rax
movq   $0x0,(%rax)
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
lea    0xe9f(%rip),%rdx
lea    0x2c0e(%rip),%rcx
lea    -0x28(%rbp),%r8
call   1030 <getopt_long@plt>
mov    %eax,-0x24(%rbp)
cmp    $0xffffffff,%eax
je     127f <parse_cmdline+0x13f>
mov    -0x24(%rbp),%eax
mov    %eax,-0x2c(%rbp)
test   %eax,%eax
je     1226 <parse_cmdline+0xe6>
jmp    11aa <parse_cmdline+0x6a>
mov    -0x2c(%rbp),%eax
sub    $0x3a,%eax
je     11ee <parse_cmdline+0xae>
jmp    11bb <parse_cmdline+0x7b>
mov    -0x2c(%rbp),%eax
sub    $0x3f,%eax
je     11ee <parse_cmdline+0xae>
jmp    11cc <parse_cmdline+0x8c>
mov    -0x2c(%rbp),%eax
sub    $0x69,%eax
je     11fa <parse_cmdline+0xba>
jmp    11dd <parse_cmdline+0x9d>
mov    -0x2c(%rbp),%eax
sub    $0x6f,%eax
je     1210 <parse_cmdline+0xd0>
jmp    127a <parse_cmdline+0x13a>
movl   $0x0,-0x4(%rbp)
jmp    12f2 <parse_cmdline+0x1b2>
mov    0x2df7(%rip),%rax
mov    (%rax),%rcx
mov    -0x18(%rbp),%rax
mov    %rcx,(%rax)
jmp    127a <parse_cmdline+0x13a>
mov    0x2de1(%rip),%rax
mov    (%rax),%rcx
mov    -0x20(%rbp),%rax
mov    %rcx,(%rax)
jmp    127a <parse_cmdline+0x13a>
mov    -0x28(%rbp),%eax
mov    %eax,-0x30(%rbp)
test   %eax,%eax
je     124a <parse_cmdline+0x10a>
jmp    1239 <parse_cmdline+0xf9>
mov    -0x30(%rbp),%eax
sub    $0x1,%eax
je     1262 <parse_cmdline+0x122>
jmp    1275 <parse_cmdline+0x135>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   1060 <usage@plt>
movl   $0x0,-0x4(%rbp)
jmp    12f2 <parse_cmdline+0x1b2>
mov    $0x0,%al
call   1050 <version@plt>
movl   $0x0,-0x4(%rbp)
jmp    12f2 <parse_cmdline+0x1b2>
jmp    127a <parse_cmdline+0x13a>
jmp    116d <parse_cmdline+0x2d>
mov    -0x18(%rbp),%rax
cmpq   $0x0,(%rax)
jne    12b5 <parse_cmdline+0x175>
mov    0x2d44(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xd7b(%rip),%rsi
call   1040 <fprintf@plt>
movl   $0x0,-0x4(%rbp)
jmp    12f2 <parse_cmdline+0x1b2>
mov    -0x20(%rbp),%rax
cmpq   $0x0,(%rax)
jne    12eb <parse_cmdline+0x1ab>
mov    0x2d0e(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xd7f(%rip),%rsi
call   1040 <fprintf@plt>
movl   $0x0,-0x4(%rbp)
jmp    12f2 <parse_cmdline+0x1b2>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<parse_cmdline>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rdx,%r15
mov    %rsi,%rbx
mov    %edi,%ebp
movq   $0x0,(%rdx)
mov    %rcx,0x10(%rsp)
movq   $0x0,(%rcx)
lea    0xeaa(%rip),%r12
lea    0x2c19(%rip),%r13
lea    0xc(%rsp),%r14
jmp    118d <parse_cmdline+0x4d>
xchg   %ax,%ax
mov    0x2e71(%rip),%rax
mov    (%rax),%rax
mov    %rax,(%rcx)
mov    %ebp,%edi
mov    %rbx,%rsi
mov    %r12,%rdx
mov    %r13,%rcx
mov    %r14,%r8
call   1030 <getopt_long@plt>
cmp    $0x3e,%eax
jle    11c0 <parse_cmdline+0x80>
mov    %r15,%rcx
cmp    $0x69,%eax
je     1180 <parse_cmdline+0x40>
mov    0x10(%rsp),%rcx
cmp    $0x6f,%eax
je     1180 <parse_cmdline+0x40>
cmp    $0x3f,%eax
jne    118d <parse_cmdline+0x4d>
jmp    1237 <parse_cmdline+0xf7>
xchg   %ax,%ax
test   %eax,%eax
jne    11d3 <parse_cmdline+0x93>
mov    0xc(%rsp),%eax
cmp    $0x1,%eax
je     120a <parse_cmdline+0xca>
test   %eax,%eax
jne    118d <parse_cmdline+0x4d>
jmp    1215 <parse_cmdline+0xd5>
cmp    $0xffffffff,%eax
je     11df <parse_cmdline+0x9f>
cmp    $0x3a,%eax
jne    118d <parse_cmdline+0x4d>
jmp    1237 <parse_cmdline+0xf7>
cmpq   $0x0,(%r15)
je     121f <parse_cmdline+0xdf>
mov    $0x1,%ebp
mov    0x10(%rsp),%rax
cmpq   $0x0,(%rax)
jne    1239 <parse_cmdline+0xf9>
mov    0x2ddc(%rip),%rax
mov    (%rax),%edi
mov    (%rbx),%rdx
lea    0xe51(%rip),%rsi
jmp    1232 <parse_cmdline+0xf2>
xor    %ebp,%ebp
xor    %eax,%eax
call   1050 <version@plt>
jmp    1239 <parse_cmdline+0xf9>
mov    (%rbx),%rdi
call   1060 <usage@plt>
jmp    1237 <parse_cmdline+0xf7>
mov    0x2db2(%rip),%rax
mov    (%rax),%edi
mov    (%rbx),%rdx
lea    0xded(%rip),%rsi
call   1040 <fprintf@plt>
xor    %ebp,%ebp
mov    %ebp,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.option = type { i8*, i8, i32*, i32 }
@parse_cmdline.options = internal constant [4 x %struct.option] [%struct.option { i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i32 0, i32 0), i8 0, i32* null, i32 129 }, %struct.option { i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i32 0, i32 0), i8 0, i32* null, i32 129 }, %struct.option { i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i32 0, i32 0), i8 105, i32* null, i32 128 }, %struct.option { i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i32 0, i32 0), i8 111, i32* null, i32 128 }]
@.str = [5 x i8] c"help\00"
@.str.1 = [8 x i8] c"version\00"
@.str.2 = [6 x i8] c"input\00"
@.str.3 = [7 x i8] c"output\00"
@.str.4 = [5 x i8] c"i:o:\00"
@optarg = global i8* null
@stderr = global i32 0
@.str.5 = [58 x i8] c"%1$s: RIL file name is not specified. Try '%1$s --help'.\0A\00"
@.str.6 = [61 x i8] c"%1$s: output file name is not specified. Try '%1$s --help'.\0A\00"
define i32 @parse_cmdline(i32 %0, i8** %1, i8** %2, i8** %3) {
%5 = alloca i32
%6 = alloca i32
%7 = alloca i8**
%8 = alloca i8**
%9 = alloca i8**
%10 = alloca i32
%11 = alloca i32
store i32 %0, i32* %6
store i8** %1, i8*** %7
store i8** %2, i8*** %8
store i8** %3, i8*** %9
%12 = load i8**, i8*** %8
store i8* null, i8** %12
%13 = load i8**, i8*** %9
store i8* null, i8** %13
br label %14
14: ; preds = %38, %4
%15 = load i32, i32* %6
%16 = load i8**, i8*** %7
%17 = call i32 @getopt_long(i32 %15, i8** %16, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), %struct.option* getelementptr inbounds ([4 x %struct.option], [4 x %struct.option]* @parse_cmdline.options, i64 0, i64 0), i32* %11)
store i32 %17, i32* %10
%18 = icmp ne i32 %17, -1
br i1 %18, label %19, label %39
19: ; preds = %14
%20 = load i32, i32* %10
switch i32 %20, label %38 [
i32 63, label %21
i32 58, label %21
i32 105, label %22
i32 111, label %25
i32 0, label %28
]
21: ; preds = %19, %19
store i32 0, i32* %5
br label %60
22: ; preds = %19
%23 = load i8*, i8** @optarg
%24 = load i8**, i8*** %8
store i8* %23, i8** %24
br label %38
25: ; preds = %19
%26 = load i8*, i8** @optarg
%27 = load i8**, i8*** %9
store i8* %26, i8** %27
br label %38
28: ; preds = %19
%29 = load i32, i32* %11
switch i32 %29, label %37 [
i32 0, label %30
i32 1, label %35
]
30: ; preds = %28
%31 = load i8**, i8*** %7
%32 = getelementptr inbounds i8*, i8** %31, i64 0
%33 = load i8*, i8** %32
%34 = call i32 @usage(i8* %33)
store i32 0, i32* %5
br label %60
35: ; preds = %28
%36 = call i32 (...) @version()
store i32 0, i32* %5
br label %60
37: ; preds = %28
br label %38
38: ; preds = %19, %37, %25, %22
br label %14
39: ; preds = %14
%40 = load i8**, i8*** %8
%41 = load i8*, i8** %40
%42 = icmp eq i8* %41, null
br i1 %42, label %43, label %49
43: ; preds = %39
%44 = load i32, i32* @stderr
%45 = load i8**, i8*** %7
%46 = getelementptr inbounds i8*, i8** %45, i64 0
%47 = load i8*, i8** %46
%48 = call i32 @fprintf(i32 %44, i8* getelementptr inbounds ([58 x i8], [58 x i8]* @.str.5, i64 0, i64 0), i8* %47)
store i32 0, i32* %5
br label %60
49: ; preds = %39
%50 = load i8**, i8*** %9
%51 = load i8*, i8** %50
%52 = icmp eq i8* %51, null
br i1 %52, label %53, label %59
53: ; preds = %49
%54 = load i32, i32* @stderr
%55 = load i8**, i8*** %7
%56 = getelementptr inbounds i8*, i8** %55, i64 0
%57 = load i8*, i8** %56
%58 = call i32 @fprintf(i32 %54, i8* getelementptr inbounds ([61 x i8], [61 x i8]* @.str.6, i64 0, i64 0), i8* %57)
store i32 0, i32* %5
br label %60
59: ; preds = %49
store i32 1, i32* %5
br label %60
60: ; preds = %59, %53, %43, %35, %30, %21
%61 = load i32, i32* %5
ret i32 %61
}

LLVM IR (-O2):
%struct.option = type { i8*, i8, i32*, i32 }
@parse_cmdline.options = internal constant [4 x %struct.option] [%struct.option { i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i32 0, i32 0), i8 0, i32* null, i32 129 }, %struct.option { i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i32 0, i32 0), i8 0, i32* null, i32 129 }, %struct.option { i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i32 0, i32 0), i8 105, i32* null, i32 128 }, %struct.option { i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i32 0, i32 0), i8 111, i32* null, i32 128 }]
@.str = [5 x i8] c"help\00"
@.str.1 = [8 x i8] c"version\00"
@.str.2 = [6 x i8] c"input\00"
@.str.3 = [7 x i8] c"output\00"
@.str.4 = [5 x i8] c"i:o:\00"
@optarg = global i8* null
@stderr = global i32 0
@.str.5 = [58 x i8] c"%1$s: RIL file name is not specified. Try '%1$s --help'.\0A\00"
@.str.6 = [61 x i8] c"%1$s: output file name is not specified. Try '%1$s --help'.\0A\00"
define i32 @parse_cmdline(i32 %0, i8** %1, i8** nocapture %2, i8** nocapture %3) {
%5 = alloca i32
%6 = bitcast i32* %5 to i8*
store i8* null, i8** %2
store i8* null, i8** %3
br label %7
7: ; preds = %20, %4
%8 = call i32 @getopt_long(i32 %0, i8** %1, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), %struct.option* getelementptr inbounds ([4 x %struct.option], [4 x %struct.option]* @parse_cmdline.options, i64 0, i64 0), i32* %5)
switch i32 %8, label %20 [
i32 -1, label %21
i32 63, label %35
i32 58, label %35
i32 105, label %17
i32 111, label %9
i32 0, label %10
]
9: ; preds = %7
br label %17
10: ; preds = %7
%11 = load i32, i32* %5
switch i32 %11, label %20 [
i32 0, label %12
i32 1, label %15
]
12: ; preds = %10
%13 = load i8*, i8** %1
%14 = call i32 @usage(i8* %13)
br label %35
15: ; preds = %10
%16 = call i32 (...) @version()
br label %35
17: ; preds = %7, %9
%18 = phi i8** [ %3, %9 ], [ %2, %7 ]
%19 = load i8*, i8** @optarg
store i8* %19, i8** %18
br label %20
20: ; preds = %17, %7, %10
br label %7
21: ; preds = %7
%22 = load i8*, i8** %2
%23 = icmp eq i8* %22, null
br i1 %23, label %24, label %28
24: ; preds = %21
%25 = load i32, i32* @stderr
%26 = load i8*, i8** %1
%27 = call i32 @fprintf(i32 %25, i8* getelementptr inbounds ([58 x i8], [58 x i8]* @.str.5, i64 0, i64 0), i8* %26)
br label %35
28: ; preds = %21
%29 = load i8*, i8** %3
%30 = icmp eq i8* %29, null
br i1 %30, label %31, label %35
31: ; preds = %28
%32 = load i32, i32* @stderr
%33 = load i8*, i8** %1
%34 = call i32 @fprintf(i32 %32, i8* getelementptr inbounds ([61 x i8], [61 x i8]* @.str.6, i64 0, i64 0), i8* %33)
br label %35
35: ; preds = %7, %7, %28, %31, %24, %15, %12
%36 = phi i32 [ 0, %15 ], [ 0, %12 ], [ 0, %24 ], [ 0, %31 ], [ 1, %28 ], [ 0, %7 ], [ 0, %7 ]
ret i32 %36
}