#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*/ dlight_usage();
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ strcmp(char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
void handle_options(int *argc, char ***argv) {
  char *opt = (*argv)[0];
  if (*argc < 1 || opt[0] != '-')
    return;
  if (!strcmp(opt, "-v") || !strcmp(opt, "--version")) {
    strcpy(opt, "version");
    return;
  }
  if (!strcmp(opt, "-h") || !strcmp(opt, "--help")) {
    dlight_usage();
  }
  printf("Unknown option '%s'\n", opt);
  exit(1);
}


x86 assembly (clang, -O0):
<handle_options>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    (%rax),%rax
mov    %rax,-0x18(%rbp)
mov    -0x8(%rbp),%rax
cmpl   $0x1,(%rax)
jl     118b <handle_options+0x3b>
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2d,%eax
je     1190 <handle_options+0x40>
jmp    122a <handle_options+0xda>
mov    -0x18(%rbp),%rdi
lea    0xe65(%rip),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%eax
je     11c2 <handle_options+0x72>
mov    -0x18(%rbp),%rdi
lea    0xe4f(%rip),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%eax
jne    11d7 <handle_options+0x87>
mov    -0x18(%rbp),%rdi
lea    0xe38(%rip),%rsi
call   1030 <strcpy@plt>
jmp    122a <handle_options+0xda>
mov    -0x18(%rbp),%rdi
lea    0xe2b(%rip),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%eax
je     1209 <handle_options+0xb9>
mov    -0x18(%rbp),%rdi
lea    0xe15(%rip),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%eax
jne    1210 <handle_options+0xc0>
mov    $0x0,%al
call   1040 <dlight_usage@plt>
mov    -0x18(%rbp),%rsi
lea    0xdfc(%rip),%rdi
call   1050 <printf@plt>
mov    $0x1,%edi
call   1070 <exit@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<handle_options>:
push   %rbx
cmpl   $0x0,(%rdi)
jle    1197 <handle_options+0x47>
mov    (%rsi),%rax
mov    (%rax),%rbx
cmpb   $0x2d,(%rbx)
jne    1197 <handle_options+0x47>
lea    0xe98(%rip),%rsi
mov    %rbx,%rdi
call   1060 <strcmp@plt>
test   %eax,%eax
je     1187 <handle_options+0x37>
lea    0xe88(%rip),%rsi
mov    %rbx,%rdi
call   1060 <strcmp@plt>
test   %eax,%eax
jne    1199 <handle_options+0x49>
lea    0xe77(%rip),%rsi
mov    %rbx,%rdi
pop    %rbx
jmp    1030 <strcpy@plt>
pop    %rbx
ret
lea    0xe6d(%rip),%rsi
mov    %rbx,%rdi
call   1060 <strcmp@plt>
test   %eax,%eax
je     11bf <handle_options+0x6f>
lea    0xe5d(%rip),%rsi
mov    %rbx,%rdi
call   1060 <strcmp@plt>
test   %eax,%eax
jne    11c6 <handle_options+0x76>
xor    %eax,%eax
call   1040 <dlight_usage@plt>
lea    0xe4a(%rip),%rdi
mov    %rbx,%rsi
call   1050 <printf@plt>
mov    $0x1,%edi
call   1070 <exit@plt>

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

LLVM IR (-O2):
@.str = [3 x i8] c"-v\00"
@.str.1 = [10 x i8] c"--version\00"
@.str.2 = [8 x i8] c"version\00"
@.str.3 = [3 x i8] c"-h\00"
@.str.4 = [7 x i8] c"--help\00"
@.str.5 = [21 x i8] c"Unknown option '%s'\0A\00"
define void @handle_options(i32* nocapture %0, i8*** nocapture %1) {
%3 = load i8**, i8*** %1
%4 = load i8*, i8** %3
%5 = load i32, i32* %0
%6 = icmp slt i32 %5, 1
br i1 %6, label %29, label %7
7: ; preds = %2
%8 = load i8, i8* %4
%9 = icmp eq i8 %8, 45
br i1 %9, label %10, label %29
10: ; preds = %7
%11 = tail call i32 @strcmp(i8* %4, 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 %16, label %13
13: ; preds = %10
%14 = tail call i32 @strcmp(i8* %4, i8* dereferenceable(10) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0))
%15 = icmp eq i32 %14, 0
br i1 %15, label %16, label %18
16: ; preds = %13, %10
%17 = tail call i32 @strcpy(i8* %4, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0))
br label %29
18: ; preds = %13
%19 = tail call i32 @strcmp(i8* %4, i8* dereferenceable(3) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
%20 = icmp eq i32 %19, 0
br i1 %20, label %24, label %21
21: ; preds = %18
%22 = tail call i32 @strcmp(i8* %4, i8* dereferenceable(7) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0))
%23 = icmp eq i32 %22, 0
br i1 %23, label %24, label %26
24: ; preds = %21, %18
%25 = tail call i32 (...) @dlight_usage()
br label %26
26: ; preds = %24, %21
%27 = tail call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.5, i64 0, i64 0), i8* %4)
%28 = tail call i32 @exit(i32 1)
unreachable
29: ; preds = %2, %7, %16
ret void
}