#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 get_config_value(char *);
int get_default_browser();
int getopt(int, char **, char *);
char *optarg;
int optind;
int /*<<< orphan*/ printf(char *);
int set_config_value(char *, char *);
int /*<<< orphan*/ strcmp(char *, char *);
int /*<<< orphan*/ usage();
int main(int argc, char **argv) {
  int opt, done = 0;
  int set = 0;
  char *selected_opt = NULL;
  while (!done && (opt = getopt(argc, argv, "hsbcmo:")) != -1) {
    switch (opt) {
    case 'h':
      usage();
      exit(0);
      break;
    case 's':
      set = 1;
      break;
    case 'b':
      selected_opt = "default_browser";
      done = 1;
      break;
    case 'c':
      selected_opt = "other_browser_cmd";
      done = 1;
      break;
    case 'm':
      selected_opt = "continuous_mode";
      done = 1;
      break;
    case 'o':
      selected_opt = optarg;
      done = 1;
      break;
    default:
      usage();
      exit(1);
      break;
    }
  }
  if (!selected_opt) {
    printf("Must specify one of -b, -c, -m, -o\n");
    usage();
    exit(1);
  }
  if (set) {
    if (optind >= argc) {
      printf("Value to set config option to not provided\n");
      usage();
      exit(1);
    }
    return set_config_value(selected_opt, argv[optind]);
  } else if (!strcmp(selected_opt, "default_browser"))
    return get_default_browser();
  else
    return get_config_value(selected_opt);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
movq   $0x0,-0x28(%rbp)
xor    %eax,%eax
cmpl   $0x0,-0x18(%rbp)
mov    %al,-0x29(%rbp)
jne    11da <main+0x5a>
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
lea    0xe7f(%rip),%rdx
call   1090 <getopt@plt>
mov    %eax,-0x14(%rbp)
cmp    $0xffffffff,%eax
setne  %al
mov    %al,-0x29(%rbp)
mov    -0x29(%rbp),%al
test   $0x1,%al
jne    11ea <main+0x6a>
jmp    12a2 <main+0x122>
mov    -0x14(%rbp),%eax
add    $0xffffff9e,%eax
mov    %eax,%ecx
mov    %rcx,-0x38(%rbp)
sub    $0x11,%eax
ja     128c <main+0x10c>
mov    -0x38(%rbp),%rax
lea    0xdf6(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    $0x0,%al
call   1080 <usage@plt>
xor    %edi,%edi
call   10a0 <exit@plt>
movl   $0x1,-0x1c(%rbp)
jmp    129d <main+0x11d>
lea    0xe1c(%rip),%rax
mov    %rax,-0x28(%rbp)
movl   $0x1,-0x18(%rbp)
jmp    129d <main+0x11d>
lea    0xe15(%rip),%rax
mov    %rax,-0x28(%rbp)
movl   $0x1,-0x18(%rbp)
jmp    129d <main+0x11d>
lea    0xe10(%rip),%rax
mov    %rax,-0x28(%rbp)
movl   $0x1,-0x18(%rbp)
jmp    129d <main+0x11d>
mov    0x2d7f(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x28(%rbp)
movl   $0x1,-0x18(%rbp)
jmp    129d <main+0x11d>
mov    $0x0,%al
call   1080 <usage@plt>
mov    $0x1,%edi
call   10a0 <exit@plt>
jmp    11ac <main+0x2c>
cmpq   $0x0,-0x28(%rbp)
jne    12ca <main+0x14a>
lea    0xdce(%rip),%rdi
call   1040 <printf@plt>
mov    $0x0,%al
call   1080 <usage@plt>
mov    $0x1,%edi
call   10a0 <exit@plt>
cmpl   $0x0,-0x1c(%rbp)
je     1326 <main+0x1a6>
mov    0x2d05(%rip),%rax
mov    (%rax),%eax
cmp    -0x8(%rbp),%eax
jl     1303 <main+0x183>
lea    0xdb9(%rip),%rdi
call   1040 <printf@plt>
mov    $0x0,%al
call   1080 <usage@plt>
mov    $0x1,%edi
call   10a0 <exit@plt>
mov    -0x28(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    0x2cce(%rip),%rcx
movslq (%rcx),%rcx
mov    (%rax,%rcx,8),%rsi
call   1070 <set_config_value@plt>
mov    %eax,-0x4(%rbp)
jmp    135a <main+0x1da>
mov    -0x28(%rbp),%rdi
lea    0xd1f(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%eax
jne    134e <main+0x1ce>
mov    $0x0,%al
call   1030 <get_default_browser@plt>
mov    %eax,-0x4(%rbp)
jmp    135a <main+0x1da>
mov    -0x28(%rbp),%rdi
call   1060 <get_config_value@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rsi,%r15
mov    %edi,%r12d
mov    $0x1,%cl
lea    0xea1(%rip),%rbp
nopw   0x0(%rax,%rax,1)
mov    %ecx,%ebx
mov    %r12d,%edi
mov    %r15,%rsi
mov    %rbp,%rdx
call   1090 <getopt@plt>
xor    %ecx,%ecx
cmp    $0x73,%eax
je     11a0 <main+0x20>
lea    -0x62(%rax),%ecx
cmp    $0xd,%ecx
ja     11d8 <main+0x58>
lea    0xe3a(%rip),%rax
movslq (%rax,%rcx,4),%rcx
add    %rax,%rcx
jmp    *%rcx
lea    0xe6a(%rip),%r14
jmp    1202 <main+0x82>
cmp    $0xffffffff,%eax
jne    1284 <main+0x104>
xor    %r14d,%r14d
jmp    1202 <main+0x82>
lea    0xe63(%rip),%r14
jmp    1202 <main+0x82>
lea    0xe6c(%rip),%r14
jmp    1202 <main+0x82>
mov    0x2df9(%rip),%rax
mov    (%rax),%r14
test   %r14,%r14
je     126f <main+0xef>
test   $0x1,%bl
je     122f <main+0xaf>
lea    0xe2d(%rip),%rsi
mov    %r14,%rdi
call   1050 <strcmp@plt>
test   %eax,%eax
je     1252 <main+0xd2>
mov    %r14,%rdi
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
jmp    1060 <get_config_value@plt>
mov    0x2daa(%rip),%rax
movslq (%rax),%rax
cmp    %r12d,%eax
jge    1278 <main+0xf8>
mov    (%r15,%rax,8),%rsi
mov    %r14,%rdi
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
jmp    1070 <set_config_value@plt>
xor    %eax,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <get_default_browser@plt>
xor    %eax,%eax
call   1080 <usage@plt>
xor    %edi,%edi
call   10a0 <exit@plt>
lea    0xdfc(%rip),%rdi
jmp    127f <main+0xff>
lea    0xe16(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
call   1080 <usage@plt>
mov    $0x1,%edi
call   10a0 <exit@plt>

LLVM IR (-O0):
@.str = [8 x i8] c"hsbcmo:\00"
@.str.1 = [16 x i8] c"default_browser\00"
@.str.2 = [18 x i8] c"other_browser_cmd\00"
@.str.3 = [16 x i8] c"continuous_mode\00"
@optarg = global i8* null
@.str.4 = [36 x i8] c"Must specify one of -b, -c, -m, -o\0A\00"
@optind = global i32 0
@.str.5 = [44 x i8] c"Value to set config option to not provided\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i8*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %7
store i32 0, i32* %8
store i8* null, i8** %9
br label %10
10: ; preds = %34, %2
%11 = load i32, i32* %7
%12 = icmp ne i32 %11, 0
br i1 %12, label %18, label %13
13: ; preds = %10
%14 = load i32, i32* %4
%15 = load i8**, i8*** %5
%16 = call i32 @getopt(i32 %14, i8** %15, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
store i32 %16, i32* %6
%17 = icmp ne i32 %16, -1
br label %18
18: ; preds = %13, %10
%19 = phi i1 [ false, %10 ], [ %17, %13 ]
br i1 %19, label %20, label %35
20: ; preds = %18
%21 = load i32, i32* %6
switch i32 %21, label %31 [
i32 104, label %22
i32 115, label %25
i32 98, label %26
i32 99, label %27
i32 109, label %28
i32 111, label %29
]
22: ; preds = %20
%23 = call i32 (...) @usage()
%24 = call i32 @exit(i32 0)
unreachable
25: ; preds = %20
store i32 1, i32* %8
br label %34
26: ; preds = %20
store i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0), i8** %9
store i32 1, i32* %7
br label %34
27: ; preds = %20
store i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0), i8** %9
store i32 1, i32* %7
br label %34
28: ; preds = %20
store i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0), i8** %9
store i32 1, i32* %7
br label %34
29: ; preds = %20
%30 = load i8*, i8** @optarg
store i8* %30, i8** %9
store i32 1, i32* %7
br label %34
31: ; preds = %20
%32 = call i32 (...) @usage()
%33 = call i32 @exit(i32 1)
unreachable
34: ; preds = %29, %28, %27, %26, %25
br label %10
35: ; preds = %18
%36 = load i8*, i8** %9
%37 = icmp ne i8* %36, null
br i1 %37, label %42, label %38
38: ; preds = %35
%39 = call i32 @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.4, i64 0, i64 0))
%40 = call i32 (...) @usage()
%41 = call i32 @exit(i32 1)
unreachable
42: ; preds = %35
%43 = load i32, i32* %8
%44 = icmp ne i32 %43, 0
br i1 %44, label %45, label %61
45: ; preds = %42
%46 = load i32, i32* @optind
%47 = load i32, i32* %4
%48 = icmp sge i32 %46, %47
br i1 %48, label %49, label %53
49: ; preds = %45
%50 = call i32 @printf(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.5, i64 0, i64 0))
%51 = call i32 (...) @usage()
%52 = call i32 @exit(i32 1)
unreachable
53: ; preds = %45
%54 = load i8*, i8** %9
%55 = load i8**, i8*** %5
%56 = load i32, i32* @optind
%57 = sext i32 %56 to i64
%58 = getelementptr inbounds i8*, i8** %55, i64 %57
%59 = load i8*, i8** %58
%60 = call i32 @set_config_value(i8* %54, i8* %59)
store i32 %60, i32* %3
br label %70
61: ; preds = %42
%62 = load i8*, i8** %9
%63 = call i32 @strcmp(i8* %62, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0))
%64 = icmp ne i32 %63, 0
br i1 %64, label %67, label %65
65: ; preds = %61
%66 = call i32 (...) @get_default_browser()
store i32 %66, i32* %3
br label %70
67: ; preds = %61
%68 = load i8*, i8** %9
%69 = call i32 @get_config_value(i8* %68)
store i32 %69, i32* %3
br label %70
70: ; preds = %67, %65, %53
%71 = load i32, i32* %3
ret i32 %71
}

