// File: /workspace/github_cpp_makefile_star2_O3/nicluo[P]sorting-numbers/generate.cpp
// Function: main
int main(int argc, char *argv[]) {
    /* Must provide -n and -o argument */
    if (argc != 5 || strncmp(argv[1], "-n", 3) != 0 || strncmp(argv[3], "-o", 3) != 0) {
        printUsage(argv[0]);
        return 1;
    }
    
    /* Parse n */
    int n = 10;
    
    try {
        int nArg = std::stoi(argv[2]);
        n = nArg;
    } catch (std::invalid_argument &e) {
        printInvalidArgument();
        printUsage(argv[0]);
        return 1;
    }
    
    /* Open output file */
    char* outputFilename = argv[4];
    std::ofstream out;
    out.open(outputFilename, std::ofstream::out);
    
    /* Seed random number generator with current time */
    std::srand(std::time(0));
    
    /* Print n random numbers */
    for (int i = 0; i < n; i++) {
        out << std::rand() << "\n";
    }
    
    /* Flush and close output file */
    out.close();
        
    return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x218, %rsp            # imm = 0x218
movq %rsi, %rbx
cmpl $0x5, %edi
jne 0x245f
movq 0x8(%rbx), %rax
cmpb $0x2d, (%rax)
jne 0x245f
cmpb $0x6e, 0x1(%rax)
jne 0x245f
cmpb $0x0, 0x2(%rax)
jne 0x245f
movq 0x18(%rbx), %rax
cmpb $0x2d, (%rax)
jne 0x245f
cmpb $0x6f, 0x1(%rax)
jne 0x245f
cmpb $0x0, 0x2(%rax)
je 0x247e
movq (%rbx), %rdi
callq 0x233c
movl $0x1, %eax
addq $0x218, %rsp            # imm = 0x218
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x10(%rbx), %rsi
leaq 0x18(%rsp), %rdi
leaq 0xf(%rsp), %rdx
callq 0x2642
movq 0x18(%rsp), %r12
callq 0x2040
movq %rax, %r15
movl (%rax), %ebp
movl $0x0, (%rax)
leaq 0x10(%rsp), %r13
movq %r12, %rdi
movq %r13, %rsi
movl $0xa, %edx
callq 0x2160
cmpq %r12, (%r13)
je 0x25a9
movq %rax, %r14
movslq %r14d, %rax
cmpq %r14, %rax
jne 0x25b5
movl (%r15), %eax
cmpl $0x22, %eax
je 0x25b5
testl %eax, %eax
jne 0x24e7
movl %ebp, (%r15)
leaq 0x28(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x2502
movq 0x28(%rsp), %rsi
incq %rsi
callq 0x2140
movq 0x20(%rbx), %rbx
leaq 0x18(%rsp), %r15
movq %r15, %rdi
callq 0x21d0
movq %r15, %rdi
movq %rbx, %rsi
movl $0x10, %edx
callq 0x2050
xorl %edi, %edi
callq 0x2110
movl %eax, %edi
callq 0x2120
testl %r14d, %r14d
jle 0x2566
leaq 0x18(%rsp), %rbx
leaq 0xb01(%rip), %r15       # 0x3043
callq 0x2060
movq %rbx, %rdi
movl %eax, %esi
callq 0x21e0
movl $0x1, %edx
movq %rax, %rdi
movq %r15, %rsi
callq 0x2150
decl %r14d
jne 0x2542
leaq 0x18(%rsp), %rdi
callq 0x2170
movq 0x2a59(%rip), %rax      # 0x4fd0
movq (%rax), %rcx
movq 0x18(%rax), %rax
leaq 0x20(%rsp), %rdi
movq %rcx, -0x8(%rdi)
movq -0x18(%rcx), %rcx
movq %rax, 0x18(%rsp,%rcx)
callq 0x20f0
leaq 0x110(%rsp), %rdi
callq 0x2080
xorl %eax, %eax
jmp 0x246c
leaq 0xa95(%rip), %rdi       # 0x3045
callq 0x20b0
leaq 0xa89(%rip), %rdi       # 0x3045
callq 0x2180
movq %rdx, %r12
movq %rax, %r14
jmp 0x25f5
jmp 0x262c
movq %rdx, %r12
movq %rax, %r14
cmpl $0x0, (%r15)
jne 0x25da
movl %ebp, (%r15)
leaq 0x28(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x25f5
movq 0x28(%rsp), %rsi
incq %rsi
callq 0x2140
cmpl $0x1, %r12d
jne 0x2639
movq %r14, %rdi
callq 0x2090
callq 0x23d8
movq (%rbx), %rdi
callq 0x233c
callq 0x21b0
jmp 0x2467
movq %rax, %r14
callq 0x21b0
jmp 0x2639
movq %rax, %rdi
callq 0x267f
movq %rax, %r14
leaq 0x18(%rsp), %rdi
callq 0x2190
movq %r14, %rdi
callq 0x21f0
nop