#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*/ assert(int);
unsigned int atoi(int /*<<< orphan*/);
int /*<<< orphan*/ close_database();
int /*<<< orphan*/ distance_between_all_chunk_references(unsigned int,
                                                         unsigned int);
int /*<<< orphan*/ distance_between_first_two_chunk_references(unsigned int,
                                                               unsigned int);
int getopt_long(int, char **, char *, int /*<<< orphan*/ *,
                int /*<<< orphan*/ *);
int /*<<< orphan*/ open_database();
int /*<<< orphan*/ optarg;
int main(int argc, char *argv[]) {
  int opt = 0;
  int all = 0;
  unsigned int lb = 2, rb = -1;
  while ((opt = getopt_long(argc, argv, "al:r:", NULL, NULL)) != -1) {
    switch (opt) {
    case 'a':
      all = 1;
      break;
    case 'l':
      lb = atoi(optarg);
      break;
    case 'r':
      rb = atoi(optarg);
      break;
    default:
      return -1;
    }
  }
  assert(lb >= 2);
  open_database();
  if (all == 1)
    distance_between_all_chunk_references(lb, rb);
  else
    distance_between_first_two_chunk_references(lb, rb);
  close_database();
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
movl   $0x2,-0x1c(%rbp)
movl   $0xffffffff,-0x20(%rbp)
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
lea    0xe50(%rip),%rdx
xor    %eax,%eax
mov    %eax,%r8d
mov    %r8,%rcx
call   1040 <getopt_long@plt>
mov    %eax,-0x14(%rbp)
cmp    $0xffffffff,%eax
je     1248 <main+0xd8>
mov    -0x14(%rbp),%eax
mov    %eax,-0x24(%rbp)
sub    $0x61,%eax
je     11ff <main+0x8f>
jmp    11dd <main+0x6d>
mov    -0x24(%rbp),%eax
sub    $0x6c,%eax
je     120b <main+0x9b>
jmp    11ee <main+0x7e>
mov    -0x24(%rbp),%eax
sub    $0x72,%eax
je     1221 <main+0xb1>
jmp    1237 <main+0xc7>
movl   $0x1,-0x18(%rbp)
jmp    1243 <main+0xd3>
mov    0x2de6(%rip),%rax
mov    (%rax),%edi
call   1080 <atoi@plt>
mov    %eax,-0x1c(%rbp)
jmp    1243 <main+0xd3>
mov    0x2dd0(%rip),%rax
mov    (%rax),%edi
call   1080 <atoi@plt>
mov    %eax,-0x20(%rbp)
jmp    1243 <main+0xd3>
movl   $0xffffffff,-0x4(%rbp)
jmp    1293 <main+0x123>
jmp    11a2 <main+0x32>
cmpl   $0x2,-0x1c(%rbp)
setae  %al
and    $0x1,%al
movzbl %al,%edi
call   1070 <assert@plt>
mov    $0x0,%al
call   1090 <open_database@plt>
cmpl   $0x1,-0x18(%rbp)
jne    127a <main+0x10a>
mov    -0x1c(%rbp),%edi
mov    -0x20(%rbp),%esi
call   1030 <distance_between_all_chunk_references@plt>
jmp    1285 <main+0x115>
mov    -0x1c(%rbp),%edi
mov    -0x20(%rbp),%esi
call   1060 <distance_between_first_two_chunk_references@plt>
mov    $0x0,%al
call   1050 <close_database@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rsi,%rbp
mov    %edi,%ebx
mov    $0xffffffff,%r15d
mov    $0x2,%r14d
xor    %eax,%eax
mov    %rax,(%rsp)
lea    0xe67(%rip),%r12
mov    0x2e58(%rip),%r13
jmp    11bc <main+0x4c>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    0x0(%r13),%edi
call   1080 <atoi@plt>
mov    %eax,%r15d
mov    %ebx,%edi
mov    %rbp,%rsi
mov    %r12,%rdx
xor    %ecx,%ecx
xor    %r8d,%r8d
call   1040 <getopt_long@plt>
cmp    $0x72,%eax
je     11b0 <main+0x40>
cmp    $0xffffffff,%eax
je     11f8 <main+0x88>
cmp    $0x61,%eax
je     11f0 <main+0x80>
cmp    $0x6c,%eax
jne    1221 <main+0xb1>
mov    0x0(%r13),%edi
call   1080 <atoi@plt>
mov    %eax,%r14d
jmp    11bc <main+0x4c>
mov    $0x1,%al
mov    %rax,(%rsp)
jmp    11bc <main+0x4c>
xor    %edi,%edi
cmp    $0x2,%r14d
setae  %dil
call   1070 <assert@plt>
xor    %eax,%eax
call   1090 <open_database@plt>
testb  $0x1,(%rsp)
je     1228 <main+0xb8>
mov    %r14d,%edi
mov    %r15d,%esi
call   1030 <distance_between_all_chunk_references@plt>
jmp    1233 <main+0xc3>
mov    $0xffffffff,%ebx
jmp    123c <main+0xcc>
mov    %r14d,%edi
mov    %r15d,%esi
call   1060 <distance_between_first_two_chunk_references@plt>
xor    %ebx,%ebx
xor    %eax,%eax
call   1050 <close_database@plt>
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [6 x i8] c"al:r:\00"
@optarg = global i32 0
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 i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %6
store i32 0, i32* %7
store i32 2, i32* %8
store i32 -1, i32* %9
br label %10
10: ; preds = %25, %2
%11 = load i32, i32* %4
%12 = load i8**, i8*** %5
%13 = call i32 @getopt_long(i32 %11, i8** %12, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32* null, i32* null)
store i32 %13, i32* %6
%14 = icmp ne i32 %13, -1
br i1 %14, label %15, label %26
15: ; preds = %10
%16 = load i32, i32* %6
switch i32 %16, label %24 [
i32 97, label %17
i32 108, label %18
i32 114, label %21
]
17: ; preds = %15
store i32 1, i32* %7
br label %25
18: ; preds = %15
%19 = load i32, i32* @optarg
%20 = call i32 @atoi(i32 %19)
store i32 %20, i32* %8
br label %25
21: ; preds = %15
%22 = load i32, i32* @optarg
%23 = call i32 @atoi(i32 %22)
store i32 %23, i32* %9
br label %25
24: ; preds = %15
store i32 -1, i32* %3
br label %44
25: ; preds = %21, %18, %17
br label %10
26: ; preds = %10
%27 = load i32, i32* %8
%28 = icmp uge i32 %27, 2
%29 = zext i1 %28 to i32
%30 = call i32 @assert(i32 %29)
%31 = call i32 (...) @open_database()
%32 = load i32, i32* %7
%33 = icmp eq i32 %32, 1
br i1 %33, label %34, label %38
34: ; preds = %26
%35 = load i32, i32* %8
%36 = load i32, i32* %9
%37 = call i32 @distance_between_all_chunk_references(i32 %35, i32 %36)
br label %42
38: ; preds = %26
%39 = load i32, i32* %8
%40 = load i32, i32* %9
%41 = call i32 @distance_between_first_two_chunk_references(i32 %39, i32 %40)
br label %42
42: ; preds = %38, %34
%43 = call i32 (...) @close_database()
store i32 0, i32* %3
br label %44
44: ; preds = %42, %24
%45 = load i32, i32* %3
ret i32 %45
}

