#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(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
int /*<<< orphan*/ print_help();
int /*<<< orphan*/ stderr;
int parse_options(int argc, char *argv[]) {
  int options = 0;
  int flags = 0;
  while (1 + flags < argc && argv[1 + flags][0] == '-') {
    switch (argv[1 + flags][1]) {
    case 'r':
      options |= 0x1;
      break;
    case 'm':
      options |= 0x4;
      break;
    case 's':
      options |= 0x2;
      break;
    default:
      fprintf(stderr, "am2321: Unsupported option \"%s\"\n", argv[1 + flags]);
      print_help();
      exit(1);
    }
    flags++;
  }
  return options;
}


x86 assembly (clang, -O0):
<parse_options>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%ecx
add    $0x1,%ecx
xor    %eax,%eax
cmp    -0x4(%rbp),%ecx
mov    %al,-0x19(%rbp)
jge    117e <parse_options+0x4e>
mov    -0x10(%rbp),%rax
mov    -0x18(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,8),%rax
movsbl (%rax),%eax
cmp    $0x2d,%eax
sete   %al
mov    %al,-0x19(%rbp)
mov    -0x19(%rbp),%al
test   $0x1,%al
jne    118e <parse_options+0x5e>
jmp    1241 <parse_options+0x111>
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
mov    0x8(%rax,%rcx,8),%rax
movsbl 0x1(%rax),%eax
mov    %eax,-0x20(%rbp)
sub    $0x6d,%eax
je     11e0 <parse_options+0xb0>
jmp    11b0 <parse_options+0x80>
mov    -0x20(%rbp),%eax
sub    $0x72,%eax
je     11d2 <parse_options+0xa2>
jmp    11c1 <parse_options+0x91>
mov    -0x20(%rbp),%eax
sub    $0x73,%eax
je     11ee <parse_options+0xbe>
jmp    11fc <parse_options+0xcc>
mov    -0x14(%rbp),%eax
or     $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1233 <parse_options+0x103>
mov    -0x14(%rbp),%eax
or     $0x4,%eax
mov    %eax,-0x14(%rbp)
jmp    1233 <parse_options+0x103>
mov    -0x14(%rbp),%eax
or     $0x2,%eax
mov    %eax,-0x14(%rbp)
jmp    1233 <parse_options+0x103>
mov    0x2ddd(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    -0x18(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,8),%rdx
lea    0xde3(%rip),%rsi
call   1030 <fprintf@plt>
mov    $0x0,%al
call   1040 <print_help@plt>
mov    $0x1,%edi
call   1050 <exit@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    114d <parse_options+0x1d>
mov    -0x14(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<parse_options>:
push   %rax
xor    %eax,%eax
cmp    $0x2,%edi
jl     118c <parse_options+0x5c>
mov    %edi,%r8d
xor    %eax,%eax
mov    $0x1,%edi
jmp    1162 <parse_options+0x32>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    $0x2,%r9d
or     %r9d,%eax
add    $0x1,%rdi
cmp    %rdi,%r8
je     118c <parse_options+0x5c>
mov    (%rsi,%rdi,8),%rdx
cmpb   $0x2d,(%rdx)
jne    118c <parse_options+0x5c>
movsbl 0x1(%rdx),%ecx
cmp    $0x73,%ecx
je     1150 <parse_options+0x20>
mov    $0x1,%r9d
cmp    $0x72,%ecx
je     1156 <parse_options+0x26>
cmp    $0x6d,%ecx
jne    118e <parse_options+0x5e>
mov    $0x4,%r9d
jmp    1156 <parse_options+0x26>
pop    %rcx
ret
mov    0x2e4b(%rip),%rax
mov    (%rax),%edi
lea    0xe62(%rip),%rsi
call   1030 <fprintf@plt>
xor    %eax,%eax
call   1040 <print_help@plt>
mov    $0x1,%edi
call   1050 <exit@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [33 x i8] c"am2321: Unsupported option \22%s\22\0A\00"
define i32 @parse_options(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i8**
%5 = alloca i32
%6 = alloca i32
store i32 %0, i32* %3
store i8** %1, i8*** %4
store i32 0, i32* %5
store i32 0, i32* %6
br label %7
7: ; preds = %55, %2
%8 = load i32, i32* %6
%9 = add nsw i32 1, %8
%10 = load i32, i32* %3
%11 = icmp slt i32 %9, %10
br i1 %11, label %12, label %23
12: ; preds = %7
%13 = load i8**, i8*** %4
%14 = load i32, i32* %6
%15 = add nsw i32 1, %14
%16 = sext i32 %15 to i64
%17 = getelementptr inbounds i8*, i8** %13, i64 %16
%18 = load i8*, i8** %17
%19 = getelementptr inbounds i8, i8* %18, i64 0
%20 = load i8, i8* %19
%21 = sext i8 %20 to i32
%22 = icmp eq i32 %21, 45
br label %23
23: ; preds = %12, %7
%24 = phi i1 [ false, %7 ], [ %22, %12 ]
br i1 %24, label %25, label %58
25: ; preds = %23
%26 = load i8**, i8*** %4
%27 = load i32, i32* %6
%28 = add nsw i32 1, %27
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds i8*, i8** %26, i64 %29
%31 = load i8*, i8** %30
%32 = getelementptr inbounds i8, i8* %31, i64 1
%33 = load i8, i8* %32
%34 = sext i8 %33 to i32
switch i32 %34, label %44 [
i32 114, label %35
i32 109, label %38
i32 115, label %41
]
35: ; preds = %25
%36 = load i32, i32* %5
%37 = or i32 %36, 1
store i32 %37, i32* %5
br label %55
38: ; preds = %25
%39 = load i32, i32* %5
%40 = or i32 %39, 4
store i32 %40, i32* %5
br label %55
41: ; preds = %25
%42 = load i32, i32* %5
%43 = or i32 %42, 2
store i32 %43, i32* %5
br label %55
44: ; preds = %25
%45 = load i32, i32* @stderr
%46 = load i8**, i8*** %4
%47 = load i32, i32* %6
%48 = add nsw i32 1, %47
%49 = sext i32 %48 to i64
%50 = getelementptr inbounds i8*, i8** %46, i64 %49
%51 = load i8*, i8** %50
%52 = call i32 @fprintf(i32 %45, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0), i8* %51)
%53 = call i32 (...) @print_help()
%54 = call i32 @exit(i32 1)
unreachable
55: ; preds = %41, %38, %35
%56 = load i32, i32* %6
%57 = add nsw i32 %56, 1
store i32 %57, i32* %6
br label %7
58: ; preds = %23
%59 = load i32, i32* %5
ret i32 %59
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [33 x i8] c"am2321: Unsupported option \22%s\22\0A\00"
define i32 @parse_options(i32 %0, i8** nocapture %1) {
%3 = icmp sgt i32 %0, 1
br i1 %3, label %4, label %29
4: ; preds = %2
%5 = zext i32 %0 to i64
br label %6
6: ; preds = %4, %24
%7 = phi i64 [ 1, %4 ], [ %27, %24 ]
%8 = phi i32 [ 0, %4 ], [ %26, %24 ]
%9 = getelementptr inbounds i8*, i8** %1, i64 %7
%10 = load i8*, i8** %9
%11 = load i8, i8* %10
%12 = icmp eq i8 %11, 45
br i1 %12, label %13, label %29
13: ; preds = %6
%14 = getelementptr inbounds i8, i8* %10, i64 1
%15 = load i8, i8* %14
%16 = sext i8 %15 to i32
switch i32 %16, label %19 [
i32 114, label %24
i32 109, label %17
i32 115, label %18
]
17: ; preds = %13
br label %24
18: ; preds = %13
br label %24
19: ; preds = %13
%20 = load i32, i32* @stderr
%21 = tail call i32 @fprintf(i32 %20, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0), i8* %10)
%22 = tail call i32 (...) @print_help()
%23 = tail call i32 @exit(i32 1)
unreachable
24: ; preds = %13, %18, %17
%25 = phi i32 [ 2, %18 ], [ 4, %17 ], [ 1, %13 ]
%26 = or i32 %8, %25
%27 = add nuw nsw i64 %7, 1
%28 = icmp eq i64 %27, %5
br i1 %28, label %29, label %6
29: ; preds = %6, %24, %2
%30 = phi i32 [ 0, %2 ], [ %26, %24 ], [ %8, %6 ]
ret i32 %30
}