// File: /workspace/github_c_makefile_star2_O1/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 $0x1078, %rsp           # imm = 0x1078
movl %edx, %r14d
movq %rsi, %r12
movl %edi, %ebp
movl 0xba53(%rip), %r13d     # 0xf548
movl $0x0, 0xba49(%rip)      # 0xf548
cmpl $0x1, 0xba3e(%rip)      # 0xf544
jne 0x3b3e
movsd 0xb900(%rip), %xmm1     # 0xf410
ucomisd %xmm0, %xmm1
jne 0x3b3e
jp 0x3b3e
xorl %eax, %eax
cmpl $0x0, 0xb8f7(%rip)      # 0xf418
sete %al
leaq 0x67b5(%rip), %rcx      # 0xa2e0
mulsd (%rcx,%rax,8), %xmm0
divsd 0x6750(%rip), %xmm0     # 0xa288
movl %eax, 0xb8da(%rip)      # 0xf418
movsd %xmm0, 0x8(%rsp)
cmpl $0x0, 0x1b521(%rip)     # 0x1f06c
je 0x3db5
movl %r13d, 0x20(%rsp)
movl %ebp, 0x24(%rsp)
movl %r14d, %r13d
testl %r14d, %r14d
jle 0x3b77
leaq (,%r13,4), %rdx
leaq 0x70(%rsp), %rdi
movq %r12, %rsi
callq 0x2200
movq %r12, 0x10(%rsp)
movq %r14, 0x40(%rsp)
cmpl %r14d, 0xb9b8(%rip)     # 0xf540
jne 0x3d14
cmpl $0x0, 0x40(%rsp)
setle %al
movl 0x1b533(%rip), %r10d    # 0x1f0d0
movq 0x10(%rsp), %rcx
movl (%rcx), %r11d
cmpl %r11d, %r10d
sete %cl
orb %al, %cl
jne 0x3d14
leaq (,%r13,4), %r15
leaq -0x4(,%r13,4), %rax
movq %rax, 0x30(%rsp)
leaq (%rsp,%r13,4), %rax
addq $0x86c, %rax            # imm = 0x86C
movq %rax, 0x50(%rsp)
movq 0x10(%rsp), %rcx
leaq -0x4(%rcx,%r13,8), %rax
movq %rax, 0x48(%rsp)
leaq (%rcx,%r13,4), %rbx
addq $-0x4, %rbx
leaq -0x1(%r13), %r14
movq %r15, %rax
negq %rax
movq %rax, 0x60(%rsp)
movl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
xorl %esi, %esi
leaq 0x1b4c5(%rip), %rbp     # 0x1f0d0
movq %rcx, 0x18(%rsp)
movl %r10d, 0x2c(%rsp)
movl %r11d, 0x28(%rsp)
cmpl %r11d, %r10d
movq %rsi, 0x68(%rsp)
jle 0x3c74
movq 0x60(%rsp), %rcx
movq 0x18(%rsp), %rdx
addq %rdx, %rcx
xorl %edx, %edx
xorl %r12d, %r12d
cmpq %r13, %rsi
jae 0x3c45
movq 0x18(%rsp), %rdi
movl (%rdi,%rdx), %edi
jmp 0x3c4b
movl (%rcx,%rdx), %edi
addl $0xc, %edi
movl (%rdx,%rbp), %r8d
subl %edi, %r8d
movl %r8d, %r9d
negl %r9d
cmovsl %r8d, %r9d
movl %edi, 0x870(%rsp,%rdx)
addl %r9d, %r12d
addq $0x4, %rdx
incq %rsi
cmpq %rdx, %r15
jne 0x3c36
jmp 0x3cc5
xorl %ecx, %ecx
xorl %r12d, %r12d
movq %r14, %rdx
addq %rcx, %rdx
js 0x3c86
movl (%rbx,%rcx,4), %edx
jmp 0x3c91
movq 0x48(%rsp), %rdx
movl (%rdx,%rcx,4), %edx
addl $-0xc, %edx
movq 0x30(%rsp), %rsi
leaq (%rsi,%rcx,4), %rsi
movl (%rbp,%rsi), %esi
subl %edx, %esi
movl %esi, %edi
negl %edi
cmovsl %esi, %edi
movq 0x50(%rsp), %rsi
movl %edx, (%rsi,%rcx,4)
addl %edi, %r12d
leaq (%rcx,%r13), %rdx
decq %rdx
decq %rcx
incq %rdx
cmpq $0x1, %rdx
jg 0x3c79
cmpl %eax, %r12d
cmovll %r12d, %eax
jge 0x3cf0
leaq 0x70(%rsp), %rdi
leaq 0x870(%rsp), %rsi
movq %r15, %rdx
callq 0x2200
movl 0x28(%rsp), %r11d
movl 0x2c(%rsp), %r10d
movl %r12d, %eax
movq 0x68(%rsp), %rsi
incq %rsi
addq $-0x4, 0x48(%rsp)
addq $-0x4, %rbx
decq %r14
addq $0x4, 0x18(%rsp)
cmpq %r13, %rsi
jne 0x3c1a
movq 0x40(%rsp), %r14
testl %r14d, %r14d
movq 0x10(%rsp), %r12
jle 0x3d48
leaq (,%r13,4), %rax
xorl %ecx, %ecx
leaq 0x1b39c(%rip), %rdx     # 0x1f0d0
movl 0x70(%rsp,%rcx), %esi
movl %esi, (%r12,%rcx)
movl %esi, (%rcx,%rdx)
addq $0x4, %rcx
cmpq %rcx, %rax
jne 0x3d34
movl %r14d, 0xb7f1(%rip)     # 0xf540
cmpl $0x2, %r14d
movl 0x24(%rsp), %ebp
jl 0x3db0
leal -0x1(%r14), %eax
movl $0x1, %ecx
xorl %esi, %esi
leaq 0x1b365(%rip), %rdx     # 0x1f0d0
movq %rcx, %rdi
movl %esi, %r9d
movl (%rdx,%rdi,4), %r10d
movslq %r9d, %r11
movl %edi, %r8d
cmpl (%rdx,%r11,4), %r10d
jl 0x3d84
movl %r9d, %r8d
incq %rdi
movl %r8d, %r9d
cmpq %rdi, %r13
jne 0x3d71
movl (%rdx,%rsi,4), %edi
movslq %r8d, %r8
movl (%rdx,%r8,4), %r9d
movl %r9d, (%rdx,%rsi,4)
leaq 0x1(%rsi), %r9
movl %edi, (%rdx,%r8,4)
incq %rcx
movq %r9, %rsi
cmpq %rax, %r9
jne 0x3d6b
movl 0x20(%rsp), %r13d
movsd 0x1af4b(%rip), %xmm0    # 0x1ed08
movapd %xmm0, 0x50(%rsp)
movl 0xb6bf(%rip), %eax      # 0xf488
testl %eax, %eax
je 0x3e64
cmpl $0x1, %eax
jne 0x3f96
movl 0xb780(%rip), %eax      # 0xf560
cmpl $0x1, %eax
je 0x3ef1
testl %eax, %eax
jne 0x3f96
testl %r14d, %r14d
jle 0x3f96
leal -0x1(%r14), %ebx
movl %r14d, %r14d
xorl %r15d, %r15d
cmpq %r15, %rbx
jne 0x3e10
movl %r13d, 0xb738(%rip)     # 0xf548
xorps %xmm1, %xmm1
cvtsi2sd %r15d, %xmm1
mulsd 0xb738(%rip), %xmm1     # 0xf558
movsd 0x8(%rsp), %xmm0
subsd %xmm1, %xmm0
movapd %xmm0, 0x30(%rsp)
movl (%r12,%r15,4), %esi
movl %ebp, %edi
callq *0xb604(%rip)           # 0xf440
movapd 0x30(%rsp), %xmm0
subsd 0xb70e(%rip), %xmm0     # 0xf558
xorpd 0x649e(%rip), %xmm0     # 0xa2f0
callq 0x5359
incq %r15
cmpq %r15, %r14
jne 0x3e04
jmp 0x3f96
movl 0xb6f6(%rip), %eax      # 0xf560
cmpl $0x1, %eax
je 0x3f47
testl %eax, %eax
jne 0x3f96
testl %r14d, %r14d
jle 0x3f96
movl %r14d, %eax
cmpq $0x1, %rax
jne 0x3e94
movl %r13d, 0xb6b4(%rip)     # 0xf548
leaq -0x1(%rax), %rbx
xorps %xmm1, %xmm1
cvtsi2sd %ebx, %xmm1
mulsd 0xb6b1(%rip), %xmm1     # 0xf558
movsd 0x8(%rsp), %xmm0
subsd %xmm1, %xmm0
movapd %xmm0, 0x30(%rsp)
movl -0x4(%r12,%rax,4), %esi
movl %ebp, %edi
callq *0xb57c(%rip)           # 0xf440
movapd 0x30(%rsp), %xmm0
subsd 0xb686(%rip), %xmm0     # 0xf558
xorpd 0x6416(%rip), %xmm0     # 0xa2f0
callq 0x5359
leaq 0x1(%rbx), %rcx
movq %rbx, %rax
cmpq $0x1, %rcx
jg 0x3e87
jmp 0x3f96
testl %r14d, %r14d
jle 0x3f96
leal -0x1(%r14), %ebx
movl %r14d, %r14d
xorl %r15d, %r15d
cmpq %r15, %rbx
jne 0x3f10
movl %r13d, 0xb638(%rip)     # 0xf548
movl (%r12,%r15,4), %esi
movsd 0x8(%rsp), %xmm0
movl %ebp, %edi
callq *0xb51e(%rip)           # 0xf440
movsd 0x8(%rsp), %xmm0
subsd 0xb628(%rip), %xmm0     # 0xf558
xorpd 0x63b8(%rip), %xmm0     # 0xa2f0
callq 0x5359
incq %r15
cmpq %r15, %r14
jne 0x3f04
jmp 0x3f96
testl %r14d, %r14d
jle 0x3f96
movl %r14d, %ebx
incq %rbx
cmpq $0x2, %rbx
jne 0x3f5f
movl %r13d, 0xb5e9(%rip)     # 0xf548
movl -0x8(%r12,%rbx,4), %esi
movsd 0x8(%rsp), %xmm0
movl %ebp, %edi
callq *0xb4ce(%rip)           # 0xf440
movsd 0x8(%rsp), %xmm0
subsd 0xb5d8(%rip), %xmm0     # 0xf558
xorpd 0x6368(%rip), %xmm0     # 0xa2f0
callq 0x5359
decq %rbx
cmpq $0x1, %rbx
jg 0x3f52
cvttpd2dq 0x50(%rsp), %xmm0
cvtdq2pd %xmm0, %xmm0
movsd 0x8(%rsp), %xmm2
mulsd 0x62d2(%rip), %xmm2     # 0xa280
divsd 0xb4fa(%rip), %xmm2     # 0xf4b0
xorps %xmm1, %xmm1
cvtsi2sdl 0xb46f(%rip), %xmm1 # 0xf430
mulsd %xmm2, %xmm1
addsd %xmm0, %xmm1
cvttsd2si %xmm1, %edi
addq $0x1078, %rsp           # imm = 0x1078
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x36fb