// File: /workspace/github_cpp_makefile_star2_O3/Lartu[P]coraldb/source/coraldb.cpp
// Function: parse_arguments(int, char**)
int parse_arguments(int argc, char **argv)
{
    std::string argument;
    switch_types requested_switch = none;
    for (int i = 1; i < argc; ++i)
    {
        argument = argv[i];
        if (requested_switch == none)
        {
            if (argument == "-h" || argument == "--help")
            {
                show_help();
                exit(0);
            }
            else if (argument == "-p" || argument == "--port")
            {
                requested_switch = port;
            }
            else if (argument == "-f" || argument == "--file")
            {
                requested_switch = file;
            }
            else if (argument == "-c" || argument == "--checkpoint")
            {
                requested_switch = checkpoint;
            }
            else if (argument == "-a" || argument == "--anyport")
            {
                global_port = 0;
            }
            else if (argument == "-v" || argument == "--version")
            {
                print_version();
                exit(0);
            }
            else
            {
                err_unknown_switch(argument);
            }
        }
        else
        {
            if (requested_switch == port)
            {
                try
                {
                    global_port = stoi(argument);
                }
                catch (const std::invalid_argument &ia)
                {
                    err_malformed_port(argument);
                    return 1;
                }
            }
            else if (requested_switch == file)
            {
                global_filename = argument;
            }
            else if (requested_switch == checkpoint)
            {
                try
                {
                    CHECKPOINT_TIME = stoi(argument) * 1000;
                }
                catch (const std::invalid_argument &ia)
                {
                    err_malformed_checkpoint_timeout(argument);
                    return 1;
                }
            }
            requested_switch = none;
        }
    }
    if (requested_switch != none)
    {
        err_expected_switch_value(argument);
        return 1;
    }
    if (global_filename == "")
    {
        const char *homedir = getenv("HOME");
        if (homedir == NULL)
        {
            homedir = getpwuid(getuid())->pw_dir;
        }
        global_filename = (std::string)homedir + "/coraldb.db";
    }
    return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x78, %rsp
movq %rsi, -0x60(%rbp)
leaq -0x40(%rbp), %r14
movq %r14, -0x10(%r14)
movq $0x0, -0x8(%r14)
movb $0x0, (%r14)
cmpl $0x2, %edi
jl 0x4fff
movl %edi, %eax
movq %rax, -0x58(%rbp)
movl $0x2, %ebx
movl $0x1, %r15d
leaq -0x50(%rbp), %r14
movq -0x60(%rbp), %rax
movq (%rax,%r15,8), %r12
movq -0x48(%rbp), %r13
movq %r12, %rdi
callq 0x3150
movq %r14, %rdi
xorl %esi, %esi
movq %r13, %rdx
movq %r12, %rcx
movq %rax, %r8
callq 0x3440
movl %ebx, %eax
leaq 0x2266(%rip), %rcx      # 0x7018
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq -0x50(%rbp), %r13
callq 0x3040
movq %rax, %r12
movl (%rax), %ebx
movl $0x0, (%rax)
movq %r13, %rdi
leaq -0x80(%rbp), %rsi
movl $0xa, %edx
callq 0x33d0
cmpq %r13, -0x80(%rbp)
je 0x5131
leaq -0x80000000(%rax), %rcx
movabsq $-0x100000000, %rdx     # imm = 0xFFFFFFFF00000000
cmpq %rdx, %rcx
jb 0x513d
movl (%r12), %ecx
cmpl $0x22, %ecx
je 0x513d
testl %ecx, %ecx
jne 0x4e19
movl %ebx, (%r12)
movl %eax, 0x5485(%rip)      # 0xa2a4
jmp 0x4fc7
movq %r14, %rdi
leaq 0x260b(%rip), %rsi      # 0x7439
callq 0x30c0
testl %eax, %eax
je 0x510d
movq %r14, %rdi
leaq 0x25f7(%rip), %rsi      # 0x743c
callq 0x30c0
testl %eax, %eax
je 0x510d
movq %r14, %rdi
leaq 0x25e7(%rip), %rsi      # 0x7443
callq 0x30c0
testl %eax, %eax
je 0x4fdd
movq %r14, %rdi
leaq 0x25d3(%rip), %rsi      # 0x7446
callq 0x30c0
testl %eax, %eax
je 0x4fdd
movq %r14, %rdi
leaq 0x25c3(%rip), %rsi      # 0x744d
callq 0x30c0
movl $0x1, %ebx
testl %eax, %eax
je 0x4fe3
movq %r14, %rdi
leaq 0x25aa(%rip), %rsi      # 0x7450
callq 0x30c0
testl %eax, %eax
je 0x4fe3
movq %r14, %rdi
leaq 0x259a(%rip), %rsi      # 0x7457
callq 0x30c0
movl $0x3, %ebx
testl %eax, %eax
je 0x4fe3
movq %r14, %rdi
leaq 0x2581(%rip), %rsi      # 0x745a
callq 0x30c0
testl %eax, %eax
je 0x4fe3
movq %r14, %rdi
leaq 0x2577(%rip), %rsi      # 0x7467
callq 0x30c0
testl %eax, %eax
je 0x4fe7
movq %r14, %rdi
leaq 0x2563(%rip), %rsi      # 0x746a
callq 0x30c0
testl %eax, %eax
je 0x4fe7
movq %r14, %rdi
leaq 0x2556(%rip), %rsi      # 0x7474
callq 0x30c0
testl %eax, %eax
je 0x5149
movq %r14, %rdi
leaq 0x2542(%rip), %rsi      # 0x7477
callq 0x30c0
testl %eax, %eax
je 0x5149
movq %r14, %rdi
callq 0x375a
jmp 0x4fc7
movq -0x50(%rbp), %r13
callq 0x3040
movq %rax, %r12
movl (%rax), %ebx
movl $0x0, (%rax)
movq %r13, %rdi
leaq -0x80(%rbp), %rsi
movl $0xa, %edx
callq 0x33d0
cmpq %r13, -0x80(%rbp)
je 0x5125
leaq -0x80000000(%rax), %rcx
movabsq $-0x100000000, %rdx     # imm = 0xFFFFFFFF00000000
cmpq %rdx, %rcx
jb 0x5119
movl (%r12), %ecx
cmpl $0x22, %ecx
je 0x5119
testl %ecx, %ecx
jne 0x4faa
movl %ebx, (%r12)
imull $0x3e8, %eax, %eax      # imm = 0x3E8
movl %eax, 0x52ea(%rip)      # 0xa2a0
jmp 0x4fc7
leaq 0x53b1(%rip), %rdi      # 0xa370
movq %r14, %rsi
callq 0x31b0
movl $0x2, %ebx
movb $0x1, %al
incq %r15
cmpq %r15, -0x58(%rbp)
jne 0x4d82
jmp 0x4ff3
xorl %eax, %eax
xorl %ebx, %ebx
jmp 0x4fce
xorl %eax, %eax
jmp 0x4fce
movl $0x0, 0x52b3(%rip)      # 0xa2a4
jmp 0x4fc7
testb %al, %al
leaq -0x40(%rbp), %r14
je 0x5087
leaq 0x536a(%rip), %rdi      # 0xa370
leaq 0x21a7(%rip), %rsi      # 0x71b4
callq 0x30c0
xorl %ebx, %ebx
testl %eax, %eax
jne 0x50ee
leaq 0x245e(%rip), %rdi      # 0x7481
callq 0x3370
testq %rax, %rax
jne 0x503d
callq 0x3180
movl %eax, %edi
callq 0x3340
movq 0x20(%rax), %rax
leaq -0xa0(%rbp), %rdi
leaq -0x29(%rbp), %rdx
movq %rax, %rsi
callq 0x3130
leaq 0x242f(%rip), %rsi      # 0x7486
leaq -0xa0(%rbp), %rdi
callq 0x34d0
leaq -0x70(%rbp), %r15
movq %r15, -0x10(%r15)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
je 0x5097
movq %rdx, -0x80(%rbp)
movq (%rcx), %rdx
movq %rdx, -0x70(%rbp)
jmp 0x509e
movl $0x1, %ebx
leaq -0x50(%rbp), %rdi
callq 0x388f
jmp 0x50ee
movups (%rcx), %xmm0
movups %xmm0, (%r15)
movq 0x8(%rax), %rdx
leaq -0x80(%rbp), %r14
movq %rdx, 0x8(%r14)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
leaq 0x52b0(%rip), %rdi      # 0xa370
movq %r14, %rsi
callq 0x3380
movq (%r14), %rdi
cmpq %r15, %rdi
je 0x50d5
callq 0x32c0
leaq -0x90(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
leaq -0x40(%rbp), %r14
je 0x50ee
callq 0x32c0
movq -0x50(%rbp), %rdi
cmpq %r14, %rdi
je 0x50fc
callq 0x32c0
movl %ebx, %eax
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x4b86
xorl %edi, %edi
callq 0x3360
leaq 0x2398(%rip), %rdi      # 0x74b8
callq 0x33f0
leaq 0x238c(%rip), %rdi      # 0x74b8
callq 0x31d0
leaq 0x2380(%rip), %rdi      # 0x74b8
callq 0x31d0
leaq 0x2374(%rip), %rdi      # 0x74b8
callq 0x33f0
callq 0x4ae8
jmp 0x5112
jmp 0x5213
jmp 0x5213
movq %rax, %r14
leaq -0x90(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x5216
callq 0x32c0
jmp 0x5216
jmp 0x5213
jmp 0x5213
movq %rax, %r14
cmpl $0x0, (%r12)
jne 0x5193
movl %ebx, (%r12)
cmpl $0x1, %edx
jne 0x5216
movq %r14, %rdi
callq 0x3140
leaq -0x50(%rbp), %rdi
callq 0x37c1
movl $0x1, %ebx
leaq -0x40(%rbp), %r14
callq 0x3460
jmp 0x50ee
jmp 0x5213
movq %rax, %r14
callq 0x3460
jmp 0x5216
movq %rax, %r14
cmpl $0x0, (%r12)
jne 0x51d6
movl %ebx, (%r12)
cmpl $0x1, %edx
jne 0x5216
movq %r14, %rdi
callq 0x3140
leaq -0x50(%rbp), %rdi
callq 0x3828
movl $0x1, %ebx
leaq -0x40(%rbp), %r14
callq 0x3460
jmp 0x50ee
jmp 0x5213
movq %rax, %r14
callq 0x3460
jmp 0x5216
movq %rax, %rdi
callq 0x5703
movq %rax, %r14
movq -0x50(%rbp), %rdi
leaq -0x40(%rbp), %rax
cmpq %rax, %rdi
je 0x5228
callq 0x32c0
movq %r14, %rdi
callq 0x34a0