LLVM IR (-O2):
@.str = [6 x i8] c"al:r:\00"
@optarg = global i32 0
define i32 @main(i32 %0, i8** %1) {
br label %3
3: ; preds = %10, %2
%4 = phi i1 [ false, %2 ], [ true, %10 ]
%5 = phi i32 [ 2, %2 ], [ %8, %10 ]
%6 = phi i32 [ -1, %2 ], [ %11, %10 ]
br label %7
7: ; preds = %3, %13
%8 = phi i32 [ %5, %3 ], [ %15, %13 ]
%9 = phi i32 [ %6, %3 ], [ %11, %13 ]
br label %10
10: ; preds = %7, %16
%11 = phi i32 [ %18, %16 ], [ %9, %7 ]
%12 = tail call i32 @getopt_long(i32 %0, i8** %1, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32* null, i32* null)
switch i32 %12, label %30 [
i32 -1, label %19
i32 97, label %3
i32 108, label %13
i32 114, label %16
]
13: ; preds = %10
%14 = load i32, i32* @optarg
%15 = tail call i32 @atoi(i32 %14)
br label %7
16: ; preds = %10
%17 = load i32, i32* @optarg
%18 = tail call i32 @atoi(i32 %17)
br label %10
19: ; preds = %10
%20 = icmp ugt i32 %8, 1
%21 = zext i1 %20 to i32
%22 = tail call i32 @assert(i32 %21)
%23 = tail call i32 (...) @open_database()
br i1 %4, label %24, label %26
24: ; preds = %19
%25 = tail call i32 @distance_between_all_chunk_references(i32 %8, i32 %11)
br label %28
26: ; preds = %19
%27 = tail call i32 @distance_between_first_two_chunk_references(i32 %8, i32 %11)
br label %28
28: ; preds = %26, %24
%29 = tail call i32 (...) @close_database()
br label %30
30: ; preds = %10, %28
%31 = phi i32 [ 0, %28 ], [ -1, %10 ]
ret i32 %31
}