// File: /workspace/github_c_makefile_star2_O2/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 $0x1068, %rsp           # imm = 0x1068
movq %rsi, %r15
movl 0xae86(%rip), %ebp      # 0xe548
andl $0x0, 0xae7f(%rip)      # 0xe548
movl %edi, %r13d
cmpl $0x1, 0xae71(%rip)      # 0xe544
jne 0x370b
movsd 0xad33(%rip), %xmm1     # 0xe410
ucomisd %xmm0, %xmm1
jne 0x370b
jp 0x370b
xorl %eax, %eax
cmpl $0x0, 0xad2a(%rip)      # 0xe418
sete %al
leaq 0x5c08(%rip), %rcx      # 0x9300
mulsd (%rcx,%rax,8), %xmm0
divsd 0x5b7b(%rip), %xmm0     # 0x9280
movl %eax, 0xad0d(%rip)      # 0xe418
cmpl $0x0, 0x1a95a(%rip)     # 0x1e06c
movq %rdx, 0x10(%rsp)
movl %edx, %r12d
je 0x397c
xorl %ecx, %ecx
movq 0x10(%rsp), %rdx
testl %edx, %edx
movl $0x0, %eax
cmovgl %edx, %eax
cmpq %rcx, %rax
je 0x3743
movl (%r15,%rcx,4), %edx
movl %edx, 0x60(%rsp,%rcx,4)
incq %rcx
jmp 0x3731
movl %r13d, 0x28(%rsp)
movl %ebp, 0x2c(%rsp)
movq %r15, 0x20(%rsp)
movq 0x10(%rsp), %rcx
cmpl %ecx, 0xade4(%rip)      # 0xe540
jne 0x38ee
movl 0x1a968(%rip), %ebx     # 0x1e0d0
movq 0x20(%rsp), %rcx
movl (%rcx), %r14d
cmpl %r14d, %ebx
je 0x38ee
movslq 0x10(%rsp), %rsi
leaq (,%rsi,4), %rcx
leaq -0x4(,%rsi,4), %r8
leaq (%rsp,%rsi,4), %r9
addq $0x85c, %r9             # imm = 0x85C
movq 0x20(%rsp), %rdx
leaq -0x4(%rdx,%rsi,8), %rdi
movq %rdi, 0x40(%rsp)
leaq (%rdx,%rsi,4), %rdi
addq $-0x4, %rdi
movq %rdi, (%rsp)
leaq -0x1(%rsi), %r13
negq %rcx
movq %rcx, 0x58(%rsp)
leaq (,%r12,4), %r15
movl $0x7fffffff, 0x1c(%rsp) # imm = 0x7FFFFFFF
xorl %edi, %edi
leaq 0x1a8f7(%rip), %rcx     # 0x1e0d0
movq %rdx, 0x8(%rsp)
movl %ebx, 0x34(%rsp)
movl %r14d, 0x30(%rsp)
cmpq %rax, %rdi
je 0x38ee
movq %rdi, 0x38(%rsp)
cmpl %r14d, %ebx
jle 0x3855
movq 0x58(%rsp), %rdx
movq 0x8(%rsp), %rdi
leaq (%rdi,%rdx), %r14
xorl %edi, %edi
movq 0x38(%rsp), %rbp
xorl %edx, %edx
cmpq %rdi, %r15
je 0x38a1
cmpq %rsi, %rbp
jge 0x382a
movq 0x8(%rsp), %r10
movl (%r10,%rdi), %r10d
jmp 0x3832
movl (%r14,%rdi), %r10d
addl $0xc, %r10d
movl (%rdi,%rcx), %r11d
subl %r10d, %r11d
movl %r11d, %ebx
negl %ebx
cmovsl %r11d, %ebx
movl %r10d, 0x860(%rsp,%rdi)
addl %ebx, %edx
addq $0x4, %rdi
incq %rbp
jmp 0x3811
xorl %edi, %edi
xorl %edx, %edx
leaq (%rsi,%rdi), %r10
testq %r10, %r10
jle 0x38aa
movq %r13, %r10
addq %rdi, %r10
js 0x3874
movq (%rsp), %r10
movl (%r10,%rdi,4), %ebp
jmp 0x3880
movq 0x40(%rsp), %r10
movl (%r10,%rdi,4), %ebp
addl $-0xc, %ebp
leaq (%r8,%rdi,4), %r10
movl (%rcx,%r10), %r10d
subl %ebp, %r10d
movl %r10d, %r11d
negl %r11d
cmovsl %r10d, %r11d
movl %ebp, (%r9,%rdi,4)
addl %r11d, %edx
decq %rdi
jmp 0x3859
movl 0x34(%rsp), %ebx
movl 0x30(%rsp), %r14d
cmpl 0x1c(%rsp), %edx
jge 0x38cd
xorl %edi, %edi
cmpq %rdi, %rax
je 0x38c9
movl 0x860(%rsp,%rdi,4), %r10d
movl %r10d, 0x60(%rsp,%rdi,4)
incq %rdi
jmp 0x38b2
movl %edx, 0x1c(%rsp)
movq 0x38(%rsp), %rdi
incq %rdi
addq $-0x4, 0x40(%rsp)
addq $-0x4, (%rsp)
decq %r13
addq $0x4, 0x8(%rsp)
jmp 0x37e7
shlq $0x2, %rax
xorl %edx, %edx
leaq 0x1a7d5(%rip), %rcx     # 0x1e0d0
movq 0x20(%rsp), %r15
movl 0x2c(%rsp), %ebp
movl 0x28(%rsp), %r13d
cmpq %rdx, %rax
je 0x391f
movl 0x60(%rsp,%rdx), %esi
movl %esi, (%r15,%rdx)
movl %esi, (%rdx,%rcx)
addq $0x4, %rdx
jmp 0x3909
movq 0x10(%rsp), %rdx
cmpl $0x2, %edx
pushq $0x1
popq %rax
cmovgel %edx, %eax
movl %edx, 0xac0d(%rip)      # 0xe540
decl %eax
pushq $0x1
popq %rdx
xorl %esi, %esi
cmpq %rax, %rsi
je 0x397c
movq %rdx, %rdi
movl %esi, %r8d
movslq %r8d, %r9
cmpq %rdi, %r12
je 0x3965
movl (%rcx,%rdi,4), %r11d
movl %edi, %r10d
cmpl (%rcx,%r9,4), %r11d
jl 0x395d
movl %r8d, %r10d
incq %rdi
movl %r10d, %r8d
jmp 0x3945
movl (%rcx,%rsi,4), %edi
movl (%rcx,%r9,4), %r8d
movl %r8d, (%rcx,%rsi,4)
incq %rsi
movl %edi, (%rcx,%r9,4)
incq %rdx
jmp 0x393a
movsd 0x1a384(%rip), %xmm1    # 0x1dd08
movapd %xmm1, 0x40(%rsp)
movl 0xaaf8(%rip), %eax      # 0xe488
testl %eax, %eax
movsd %xmm0, (%rsp)
je 0x3a26
cmpl $0x1, %eax
movq 0x10(%rsp), %r12
jne 0x3ad9
movl 0xabaf(%rip), %eax      # 0xe560
cmpl $0x1, %eax
je 0x3b1d
testl %eax, %eax
jne 0x3ad9
leal -0x1(%r12), %ebx
xorl %r14d, %r14d
testl %r12d, %r12d
cmovlel %r14d, %r12d
cmpq %r14, %r12
je 0x3ad9
cmpq %r14, %rbx
jne 0x39e5
movl %ebp, 0xab63(%rip)      # 0xe548
cvtsi2sd %r14d, %xmm1
mulsd 0xab66(%rip), %xmm1     # 0xe558
subsd %xmm1, %xmm0
movsd %xmm0, 0x8(%rsp)
movl (%r15,%r14,4), %esi
movl %r13d, %edi
callq *0xaa37(%rip)           # 0xe440
movsd 0x8(%rsp), %xmm0
subsd 0xab41(%rip), %xmm0     # 0xe558
callq 0x32ff
movsd (%rsp), %xmm0
incq %r14
jmp 0x39d1
movl 0xab34(%rip), %eax      # 0xe560
cmpl $0x1, %eax
je 0x3ad4
testl %eax, %eax
jne 0x3ad9
testl %r12d, %r12d
jle 0x3ad9
cmpl $0x1, %r12d
jne 0x3a52
movl %ebp, 0xaaf6(%rip)      # 0xe548
movq %r12, %rbx
decq %rbx
leal -0x1(%r12), %eax
cvtsi2sd %eax, %xmm1
mulsd 0xaaef(%rip), %xmm1     # 0xe558
subsd %xmm1, %xmm0
movsd %xmm0, 0x8(%rsp)
movl %ebx, %eax
movl (%r15,%rax,4), %esi
movl %r13d, %edi
callq *0xa9be(%rip)           # 0xe440
movsd 0x8(%rsp), %xmm0
subsd 0xaac8(%rip), %xmm0     # 0xe558
callq 0x32ff
movsd (%rsp), %xmm0
movq %rbx, %r12
jmp 0x3a3d
decq %r12
testl %r12d, %r12d
jne 0x3aad
movl %ebp, 0xaa9b(%rip)      # 0xe548
movl %r12d, %eax
movl (%r15,%rax,4), %esi
movl %r13d, %edi
callq *0xa983(%rip)           # 0xe440
movsd (%rsp), %xmm0
subsd 0xaa8e(%rip), %xmm0     # 0xe558
callq 0x32ff
movsd (%rsp), %xmm0
testl %r12d, %r12d
jg 0x3a9f
cvttpd2dq 0x40(%rsp), %xmm1
cvtdq2pd %xmm1, %xmm2
mulsd 0x578d(%rip), %xmm0     # 0x9278
divsd 0xa9bd(%rip), %xmm0     # 0xe4b0
cvtsi2sdl 0xa935(%rip), %xmm1 # 0xe430
mulsd %xmm0, %xmm1
addsd %xmm2, %xmm1
cvttsd2si %xmm1, %edi
addq $0x1068, %rsp           # imm = 0x1068
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x3331
leal -0x1(%r12), %ebx
xorl %r14d, %r14d
testl %r12d, %r12d
cmovlel %r14d, %r12d
cmpq %r14, %r12
je 0x3ad9
cmpq %r14, %rbx
jne 0x3b3c
movl %ebp, 0xaa0c(%rip)      # 0xe548
movl (%r15,%r14,4), %esi
movl %r13d, %edi
callq *0xa8f7(%rip)           # 0xe440
movsd (%rsp), %xmm0
subsd 0xaa02(%rip), %xmm0     # 0xe558
callq 0x32ff
movsd (%rsp), %xmm0
incq %r14
jmp 0x3b2c