// File: /workspace/github_cpp_makefile_star2_O1/IsaacLaw12[P]RayTracer/./src/raytracer.cpp
// Function: parse_args(int, char**, int&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>&)
int parse_args(int argc, char*argv[], int &num_threads, std::string &driver_file, std::string &save_folder){
    int status = 0;

    // Set Defaults
    num_threads = 1;

    // Parse flags
    for (int i=1; i<argc-2; i++){
        std::string arg = argv[i];
        if (arg == "-t" || arg == "--threads"){
            int valid_int = 0;
            num_threads = parse_int(std::string(argv[++i]), valid_int);
            if (valid_int != 0 || (!(i < argc-2))){
                std::cout << "Number of threads not specified\n";
                status = 1;
                num_threads = 1;
            } else{
                num_threads = std::max(std::min(num_threads, 100), 1);
            }
        }
    }
    if (!(argc >= 3)){
        status = 1;
    }
    // Extract two mandatory arguments
    if (status == 0){
        driver_file = argv[argc-2];
        save_folder = parse_folder_name(argv[argc-1]);
    } else{
        std::cout << "Error: run with " << argv[0] << " <driver_file> <save_folder>\n\n"
                  << "    driver_file: A scene specification file, more detail in scene_driver.md\n"
                  << "    save_folder: The folder to save output images to. If it already exists current\n"
                  << "        contents will be replaced\n\n"
                  << "    Optional:\n"
                  << "         --threads, -t  specify number of threads\n\n";
    }
    return status;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x98, %rsp
movq %r8, 0x40(%rsp)
movq %rcx, 0x48(%rsp)
movq %rsi, 0x18(%rsp)
movl $0x1, (%rdx)
leal -0x2(%rdi), %r12d
movl $0x0, 0x10(%rsp)
movq %rdi, 0x50(%rsp)
cmpl $0x4, %edi
jl 0x5fdf
movq %rdx, %r13
movl $0x0, 0x10(%rsp)
leaq 0x20(%rsp), %r14
leaq 0x58(%rsp), %rbp
movl $0x1, %ebx
movslq %ebx, %r15
movq 0x18(%rsp), %rax
movq (%rax,%r15,8), %rsi
movq %r14, %rdi
leaq 0xc(%rsp), %rdx
callq 0x6916
movq %r14, %rdi
leaq 0x10d2b(%rip), %rsi     # 0x16c17
callq 0x30c0
testl %eax, %eax
je 0x5f0c
movq %r14, %rdi
leaq 0x10d1b(%rip), %rsi     # 0x16c1a
callq 0x30c0
testl %eax, %eax
jne 0x5fb3
movl $0x0, 0xc(%rsp)
movq 0x18(%rsp), %rax
movq 0x8(%rax,%r15,8), %rsi
movq %rbp, %r15
movq %rbp, %rdi
leaq 0x17(%rsp), %rdx
callq 0x6916
movq %r15, %rdi
leaq 0xc(%rsp), %rsi
callq 0x5d49
movl %eax, (%r13)
movq 0x58(%rsp), %rdi
leaq 0x68(%rsp), %rax
cmpq %rax, %rdi
je 0x5f5b
movq 0x68(%rsp), %rsi
incq %rsi
callq 0x32d0
incl %ebx
cmpl %r12d, %ebx
jge 0x5f89
cmpl $0x0, 0xc(%rsp)
jne 0x5f89
movl (%r13), %r15d
cmpl $0x64, %r15d
movl $0x64, %eax
cmovgel %eax, %r15d
cmpl $0x2, %r15d
movl $0x1, %eax
cmovll %eax, %r15d
jmp 0x5faf
movl $0x1, %r15d
movl $0x20, %edx
movq 0x1a02d(%rip), %rdi     # 0x1ffc8
leaq 0x10c82(%rip), %rsi     # 0x16c24
callq 0x32f0
movl $0x1, 0x10(%rsp)
movl %r15d, (%r13)
movq 0x20(%rsp), %rdi
leaq 0x30(%rsp), %rax
cmpq %rax, %rdi
je 0x5fcf
movq 0x30(%rsp), %rsi
incq %rsi
callq 0x32d0
incl %ebx
cmpl %r12d, %ebx
leaq 0x20(%rsp), %r14
jl 0x5ec9
movq 0x50(%rsp), %r13
cmpl $0x3, %r13d
movl $0x1, %ebp
cmovgel 0x10(%rsp), %ebp
testl %ebp, %ebp
je 0x6041
movq 0x19fcb(%rip), %rbx     # 0x1ffc8
leaq 0x10c41(%rip), %rsi     # 0x16c45
movl $0x10, %edx
movq %rbx, %rdi
callq 0x32f0
movq 0x18(%rsp), %rax
movq (%rax), %r14
testq %r14, %r14
je 0x60ee
movq %r14, %rdi
callq 0x3110
movq 0x19f97(%rip), %rdi     # 0x1ffc8
movq %r14, %rsi
movq %rax, %rdx
callq 0x32f0
jmp 0x6105
movslq %r12d, %rax
movq 0x18(%rsp), %r14
movq (%r14,%rax,8), %rbx
movq 0x48(%rsp), %r12
movq 0x8(%r12), %r15
movq %rbx, %rdi
callq 0x3110
movq %r12, %rdi
xorl %esi, %esi
movq %r15, %rdx
movq %rbx, %rcx
movq %rax, %r8
callq 0x33e0
movslq %r13d, %rax
movq -0x8(%r14,%rax,8), %rsi
leaq 0x78(%rsp), %rdi
leaq 0xc(%rsp), %rdx
callq 0x6916
leaq 0x20(%rsp), %rdi
leaq 0x78(%rsp), %rsi
callq 0x5dec
leaq 0x20(%rsp), %rbx
movq 0x40(%rsp), %rdi
movq %rbx, %rsi
callq 0x3330
movq (%rbx), %rdi
leaq 0x30(%rsp), %rax
cmpq %rax, %rdi
je 0x60c4
movq 0x30(%rsp), %rsi
incq %rsi
callq 0x32d0
leaq 0x88(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x6184
movq 0x88(%rsp), %rsi
incq %rsi
callq 0x32d0
jmp 0x6184
movq (%rbx), %rax
movq -0x18(%rax), %rax
leaq (%rbx,%rax), %rdi
movl 0x20(%rbx,%rax), %esi
orl $0x1, %esi
callq 0x3460
movq 0x19ebc(%rip), %rbx     # 0x1ffc8
leaq 0x10b43(%rip), %rsi     # 0x16c56
movl $0x1e, %edx
movq %rbx, %rdi
callq 0x32f0
leaq 0x10b4e(%rip), %rsi     # 0x16c75
movl $0x4c, %edx
movq %rbx, %rdi
callq 0x32f0
leaq 0x10b87(%rip), %rsi     # 0x16cc2
movl $0x53, %edx
movq %rbx, %rdi
callq 0x32f0
leaq 0x10bc7(%rip), %rsi     # 0x16d16
movl $0x23, %edx
movq %rbx, %rdi
callq 0x32f0
leaq 0x10bd7(%rip), %rsi     # 0x16d3a
movl $0xe, %edx
movq %rbx, %rdi
callq 0x32f0
leaq 0x10bd2(%rip), %rsi     # 0x16d49
movl $0x33, %edx
movq %rbx, %rdi
callq 0x32f0
movl %ebp, %eax
addq $0x98, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
leaq 0x88(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x61ff
movq 0x88(%rsp), %rsi
jmp 0x61f2
jmp 0x61fc
jmp 0x61ba
movq %rax, %rbx
jmp 0x61de
movq %rax, %rbx
movq 0x58(%rsp), %rdi
leaq 0x68(%rsp), %rax
cmpq %rax, %rdi
je 0x61de
movq 0x68(%rsp), %rsi
incq %rsi
callq 0x32d0
movq 0x20(%rsp), %rdi
leaq 0x30(%rsp), %rax
cmpq %rax, %rdi
je 0x61ff
movq 0x30(%rsp), %rsi
incq %rsi
callq 0x32d0
jmp 0x61ff
movq %rax, %rbx
movq %rbx, %rdi
callq 0x34b0