#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*/ fprintf(int /*<<< orphan*/, char *);
char getopt(int, char **, char *);
scalar_t__ optind;
int /*<<< orphan*/ stderr;
char parse_argv(int *argc, char *argv[]) {
  char ch;
  while ((ch = getopt(*argc, argv, "al")) != -1) {
    switch (ch) {
    case 'a':
      return ch;
    case 'l':
      return ch;
    default:
      fprintf(stderr, "Usage:stringsort -[as]\n"
                      "-a = lexical order sort\n"
                      "-s = length order sort\n");
    }
  }
  *argc -= optind;
  argv += optind;
  return 0;
}


x86 assembly (clang, -O0):
<parse_argv>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%edi
mov    -0x18(%rbp),%rsi
lea    0xebf(%rip),%rdx
call   1040 <getopt@plt>
mov    %al,-0x19(%rbp)
movsbl %al,%eax
cmp    $0xffffffff,%eax
je     11ab <parse_argv+0x8b>
movsbl -0x19(%rbp),%eax
mov    %eax,-0x20(%rbp)
sub    $0x61,%eax
je     117b <parse_argv+0x5b>
jmp    116a <parse_argv+0x4a>
mov    -0x20(%rbp),%eax
sub    $0x6c,%eax
je     1186 <parse_argv+0x66>
jmp    1191 <parse_argv+0x71>
mov    -0x19(%rbp),%al
mov    %al,-0x1(%rbp)
jmp    11db <parse_argv+0xbb>
mov    -0x19(%rbp),%al
mov    %al,-0x1(%rbp)
jmp    11db <parse_argv+0xbb>
mov    0x2e40(%rip),%rax
mov    (%rax),%edi
lea    0xe62(%rip),%rsi
call   1030 <fprintf@plt>
jmp    1130 <parse_argv+0x10>
mov    0x2e36(%rip),%rax
mov    (%rax),%rdx
mov    -0x10(%rbp),%rax
movslq (%rax),%rcx
sub    %rdx,%rcx
mov    %ecx,(%rax)
mov    0x2e20(%rip),%rax
mov    (%rax),%rax
shl    $0x3,%rax
add    -0x18(%rbp),%rax
mov    %rax,-0x18(%rbp)
movb   $0x0,-0x1(%rbp)
movsbl -0x1(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<parse_argv>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
mov    %rsi,%r14
mov    %rdi,%rbx
mov    (%rdi),%edi
lea    0xec8(%rip),%rdx
call   1040 <getopt@plt>
cmp    $0xff,%al
je     118a <parse_argv+0x6a>
mov    0x2e90(%rip),%r13
lea    0xeb4(%rip),%r15
lea    0xeaa(%rip),%r12
cs nopw 0x0(%rax,%rax,1)
movsbl %al,%ecx
cmp    $0x61,%ecx
je     1197 <parse_argv+0x77>
cmp    $0x6c,%ecx
je     1197 <parse_argv+0x77>
mov    0x0(%r13),%edi
mov    %r15,%rsi
call   1030 <fprintf@plt>
mov    (%rbx),%edi
mov    %r14,%rsi
mov    %r12,%rdx
call   1040 <getopt@plt>
cmp    $0xff,%al
jne    1160 <parse_argv+0x40>
mov    0x2e57(%rip),%rax
mov    (%rax),%eax
sub    %eax,(%rbx)
xor    %eax,%eax
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [3 x i8] c"al\00"
@stderr = global i32 0
@.str.1 = [71 x i8] c"Usage:stringsort -[as]\0A-a = lexical order sort\0A-s = length order sort\0A\00"
@optind = global i64 0
define signext i8 @parse_argv(i32* %0, i8** %1) {
%3 = alloca i8
%4 = alloca i32*
%5 = alloca i8**
%6 = alloca i8
store i32* %0, i32** %4
store i8** %1, i8*** %5
br label %7
7: ; preds = %24, %2
%8 = load i32*, i32** %4
%9 = load i32, i32* %8
%10 = load i8**, i8*** %5
%11 = call signext i8 @getopt(i32 %9, i8** %10, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
store i8 %11, i8* %6
%12 = sext i8 %11 to i32
%13 = icmp ne i32 %12, -1
br i1 %13, label %14, label %25
14: ; preds = %7
%15 = load i8, i8* %6
%16 = sext i8 %15 to i32
switch i32 %16, label %21 [
i32 97, label %17
i32 108, label %19
]
17: ; preds = %14
%18 = load i8, i8* %6
store i8 %18, i8* %3
br label %35
19: ; preds = %14
%20 = load i8, i8* %6
store i8 %20, i8* %3
br label %35
21: ; preds = %14
%22 = load i32, i32* @stderr
%23 = call i32 @fprintf(i32 %22, i8* getelementptr inbounds ([71 x i8], [71 x i8]* @.str.1, i64 0, i64 0))
br label %24
24: ; preds = %21
br label %7
25: ; preds = %7
%26 = load i64, i64* @optind
%27 = load i32*, i32** %4
%28 = load i32, i32* %27
%29 = sext i32 %28 to i64
%30 = sub nsw i64 %29, %26
%31 = trunc i64 %30 to i32
store i32 %31, i32* %27
%32 = load i64, i64* @optind
%33 = load i8**, i8*** %5
%34 = getelementptr inbounds i8*, i8** %33, i64 %32
store i8** %34, i8*** %5
store i8 0, i8* %3
br label %35
35: ; preds = %25, %19, %17
%36 = load i8, i8* %3
ret i8 %36
}

LLVM IR (-O2):
@.str = [3 x i8] c"al\00"
@stderr = global i32 0
@.str.1 = [71 x i8] c"Usage:stringsort -[as]\0A-a = lexical order sort\0A-s = length order sort\0A\00"
@optind = global i64 0
define signext i8 @parse_argv(i32* nocapture %0, i8** %1) {
%3 = load i32, i32* %0
%4 = tail call signext i8 @getopt(i32 %3, i8** %1, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%5 = icmp eq i8 %4, -1
br i1 %5, label %15, label %6
6: ; preds = %2, %9
%7 = phi i8 [ %13, %9 ], [ %4, %2 ]
%8 = sext i8 %7 to i32
switch i32 %8, label %9 [
i32 97, label %20
i32 108, label %20
]
9: ; preds = %6
%10 = load i32, i32* @stderr
%11 = tail call i32 @fprintf(i32 %10, i8* getelementptr inbounds ([71 x i8], [71 x i8]* @.str.1, i64 0, i64 0))
%12 = load i32, i32* %0
%13 = tail call signext i8 @getopt(i32 %12, i8** %1, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%14 = icmp eq i8 %13, -1
br i1 %14, label %15, label %6
15: ; preds = %9, %2
%16 = load i64, i64* @optind
%17 = load i32, i32* %0
%18 = trunc i64 %16 to i32
%19 = sub i32 %17, %18
store i32 %19, i32* %0
br label %20
20: ; preds = %6, %6, %15
%21 = phi i8 [ 0, %15 ], [ %7, %6 ], [ %7, %6 ]
ret i8 %21
}