// File: /workspace/github_cpp_makefile_star2_O3/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 $0xc8, %rsp
movq %rdi, %r14
movq %rsi, (%rdi)
movq %rsi, 0x10(%rdi)
movl $0x0, 0x18(%rdi)
leaq 0x20(%rdi), %rax
movq %rax, -0x58(%rbp)
leaq 0x30(%rdi), %rax
movq %rax, -0xa8(%rbp)
movq %rax, 0x20(%rdi)
movq $0x0, 0x28(%rdi)
movb $0x0, 0x30(%rdi)
leaq 0x40(%rdi), %rax
movq %rax, -0xb0(%rbp)
leaq 0x58(%rdi), %rax
movq %rax, -0x50(%rbp)
xorps %xmm0, %xmm0
movups %xmm0, 0x40(%rdi)
movups %xmm0, 0x50(%rdi)
movups %xmm0, 0x60(%rdi)
movq 0x8(%rdx), %rax
subq (%rdx), %rax
sarq $0x3, %rax
movabsq $-0x3333333333333333, %r12 # imm = 0xCCCCCCCCCCCCCCCD
imulq %r12, %rax
andq $-0x2, %rax
cmpq $0x2, %rax
jne 0x8d8c
movq %rdx, %r15
movq %rsi, %r13
movl $0x88, %edi
callq 0x3180
movq %rax, %rbx
leaq -0xe8(%rbp), %rdi
movq %r15, %rsi
callq 0x907c
leaq -0xe8(%rbp), %rdx
movq %rbx, %rdi
movq %r13, %rsi
callq 0xaa9a
movq %rbx, 0x8(%r14)
leaq -0xe8(%rbp), %rdi
callq 0x9120
movq (%r15), %rbx
movq 0x8(%r15), %rdx
subq %rbx, %rdx
cmpq $0x50, %rdx
jne 0x886d
movq 0x8(%r14), %rsi
leaq -0x80(%rbp), %rdi
callq 0xb854
leaq -0x80(%rbp), %rbx
movq -0x58(%rbp), %rdi
movq %rbx, %rsi
callq 0x31d0
movq (%rbx), %rdi
leaq -0x70(%rbp), %rax
cmpq %rax, %rdi
je 0x87fa
movq -0x70(%rbp), %rsi
incq %rsi
callq 0x3190
movq 0x8(%r14), %rsi
addq $0x70, %rsi
movq -0x50(%rbp), %rdi
callq 0x9176
movq 0x8(%r14), %rsi
leaq -0xa0(%rbp), %rdi
callq 0xb896
movups 0x40(%r14), %xmm0
movq 0x50(%r14), %rax
leaq -0xa0(%rbp), %rbx
movq (%rbx), %rcx
movq %rcx, 0x40(%r14)
movq 0x8(%rbx), %rcx
movq %rcx, 0x48(%r14)
movq 0x10(%rbx), %rcx
movq %rcx, 0x50(%r14)
leaq -0x80(%rbp), %rdi
movups %xmm0, (%rdi)
movq %rax, 0x10(%rdi)
xorps %xmm0, %xmm0
movaps %xmm0, (%rbx)
movq $0x0, 0x10(%rbx)
callq 0x9120
movq %rbx, %rdi
callq 0x9120
jmp 0x8d7a
sarq $0x3, %rdx
imulq %r12, %rdx
leaq -0x90(%rbp), %rax
movq %rax, -0x10(%rax)
movq $0x0, -0x8(%rax)
movb $0x0, (%rax)
cmpq $0x2, %rdx
jbe 0x8dad
leaq -0x70(%rbp), %rax
movq %rax, -0x10(%rax)
movq 0x50(%rbx), %rsi
movq 0x58(%rbx), %rdx
addq %rsi, %rdx
leaq -0x80(%rbp), %rdi
callq 0x663a
movq 0x70(%rbx), %rax
movq %rax, -0x60(%rbp)
movq -0xb0(%rbp), %rdi
movq %r15, %rsi
callq 0x9264
movq 0x8(%r14), %rsi
addq $0x70, %rsi
movq -0x50(%rbp), %rdi
callq 0x9176
leaq -0x48(%rbp), %rdi
leaq -0x80(%rbp), %rsi
callq 0x782c
leaq 0x59af(%rip), %rsi      # 0xe29c
leaq -0x48(%rbp), %r15
movq %r15, %rdi
callq 0x3070
movl %eax, %ebx
movq (%r15), %rdi
leaq -0x38(%rbp), %r12
cmpq %r12, %rdi
je 0x8913
movq -0x38(%rbp), %rsi
incq %rsi
callq 0x3190
testl %ebx, %ebx
je 0x8a2b
leaq -0x48(%rbp), %rdi
leaq -0x80(%rbp), %rsi
callq 0x782c
leaq 0x597b(%rip), %rsi      # 0xe2aa
movq %r15, %rdi
callq 0x3070
movl %eax, %ebx
movq (%r15), %rdi
cmpq %r12, %rdi
je 0x894d
movq -0x38(%rbp), %rsi
incq %rsi
callq 0x3190
testl %ebx, %ebx
je 0x8b01
leaq -0x48(%rbp), %rdi
leaq -0x80(%rbp), %rsi
callq 0x782c
leaq 0x5904(%rip), %rsi      # 0xe26d
movq %r15, %rdi
callq 0x3070
movl %eax, %ebx
movq (%r15), %rdi
cmpq %r12, %rdi
je 0x8987
movq -0x38(%rbp), %rsi
incq %rsi
callq 0x3190
testl %ebx, %ebx
je 0x8bd7
leaq -0x48(%rbp), %rdi
leaq -0x80(%rbp), %rsi
callq 0x782c
leaq 0x58e6(%rip), %rsi      # 0xe289
movq %r15, %rdi
callq 0x3070
movl %eax, %ebx
movq (%r15), %rdi
cmpq %r12, %rdi
je 0x89c1
movq -0x38(%rbp), %rsi
incq %rsi
callq 0x3190
testl %ebx, %ebx
jne 0x8dc0
movq (%r14), %rsi
leaq -0x80(%rbp), %rdi
callq 0x71f2
leaq -0x48(%rbp), %rsi
movq %rax, (%rsi)
movq -0x50(%rbp), %rdi
callq 0x96e6
movq 0x8(%r14), %rsi
leaq -0x48(%rbp), %rdi
callq 0xb8bc
leaq 0x58cd(%rip), %rsi      # 0xe2c6
movq %r15, %rdi
callq 0x3070
movl %eax, %ebx
movq (%r15), %rdi
cmpq %r12, %rdi
je 0x8a17
movq -0x38(%rbp), %rsi
incq %rsi
callq 0x3190
testl %ebx, %ebx
jne 0x8dc0
leaq 0xa9fa(%rip), %rsi      # 0x13420
jmp 0x8c97
movq (%r14), %rsi
leaq -0x80(%rbp), %rdi
callq 0x71f2
leaq -0x48(%rbp), %rsi
movq %rax, (%rsi)
movq -0x50(%rbp), %rdi
callq 0x96e6
movq 0x8(%r14), %rsi
leaq -0x48(%rbp), %rdi
callq 0xb8bc
leaq 0x5b4a(%rip), %rsi      # 0xe5a5
movq %r15, %rdi
callq 0x3070
movl %eax, %ebx
movq (%r15), %rdi
cmpq %r12, %rdi
je 0x8a79
movq -0x38(%rbp), %rsi
incq %rsi
callq 0x3190
testl %ebx, %ebx
je 0x8c6c
movq 0x8(%r14), %rsi
leaq -0x48(%rbp), %rdi
callq 0xb8bc
leaq 0x5833(%rip), %rsi      # 0xe2c8
movq %r15, %rdi
callq 0x3070
movl %eax, %ebx
movq (%r15), %rdi
cmpq %r12, %rdi
je 0x8ab3
movq -0x38(%rbp), %rsi
incq %rsi
callq 0x3190
testl %ebx, %ebx
je 0x8c75
movq 0x8(%r14), %rsi
leaq -0x48(%rbp), %rdi
callq 0xb8bc
leaq 0x57f7(%rip), %rsi      # 0xe2c6
movq %r15, %rdi
callq 0x3070
movl %eax, %ebx
movq (%r15), %rdi
cmpq %r12, %rdi
je 0x8aed
movq -0x38(%rbp), %rsi
incq %rsi
callq 0x3190
testl %ebx, %ebx
jne 0x8dc0
leaq 0xa8e4(%rip), %rsi      # 0x133e0
jmp 0x8c97
movq (%r14), %rsi
leaq -0x80(%rbp), %rdi
callq 0x71f2
leaq -0x48(%rbp), %rsi
movq %rax, (%rsi)
movq -0x50(%rbp), %rdi
callq 0x96e6
movq 0x8(%r14), %rsi
leaq -0x48(%rbp), %rdi
callq 0xb8bc
leaq 0x5a74(%rip), %rsi      # 0xe5a5
movq %r15, %rdi
callq 0x3070
movl %eax, %ebx
movq (%r15), %rdi
cmpq %r12, %rdi
je 0x8b4f
movq -0x38(%rbp), %rsi
incq %rsi
callq 0x3190
testl %ebx, %ebx
je 0x8c7e
movq 0x8(%r14), %rsi
leaq -0x48(%rbp), %rdi
callq 0xb8bc
leaq 0x575d(%rip), %rsi      # 0xe2c8
movq %r15, %rdi
callq 0x3070
movl %eax, %ebx
movq (%r15), %rdi
cmpq %r12, %rdi
je 0x8b89
movq -0x38(%rbp), %rsi
incq %rsi
callq 0x3190
testl %ebx, %ebx
je 0x8c87
movq 0x8(%r14), %rsi
leaq -0x48(%rbp), %rdi
callq 0xb8bc
leaq 0x5721(%rip), %rsi      # 0xe2c6
movq %r15, %rdi
callq 0x3070
movl %eax, %ebx
movq (%r15), %rdi
cmpq %r12, %rdi
je 0x8bc3
movq -0x38(%rbp), %rsi
incq %rsi
callq 0x3190
testl %ebx, %ebx
jne 0x8dc0
leaq 0xa82e(%rip), %rsi      # 0x13400
jmp 0x8c97
movq (%r14), %rsi
leaq -0x80(%rbp), %rdi
callq 0x71f2
leaq -0x48(%rbp), %rsi
movq %rax, (%rsi)
movq -0x50(%rbp), %rdi
callq 0x96e6
movq 0x8(%r14), %rsi
leaq -0x48(%rbp), %rdi
callq 0xb8bc
leaq 0x56c1(%rip), %rsi      # 0xe2c8
movq %r15, %rdi
callq 0x3070
movl %eax, %ebx
movq (%r15), %rdi
cmpq %r12, %rdi
je 0x8c25
movq -0x38(%rbp), %rsi
incq %rsi
callq 0x3190
testl %ebx, %ebx
je 0x8c90
movq 0x8(%r14), %rsi
leaq -0x48(%rbp), %rdi
callq 0xb8bc
leaq 0x5968(%rip), %rsi      # 0xe5a5
movq %r15, %rdi
callq 0x3070
movl %eax, %ebx
movq (%r15), %rdi
cmpq %r12, %rdi
je 0x8c5b
movq -0x38(%rbp), %rsi
incq %rsi
callq 0x3190
testl %ebx, %ebx
jne 0x8dc0
leaq 0xa6f6(%rip), %rsi      # 0x13360
jmp 0x8c97
leaq 0xa6ad(%rip), %rsi      # 0x13320
jmp 0x8c97
leaq 0xa704(%rip), %rsi      # 0x13380
jmp 0x8c97
leaq 0xa6bb(%rip), %rsi      # 0x13340
jmp 0x8c97
leaq 0xa712(%rip), %rsi      # 0x133a0
jmp 0x8c97
leaq 0xa729(%rip), %rsi      # 0x133c0
leaq -0xa0(%rbp), %rdi
callq 0x30f0
movq (%r13), %rax
leaq -0xd0(%rbp), %rdi
movq %r13, %rsi
callq *(%rax)
movq -0xa0(%rbp), %rsi
movq -0x98(%rbp), %rdx
leaq -0xd0(%rbp), %rdi
callq 0x3080
movq %r12, -0x48(%rbp)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
je 0x8ced
movq %rdx, -0x48(%rbp)
movq (%rcx), %rdx
movq %rdx, -0x38(%rbp)
jmp 0x8cf5
movups (%rcx), %xmm0
movups %xmm0, (%r12)
movq 0x8(%rax), %rdx
leaq -0x48(%rbp), %rbx
movq %rdx, 0x8(%rbx)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
movq -0x58(%rbp), %rdi
movq %rbx, %rsi
callq 0x31d0
movq (%rbx), %rdi
cmpq %r12, %rdi
je 0x8d30
movq -0x38(%rbp), %rsi
incq %rsi
callq 0x3190
leaq -0xc0(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x8d4f
movq -0xc0(%rbp), %rsi
incq %rsi
callq 0x3190
leaq -0x80(%rbp), %rdi
callq 0x780a
movq -0xa0(%rbp), %rdi
leaq -0x90(%rbp), %rax
cmpq %rax, %rdi
je 0x8d7a
movq -0x90(%rbp), %rsi
incq %rsi
callq 0x3190
addq $0xc8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl $0x4, %edi
callq 0x30d0
movl $0x1, (%rax)
leaq 0x9ad5(%rip), %rsi      # 0x12878
movq %rax, %rdi
xorl %edx, %edx
callq 0x3290
leaq 0x553a(%rip), %rdi      # 0xe2ee
movl $0x2, %esi
xorl %eax, %eax
callq 0x3210
movl $0x4, %edi
callq 0x30d0
movl $0x1, (%rax)
leaq 0x9aa1(%rip), %rsi      # 0x12878
movq %rax, %rdi
xorl %edx, %edx
callq 0x3290
jmp 0x8e50
jmp 0x8e50
jmp 0x8e50
jmp 0x8e50
jmp 0x8e50
jmp 0x8e50
jmp 0x8e50
jmp 0x8e50
jmp 0x8e50
jmp 0x8e50
jmp 0x8e50
jmp 0x8e50
jmp 0x8e50
jmp 0x8e50
jmp 0x8e50
jmp 0x8e50
movq %rax, %r13
leaq -0xc0(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x8e53
movq -0xc0(%rbp), %rsi
incq %rsi
callq 0x3190
jmp 0x8e53
jmp 0x8e50
jmp 0x8e50
jmp 0x8e80
jmp 0x8e80
movq %rax, %r13
jmp 0x8e5c
movq %rax, %r13
leaq -0xe8(%rbp), %rdi
callq 0x9120
jmp 0x8e46
movq %rax, %r13
movl $0x88, %esi
movq %rbx, %rdi
jmp 0x8e79
movq %rax, %r13
leaq -0x80(%rbp), %rdi
callq 0x780a
movq -0xa0(%rbp), %rdi
leaq -0x90(%rbp), %rax
cmpq %rax, %rdi
je 0x8e83
movq -0x90(%rbp), %rsi
incq %rsi
callq 0x3190
jmp 0x8e83
movq %rax, %r13
movq -0x50(%rbp), %rax
movq (%rax), %rdi
testq %rdi, %rdi
je 0x8e9b
movq 0x68(%r14), %rsi
subq %rdi, %rsi
callq 0x3190
movq -0xb0(%rbp), %rdi
callq 0x9120
movq -0x58(%rbp), %rax
movq (%rax), %rdi
cmpq -0xa8(%rbp), %rdi
je 0x8ec9
movq -0xa8(%rbp), %rax
movq (%rax), %rsi
incq %rsi
callq 0x3190
movq %r13, %rdi
callq 0x32b0
nop