// File: /workspace/github_cpp_makefile_star2_O2/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, -0x38(%rbp)
leaq -0x48(%rbp), %rax
movq %rax, -0x10(%rax)
andq $0x0, -0x8(%rax)
movb $0x0, (%rax)
movslq %edi, %r12
pushq $0x2
popq %rbx
pushq $0x1
popq %r15
leaq -0x58(%rbp), %r14
leaq 0x1a61(%rip), %r13      # 0x6018
cmpq %r12, %r15
jge 0x474e
movq -0x38(%rbp), %rax
movq (%rax,%r15,8), %rsi
movq %r14, %rdi
callq 0x3470
movl %ebx, %eax
movslq (%r13,%rax,4), %rax
addq %r13, %rax
jmpq *%rax
movq %r14, %rdi
xorl %esi, %esi
pushq $0xa
popq %rdx
callq 0x4d57
movl %eax, 0x4c85(%rip)      # 0x9274
jmp 0x46f4
movq %r14, %rdi
leaq 0x1e3b(%rip), %rsi      # 0x6439
callq 0x4c35
testb %al, %al
jne 0x4807
movq %r14, %rdi
leaq 0x1e27(%rip), %rsi      # 0x643c
callq 0x4c35
testb %al, %al
jne 0x4807
movq %r14, %rdi
leaq 0x1e17(%rip), %rsi      # 0x6443
callq 0x4c35
xorl %ebx, %ebx
testb %al, %al
jne 0x470b
movq %r14, %rdi
leaq 0x1e01(%rip), %rsi      # 0x6446
callq 0x4c35
testb %al, %al
jne 0x470b
movq %r14, %rdi
leaq 0x1df1(%rip), %rsi      # 0x644d
callq 0x4c35
pushq $0x1
popq %rbx
testb %al, %al
jne 0x470b
movq %r14, %rdi
leaq 0x1dda(%rip), %rsi      # 0x6450
callq 0x4c35
testb %al, %al
jne 0x470b
movq %r14, %rdi
leaq 0x1dca(%rip), %rsi      # 0x6457
callq 0x4c35
pushq $0x3
popq %rbx
testb %al, %al
jne 0x470b
movq %r14, %rdi
leaq 0x1db7(%rip), %rsi      # 0x645a
callq 0x4c35
testb %al, %al
jne 0x470b
movq %r14, %rdi
leaq 0x1db1(%rip), %rsi      # 0x6467
callq 0x4c35
testb %al, %al
jne 0x46d2
movq %r14, %rdi
leaq 0x1da1(%rip), %rsi      # 0x646a
callq 0x4c35
testb %al, %al
je 0x4713
andl $0x0, 0x4b9b(%rip)      # 0x9274
jmp 0x46f4
movq %r14, %rdi
xorl %esi, %esi
pushq $0xa
popq %rdx
callq 0x4d57
imull $0x3e8, %eax, %eax      # imm = 0x3E8
movl %eax, 0x4b7c(%rip)      # 0x9270
pushq $0x2
popq %rbx
jmp 0x470b
leaq 0x4c40(%rip), %rdi      # 0x9340
movq %r14, %rsi
callq 0x31c0
pushq $0x2
popq %rbx
incq %r15
jmp 0x45b7
movq %r14, %rdi
leaq 0x1d57(%rip), %rsi      # 0x6474
callq 0x4c35
testb %al, %al
jne 0x4813
movq %r14, %rdi
leaq 0x1d43(%rip), %rsi      # 0x6477
callq 0x4c35
testb %al, %al
jne 0x4813
movq %r14, %rdi
callq 0x369c
pushq $0x2
popq %rbx
jmp 0x470b
cmpl $0x2, %ebx
jne 0x47e1
leaq 0x4be2(%rip), %rdi      # 0x9340
leaq 0x1a4f(%rip), %rsi      # 0x61b4
callq 0x4c35
xorl %ebx, %ebx
testb %al, %al
je 0x47ed
leaq 0x1d0a(%rip), %rdi      # 0x6481
callq 0x3340
testq %rax, %rax
jne 0x4791
callq 0x3190
movl %eax, %edi
callq 0x3310
movq 0x20(%rax), %rax
leaq -0x78(%rbp), %rdi
leaq -0x29(%rbp), %rdx
movq %rax, %rsi
callq 0x3120
leaq 0x1cde(%rip), %rdx      # 0x6486
leaq -0x98(%rbp), %rdi
leaq -0x78(%rbp), %rsi
callq 0x4d86
leaq 0x4b81(%rip), %rdi      # 0x9340
leaq -0x98(%rbp), %r14
movq %r14, %rsi
callq 0x3350
movq %r14, %rdi
callq 0x3498
leaq -0x78(%rbp), %rdi
callq 0x3498
jmp 0x47ed
leaq -0x58(%rbp), %rdi
callq 0x374c
pushq $0x1
popq %rbx
leaq -0x58(%rbp), %rdi
callq 0x3498
movl %ebx, %eax
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x44c4
xorl %edi, %edi
callq 0x3330
callq 0x445e
jmp 0x480c
jmp 0x4893
movq %rax, %rbx
leaq -0x78(%rbp), %rdi
callq 0x3498
jmp 0x4896
jmp 0x4893
jmp 0x4893
movq %rax, %rbx
cmpl $0x1, %edx
jne 0x4896
movq %rbx, %rdi
callq 0x3130
leaq -0x58(%rbp), %rdi
callq 0x3710
callq 0x3420
jmp 0x47ea
jmp 0x4893
movq %rax, %rbx
callq 0x3420
jmp 0x4896
movq %rax, %rbx
cmpl $0x1, %edx
jne 0x4896
movq %rbx, %rdi
callq 0x3130
leaq -0x58(%rbp), %rdi
callq 0x36d6
callq 0x3420
jmp 0x47ea
jmp 0x4893
movq %rax, %rbx
callq 0x3420
jmp 0x4896
movq %rax, %rdi
callq 0x4d78
jmp 0x4893
movq %rax, %rbx
leaq -0x58(%rbp), %rdi
callq 0x3498
movq %rbx, %rdi
callq 0x3450