LLVM IR (-O2):
@.str = [8 x i8] c"hsbcmo:\00"
@.str.1 = [16 x i8] c"default_browser\00"
@.str.2 = [18 x i8] c"other_browser_cmd\00"
@.str.3 = [16 x i8] c"continuous_mode\00"
@optarg = global i8* null
@optind = global i32 0
@str = [35 x i8] c"Must specify one of -b, -c, -m, -o\00"
@str.6 = [43 x i8] c"Value to set config option to not provided\00"
define i32 @main(i32 %0, i8** %1) {
br label %3
3: ; preds = %3, %2
%4 = phi i1 [ false, %3 ], [ true, %2 ]
%5 = tail call i32 @getopt(i32 %0, i8** %1, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
switch i32 %5, label %11 [
i32 -1, label %14
i32 104, label %6
i32 115, label %3
i32 98, label %17
i32 99, label %15
i32 109, label %16
i32 111, label %9
]
6: ; preds = %3
%7 = tail call i32 (...) @usage()
%8 = tail call i32 @exit(i32 0)
unreachable
9: ; preds = %3
%10 = load i8*, i8** @optarg
br label %17
11: ; preds = %3
%12 = tail call i32 (...) @usage()
%13 = tail call i32 @exit(i32 1)
unreachable
14: ; preds = %3
br label %17
15: ; preds = %3
br label %17
16: ; preds = %3
br label %17
17: ; preds = %3, %16, %15, %9, %14
%18 = phi i8* [ null, %14 ], [ %10, %9 ], [ getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0), %15 ], [ getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0), %16 ], [ getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0), %3 ]
%19 = icmp eq i8* %18, null
br i1 %19, label %20, label %24
20: ; preds = %17
%21 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @str, i64 0, i64 0))
%22 = tail call i32 (...) @usage()
%23 = tail call i32 @exit(i32 1)
unreachable
24: ; preds = %17
br i1 %4, label %37, label %25
25: ; preds = %24
%26 = load i32, i32* @optind
%27 = icmp slt i32 %26, %0
br i1 %27, label %32, label %28
28: ; preds = %25
%29 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([43 x i8], [43 x i8]* @str.6, i64 0, i64 0))
%30 = tail call i32 (...) @usage()
%31 = tail call i32 @exit(i32 1)
unreachable
32: ; preds = %25
%33 = sext i32 %26 to i64
%34 = getelementptr inbounds i8*, i8** %1, i64 %33
%35 = load i8*, i8** %34
%36 = tail call i32 @set_config_value(i8* %18, i8* %35)
br label %44
37: ; preds = %24
%38 = tail call i32 @strcmp(i8* %18, i8* dereferenceable(16) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0))
%39 = icmp eq i32 %38, 0
br i1 %39, label %40, label %42
40: ; preds = %37
%41 = tail call i32 (...) @get_default_browser()
br label %44
42: ; preds = %37
%43 = tail call i32 @get_config_value(i8* %18)
br label %44
44: ; preds = %42, %40, %32
%45 = phi i32 [ %36, %32 ], [ %43, %42 ], [ %41, %40 ]
ret i32 %45
}