// File: /workspace/github_cpp_makefile_star2_O2/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, 0x20(%rsp)
movq %rcx, 0x28(%rsp)
movq %rdx, %r13
movq %rsi, 0x18(%rsp)
movl $0x1, (%rdx)
movq %rdi, 0x30(%rsp)
leal -0x2(%rdi), %r12d
pushq $0x1
popq %r15
movl $0x0, 0x14(%rsp)
leaq 0x58(%rsp), %rbp
leaq 0x78(%rsp), %r14
cmpl %r12d, %r15d
jge 0x672d
movslq %r15d, %rbx
movq 0x18(%rsp), %rax
movq (%rax,%rbx,8), %rsi
movq %rbp, %rdi
leaq 0xc(%rsp), %rdx
callq 0x61f6
movq %rbp, %rdi
leaq 0x12aec(%rip), %rsi     # 0x19171
callq 0x6cbb
testb %al, %al
jne 0x66a1
movq %rbp, %rdi
leaq 0x12adc(%rip), %rsi     # 0x19174
callq 0x6cbb
testb %al, %al
je 0x671d
andl $0x0, 0xc(%rsp)
movq 0x18(%rsp), %rax
movq 0x8(%rax,%rbx,8), %rsi
movq %r14, %rdi
leaq 0x13(%rsp), %rdx
callq 0x61f6
movq %r14, %rdi
leaq 0xc(%rsp), %rsi
callq 0x656f
incl %r15d
movl %eax, (%r13)
movq %r14, %rdi
callq 0x3100
cmpl %r12d, %r15d
jge 0x66fd
cmpl $0x0, 0xc(%rsp)
jne 0x66fd
movl (%r13), %eax
cmpl $0x64, %eax
pushq $0x64
popq %rcx
cmovgel %ecx, %eax
cmpl $0x2, %eax
pushq $0x1
popq %rcx
cmovll %ecx, %eax
jmp 0x6719
movq 0x238bc(%rip), %rdi     # 0x29fc0
leaq 0x12a73(%rip), %rsi     # 0x1917e
callq 0x32a0
pushq $0x1
popq %rcx
movl %ecx, %eax
movl %ecx, 0x14(%rsp)
movl %eax, (%r13)
movq %rbp, %rdi
callq 0x3100
incl %r15d
jmp 0x6659
movq 0x30(%rsp), %rbx
cmpl $0x3, %ebx
pushq $0x1
popq %rbp
cmovgel 0x14(%rsp), %ebp
testl %ebp, %ebp
je 0x67c0
movq 0x23878(%rip), %rdi     # 0x29fc0
leaq 0x12a50(%rip), %rsi     # 0x1919f
callq 0x32a0
movq 0x18(%rsp), %rcx
movq (%rcx), %rsi
movq %rax, %rdi
callq 0x32a0
leaq 0x12a45(%rip), %rsi     # 0x191b0
movq %rax, %rdi
callq 0x32a0
leaq 0x12a55(%rip), %rsi     # 0x191cf
movq %rax, %rdi
callq 0x32a0
leaq 0x12a93(%rip), %rsi     # 0x1921c
movq %rax, %rdi
callq 0x32a0
leaq 0x12ad8(%rip), %rsi     # 0x19270
movq %rax, %rdi
callq 0x32a0
leaq 0x12aed(%rip), %rsi     # 0x19294
movq %rax, %rdi
callq 0x32a0
leaq 0x12aed(%rip), %rsi     # 0x192a3
movq %rax, %rdi
callq 0x32a0
jmp 0x6820
movslq %r12d, %rax
movq 0x18(%rsp), %r14
movq (%r14,%rax,8), %rsi
movq 0x28(%rsp), %rdi
callq 0x34e0
movslq %ebx, %rax
movq -0x8(%r14,%rax,8), %rsi
leaq 0x38(%rsp), %rdi
leaq 0xc(%rsp), %rdx
callq 0x61f6
leaq 0x58(%rsp), %rdi
leaq 0x38(%rsp), %rsi
callq 0x65a0
leaq 0x58(%rsp), %r14
movq 0x20(%rsp), %rdi
movq %r14, %rsi
callq 0x3310
movq %r14, %rdi
callq 0x3100
leaq 0x38(%rsp), %rdi
callq 0x3100
movl %ebp, %eax
addq $0x98, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
leaq 0x38(%rsp), %rdi
jmp 0x6859
jmp 0x6860
jmp 0x6842
movq %rax, %rbx
jmp 0x6854
movq %rax, %rbx
leaq 0x78(%rsp), %rdi
callq 0x3100
leaq 0x58(%rsp), %rdi
callq 0x3100
jmp 0x6863
movq %rax, %rbx
movq %rbx, %rdi
callq 0x3490