// File: Manca[P]algorithms2/./assignment3.hpp
// Function: assignment3::binaryTree()
std::vector<std::vector<double>> binaryTree()
    {
        std::vector<int> vec = { 1,2,3,4,5,6,7 };
        std::vector<double> w = { 0.05, 0.4, 0.08,0.04,0.1,0.1,0.23 };

        std::vector<std::vector<double>> A(7, std::vector<double>(7));
        for (size_t s = 0; s < vec.size(); s++)
        {
            for (size_t i = 0; i < vec.size() - s; i++)
            {
                for (size_t r = i; r <= i + s; r++)
                {
                    double currMin = 999999999;
                    for (size_t k = i; k <= i + s; k++)
                    {
                        double resLeft = 0;
                        if ((int)i >= int(r - 1))
                            resLeft = 0;
                        else
                            resLeft = A[i][r - 1];

                        double resRight = 0;
                        if ((r + 1) >= (i + s))
                            resRight = 0;
                        else
                            resRight = A[r + 1][i + s];

                        currMin = std::min(currMin, w[k] + resLeft + resRight);
                    }
                    A[i][i + s] = currMin;
                }
            }
        }
        return A;
    }

// Assembly:
subq $0x198, %rsp            # imm = 0x198
movq %rdi, 0x40(%rsp)
movq %rdi, %rax
movq %rax, 0x48(%rsp)
movq %rdi, 0x190(%rsp)
movups 0x27981(%rip), %xmm0    # 0x30044
movups %xmm0, 0x14c(%rsp)
movups 0x27966(%rip), %xmm0    # 0x30038
movaps %xmm0, 0x140(%rsp)
leaq 0x140(%rsp), %rax
movq %rax, 0x168(%rsp)
movq $0x7, 0x170(%rsp)
leaq 0x13f(%rsp), %rdi
movq %rdi, 0x50(%rsp)
callq 0x101e0
movq 0x50(%rsp), %rcx
movq 0x168(%rsp), %rsi
movq 0x170(%rsp), %rdx
leaq 0x178(%rsp), %rdi
callq 0x101f0
jmp 0x872c
leaq 0x13f(%rsp), %rdi
callq 0x10280
movabsq $0x3fcd70a3d70a3d71, %rax # imm = 0x3FCD70A3D70A3D71
movq %rax, 0xf0(%rsp)
movups 0x27926(%rip), %xmm0    # 0x30078
movaps %xmm0, 0xe0(%rsp)
movups 0x27907(%rip), %xmm0    # 0x30068
movaps %xmm0, 0xd0(%rsp)
movups 0x278e8(%rip), %xmm0    # 0x30058
movaps %xmm0, 0xc0(%rsp)
leaq 0xc0(%rsp), %rax
movq %rax, 0x100(%rsp)
movq $0x7, 0x108(%rsp)
leaq 0xbf(%rsp), %rdi
movq %rdi, 0x38(%rsp)
callq 0x119b0
movq 0x38(%rsp), %rcx
movq 0x100(%rsp), %rsi
movq 0x108(%rsp), %rdx
leaq 0x110(%rsp), %rdi
callq 0x119c0
jmp 0x87ca
leaq 0xbf(%rsp), %rdi
callq 0x11a50
movb $0x0, 0xbe(%rsp)
leaq 0x9f(%rsp), %rdi
movq %rdi, 0x30(%rsp)
callq 0x119b0
movq 0x30(%rsp), %rdx
leaq 0xa0(%rsp), %rdi
movl $0x7, %esi
callq 0x11a60
jmp 0x880a
leaq 0x9e(%rsp), %rdi
movq %rdi, 0x28(%rsp)
callq 0x11ae0
movq 0x40(%rsp), %rdi
movq 0x28(%rsp), %rcx
movl $0x7, %esi
leaq 0xa0(%rsp), %rdx
callq 0x11af0
jmp 0x883a
leaq 0x9e(%rsp), %rdi
callq 0x11b70
leaq 0xa0(%rsp), %rdi
callq 0x11b80
leaq 0x9f(%rsp), %rdi
callq 0x11a50
movq $0x0, 0x90(%rsp)
movq 0x90(%rsp), %rax
movq %rax, 0x20(%rsp)
leaq 0x178(%rsp), %rdi
callq 0x102a0
movq %rax, %rcx
movq 0x20(%rsp), %rax
cmpq %rcx, %rax
jae 0x8bcd
movq $0x0, 0x88(%rsp)
movq 0x88(%rsp), %rax
movq %rax, 0x18(%rsp)
leaq 0x178(%rsp), %rdi
callq 0x102a0
movq %rax, %rcx
movq 0x18(%rsp), %rax
subq 0x90(%rsp), %rcx
cmpq %rcx, %rax
jae 0x8bb2
movq 0x88(%rsp), %rax
movq %rax, 0x80(%rsp)
movq 0x80(%rsp), %rax
movq 0x88(%rsp), %rcx
addq 0x90(%rsp), %rcx
cmpq %rcx, %rax
ja 0x8b97
movsd 0x276f8(%rip), %xmm0    # 0x30008
movsd %xmm0, 0x78(%rsp)
movq 0x88(%rsp), %rax
movq %rax, 0x70(%rsp)
movq 0x70(%rsp), %rax
movq 0x88(%rsp), %rcx
addq 0x90(%rsp), %rcx
cmpq %rcx, %rax
ja 0x8b3e
xorps %xmm0, %xmm0
movsd %xmm0, 0x68(%rsp)
movq 0x88(%rsp), %rax
movq 0x80(%rsp), %rcx
subq $0x1, %rcx
cmpl %ecx, %eax
jl 0x8a16
xorps %xmm0, %xmm0
movsd %xmm0, 0x68(%rsp)
jmp 0x8a46
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x130(%rsp)
movl %eax, 0x12c(%rsp)
leaq 0x13f(%rsp), %rdi
callq 0x10280
jmp 0x8c2a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x130(%rsp)
movl %eax, 0x12c(%rsp)
leaq 0xbf(%rsp), %rdi
callq 0x11a50
jmp 0x8c1d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x130(%rsp)
movl %eax, 0x12c(%rsp)
jmp 0x8a04
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x130(%rsp)
movl %eax, 0x12c(%rsp)
leaq 0x9e(%rsp), %rdi
callq 0x11b70
leaq 0xa0(%rsp), %rdi
callq 0x11b80
leaq 0x9f(%rsp), %rdi
callq 0x11a50
jmp 0x8c10
movq 0x40(%rsp), %rdi
movq 0x88(%rsp), %rsi
callq 0x11be0
movq %rax, %rdi
movq 0x80(%rsp), %rsi
subq $0x1, %rsi
callq 0x11c00
movsd (%rax), %xmm0
movsd %xmm0, 0x68(%rsp)
xorps %xmm0, %xmm0
movsd %xmm0, 0x60(%rsp)
movq 0x80(%rsp), %rax
addq $0x1, %rax
movq 0x88(%rsp), %rcx
addq 0x90(%rsp), %rcx
cmpq %rcx, %rax
jb 0x8a7b
xorps %xmm0, %xmm0
movsd %xmm0, 0x60(%rsp)
jmp 0x8ab3
movq 0x40(%rsp), %rdi
movq 0x80(%rsp), %rsi
addq $0x1, %rsi
callq 0x11be0
movq %rax, %rdi
movq 0x88(%rsp), %rsi
addq 0x90(%rsp), %rsi
callq 0x11c00
movsd (%rax), %xmm0
movsd %xmm0, 0x60(%rsp)
movq 0x70(%rsp), %rsi
leaq 0x110(%rsp), %rdi
callq 0x11c00
movsd (%rax), %xmm0
movsd 0x68(%rsp), %xmm1
addsd %xmm1, %xmm0
movsd 0x60(%rsp), %xmm1
addsd %xmm1, %xmm0
movsd %xmm0, 0x58(%rsp)
leaq 0x78(%rsp), %rdi
leaq 0x58(%rsp), %rsi
callq 0x11c20
movq %rax, 0x10(%rsp)
jmp 0x8af9
movq 0x10(%rsp), %rax
movsd (%rax), %xmm0
movsd %xmm0, 0x78(%rsp)
movq 0x70(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x70(%rsp)
jmp 0x8923
movq 0x40(%rsp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x130(%rsp)
movl %eax, 0x12c(%rsp)
callq 0x11c60
jmp 0x8c10
movq 0x40(%rsp), %rdi
movsd 0x78(%rsp), %xmm0
movsd %xmm0, 0x8(%rsp)
movq 0x88(%rsp), %rsi
callq 0x11be0
movq %rax, %rdi
movq 0x88(%rsp), %rsi
addq 0x90(%rsp), %rsi
callq 0x11c00
movsd 0x8(%rsp), %xmm0
movsd %xmm0, (%rax)
movq 0x80(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x80(%rsp)
jmp 0x88e7
jmp 0x8b99
movq 0x88(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x88(%rsp)
jmp 0x88a4
jmp 0x8bb4
movq 0x90(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x90(%rsp)
jmp 0x886d
movb $0x1, 0xbe(%rsp)
testb $0x1, 0xbe(%rsp)
jne 0x8be9
movq 0x40(%rsp), %rdi
callq 0x11c60
leaq 0x110(%rsp), %rdi
callq 0x11b80
leaq 0x178(%rsp), %rdi
callq 0x107c0
movq 0x48(%rsp), %rax
addq $0x198, %rsp            # imm = 0x198
retq
leaq 0x110(%rsp), %rdi
callq 0x11b80
leaq 0x178(%rsp), %rdi
callq 0x107c0
movq 0x130(%rsp), %rdi
callq 0x3460
nopw (%rax,%rax)