// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x40, %rsp
movsd %xmm0, -0x8(%rbp)
movl %edi, -0xc(%rbp)
movq %rsi, -0x18(%rbp)
movl %edx, -0x1c(%rbp)
movl 0xe6cb(%rip), %eax      # 0x12518
movl %eax, -0x28(%rbp)
movl $0x0, 0xe6be(%rip)      # 0x12518
cmpl $0x1, 0xe6b3(%rip)      # 0x12514
jne 0x3ed2
movsd 0xe575(%rip), %xmm0     # 0x123e0
ucomisd -0x8(%rbp), %xmm0
jne 0x3ed2
jp 0x3ed2
cmpl $0x0, 0xe56d(%rip)      # 0x123e8
je 0x3e9d
movsd 0x9183(%rip), %xmm0     # 0xd008
mulsd -0x8(%rbp), %xmm0
movsd 0x94b6(%rip), %xmm1     # 0xd348
divsd %xmm1, %xmm0
movsd %xmm0, -0x8(%rbp)
jmp 0x3ebb
movsd 0x948b(%rip), %xmm0     # 0xd330
mulsd -0x8(%rbp), %xmm0
movsd 0x9496(%rip), %xmm1     # 0xd348
divsd %xmm1, %xmm0
movsd %xmm0, -0x8(%rbp)
cmpl $0x0, 0xe526(%rip)      # 0x123e8
setne %al
xorb $-0x1, %al
andb $0x1, %al
movzbl %al, %eax
movl %eax, 0xe516(%rip)      # 0x123e8
cmpl $0x0, 0x1e163(%rip)     # 0x2203c
je 0x3ee7
movq -0x18(%rbp), %rdi
movl -0x1c(%rbp), %esi
callq 0x4210
callq 0x38b0
movl %eax, -0x24(%rbp)
cmpl $0x1, 0xe562(%rip)      # 0x12458
jne 0x4019
cmpl $0x1, 0xe62d(%rip)      # 0x12530
jne 0x3f68
movl $0x0, -0x20(%rbp)
movl -0x20(%rbp), %eax
cmpl -0x1c(%rbp), %eax
jge 0x3f63
movl -0x20(%rbp), %eax
movl -0x1c(%rbp), %ecx
subl $0x1, %ecx
cmpl %ecx, %eax
jne 0x3f2a
movl -0x28(%rbp), %eax
movl %eax, 0xe5ee(%rip)      # 0x12518
movq 0xe4df(%rip), %rax      # 0x12410
movsd -0x8(%rbp), %xmm0
movl -0xc(%rbp), %edi
movq -0x18(%rbp), %rcx
movslq -0x20(%rbp), %rdx
movl (%rcx,%rdx,4), %esi
callq *%rax
movsd -0x8(%rbp), %xmm0
subsd 0xe5d5(%rip), %xmm0     # 0x12528
callq 0x3870
movl -0x20(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x20(%rbp)
jmp 0x3f0c
jmp 0x4014
cmpl $0x0, 0xe5c1(%rip)      # 0x12530
jne 0x4012
movl $0x0, -0x20(%rbp)
movl -0x20(%rbp), %eax
cmpl -0x1c(%rbp), %eax
jge 0x4010
movsd -0x8(%rbp), %xmm1
movsd 0xe593(%rip), %xmm0     # 0x12528
cvtsi2sdl -0x20(%rbp), %xmm2
movq %xmm0, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm0
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, -0x30(%rbp)
movl -0x20(%rbp), %eax
movl -0x1c(%rbp), %ecx
subl $0x1, %ecx
cmpl %ecx, %eax
jne 0x3fd4
movl -0x28(%rbp), %eax
movl %eax, 0xe544(%rip)      # 0x12518
movq 0xe435(%rip), %rax      # 0x12410
movsd -0x30(%rbp), %xmm0
movl -0xc(%rbp), %edi
movq -0x18(%rbp), %rcx
movslq -0x20(%rbp), %rdx
movl (%rcx,%rdx,4), %esi
callq *%rax
movsd -0x30(%rbp), %xmm0
subsd 0xe52b(%rip), %xmm0     # 0x12528
callq 0x3870
movl -0x20(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x20(%rbp)
jmp 0x3f7c
jmp 0x4012
jmp 0x4014
jmp 0x4134
cmpl $0x0, 0xe438(%rip)      # 0x12458
jne 0x4132
cmpl $0x1, 0xe503(%rip)      # 0x12530
jne 0x408b
movl -0x1c(%rbp), %eax
subl $0x1, %eax
movl %eax, -0x20(%rbp)
cmpl $0x0, -0x20(%rbp)
jl 0x4086
cmpl $0x0, -0x20(%rbp)
jne 0x404d
movl -0x28(%rbp), %eax
movl %eax, 0xe4cb(%rip)      # 0x12518
movq 0xe3bc(%rip), %rax      # 0x12410
movsd -0x8(%rbp), %xmm0
movl -0xc(%rbp), %edi
movq -0x18(%rbp), %rcx
movslq -0x20(%rbp), %rdx
movl (%rcx,%rdx,4), %esi
callq *%rax
movsd -0x8(%rbp), %xmm0
subsd 0xe4b2(%rip), %xmm0     # 0x12528
callq 0x3870
movl -0x20(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x20(%rbp)
jmp 0x4038
jmp 0x4130
cmpl $0x0, 0xe49e(%rip)      # 0x12530
jne 0x412e
movl -0x1c(%rbp), %eax
subl $0x1, %eax
movl %eax, -0x20(%rbp)
cmpl $0x0, -0x20(%rbp)
jl 0x412c
movsd -0x8(%rbp), %xmm1
movsd 0xe470(%rip), %xmm0     # 0x12528
cvtsi2sdl -0x20(%rbp), %xmm2
movq %xmm0, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm0
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, -0x38(%rbp)
cmpl $0x0, -0x20(%rbp)
jne 0x40f0
movl -0x28(%rbp), %eax
movl %eax, 0xe428(%rip)      # 0x12518
movq 0xe319(%rip), %rax      # 0x12410
movsd -0x38(%rbp), %xmm0
movl -0xc(%rbp), %edi
movq -0x18(%rbp), %rcx
movslq -0x20(%rbp), %rdx
movl (%rcx,%rdx,4), %esi
callq *%rax
movsd -0x38(%rbp), %xmm0
subsd 0xe40f(%rip), %xmm0     # 0x12528
callq 0x3870
movl -0x20(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x20(%rbp)
jmp 0x40a1
jmp 0x412e
jmp 0x4130
jmp 0x4132
jmp 0x4134
cvtsi2sdl -0x24(%rbp), %xmm0
movsd %xmm0, -0x40(%rbp)
movsd -0x8(%rbp), %xmm0
callq 0x3980
movaps %xmm0, %xmm1
movsd -0x40(%rbp), %xmm0
addsd %xmm1, %xmm0
cvttsd2si %xmm0, %edi
callq 0x38f0
addq $0x40, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)