// File: /workspace/github_cpp_makefile_star2_O1/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 0x2477
movq 0x8(%rbx), %rdi
leaq 0xbf3(%rip), %rsi       # 0x3043
movl $0x3, %edx
callq 0x20b0
testl %eax, %eax
jne 0x2477
movq 0x18(%rbx), %rdi
leaq 0xbdd(%rip), %rsi       # 0x3046
movl $0x3, %edx
callq 0x20b0
testl %eax, %eax
je 0x2496
movq (%rbx), %rdi
callq 0x234c
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 0x265a
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 0x2170
cmpq %r12, (%r13)
je 0x25c1
movq %rax, %r14
movslq %r14d, %rax
cmpq %r14, %rax
jne 0x25cd
movl (%r15), %eax
cmpl $0x22, %eax
je 0x25cd
testl %eax, %eax
jne 0x24ff
movl %ebp, (%r15)
leaq 0x28(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x251a
movq 0x28(%rsp), %rsi
incq %rsi
callq 0x2150
movq 0x20(%rbx), %rbx
leaq 0x18(%rsp), %r15
movq %r15, %rdi
callq 0x21e0
movq %r15, %rdi
movq %rbx, %rsi
movl $0x10, %edx
callq 0x2050
xorl %edi, %edi
callq 0x2120
movl %eax, %edi
callq 0x2130
testl %r14d, %r14d
jle 0x257e
leaq 0x18(%rsp), %rbx
leaq 0xaef(%rip), %r15       # 0x3049
callq 0x2060
movq %rbx, %rdi
movl %eax, %esi
callq 0x21f0
movl $0x1, %edx
movq %rax, %rdi
movq %r15, %rsi
callq 0x2160
decl %r14d
jne 0x255a
leaq 0x18(%rsp), %rdi
callq 0x2180
movq 0x2a41(%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 0x2100
leaq 0x110(%rsp), %rdi
callq 0x2080
xorl %eax, %eax
jmp 0x2484
leaq 0xa83(%rip), %rdi       # 0x304b
callq 0x20c0
leaq 0xa77(%rip), %rdi       # 0x304b
callq 0x2190
movq %rdx, %r12
movq %rax, %r14
jmp 0x260d
jmp 0x2644
movq %rdx, %r12
movq %rax, %r14
cmpl $0x0, (%r15)
jne 0x25f2
movl %ebp, (%r15)
leaq 0x28(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x260d
movq 0x28(%rsp), %rsi
incq %rsi
callq 0x2150
cmpl $0x1, %r12d
jne 0x2651
movq %r14, %rdi
callq 0x2090
callq 0x23e8
movq (%rbx), %rdi
callq 0x234c
callq 0x21c0
jmp 0x247f
movq %rax, %r14
callq 0x21c0
jmp 0x2651
movq %rax, %rdi
callq 0x2697
movq %rax, %r14
leaq 0x18(%rsp), %rdi
callq 0x21a0
movq %r14, %rdi
callq 0x2200
nop