// File: /workspace/github_c_makefile_star2_O3/pipde[P]deos-songlib/lib/songlib.c
// Function: dtrill
void
dtrill(double beats,int inst1,int inst2,int octave,int pitch,int offset,
    double initial,double tlength,int count)
    {
    int i,j;
    int octaves[CHORD_LENGTH];
    int pitches[CHORD_LENGTH];
    double lengths[CHORD_LENGTH];

    octaves[0] = octave;
    pitches[0] = pitch;
    lengths[0] = initial;

    j = 1;
    for (i = 0; j < sizeof(octaves)/sizeof(int) && i < count; ++i)
        {
        octaves[j] = octave;
        pitches[j] = pitch + offset;
        lengths[j] = tlength;
        ++j;
        octaves[j] = octave;
        pitches[j] = pitch;
        lengths[j] = tlength;
        ++j;
        }

    /*
    for (i = 0; i < 2*count+1; ++i)
        printf("[%d,%d,%f]\n",octaves[i],pitches[i],lengths[i]);
    */

    adraw(beats,inst1,2*count+1,octaves,pitches,lengths);

    backwards(beats);

    softer(2);
    play(initial,inst2,octave,pitch);

    for (i = 0; i < count-1; ++i)
        {
        play(tlength,inst2,octave,pitch+offset);
        play(tlength,inst2,octave,pitch);
        }

    play(tlength,inst2,octave,pitch+offset);
    play(beats-initial-2*tlength*(count-1)-tlength,inst2,octave,pitch);

    louder(2);
    }

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x2028, %rsp           # imm = 0x2028
movl %r9d, %r12d
movl %r8d, %r15d
movl %ecx, %ebx
movl %edx, %ebp
movl %esi, %r14d
movaps %xmm0, 0x10(%rsp)
movl %edx, 0x820(%rsp)
movl %ecx, 0x20(%rsp)
movsd %xmm1, 0x8(%rsp)
movsd %xmm1, 0x1020(%rsp)
testl %r9d, %r9d
jle 0x4f31
leal (%r15,%rbx), %eax
leal -0x1(%r12), %ecx
movl $0xff, %edx
cmpq %rdx, %rcx
cmovbq %rcx, %rdx
leaq 0x8(,%rdx,8), %rcx
xorl %edx, %edx
movl %ebp, 0x824(%rsp,%rdx)
movl %eax, 0x24(%rsp,%rdx)
movsd %xmm2, 0x1028(%rsp,%rdx,2)
movl %ebp, 0x828(%rsp,%rdx)
movl %ebx, 0x28(%rsp,%rdx)
movsd %xmm2, 0x1030(%rsp,%rdx,2)
addq $0x8, %rdx
cmpl %edx, %ecx
jne 0x4f01
movsd %xmm2, (%rsp)
leal 0x1(,%r12,2), %esi
leaq 0x820(%rsp), %rdx
leaq 0x20(%rsp), %rcx
leaq 0x1020(%rsp), %r8
movaps 0x10(%rsp), %xmm0
callq 0x41da
movaps 0x53ac(%rip), %xmm0     # 0xa310
xorps 0x10(%rsp), %xmm0
callq 0x543b
movsd 0xa4f2(%rip), %xmm0     # 0xf468
mulsd 0x52ea(%rip), %xmm0     # 0xa268
movsd %xmm0, 0xa4e2(%rip)     # 0xf468
movabsq $0x4000000000000000, %rdx # imm = 0x4000000000000000
movq %rdx, 0xa489(%rip)      # 0xf420
movl 0x1a933(%rip), %eax     # 0x1f8d0
cmpq $0x1fe, %rax            # imm = 0x1FE
ja 0x4fb9
leal 0x1(%rax), %ecx
movl %ecx, 0x1a922(%rip)     # 0x1f8d0
leaq 0x1a92b(%rip), %rcx     # 0x1f8e0
movq %rdx, (%rcx,%rax,8)
movsd 0x8(%rsp), %xmm0
movl %r14d, %edi
movl %ebp, %esi
movl %ebx, %edx
callq *0xa47c(%rip)           # 0xf448
leal -0x1(%r12), %r13d
addl %ebx, %r15d
cmpl $0x2, %r12d
movsd (%rsp), %xmm0
jl 0x5011
movl %r13d, %r12d
movsd (%rsp), %xmm0
movl %r14d, %edi
movl %ebp, %esi
movl %r15d, %edx
callq *0xa453(%rip)           # 0xf448
movsd (%rsp), %xmm0
movl %r14d, %edi
movl %ebp, %esi
movl %ebx, %edx
callq *0xa441(%rip)           # 0xf448
movsd (%rsp), %xmm0
decl %r12d
jne 0x4fe2
movl %r14d, %edi
movl %ebp, %esi
movl %r15d, %edx
callq *0xa429(%rip)           # 0xf448
movapd 0x10(%rsp), %xmm2
subsd 0x8(%rsp), %xmm2
cvtsi2sd %r13d, %xmm1
movsd 0x52a8(%rip), %xmm0     # 0xa2e0
movsd (%rsp), %xmm3
mulsd %xmm3, %xmm0
mulsd %xmm1, %xmm0
addsd %xmm2, %xmm0
subsd %xmm3, %xmm0
movl %r14d, %edi
movl %ebp, %esi
movl %ebx, %edx
callq *0xa3ee(%rip)           # 0xf448
movsd 0xa406(%rip), %xmm0     # 0xf468
addsd %xmm0, %xmm0
movsd %xmm0, 0xa3fa(%rip)     # 0xf468
movabsq $0x4000000000000000, %rdx # imm = 0x4000000000000000
movq %rdx, 0xa3a1(%rip)      # 0xf420
movl 0x1a84b(%rip), %eax     # 0x1f8d0
cmpq $0x1fe, %rax            # imm = 0x1FE
ja 0x50a1
leal 0x1(%rax), %ecx
movl %ecx, 0x1a83a(%rip)     # 0x1f8d0
leaq 0x1a843(%rip), %rcx     # 0x1f8e0
movq %rdx, (%rcx,%rax,8)
addq $0x2028, %rsp           # imm = 0x2028
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq