// File: /workspace/github_cpp_makefile_star2_O2/Wombozo[P]harmony/src/Chord.cpp
// Function: Chord::Chord(Note*, std::vector<Interval, std::allocator<Interval>>)
Chord::Chord(Note *n, std::vector<Interval> ints) : root(n), bass(n), inversion(0)
{
    if (ints.size() != 2 && ints.size() != 3)
        throw E_CHORD_UNKNOWN;
    t = new Triad(n, ints);
    if (ints.size() == 2)
    {
        name = t->getName();
        notes = t->notes;
        intervals = t->getIntervals();
    }
    else
    {
        std::string str;
        Interval int4 = ints.at(2);
        intervals = ints;
        notes = t->notes;
        if (!int4.getName().compare("minor seventh"))
        {
            notes.push_back(int4.getNextSorted(root));
            if (!t->getTypeName().compare(""))
            {
                // 7
                str = chords[0];
            }
            else if (!t->getTypeName().compare("m"))
            {
                // m7
                str = chords[3];
            }
            else if (!t->getTypeName().compare("dim"))
            {
                // m7b5
                str = chords[6];
            }
            else
                throw E_CHORD_UNKNOWN;
        }
        else if (!int4.getName().compare("major seventh"))
        {
            notes.push_back(int4.getNextSorted(root));
            if (!t->getTypeName().compare(""))
            {
                // maj7
                str = chords[1];
            }
            else if (!t->getTypeName().compare("m"))
            {
                // minmaj7
                str = chords[4];
            }
            else if (!t->getTypeName().compare("dim"))
            {
                // 7b5
                str = chords[7];
            }
            else
                throw E_CHORD_UNKNOWN;
        }
        else if (!int4.getName().compare("major sixth"))
        {
            notes.push_back(int4.getNextSorted(root));
            if (!t->getTypeName().compare("m"))
            {
                // m6
                str = chords[5];
            }
            else if (!t->getTypeName().compare(""))
            {
                // 6
                str = chords[2];
            }
            else
                throw E_CHORD_UNKNOWN;
        }
        else if (!int4.getName().compare("diminished seventh"))
        {
            notes.push_back(int4.getNextSorted(root));
            if (!t->getTypeName().compare("dim"))
            {
                //dim7
                str = chords[8];
            }
            else
                throw E_CHORD_UNKNOWN;
        }
        else
            throw E_CHORD_UNKNOWN;
        name = n->display() + str;
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xb8, %rsp
movq %rsi, (%rdi)
movq %rsi, 0x10(%rdi)
andl $0x0, 0x18(%rdi)
movq %rdx, %rbx
leaq 0x20(%rdi), %rax
movq %rax, -0x50(%rbp)
leaq 0x30(%rdi), %rax
movq %rax, 0x20(%rdi)
andq $0x0, 0x28(%rdi)
movb $0x0, 0x30(%rdi)
leaq 0x40(%rdi), %rax
movq %rax, -0x58(%rbp)
xorps %xmm0, %xmm0
movups %xmm0, 0x40(%rdi)
movups %xmm0, 0x50(%rdi)
movups %xmm0, 0x60(%rdi)
movq 0x8(%rdx), %rax
subq (%rdx), %rax
leaq 0x58(%rdi), %r15
pushq $0x28
popq %rcx
cqto
idivq %rcx
andq $-0x2, %rax
cmpq $0x2, %rax
jne 0x7a5d
movq %rsi, %r12
movq %rdi, %r13
movl $0x88, %edi
callq 0x31a0
movq %rax, %r14
leaq -0x98(%rbp), %rdi
movq %rbx, %rsi
callq 0x7ca8
leaq -0x98(%rbp), %rdx
movq %r14, %rdi
movq %r12, %rsi
callq 0x94bc
movq %r14, 0x8(%r13)
leaq -0x98(%rbp), %rdi
callq 0x7d02
movq 0x8(%rbx), %rax
subq (%rbx), %rax
cmpq $0x50, %rax
jne 0x7665
movq 0x8(%r13), %rsi
leaq -0x80(%rbp), %rdi
callq 0x9d1e
leaq -0x80(%rbp), %rbx
movq -0x50(%rbp), %rdi
movq %rbx, %rsi
callq 0x31c0
movq %rbx, %rdi
callq 0x30d0
movq 0x8(%r13), %rsi
addq $0x70, %rsi
movq %r15, %rdi
callq 0x7d2e
movq 0x8(%r13), %rsi
leaq -0x80(%rbp), %rdi
callq 0x9d4e
movq -0x58(%rbp), %rdi
movq %rbx, %rsi
callq 0x8222
movq %rbx, %rdi
callq 0x7d02
jmp 0x7a4b
leaq -0xa8(%rbp), %rax
movq %rax, -0x10(%rax)
andq $0x0, -0x8(%rax)
movb $0x0, (%rax)
pushq $0x2
popq %rsi
movq %rbx, %rdi
callq 0x7e02
leaq -0x80(%rbp), %rdi
movq %rax, %rsi
callq 0x7e20
movq -0x58(%rbp), %rdi
movq %rbx, %rsi
callq 0x7e40
movq 0x8(%r13), %rsi
addq $0x70, %rsi
movq %r15, %rdi
callq 0x7d2e
leaq -0x48(%rbp), %rdi
leaq -0x80(%rbp), %rsi
callq 0x6abe
leaq 0x4c07(%rip), %rsi      # 0xc2c6
leaq -0x48(%rbp), %rbx
movq %rbx, %rdi
callq 0x3080
movl %eax, %r14d
movq %rbx, %rdi
callq 0x30d0
testl %r14d, %r14d
je 0x77c7
leaq -0x48(%rbp), %rdi
leaq -0x80(%rbp), %rsi
callq 0x6abe
leaq 0x4be1(%rip), %rsi      # 0xc2d4
movq %rbx, %rdi
callq 0x3080
movl %eax, %r14d
movq %rbx, %rdi
callq 0x30d0
testl %r14d, %r14d
je 0x787f
leaq -0x48(%rbp), %rdi
leaq -0x80(%rbp), %rsi
callq 0x6abe
leaq 0x4b74(%rip), %rsi      # 0xc297
movq %rbx, %rdi
callq 0x3080
movl %eax, %r14d
movq %rbx, %rdi
callq 0x30d0
testl %r14d, %r14d
je 0x7937
leaq -0x48(%rbp), %rdi
leaq -0x80(%rbp), %rsi
callq 0x6abe
leaq 0x4b60(%rip), %rsi      # 0xc2b3
movq %rbx, %rdi
callq 0x3080
movl %eax, %r14d
movq %rbx, %rdi
callq 0x30d0
testl %r14d, %r14d
jne 0x7a7c
movq (%r13), %rsi
leaq -0x80(%rbp), %rdi
callq 0x6516
leaq -0x48(%rbp), %rsi
movq %rax, (%rsi)
movq %r15, %rdi
callq 0x8486
movq 0x8(%r13), %rsi
leaq -0x48(%rbp), %rdi
callq 0x9d74
leaq 0x4b51(%rip), %rsi      # 0xc2f0
movq %rbx, %rdi
callq 0x3080
movl %eax, %r14d
movq %rbx, %rdi
callq 0x30d0
testl %r14d, %r14d
jne 0x7a7c
leaq 0xac5e(%rip), %rsi      # 0x12420
jmp 0x79e3
movq (%r13), %rsi
leaq -0x80(%rbp), %rdi
callq 0x6516
leaq -0x48(%rbp), %rsi
movq %rax, (%rsi)
movq %r15, %rdi
callq 0x8486
movq 0x8(%r13), %rsi
leaq -0x48(%rbp), %rdi
callq 0x9d74
leaq 0x4d9e(%rip), %rsi      # 0xc595
movq %rbx, %rdi
callq 0x3080
movl %eax, %r14d
movq %rbx, %rdi
callq 0x30d0
testl %r14d, %r14d
je 0x79b8
movq 0x8(%r13), %rsi
leaq -0x48(%rbp), %rdi
callq 0x9d74
leaq 0x4acb(%rip), %rsi      # 0xc2f2
movq %rbx, %rdi
callq 0x3080
movl %eax, %r14d
movq %rbx, %rdi
callq 0x30d0
testl %r14d, %r14d
je 0x79c1
movq 0x8(%r13), %rsi
leaq -0x48(%rbp), %rdi
callq 0x9d74
leaq 0x4a99(%rip), %rsi      # 0xc2f0
movq %rbx, %rdi
callq 0x3080
movl %eax, %r14d
movq %rbx, %rdi
callq 0x30d0
testl %r14d, %r14d
jne 0x7a7c
leaq 0xab66(%rip), %rsi      # 0x123e0
jmp 0x79e3
movq (%r13), %rsi
leaq -0x80(%rbp), %rdi
callq 0x6516
leaq -0x48(%rbp), %rsi
movq %rax, (%rsi)
movq %r15, %rdi
callq 0x8486
movq 0x8(%r13), %rsi
leaq -0x48(%rbp), %rdi
callq 0x9d74
leaq 0x4ce6(%rip), %rsi      # 0xc595
movq %rbx, %rdi
callq 0x3080
movl %eax, %r14d
movq %rbx, %rdi
callq 0x30d0
testl %r14d, %r14d
je 0x79ca
movq 0x8(%r13), %rsi
leaq -0x48(%rbp), %rdi
callq 0x9d74
leaq 0x4a13(%rip), %rsi      # 0xc2f2
movq %rbx, %rdi
callq 0x3080
movl %eax, %r14d
movq %rbx, %rdi
callq 0x30d0
testl %r14d, %r14d
je 0x79d3
movq 0x8(%r13), %rsi
leaq -0x48(%rbp), %rdi
callq 0x9d74
leaq 0x49e1(%rip), %rsi      # 0xc2f0
movq %rbx, %rdi
callq 0x3080
movl %eax, %r14d
movq %rbx, %rdi
callq 0x30d0
testl %r14d, %r14d
jne 0x7a7c
leaq 0xaace(%rip), %rsi      # 0x12400
jmp 0x79e3
movq (%r13), %rsi
leaq -0x80(%rbp), %rdi
callq 0x6516
leaq -0x48(%rbp), %rsi
movq %rax, (%rsi)
movq %r15, %rdi
callq 0x8486
movq 0x8(%r13), %rsi
leaq -0x48(%rbp), %rdi
callq 0x9d74
leaq 0x498b(%rip), %rsi      # 0xc2f2
movq %rbx, %rdi
callq 0x3080
movl %eax, %r14d
movq %rbx, %rdi
callq 0x30d0
testl %r14d, %r14d
je 0x79dc
movq 0x8(%r13), %rsi
leaq -0x48(%rbp), %rdi
callq 0x9d74
leaq 0x4c02(%rip), %rsi      # 0xc595
movq %rbx, %rdi
callq 0x3080
movl %eax, %r14d
movq %rbx, %rdi
callq 0x30d0
testl %r14d, %r14d
jne 0x7a7c
leaq 0xa9aa(%rip), %rsi      # 0x12360
jmp 0x79e3
leaq 0xa961(%rip), %rsi      # 0x12320
jmp 0x79e3
leaq 0xa9b8(%rip), %rsi      # 0x12380
jmp 0x79e3
leaq 0xa96f(%rip), %rsi      # 0x12340
jmp 0x79e3
leaq 0xa9c6(%rip), %rsi      # 0x123a0
jmp 0x79e3
leaq 0xa9dd(%rip), %rsi      # 0x123c0
leaq -0xb8(%rbp), %rdi
callq 0x3110
movq (%r12), %rax
leaq -0xd8(%rbp), %rdi
movq %r12, %rsi
callq *(%rax)
leaq -0x48(%rbp), %rdi
leaq -0xd8(%rbp), %rsi
leaq -0xb8(%rbp), %rdx
callq 0x7f1e
movq -0x50(%rbp), %rdi
movq %rbx, %rsi
callq 0x31c0
movq %rbx, %rdi
callq 0x30d0
leaq -0xd8(%rbp), %rdi
callq 0x30d0
leaq -0x80(%rbp), %rdi
callq 0x6ab4
leaq -0xb8(%rbp), %rdi
callq 0x30d0
addq $0xb8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
pushq $0x4
popq %rdi
callq 0x30f0
movl $0x1, (%rax)
leaq 0x9e06(%rip), %rsi      # 0x11878
movq %rax, %rdi
xorl %edx, %edx
callq 0x3290
pushq $0x4
popq %rdi
callq 0x30f0
movl $0x1, (%rax)
leaq 0x9de7(%rip), %rsi      # 0x11878
movq %rax, %rdi
xorl %edx, %edx
callq 0x3290
jmp 0x7afc
jmp 0x7afc
jmp 0x7afc
jmp 0x7afc
jmp 0x7afc
jmp 0x7afc
jmp 0x7afc
jmp 0x7afc
jmp 0x7afc
jmp 0x7afc
jmp 0x7afc
jmp 0x7afc
jmp 0x7afc
jmp 0x7afc
jmp 0x7afc
jmp 0x7afc
movq %rax, %r12
leaq -0xd8(%rbp), %rdi
callq 0x30d0
jmp 0x7aff
jmp 0x7afc
jmp 0x7afc
jmp 0x7b16
jmp 0x7b16
movq %rax, %r12
jmp 0x7b08
movq %rax, %r12
leaq -0x98(%rbp), %rdi
callq 0x7d02
jmp 0x7aed
movq %rax, %r12
movl $0x88, %esi
movq %r14, %rdi
callq 0x31b0
jmp 0x7b19
movq %rax, %r12
leaq -0x80(%rbp), %rdi
callq 0x6ab4
leaq -0xb8(%rbp), %rdi
callq 0x30d0
jmp 0x7b19
movq %rax, %r12
movq %r15, %rdi
callq 0x4d7a
movq -0x58(%rbp), %rdi
callq 0x7d02
movq -0x50(%rbp), %rdi
callq 0x30d0
movq %r12, %rdi
callq 0x32b0
nop