// File: /workspace/github_cpp_makefile_star2_O1/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 0x501e
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 0x2247(%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 0x5150
leaq -0x80000000(%rax), %rcx
movabsq $-0x100000000, %rdx     # imm = 0xFFFFFFFF00000000
cmpq %rdx, %rcx
jb 0x515c
movl (%r12), %ecx
cmpl $0x22, %ecx
je 0x515c
testl %ecx, %ecx
jne 0x4e38
movl %ebx, (%r12)
movl %eax, 0x5466(%rip)      # 0xa2a4
jmp 0x4fe6
movq %r14, %rdi
leaq 0x25ec(%rip), %rsi      # 0x7439
callq 0x30c0
testl %eax, %eax
je 0x512c
movq %r14, %rdi
leaq 0x25d8(%rip), %rsi      # 0x743c
callq 0x30c0
testl %eax, %eax
je 0x512c
movq %r14, %rdi
leaq 0x25c8(%rip), %rsi      # 0x7443
callq 0x30c0
testl %eax, %eax
je 0x4ffc
movq %r14, %rdi
leaq 0x25b4(%rip), %rsi      # 0x7446
callq 0x30c0
testl %eax, %eax
je 0x4ffc
movq %r14, %rdi
leaq 0x25a4(%rip), %rsi      # 0x744d
callq 0x30c0
movl $0x1, %ebx
testl %eax, %eax
je 0x5002
movq %r14, %rdi
leaq 0x258b(%rip), %rsi      # 0x7450
callq 0x30c0
testl %eax, %eax
je 0x5002
movq %r14, %rdi
leaq 0x257b(%rip), %rsi      # 0x7457
callq 0x30c0
movl $0x3, %ebx
testl %eax, %eax
je 0x5002
movq %r14, %rdi
leaq 0x2562(%rip), %rsi      # 0x745a
callq 0x30c0
testl %eax, %eax
je 0x5002
movq %r14, %rdi
leaq 0x2558(%rip), %rsi      # 0x7467
callq 0x30c0
testl %eax, %eax
je 0x5006
movq %r14, %rdi
leaq 0x2544(%rip), %rsi      # 0x746a
callq 0x30c0
testl %eax, %eax
je 0x5006
movq %r14, %rdi
leaq 0x2537(%rip), %rsi      # 0x7474
callq 0x30c0
testl %eax, %eax
je 0x5168
movq %r14, %rdi
leaq 0x2523(%rip), %rsi      # 0x7477
callq 0x30c0
testl %eax, %eax
je 0x5168
movq %r14, %rdi
callq 0x375a
jmp 0x4fe6
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 0x5144
leaq -0x80000000(%rax), %rcx
movabsq $-0x100000000, %rdx     # imm = 0xFFFFFFFF00000000
cmpq %rdx, %rcx
jb 0x5138
movl (%r12), %ecx
cmpl $0x22, %ecx
je 0x5138
testl %ecx, %ecx
jne 0x4fc9
movl %ebx, (%r12)
imull $0x3e8, %eax, %eax      # imm = 0x3E8
movl %eax, 0x52cb(%rip)      # 0xa2a0
jmp 0x4fe6
leaq 0x5392(%rip), %rdi      # 0xa370
movq %r14, %rsi
callq 0x31b0
movl $0x2, %ebx
movb $0x1, %al
incq %r15
cmpq %r15, -0x58(%rbp)
jne 0x4da1
jmp 0x5012
xorl %eax, %eax
xorl %ebx, %ebx
jmp 0x4fed
xorl %eax, %eax
jmp 0x4fed
movl $0x0, 0x5294(%rip)      # 0xa2a4
jmp 0x4fe6
testb %al, %al
leaq -0x40(%rbp), %r14
je 0x50a6
leaq 0x534b(%rip), %rdi      # 0xa370
leaq 0x2188(%rip), %rsi      # 0x71b4
callq 0x30c0
xorl %ebx, %ebx
testl %eax, %eax
jne 0x510d
leaq 0x243f(%rip), %rdi      # 0x7481
callq 0x3370
testq %rax, %rax
jne 0x505c
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 0x2410(%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 0x50b6
movq %rdx, -0x80(%rbp)
movq (%rcx), %rdx
movq %rdx, -0x70(%rbp)
jmp 0x50bd
movl $0x1, %ebx
leaq -0x50(%rbp), %rdi
callq 0x388f
jmp 0x510d
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 0x5291(%rip), %rdi      # 0xa370
movq %r14, %rsi
callq 0x3380
movq (%r14), %rdi
cmpq %r15, %rdi
je 0x50f4
callq 0x32c0
leaq -0x90(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
leaq -0x40(%rbp), %r14
je 0x510d
callq 0x32c0
movq -0x50(%rbp), %rdi
cmpq %r14, %rdi
je 0x511b
callq 0x32c0
movl %ebx, %eax
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x4ba5
xorl %edi, %edi
callq 0x3360
leaq 0x2379(%rip), %rdi      # 0x74b8
callq 0x33f0
leaq 0x236d(%rip), %rdi      # 0x74b8
callq 0x31d0
leaq 0x2361(%rip), %rdi      # 0x74b8
callq 0x31d0
leaq 0x2355(%rip), %rdi      # 0x74b8
callq 0x33f0
callq 0x4b07
jmp 0x5131
jmp 0x5232
jmp 0x5232
movq %rax, %r14
leaq -0x90(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x5235
callq 0x32c0
jmp 0x5235
jmp 0x5232
jmp 0x5232
movq %rax, %r14
cmpl $0x0, (%r12)
jne 0x51b2
movl %ebx, (%r12)
cmpl $0x1, %edx
jne 0x5235
movq %r14, %rdi
callq 0x3140
leaq -0x50(%rbp), %rdi
callq 0x37c1
movl $0x1, %ebx
leaq -0x40(%rbp), %r14
callq 0x3460
jmp 0x510d
jmp 0x5232
movq %rax, %r14
callq 0x3460
jmp 0x5235
movq %rax, %r14
cmpl $0x0, (%r12)
jne 0x51f5
movl %ebx, (%r12)
cmpl $0x1, %edx
jne 0x5235
movq %r14, %rdi
callq 0x3140
leaq -0x50(%rbp), %rdi
callq 0x3828
movl $0x1, %ebx
leaq -0x40(%rbp), %r14
callq 0x3460
jmp 0x510d
jmp 0x5232
movq %rax, %r14
callq 0x3460
jmp 0x5235
movq %rax, %rdi
callq 0x572b
movq %rax, %r14
movq -0x50(%rbp), %rdi
leaq -0x40(%rbp), %rax
cmpq %rax, %rdi
je 0x5247
callq 0x32c0
movq %r14, %rdi
callq 0x34a0