// File: /workspace/github_c_makefile_star2_O3/pipde[P]deos-songlib/lib/songlib.c
// Function: anchord
void
anchord(double beats,int inst,int *notes,int length)
    {
    int i;
    int spot;
    int oldTempoChange = TempoChange;

    TempoChange = 0;

    if (style == SWING && swingBeat == beats)
        {
        if (swingDown) beats = beats * 4 / 3;
        else beats = beats * 2 / 3;
        swingDown = !swingDown;
        }

    if (voiceLeading) useClosestChord(notes,length);

    //sort the notes from highest to lowest
    //sort(notes,length); // probably should not sort nodes

    spot = getLocation();

    if (strumDirection == STRUM_DOWN)
        {
        if (strideMode == RAGGED)
            {
            for (i = 0; i < length; ++i)
                {
                if (i == length-1) TempoChange = oldTempoChange;
                nplay(beats,inst,notes[i]);
                backwards(beats - stride);
                }
            }
        else if (strideMode == JUSTIFIED)
            {
            for (i = 0; i < length; ++i)
                {
                double b = beats - (stride * i);
                if (i == length-1) TempoChange = oldTempoChange;
                nplay(b,inst,notes[i]);
                backwards(b - stride);
                }

            }
        }
    else if (strumDirection == STRUM_UP)
        {
        if (strideMode == RAGGED)
            {
            for (i = length - 1; i >= 0; --i)
                {
                if (i == 0) TempoChange = oldTempoChange;
                nplay(beats,inst,notes[i]);
                backwards(beats - stride);
                }
            }
        else if (strideMode == JUSTIFIED)
            {
            for (i = length - 1; i >= 0; --i)
                {
                double b = beats - (stride * i);
                if (i == 0) TempoChange = oldTempoChange;
                nplay(b,inst,notes[i]);
                backwards(b - stride);
                }
            }
        }

    //printf("spot was %d\n",spot);
    setLocation(spot+beatsToSamples(beats));
    //printf("spot now is %d\n",getLocation());
    }

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x1088, %rsp           # imm = 0x1088
movl %edx, %r14d
movq %rsi, %r12
movl %edi, %ebp
movl 0xba8d(%rip), %r13d     # 0xf548
movl $0x0, 0xba83(%rip)      # 0xf548
cmpl $0x1, 0xba78(%rip)      # 0xf544
jne 0x3b04
movsd 0xb93a(%rip), %xmm1     # 0xf410
ucomisd %xmm0, %xmm1
jne 0x3b04
jp 0x3b04
xorl %eax, %eax
cmpl $0x0, 0xb931(%rip)      # 0xf418
sete %al
leaq 0x680f(%rip), %rcx      # 0xa300
mulsd (%rcx,%rax,8), %xmm0
divsd 0x678a(%rip), %xmm0     # 0xa288
movl %eax, 0xb914(%rip)      # 0xf418
movsd %xmm0, 0x8(%rsp)
cmpl $0x0, 0x1b55b(%rip)     # 0x1f06c
je 0x3d83
movl %r13d, 0x24(%rsp)
movl %ebp, 0x14(%rsp)
movl %r14d, %r13d
testl %r14d, %r14d
jle 0x3b40
leaq (,%r13,4), %rdx
leaq 0x80(%rsp), %rdi
movq %r12, %rsi
callq 0x2200
movq %r12, 0x18(%rsp)
movq %r14, 0x40(%rsp)
cmpl %r14d, 0xb9ef(%rip)     # 0xf540
jne 0x3cd0
cmpl $0x0, 0x40(%rsp)
setle %al
movl 0x1b56a(%rip), %r10d    # 0x1f0d0
movq 0x18(%rsp), %rcx
movl (%rcx), %r11d
cmpl %r11d, %r10d
sete %cl
orb %al, %cl
jne 0x3cd0
leaq (,%r13,4), %rax
movq %rax, 0x70(%rsp)
leaq -0x4(,%r13,4), %rax
movq %rax, 0x30(%rsp)
leaq (%rsp,%r13,4), %rax
addq $0x87c, %rax            # imm = 0x87C
movq %rax, 0x50(%rsp)
movq 0x18(%rsp), %r14
leaq -0x4(%r14,%r13,8), %rax
movq %rax, 0x48(%rsp)
leaq (%r14,%r13,4), %r15
addq $-0x4, %r15
leaq -0x1(%r13), %rbx
movq %r13, %rax
negq %rax
movq %rax, 0x68(%rsp)
movl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
xorl %edx, %edx
leaq 0x1b4f7(%rip), %r12     # 0x1f0d0
movl %r10d, 0x2c(%rsp)
movl %r11d, 0x28(%rsp)
cmpl %r11d, %r10d
movq %rdx, 0x78(%rsp)
jle 0x3c31
xorl %ecx, %ecx
movq 0x68(%rsp), %rsi
xorl %ebp, %ebp
cmpq %r13, %rdx
jae 0x3c01
movl (%r14,%rcx), %edi
jmp 0x3c08
movl (%r14,%rsi,4), %edi
addl $0xc, %edi
movl (%rcx,%r12), %r8d
subl %edi, %r8d
movl %r8d, %r9d
negl %r9d
cmovsl %r8d, %r9d
movl %edi, 0x880(%rsp,%rcx)
addl %r9d, %ebp
addq $0x4, %rcx
incq %rdx
incq %rsi
jne 0x3bf6
jmp 0x3c81
xorl %ecx, %ecx
xorl %ebp, %ebp
movq %rbx, %rdx
addq %rcx, %rdx
js 0x3c43
movl (%r15,%rcx,4), %edx
jmp 0x3c4e
movq 0x48(%rsp), %rdx
movl (%rdx,%rcx,4), %edx
addl $-0xc, %edx
movq 0x30(%rsp), %rsi
leaq (%rsi,%rcx,4), %rsi
movl (%r12,%rsi), %esi
subl %edx, %esi
movl %esi, %edi
negl %edi
cmovsl %esi, %edi
movq 0x50(%rsp), %rsi
movl %edx, (%rsi,%rcx,4)
addl %edi, %ebp
leaq (%rcx,%r13), %rdx
decq %rdx
decq %rcx
incq %rdx
cmpq $0x1, %rdx
ja 0x3c35
cmpl %eax, %ebp
cmovll %ebp, %eax
jge 0x3cae
leaq 0x80(%rsp), %rdi
leaq 0x880(%rsp), %rsi
movq 0x70(%rsp), %rdx
callq 0x2200
movl 0x28(%rsp), %r11d
movl 0x2c(%rsp), %r10d
movl %ebp, %eax
movq 0x78(%rsp), %rdx
incq %rdx
addq $-0x4, 0x48(%rsp)
addq $-0x4, %r15
decq %rbx
addq $0x4, %r14
cmpq %r13, %rdx
jne 0x3be3
movq 0x40(%rsp), %r14
testl %r14d, %r14d
jle 0x3d6e
leaq (,%r13,4), %rcx
xorl %edx, %edx
leaq 0x1b3e1(%rip), %rax     # 0x1f0d0
movq 0x18(%rsp), %r12
movl 0x14(%rsp), %ebp
movl 0x80(%rsp,%rdx), %esi
movl %esi, (%r12,%rdx)
movl %esi, (%rdx,%rax)
addq $0x4, %rdx
cmpq %rdx, %rcx
jne 0x3cf8
movl %r14d, 0xb82a(%rip)     # 0xf540
cmpl $0x1, %r14d
je 0x3d7e
leal -0x1(%r14), %ecx
movl $0x1, %edx
xorl %esi, %esi
movq %rdx, %rdi
movl %esi, %r9d
movl (%rax,%rdi,4), %r10d
movslq %r9d, %r11
movl %edi, %r8d
cmpl (%rax,%r11,4), %r10d
jl 0x3d40
movl %r9d, %r8d
incq %rdi
movl %r8d, %r9d
cmpq %rdi, %r13
jne 0x3d2d
movl (%rax,%rsi,4), %edi
movslq %r8d, %r8
movl (%rax,%r8,4), %r9d
movl %r9d, (%rax,%rsi,4)
leaq 0x1(%rsi), %r9
movl %edi, (%rax,%r8,4)
incq %rdx
movq %r9, %rsi
cmpq %rcx, %r9
jne 0x3d27
jmp 0x3d7e
movl %r14d, 0xb7cb(%rip)     # 0xf540
movq 0x18(%rsp), %r12
movl 0x14(%rsp), %ebp
movl 0x24(%rsp), %r13d
movsd 0x1af7d(%rip), %xmm0    # 0x1ed08
movapd %xmm0, 0x50(%rsp)
movl 0xb6f1(%rip), %eax      # 0xf488
testl %eax, %eax
je 0x3e32
cmpl $0x1, %eax
jne 0x3f64
movl 0xb7b2(%rip), %eax      # 0xf560
cmpl $0x1, %eax
je 0x3ebf
testl %eax, %eax
jne 0x3f64
testl %r14d, %r14d
jle 0x3f64
leal -0x1(%r14), %ebx
movl %r14d, %r14d
xorl %r15d, %r15d
cmpq %r15, %rbx
jne 0x3dde
movl %r13d, 0xb76a(%rip)     # 0xf548
xorps %xmm1, %xmm1
cvtsi2sd %r15d, %xmm1
mulsd 0xb76a(%rip), %xmm1     # 0xf558
movsd 0x8(%rsp), %xmm0
subsd %xmm1, %xmm0
movapd %xmm0, 0x30(%rsp)
movl (%r12,%r15,4), %esi
movl %ebp, %edi
callq *0xb636(%rip)           # 0xf440
movapd 0x30(%rsp), %xmm0
subsd 0xb740(%rip), %xmm0     # 0xf558
xorpd 0x64f0(%rip), %xmm0     # 0xa310
callq 0x543b
incq %r15
cmpq %r15, %r14
jne 0x3dd2
jmp 0x3f64
movl 0xb728(%rip), %eax      # 0xf560
cmpl $0x1, %eax
je 0x3f15
testl %eax, %eax
jne 0x3f64
testl %r14d, %r14d
jle 0x3f64
movl %r14d, %eax
cmpq $0x1, %rax
jne 0x3e62
movl %r13d, 0xb6e6(%rip)     # 0xf548
leaq -0x1(%rax), %rbx
xorps %xmm1, %xmm1
cvtsi2sd %ebx, %xmm1
mulsd 0xb6e3(%rip), %xmm1     # 0xf558
movsd 0x8(%rsp), %xmm0
subsd %xmm1, %xmm0
movapd %xmm0, 0x30(%rsp)
movl -0x4(%r12,%rax,4), %esi
movl %ebp, %edi
callq *0xb5ae(%rip)           # 0xf440
movapd 0x30(%rsp), %xmm0
subsd 0xb6b8(%rip), %xmm0     # 0xf558
xorpd 0x6468(%rip), %xmm0     # 0xa310
callq 0x543b
leaq 0x1(%rbx), %rcx
movq %rbx, %rax
cmpq $0x1, %rcx
ja 0x3e55
jmp 0x3f64
testl %r14d, %r14d
jle 0x3f64
leal -0x1(%r14), %ebx
movl %r14d, %r14d
xorl %r15d, %r15d
cmpq %r15, %rbx
jne 0x3ede
movl %r13d, 0xb66a(%rip)     # 0xf548
movl (%r12,%r15,4), %esi
movsd 0x8(%rsp), %xmm0
movl %ebp, %edi
callq *0xb550(%rip)           # 0xf440
movsd 0x8(%rsp), %xmm0
subsd 0xb65a(%rip), %xmm0     # 0xf558
xorpd 0x640a(%rip), %xmm0     # 0xa310
callq 0x543b
incq %r15
cmpq %r15, %r14
jne 0x3ed2
jmp 0x3f64
testl %r14d, %r14d
jle 0x3f64
movl %r14d, %ebx
incq %rbx
cmpq $0x2, %rbx
jne 0x3f2d
movl %r13d, 0xb61b(%rip)     # 0xf548
movl -0x8(%r12,%rbx,4), %esi
movsd 0x8(%rsp), %xmm0
movl %ebp, %edi
callq *0xb500(%rip)           # 0xf440
movsd 0x8(%rsp), %xmm0
subsd 0xb60a(%rip), %xmm0     # 0xf558
xorpd 0x63ba(%rip), %xmm0     # 0xa310
callq 0x543b
decq %rbx
cmpq $0x1, %rbx
ja 0x3f20
cvttpd2dq 0x50(%rsp), %xmm0
cvtdq2pd %xmm0, %xmm0
movsd 0x8(%rsp), %xmm2
mulsd 0x6304(%rip), %xmm2     # 0xa280
divsd 0xb52c(%rip), %xmm2     # 0xf4b0
xorps %xmm1, %xmm1
cvtsi2sdl 0xb4a1(%rip), %xmm1 # 0xf430
mulsd %xmm2, %xmm1
addsd %xmm0, %xmm1
cvttsd2si %xmm1, %edi
addq $0x1088, %rsp           # imm = 0x1088
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x36ce