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

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x68, %rsp
movl %esi, %ebp
movq %rdi, 0x8(%rsp)
movl $0x10, %edi
callq 0x3320
movq %rax, %r15
movq %rax, %rbx
xorps %xmm0, %xmm0
movups %xmm0, (%rax)
movl $0x10, %edi
callq 0x3320
movq %rax, %r14
movq %rax, 0x20(%rsp)
addq $0x10, %rax
movq %rax, 0x30(%rsp)
xorps %xmm0, %xmm0
movups %xmm0, (%r14)
movq %rax, 0x28(%rsp)
testl %ebp, %ebp
jle 0x1b118
cmpl $0x1, %ebp
je 0x1b166
addq $0x10, %r15
cmpl $0x2, %ebp
jne 0x1b1b0
movq 0x8(%rsp), %r13
movq %rbx, (%r13)
movq %r15, 0x8(%r13)
movl $0x10, %r12d
xorl %ebx, %ebx
jmp 0x1b19e
xorps %xmm0, %xmm0
callq 0x3290
movsd %xmm0, 0x10(%rsp)
xorps %xmm0, %xmm0
movq 0x8(%rsp), %r13
movups %xmm0, (%r13)
movq $0x0, 0x10(%r13)
movl $0x8, %r12d
movl $0x8, %edi
callq 0x3320
movq %rax, (%r13)
movq %rax, %r15
addq $0x8, %r15
movq %r15, 0x10(%r13)
movsd 0x10(%rsp), %xmm0
movsd %xmm0, (%rax)
jmp 0x1b19e
movq 0x8(%rsp), %r13
movups %xmm0, (%r13)
movq $0x0, 0x10(%r13)
movl $0x8, %r12d
movl $0x8, %edi
callq 0x3320
movq %rax, (%r13)
movq %rax, %r15
addq $0x8, %r15
movq %r15, 0x10(%r13)
movq $0x0, (%rax)
movq %r15, (%r13,%r12)
movq %r14, %rdi
callq 0x3310
jmp 0x1b2d0
movl %ebp, 0x1c(%rsp)
movl $0x2, %r12d
leaq 0x20(%rsp), %rbp
movq %rbx, %r14
subq %rbx, %r15
shrq $0x3, %r15
cmpl $0x2, %r15d
jl 0x1b22c
andl $0x7fffffff, %r15d      # imm = 0x7FFFFFFF
movl $0x1, %ebx
movsd -0x8(%r14,%rbx,8), %xmm0
movsd %xmm0, 0x10(%rsp)
movsd (%r14,%rbx,8), %xmm0
movsd %xmm0, 0x60(%rsp)
leaq 0x1(%rbx), %r13
xorps %xmm0, %xmm0
cvtsi2sd %r13d, %xmm0
callq 0x3290
movsd 0x60(%rsp), %xmm1
addsd %xmm0, %xmm1
movsd 0x10(%rsp), %xmm0
callq 0x1a75d
movq 0x20(%rsp), %rax
movsd %xmm0, (%rax,%rbx,8)
movq %r13, %rbx
cmpq %r13, %r15
jne 0x1b1db
movq $0x0, 0x40(%rsp)
movq 0x28(%rsp), %rsi
cmpq 0x30(%rsp), %rsi
je 0x1b258
movq $0x0, (%rsi)
addq $0x8, %rsi
movq %rsi, 0x28(%rsp)
leaq 0x40(%rsp), %rbx
jmp 0x1b268
movq %rbp, %rdi
leaq 0x40(%rsp), %rbx
movq %rbx, %rdx
callq 0x1d05a
movq %rbx, %rdi
movq %rbp, %rsi
callq 0x5d20
movq 0x40(%rsp), %rbx
movq 0x48(%rsp), %r15
xorps %xmm0, %xmm0
movaps %xmm0, 0x40(%rsp)
movq $0x0, 0x50(%rsp)
testq %r14, %r14
je 0x1b2aa
movq %r14, %rdi
callq 0x3310
movq 0x40(%rsp), %rdi
testq %rdi, %rdi
je 0x1b2aa
callq 0x3310
incl %r12d
cmpl 0x1c(%rsp), %r12d
jne 0x1b1bf
movq 0x30(%rsp), %rax
movaps 0x20(%rsp), %xmm0
movq 0x8(%rsp), %r13
movups %xmm0, (%r13)
movq %rax, 0x10(%r13)
testq %rbx, %rbx
je 0x1b2dd
movq %rbx, %rdi
callq 0x3310
movq %r13, %rax
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x1b2f1
movq %rax, %r15
jmp 0x1b303
movq %rax, %r15
jmp 0x1b317
jmp 0x1b2fd
movq %rax, %r15
movq %r14, %rbx
movq 0x20(%rsp), %rdi
testq %rdi, %rdi
je 0x1b312
callq 0x3310
testq %rbx, %rbx
je 0x1b31f
movq %rbx, %rdi
callq 0x3310
movq %r15, %rdi
callq 0x3580