#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*/ abort();
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char);
int getopt(int, char **, char *);
int /*<<< orphan*/ isprint(char);
char *optarg;
char optopt;
int /*<<< orphan*/ show_usage();
int /*<<< orphan*/ stderr;
int parse_command_line(int argc, char **argv, char **mandel_params,
                       char **sort_params, char **query_params,
                       char *mode_select) {
  int option;
  while ((option = getopt(argc, argv, "m:s:q:h")) != -1) {
    switch (option) {
    case 'h':
      show_usage();
      exit(0);
      break;
    case 'm':
      *mode_select = 'm';
      *mandel_params = optarg;
      break;
    case 's':
      *mode_select = 's';
      if (optarg != NULL) {
        *sort_params = optarg;
      }
      break;
    case 'q':
      *mode_select = 'q';
      if (optarg != NULL) {
        *query_params = optarg;
      }
      break;
    case '?':
      if (optopt == 'm' || optopt == 's' || optopt == 'q')
        fprintf(stderr, "Option %c requires an argument\n", optopt);
      else if (isprint(optopt))
        fprintf(stderr, "Unknown option `-%c'.\n", optopt);
      else
        fprintf(stderr, "Unknown option character `\\x%x'.\n", optopt);
      return 1;
      break;
    default:
      abort();
      break;
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<parse_command_line>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
mov    %r9,-0x30(%rbp)
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
lea    0xe73(%rip),%rdx
call   1070 <getopt@plt>
mov    %eax,-0x34(%rbp)
cmp    $0xffffffff,%eax
je     1352 <parse_command_line+0x1f2>
mov    -0x34(%rbp),%eax
mov    %eax,-0x38(%rbp)
sub    $0x3f,%eax
je     127d <parse_command_line+0x11d>
jmp    11b2 <parse_command_line+0x52>
mov    -0x38(%rbp),%eax
sub    $0x68,%eax
je     11f6 <parse_command_line+0x96>
jmp    11c3 <parse_command_line+0x63>
mov    -0x38(%rbp),%eax
sub    $0x6d,%eax
je     1204 <parse_command_line+0xa4>
jmp    11d4 <parse_command_line+0x74>
mov    -0x38(%rbp),%eax
sub    $0x71,%eax
je     124f <parse_command_line+0xef>
jmp    11e5 <parse_command_line+0x85>
mov    -0x38(%rbp),%eax
sub    $0x73,%eax
je     1221 <parse_command_line+0xc1>
jmp    1346 <parse_command_line+0x1e6>
mov    $0x0,%al
call   1060 <show_usage@plt>
xor    %edi,%edi
call   1080 <exit@plt>
mov    -0x30(%rbp),%rax
movb   $0x6d,(%rax)
mov    0x2de6(%rip),%rax
mov    (%rax),%rcx
mov    -0x18(%rbp),%rax
mov    %rcx,(%rax)
jmp    134d <parse_command_line+0x1ed>
mov    -0x30(%rbp),%rax
movb   $0x73,(%rax)
mov    0x2dc9(%rip),%rax
cmpq   $0x0,(%rax)
je     124a <parse_command_line+0xea>
mov    0x2db8(%rip),%rax
mov    (%rax),%rcx
mov    -0x20(%rbp),%rax
mov    %rcx,(%rax)
jmp    134d <parse_command_line+0x1ed>
mov    -0x30(%rbp),%rax
movb   $0x71,(%rax)
mov    0x2d9b(%rip),%rax
cmpq   $0x0,(%rax)
je     1278 <parse_command_line+0x118>
mov    0x2d8a(%rip),%rax
mov    (%rax),%rcx
mov    -0x28(%rbp),%rax
mov    %rcx,(%rax)
jmp    134d <parse_command_line+0x1ed>
mov    0x2d5c(%rip),%rax
movsbl (%rax),%eax
cmp    $0x6d,%eax
je     12b6 <parse_command_line+0x156>
mov    0x2d49(%rip),%rax
movsbl (%rax),%eax
cmp    $0x73,%eax
je     12b6 <parse_command_line+0x156>
mov    0x2d36(%rip),%rax
movsbl (%rax),%eax
cmp    $0x71,%eax
jne    12da <parse_command_line+0x17a>
mov    0x2d13(%rip),%rax
mov    (%rax),%edi
lea    0xd42(%rip),%rsi
mov    0x2d13(%rip),%rax
movsbl (%rax),%edx
call   1040 <fprintf@plt>
jmp    133a <parse_command_line+0x1da>
mov    0x2cff(%rip),%rax
movsbl (%rax),%edi
call   1050 <isprint@plt>
cmp    $0x0,%eax
je     1316 <parse_command_line+0x1b6>
mov    0x2cd7(%rip),%rax
mov    (%rax),%edi
lea    0xd26(%rip),%rsi
mov    0x2cd7(%rip),%rax
movsbl (%rax),%edx
call   1040 <fprintf@plt>
jmp    1335 <parse_command_line+0x1d5>
mov    0x2cb3(%rip),%rax
mov    (%rax),%edi
lea    0xd19(%rip),%rsi
mov    0x2cb3(%rip),%rax
movsbl (%rax),%edx
call   1040 <fprintf@plt>
jmp    133a <parse_command_line+0x1da>
movl   $0x1,-0x4(%rbp)
jmp    1359 <parse_command_line+0x1f9>
mov    $0x0,%al
call   1030 <abort@plt>
jmp    117f <parse_command_line+0x1f>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<parse_command_line>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %r9,%r13
mov    %r8,0x8(%rsp)
mov    %rcx,(%rsp)
mov    %rdx,0x10(%rsp)
mov    %rsi,%rbx
mov    %edi,%ebp
lea    0xea5(%rip),%r14
lea    0xe6e(%rip),%r15
mov    0x2e5f(%rip),%r12
jmp    11b1 <parse_command_line+0x51>
nopl   0x0(%rax,%rax,1)
movb   $0x6d,0x0(%r13)
mov    (%r12),%rax
mov    0x10(%rsp),%rcx
mov    %rax,(%rcx)
mov    %ebp,%edi
mov    %rbx,%rsi
mov    %r14,%rdx
call   1070 <getopt@plt>
lea    -0x68(%rax),%ecx
cmp    $0xb,%ecx
ja     1207 <parse_command_line+0xa7>
movslq (%r15,%rcx,4),%rax
add    %r15,%rax
jmp    *%rax
movb   $0x71,0x0(%r13)
mov    (%r12),%rax
test   %rax,%rax
je     11b1 <parse_command_line+0x51>
mov    0x8(%rsp),%rcx
mov    %rax,(%rcx)
jmp    11b1 <parse_command_line+0x51>
nopw   0x0(%rax,%rax,1)
movb   $0x73,0x0(%r13)
mov    (%r12),%rax
test   %rax,%rax
je     11b1 <parse_command_line+0x51>
mov    (%rsp),%rcx
mov    %rax,(%rcx)
jmp    11b1 <parse_command_line+0x51>
cmp    $0xffffffff,%eax
je     124e <parse_command_line+0xee>
cmp    $0x3f,%eax
jne    128b <parse_command_line+0x12b>
mov    0x2dc8(%rip),%rbx
mov    (%rbx),%al
lea    -0x6d(%rax),%ecx
cmp    $0x6,%cl
ja     125f <parse_command_line+0xff>
movzbl %cl,%ecx
mov    $0x51,%edx
bt     %ecx,%edx
jae    125f <parse_command_line+0xff>
mov    0x2d9a(%rip),%rcx
mov    (%rcx),%edi
movsbl %al,%edx
lea    0xdf6(%rip),%rsi
call   1040 <fprintf@plt>
mov    $0x1,%eax
jmp    1250 <parse_command_line+0xf0>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
movsbl %al,%edi
call   1050 <isprint@plt>
mov    0x2d62(%rip),%rcx
mov    (%rcx),%edi
mov    (%rbx),%cl
movsbl %cl,%edx
test   %eax,%eax
je     1282 <parse_command_line+0x122>
lea    0xdd8(%rip),%rsi
jmp    1242 <parse_command_line+0xe2>
lea    0xde6(%rip),%rsi
jmp    1242 <parse_command_line+0xe2>
xor    %eax,%eax
call   1030 <abort@plt>
xor    %eax,%eax
call   1060 <show_usage@plt>
xor    %edi,%edi
call   1080 <exit@plt>

LLVM IR (-O0):
@.str = [8 x i8] c"m:s:q:h\00"
@optarg = global i8* null
@optopt = global i8 0
@stderr = global i32 0
@.str.1 = [32 x i8] c"Option %c requires an argument\0A\00"
@.str.2 = [23 x i8] c"Unknown option `-%c'.\0A\00"
@.str.3 = [34 x i8] c"Unknown option character `\\x%x'.\0A\00"
define i32 @parse_command_line(i32 %0, i8** %1, i8** %2, i8** %3, i8** %4, i8* %5) {
%7 = alloca i32
%8 = alloca i32
%9 = alloca i8**
%10 = alloca i8**
%11 = alloca i8**
%12 = alloca i8**
%13 = alloca i8*
%14 = alloca i32
store i32 %0, i32* %8
store i8** %1, i8*** %9
store i8** %2, i8*** %10
store i8** %3, i8*** %11
store i8** %4, i8*** %12
store i8* %5, i8** %13
br label %15
15: ; preds = %77, %6
%16 = load i32, i32* %8
%17 = load i8**, i8*** %9
%18 = call i32 @getopt(i32 %16, i8** %17, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
store i32 %18, i32* %14
%19 = icmp ne i32 %18, -1
br i1 %19, label %20, label %78
20: ; preds = %15
%21 = load i32, i32* %14
switch i32 %21, label %75 [
i32 104, label %22
i32 109, label %25
i32 115, label %29
i32 113, label %37
i32 63, label %45
]
22: ; preds = %20
%23 = call i32 (...) @show_usage()
%24 = call i32 @exit(i32 0)
unreachable
25: ; preds = %20
%26 = load i8*, i8** %13
store i8 109, i8* %26
%27 = load i8*, i8** @optarg
%28 = load i8**, i8*** %10
store i8* %27, i8** %28
br label %77
29: ; preds = %20
%30 = load i8*, i8** %13
store i8 115, i8* %30
%31 = load i8*, i8** @optarg
%32 = icmp ne i8* %31, null
br i1 %32, label %33, label %36
33: ; preds = %29
%34 = load i8*, i8** @optarg
%35 = load i8**, i8*** %11
store i8* %34, i8** %35
br label %36
36: ; preds = %33, %29
br label %77
37: ; preds = %20
%38 = load i8*, i8** %13
store i8 113, i8* %38
%39 = load i8*, i8** @optarg
%40 = icmp ne i8* %39, null
br i1 %40, label %41, label %44
41: ; preds = %37
%42 = load i8*, i8** @optarg
%43 = load i8**, i8*** %12
store i8* %42, i8** %43
br label %44
44: ; preds = %41, %37
br label %77
45: ; preds = %20
%46 = load i8, i8* @optopt
%47 = sext i8 %46 to i32
%48 = icmp eq i32 %47, 109
br i1 %48, label %57, label %49
49: ; preds = %45
%50 = load i8, i8* @optopt
%51 = sext i8 %50 to i32
%52 = icmp eq i32 %51, 115
br i1 %52, label %57, label %53
53: ; preds = %49
%54 = load i8, i8* @optopt
%55 = sext i8 %54 to i32
%56 = icmp eq i32 %55, 113
br i1 %56, label %57, label %61
57: ; preds = %53, %49, %45
%58 = load i32, i32* @stderr
%59 = load i8, i8* @optopt
%60 = call i32 @fprintf(i32 %58, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.1, i64 0, i64 0), i8 signext %59)
br label %74
61: ; preds = %53
%62 = load i8, i8* @optopt
%63 = call i32 @isprint(i8 signext %62)
%64 = icmp ne i32 %63, 0
br i1 %64, label %65, label %69
65: ; preds = %61
%66 = load i32, i32* @stderr
%67 = load i8, i8* @optopt
%68 = call i32 @fprintf(i32 %66, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0), i8 signext %67)
br label %73
69: ; preds = %61
%70 = load i32, i32* @stderr
%71 = load i8, i8* @optopt
%72 = call i32 @fprintf(i32 %70, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.3, i64 0, i64 0), i8 signext %71)
br label %73
73: ; preds = %69, %65
br label %74
74: ; preds = %73, %57
store i32 1, i32* %7
br label %79
75: ; preds = %20
%76 = call i32 (...) @abort()
unreachable
77: ; preds = %44, %36, %25
br label %15
78: ; preds = %15
store i32 0, i32* %7
br label %79
79: ; preds = %78, %74
%80 = load i32, i32* %7
ret i32 %80
}

LLVM IR (-O2):
@.str = [8 x i8] c"m:s:q:h\00"
@optarg = global i8* null
@optopt = global i8 0
@stderr = global i32 0
@.str.1 = [32 x i8] c"Option %c requires an argument\0A\00"
@.str.2 = [23 x i8] c"Unknown option `-%c'.\0A\00"
@.str.3 = [34 x i8] c"Unknown option character `\\x%x'.\0A\00"
define i32 @parse_command_line(i32 %0, i8** %1, i8** nocapture writeonly %2, i8** nocapture writeonly %3, i8** nocapture writeonly %4, i8* nocapture writeonly %5) {
br label %7
7: ; preds = %21, %6
%8 = tail call i32 @getopt(i32 %0, i8** %1, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
switch i32 %8, label %37 [
i32 -1, label %39
i32 104, label %9
i32 109, label %12
i32 115, label %14
i32 113, label %18
i32 63, label %23
]
9: ; preds = %7
%10 = tail call i32 (...) @show_usage()
%11 = tail call i32 @exit(i32 0)
unreachable
12: ; preds = %7
store i8 109, i8* %5
%13 = load i8*, i8** @optarg
store i8* %13, i8** %2
br label %21
14: ; preds = %7
store i8 115, i8* %5
%15 = load i8*, i8** @optarg
%16 = icmp eq i8* %15, null
br i1 %16, label %21, label %17
17: ; preds = %14
store i8* %15, i8** %3
br label %21
18: ; preds = %7
store i8 113, i8* %5
%19 = load i8*, i8** @optarg
%20 = icmp eq i8* %19, null
br i1 %20, label %21, label %22
21: ; preds = %18, %22, %14, %17, %12
br label %7
22: ; preds = %18
store i8* %19, i8** %4
br label %21
23: ; preds = %7
%24 = load i8, i8* @optopt
switch i8 %24, label %28 [
i8 115, label %25
i8 113, label %25
i8 109, label %25
]
25: ; preds = %23, %23, %23
%26 = load i32, i32* @stderr
%27 = tail call i32 @fprintf(i32 %26, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.1, i64 0, i64 0), i8 signext %24)
br label %39
28: ; preds = %23
%29 = tail call i32 @isprint(i8 signext %24)
%30 = icmp eq i32 %29, 0
%31 = load i32, i32* @stderr
%32 = load i8, i8* @optopt
br i1 %30, label %35, label %33
33: ; preds = %28
%34 = tail call i32 @fprintf(i32 %31, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0), i8 signext %32)
br label %39
35: ; preds = %28
%36 = tail call i32 @fprintf(i32 %31, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.3, i64 0, i64 0), i8 signext %32)
br label %39
37: ; preds = %7
%38 = tail call i32 (...) @abort()
unreachable
39: ; preds = %7, %25, %35, %33
%40 = phi i32 [ 1, %33 ], [ 1, %35 ], [ 1, %25 ], [ 0, %7 ]
ret i32 %40
}