// File: 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:
subq $0xd8, %rsp
movq %rdi, 0x30(%rsp)
movq %rdi, %rax
movq %rax, 0x38(%rsp)
movq %rdi, 0xd0(%rsp)
movl %esi, 0xcc(%rsp)
movl $0x1, 0xac(%rsp)
leaq 0xab(%rsp), %rdi
movq %rdi, 0x40(%rsp)
callq 0xc5e0
movq 0x40(%rsp), %rcx
leaq 0xb0(%rsp), %rdi
movl $0x2, %esi
leaq 0xac(%rsp), %rdx
callq 0xc5f0
jmp 0x346c1
leaq 0xab(%rsp), %rdi
callq 0xc670
leaq 0x7f(%rsp), %rdi
movq %rdi, 0x28(%rsp)
callq 0xc5e0
movq 0x28(%rsp), %rdx
leaq 0x80(%rsp), %rdi
movl $0x2, %esi
callq 0xc7b0
jmp 0x346f6
leaq 0x7f(%rsp), %rdi
callq 0xc670
cmpl $0x0, 0xcc(%rsp)
jg 0x347b6
leaq 0x7e(%rsp), %rdi
movq %rdi, 0x20(%rsp)
callq 0xc5e0
movq 0x30(%rsp), %rdi
movq 0x20(%rsp), %rdx
movl $0x1, %esi
callq 0xc7b0
jmp 0x34733
leaq 0x7e(%rsp), %rdi
callq 0xc670
movl $0x1, 0x78(%rsp)
jmp 0x349c2
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xa0(%rsp)
movl %eax, 0x9c(%rsp)
leaq 0xab(%rsp), %rdi
callq 0xc670
jmp 0x34a03
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xa0(%rsp)
movl %eax, 0x9c(%rsp)
leaq 0x7f(%rsp), %rdi
callq 0xc670
jmp 0x349f6
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xa0(%rsp)
movl %eax, 0x9c(%rsp)
leaq 0x7e(%rsp), %rdi
callq 0xc670
jmp 0x349e9
cmpl $0x1, 0xcc(%rsp)
jne 0x3482c
movl $0x1, 0x74(%rsp)
leaq 0x73(%rsp), %rdi
movq %rdi, 0x18(%rsp)
callq 0xc5e0
movq 0x30(%rsp), %rdi
movq 0x18(%rsp), %rcx
movl $0x1, %esi
leaq 0x74(%rsp), %rdx
callq 0xc5f0
jmp 0x347f2
leaq 0x73(%rsp), %rdi
callq 0xc670
movl $0x1, 0x78(%rsp)
jmp 0x349c2
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xa0(%rsp)
movl %eax, 0x9c(%rsp)
leaq 0x73(%rsp), %rdi
callq 0xc670
jmp 0x349e9
cmpl $0x2, 0xcc(%rsp)
jne 0x34855
movq 0x30(%rsp), %rdi
leaq 0xb0(%rsp), %rsi
callq 0x36ea0
movl $0x1, 0x78(%rsp)
jmp 0x349c2
jmp 0x34857
jmp 0x34859
movl $0x2, 0x6c(%rsp)
movl 0x6c(%rsp), %eax
cmpl 0xcc(%rsp), %eax
jge 0x349a8
leaq 0xb0(%rsp), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x8ba0
movl (%rax), %eax
imull 0x6c(%rsp), %eax
movl %eax, 0x14(%rsp)
leaq 0x80(%rsp), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x8ba0
movl 0x14(%rsp), %ecx
movl %ecx, (%rax)
movl $0x1, 0x68(%rsp)
movl 0x68(%rsp), %eax
movl %eax, 0x10(%rsp)
leaq 0xb0(%rsp), %rdi
callq 0xb030
movq %rax, %rcx
movl 0x10(%rsp), %eax
cmpl %ecx, %eax
jge 0x34936
movslq 0x68(%rsp), %rsi
leaq 0xb0(%rsp), %rdi
callq 0x8ba0
movl (%rax), %eax
imull 0x6c(%rsp), %eax
movl %eax, 0x8(%rsp)
movl 0x68(%rsp), %eax
subl $0x1, %eax
movslq %eax, %rsi
leaq 0xb0(%rsp), %rdi
callq 0x8ba0
movq %rax, %rcx
movl 0x8(%rsp), %eax
addl (%rcx), %eax
movl %eax, 0xc(%rsp)
movslq 0x68(%rsp), %rsi
leaq 0x80(%rsp), %rdi
callq 0x8ba0
movl 0xc(%rsp), %ecx
movl %ecx, (%rax)
movl 0x68(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x68(%rsp)
jmp 0x348ad
movl $0x1, 0x64(%rsp)
leaq 0x80(%rsp), %rdi
leaq 0x64(%rsp), %rsi
callq 0x36ed0
jmp 0x34952
leaq 0x48(%rsp), %rdi
leaq 0x80(%rsp), %rsi
callq 0xc8f0
jmp 0x34966
leaq 0xb0(%rsp), %rdi
leaq 0x48(%rsp), %rsi
callq 0xc6a0
leaq 0x48(%rsp), %rdi
callq 0xc6e0
movl 0x6c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x6c(%rsp)
jmp 0x34861
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xa0(%rsp)
movl %eax, 0x9c(%rsp)
jmp 0x349e9
movq 0x30(%rsp), %rdi
leaq 0x80(%rsp), %rsi
callq 0x36ea0
movl $0x1, 0x78(%rsp)
leaq 0x80(%rsp), %rdi
callq 0xc6e0
leaq 0xb0(%rsp), %rdi
callq 0xc6e0
movq 0x38(%rsp), %rax
addq $0xd8, %rsp
retq
leaq 0x80(%rsp), %rdi
callq 0xc6e0
leaq 0xb0(%rsp), %rdi
callq 0xc6e0
movq 0xa0(%rsp), %rdi
callq 0x4730