#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*/ strcmp(char *, char *);
unsigned get_commandline_options(int argc, char **argv) {
  unsigned options = 0x0;
  register int i;
  for (i = 0; i < argc; ++i) {
    char *p = argv[i];
    if (!strcmp(p, "-r")) {
      options |= 0x1;
    } else if (!strcmp(p, "-l")) {
      options |= 0x4;
    } else if (!strcmp(p, "-h")) {
      options |= 0x2;
    }
  }
  return options;
}


x86 assembly (clang, -O0):
<get_commandline_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),%eax
cmp    -0x4(%rbp),%eax
jge    11d6 <get_commandline_options+0xc6>
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
lea    0xeac(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%eax
jne    1170 <get_commandline_options+0x60>
mov    -0x14(%rbp),%eax
or     $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    11c3 <get_commandline_options+0xb3>
mov    -0x20(%rbp),%rdi
lea    0xe88(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%eax
jne    1197 <get_commandline_options+0x87>
mov    -0x14(%rbp),%eax
or     $0x4,%eax
mov    %eax,-0x14(%rbp)
jmp    11be <get_commandline_options+0xae>
mov    -0x20(%rbp),%rdi
lea    0xe64(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%eax
jne    11b9 <get_commandline_options+0xa9>
mov    -0x14(%rbp),%eax
or     $0x2,%eax
mov    %eax,-0x14(%rbp)
jmp    11be <get_commandline_options+0xae>
jmp    11c3 <get_commandline_options+0xb3>
jmp    11c8 <get_commandline_options+0xb8>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    112d <get_commandline_options+0x1d>
mov    -0x14(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_commandline_options>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
test   %edi,%edi
jle    1195 <get_commandline_options+0x85>
mov    %rsi,%r13
mov    %edi,%r12d
xor    %r15d,%r15d
lea    0xed1(%rip),%r14
xor    %ebp,%ebp
jmp    114c <get_commandline_options+0x3c>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
or     $0x1,%ebp
add    $0x1,%r15
cmp    %r15,%r12
je     1197 <get_commandline_options+0x87>
mov    0x0(%r13,%r15,8),%rbx
mov    %rbx,%rdi
mov    %r14,%rsi
call   1030 <strcmp@plt>
test   %eax,%eax
je     1140 <get_commandline_options+0x30>
mov    %rbx,%rdi
lea    0xe99(%rip),%rsi
call   1030 <strcmp@plt>
test   %eax,%eax
je     1190 <get_commandline_options+0x80>
mov    %rbx,%rdi
lea    0xe89(%rip),%rsi
call   1030 <strcmp@plt>
mov    %ebp,%ecx
or     $0x2,%ecx
test   %eax,%eax
cmove  %ecx,%ebp
jmp    1143 <get_commandline_options+0x33>
xchg   %ax,%ax
or     $0x4,%ebp
jmp    1143 <get_commandline_options+0x33>
xor    %ebp,%ebp
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"-r\00"
@.str.1 = [3 x i8] c"-l\00"
@.str.2 = [3 x i8] c"-h\00"
define i32 @get_commandline_options(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i8**
%5 = alloca i32
%6 = alloca i32
%7 = alloca i8*
store i32 %0, i32* %3
store i8** %1, i8*** %4
store i32 0, i32* %5
store i32 0, i32* %6
br label %8
8: ; preds = %41, %2
%9 = load i32, i32* %6
%10 = load i32, i32* %3
%11 = icmp slt i32 %9, %10
br i1 %11, label %12, label %44
12: ; preds = %8
%13 = load i8**, i8*** %4
%14 = load i32, i32* %6
%15 = sext i32 %14 to i64
%16 = getelementptr inbounds i8*, i8** %13, i64 %15
%17 = load i8*, i8** %16
store i8* %17, i8** %7
%18 = load i8*, i8** %7
%19 = call i32 @strcmp(i8* %18, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%20 = icmp ne i32 %19, 0
br i1 %20, label %24, label %21
21: ; preds = %12
%22 = load i32, i32* %5
%23 = or i32 %22, 1
store i32 %23, i32* %5
br label %40
24: ; preds = %12
%25 = load i8*, i8** %7
%26 = call i32 @strcmp(i8* %25, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%27 = icmp ne i32 %26, 0
br i1 %27, label %31, label %28
28: ; preds = %24
%29 = load i32, i32* %5
%30 = or i32 %29, 4
store i32 %30, i32* %5
br label %39
31: ; preds = %24
%32 = load i8*, i8** %7
%33 = call i32 @strcmp(i8* %32, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%34 = icmp ne i32 %33, 0
br i1 %34, label %38, label %35
35: ; preds = %31
%36 = load i32, i32* %5
%37 = or i32 %36, 2
store i32 %37, i32* %5
br label %38
38: ; preds = %35, %31
br label %39
39: ; preds = %38, %28
br label %40
40: ; preds = %39, %21
br label %41
41: ; preds = %40
%42 = load i32, i32* %6
%43 = add nsw i32 %42, 1
store i32 %43, i32* %6
br label %8
44: ; preds = %8
%45 = load i32, i32* %5
ret i32 %45
}

LLVM IR (-O2):
@.str = [3 x i8] c"-r\00"
@.str.1 = [3 x i8] c"-l\00"
@.str.2 = [3 x i8] c"-h\00"
define i32 @get_commandline_options(i32 %0, i8** nocapture %1) {
%3 = icmp sgt i32 %0, 0
br i1 %3, label %4, label %29
4: ; preds = %2
%5 = zext i32 %0 to i64
br label %6
6: ; preds = %4, %25
%7 = phi i64 [ 0, %4 ], [ %27, %25 ]
%8 = phi i32 [ 0, %4 ], [ %26, %25 ]
%9 = getelementptr inbounds i8*, i8** %1, i64 %7
%10 = load i8*, i8** %9
%11 = tail call i32 @strcmp(i8* dereferenceable(1) %10, i8* dereferenceable(3) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%12 = icmp eq i32 %11, 0
br i1 %12, label %13, label %15
13: ; preds = %6
%14 = or i32 %8, 1
br label %25
15: ; preds = %6
%16 = tail call i32 @strcmp(i8* dereferenceable(1) %10, i8* dereferenceable(3) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%17 = icmp eq i32 %16, 0
br i1 %17, label %18, label %20
18: ; preds = %15
%19 = or i32 %8, 4
br label %25
20: ; preds = %15
%21 = tail call i32 @strcmp(i8* dereferenceable(1) %10, i8* dereferenceable(3) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%22 = icmp eq i32 %21, 0
%23 = or i32 %8, 2
%24 = select i1 %22, i32 %23, i32 %8
br label %25
25: ; preds = %20, %18, %13
%26 = phi i32 [ %19, %18 ], [ %14, %13 ], [ %24, %20 ]
%27 = add nuw nsw i64 %7, 1
%28 = icmp eq i64 %27, %5
br i1 %28, label %29, label %6
29: ; preds = %25, %2
%30 = phi i32 [ 0, %2 ], [ %26, %25 ]
ret i32 %30
}