// File: /workspace/github_cpp_makefile_star2_O1/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 $0x58, %rsp
movl %esi, %ebp
movq %rdi, %r14
movl $0x10, %edi
callq 0x3320
movq %rax, %r15
movq %rax, %rbx
xorps %xmm0, %xmm0
movups %xmm0, (%rax)
movaps %xmm0, (%rsp)
movq $0x0, 0x10(%rsp)
movl $0x10, %edi
callq 0x3320
movq %rax, (%rsp)
movq %rax, 0x8(%rsp)
movq %rax, %rcx
addq $0x10, %rcx
movq %rcx, 0x10(%rsp)
xorps %xmm0, %xmm0
movups %xmm0, (%rax)
movq %rcx, 0x8(%rsp)
testl %ebp, %ebp
jle 0x1b43c
cmpl $0x1, %ebp
je 0x1b481
addq $0x10, %r15
cmpl $0x2, %ebp
jne 0x1b4b9
movq %rbx, (%r14)
movq %r15, 0x8(%r14)
movq %r15, 0x10(%r14)
xorl %ebx, %ebx
jmp 0x1b5f9
xorps %xmm0, %xmm0
callq 0x3290
movsd %xmm0, 0x20(%rsp)
xorps %xmm0, %xmm0
movups %xmm0, (%r14)
movq $0x0, 0x10(%r14)
movl $0x8, %edi
callq 0x3320
movq %rax, (%r14)
movq %rax, 0x8(%r14)
movq %rax, %rcx
addq $0x8, %rcx
movq %rcx, 0x10(%r14)
movsd 0x20(%rsp), %xmm0
movsd %xmm0, (%rax)
jmp 0x1b4b0
movups %xmm0, (%r14)
movq $0x0, 0x10(%r14)
movl $0x8, %edi
callq 0x3320
movq %rax, (%r14)
movq %rax, 0x8(%r14)
movq %rax, %rcx
addq $0x8, %rcx
movq %rcx, 0x10(%r14)
movq $0x0, (%rax)
movq %rcx, 0x8(%r14)
jmp 0x1b5f9
movq %r14, 0x48(%rsp)
jle 0x1b5cd
movl %ebp, 0x2c(%rsp)
movl $0x2, %r12d
movq %rsp, %rbp
subq %rbx, %r15
shrq $0x3, %r15
cmpl $0x2, %r15d
jl 0x1b53c
andl $0x7fffffff, %r15d      # imm = 0x7FFFFFFF
movl $0x1, %r13d
movsd -0x8(%rbx,%r13,8), %xmm0
movsd %xmm0, 0x20(%rsp)
movsd (%rbx,%r13,8), %xmm0
movsd %xmm0, 0x50(%rsp)
leaq 0x1(%r13), %r14
xorps %xmm0, %xmm0
cvtsi2sd %r14d, %xmm0
callq 0x3290
movsd 0x50(%rsp), %xmm1
addsd %xmm0, %xmm1
movsd 0x20(%rsp), %xmm0
callq 0x1aa59
movq (%rsp), %rax
movsd %xmm0, (%rax,%r13,8)
movq %r14, %r13
cmpq %r14, %r15
jne 0x1b4eb
movq $0x0, 0x30(%rsp)
movq 0x8(%rsp), %rsi
cmpq 0x10(%rsp), %rsi
je 0x1b568
movq $0x0, (%rsi)
addq $0x8, %rsi
movq %rsi, 0x8(%rsp)
leaq 0x30(%rsp), %r15
jmp 0x1b578
movq %rbp, %rdi
leaq 0x30(%rsp), %r15
movq %r15, %rdx
callq 0x1d3b0
movq %r15, %rdi
movq %rbp, %rsi
callq 0x5da0
movq 0x30(%rsp), %r13
movq 0x38(%rsp), %r15
xorps %xmm0, %xmm0
movaps %xmm0, 0x30(%rsp)
movq $0x0, 0x40(%rsp)
testq %rbx, %rbx
je 0x1b5ab
movq %rbx, %rdi
callq 0x3310
movq 0x30(%rsp), %rdi
testq %rdi, %rdi
je 0x1b5ba
callq 0x3310
incl %r12d
movq %r13, %rbx
cmpl 0x2c(%rsp), %r12d
jne 0x1b4d1
jmp 0x1b5d0
movq %rbx, %r13
movaps (%rsp), %xmm0
movq 0x48(%rsp), %r14
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 0x1b607
callq 0x3310
testq %rbx, %rbx
je 0x1b614
movq %rbx, %rdi
callq 0x3310
movq %r14, %rax
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x1b631
jmp 0x1b631
movq %rax, %r14
jmp 0x1b642
jmp 0x1b631
movq %rax, %r14
movq (%rsp), %rdi
testq %rdi, %rdi
je 0x1b642
callq 0x3310
testq %rbx, %rbx
je 0x1b64f
movq %rbx, %rdi
callq 0x3310
movq %r14, %rdi
callq 0x3580