// File: /workspace/github_cpp_makefile_star2_O1/bobverity[P]MavericK/misc.cpp
// Function: StirlingFirst(int)
vector<int> StirlingFirst(int n) {
    
    vector<int> oldVec(2,1);
    vector<int> newVec(2);
    
    // simple answer if n<=0, n==1 or n==2
    if (n<=0)
        return(vector<int>(1));
    else if (n==1)
        return(vector<int>(1,1));
    else if (n==2)
        return(oldVec);
    
    // otherwise calculate by looping
    for (int i=2; i<n; i++) {
        newVec[0] = oldVec[0]*i;
        for (int j=1; j<int(oldVec.size()); j++) {
            newVec[j] = oldVec[j]*i + oldVec[j-1];
        }
        newVec.push_back(1);
        oldVec = vector<int>(newVec);
    }
    
    return(newVec);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movl %esi, %ebp
movq %rdi, %r14
movl $0x8, %edi
callq 0x3320
movq %rax, %r15
movq %rax, %rbx
movabsq $0x100000001, %rax      # imm = 0x100000001
movq %rax, (%r15)
xorps %xmm0, %xmm0
movaps %xmm0, (%rsp)
movq $0x0, 0x10(%rsp)
movl $0x8, %edi
callq 0x3320
movq %rax, (%rsp)
movq %rax, 0x8(%rsp)
movq %rax, %rcx
addq $0x8, %rcx
movq %rcx, 0x10(%rsp)
movq $0x0, (%rax)
movq %rcx, 0x8(%rsp)
testl %ebp, %ebp
jle 0x1b1f7
cmpl $0x1, %ebp
je 0x1b22a
addq $0x8, %r15
cmpl $0x2, %ebp
jne 0x1b264
movq %rbx, (%r14)
movq %r15, 0x8(%r14)
movq %r15, 0x10(%r14)
xorl %ebx, %ebx
jmp 0x1b35b
xorps %xmm0, %xmm0
movups %xmm0, (%r14)
movq $0x0, 0x10(%r14)
movl $0x4, %edi
callq 0x3320
movq %rax, (%r14)
movq %rax, 0x8(%r14)
movq %rax, %rcx
addq $0x4, %rcx
movq %rcx, 0x10(%r14)
movl $0x0, (%rax)
jmp 0x1b25b
xorps %xmm0, %xmm0
movups %xmm0, (%r14)
movq $0x0, 0x10(%r14)
movl $0x4, %edi
callq 0x3320
movq %rax, (%r14)
movq %rax, 0x8(%r14)
movq %rax, %rcx
addq $0x4, %rcx
movq %rcx, 0x10(%r14)
movl $0x1, (%rax)
movq %rcx, 0x8(%r14)
jmp 0x1b35b
jle 0x1b334
movl $0x2, %r12d
movl (%rbx), %ecx
imull %r12d, %ecx
movq (%rsp), %rax
movl %ecx, (%rax)
subq %rbx, %r15
shrq $0x2, %r15
cmpl $0x2, %r15d
jl 0x1b2ab
andl $0x7fffffff, %r15d      # imm = 0x7FFFFFFF
movl $0x1, %ecx
movl (%rbx,%rcx,4), %edx
imull %r12d, %edx
addl -0x4(%rbx,%rcx,4), %edx
movl %edx, (%rax,%rcx,4)
incq %rcx
cmpq %rcx, %r15
jne 0x1b295
movl $0x1, 0x20(%rsp)
movq 0x8(%rsp), %rsi
cmpq 0x10(%rsp), %rsi
leaq 0x20(%rsp), %r13
je 0x1b2d8
movl $0x1, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x8(%rsp)
movq %rsp, %r15
jmp 0x1b2e6
movq %rsp, %r15
movq %r15, %rdi
movq %r13, %rdx
callq 0x1d2dc
movq %r13, %rdi
movq %r15, %rsi
callq 0x6b8e
movq 0x20(%rsp), %r13
movq 0x28(%rsp), %r15
xorps %xmm0, %xmm0
movaps %xmm0, 0x20(%rsp)
movq $0x0, 0x30(%rsp)
movq %rbx, %rdi
callq 0x3310
movq 0x20(%rsp), %rdi
testq %rdi, %rdi
je 0x1b323
callq 0x3310
incl %r12d
movq %r13, %rbx
cmpl %ebp, %r12d
jne 0x1b270
jmp 0x1b337
movq %rbx, %r13
movaps (%rsp), %xmm0
movups %xmm0, (%r14)
movq 0x10(%rsp), %rax
movq %rax, 0x10(%r14)
xorps %xmm0, %xmm0
movaps %xmm0, (%rsp)
movq $0x0, 0x10(%rsp)
movq %r13, %rbx
movq (%rsp), %rdi
testq %rdi, %rdi
je 0x1b369
callq 0x3310
testq %rbx, %rbx
je 0x1b376
movq %rbx, %rdi
callq 0x3310
movq %r14, %rax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x1b393
jmp 0x1b393
movq %rax, %r14
jmp 0x1b3a4
jmp 0x1b393
movq %rax, %r14
movq (%rsp), %rdi
testq %rdi, %rdi
je 0x1b3a4
callq 0x3310
movq %rbx, %rdi
callq 0x3310
movq %r14, %rdi
callq 0x3580