// File: /workspace/github_c_makefile_star2_O1/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 $0x2038, %rsp           # imm = 0x2038
movl %r9d, %r12d
movl %ecx, %ebx
movl %edx, %ebp
movl %esi, %r14d
movaps %xmm0, 0x20(%rsp)
movl %edx, 0x830(%rsp)
movl %ecx, 0x30(%rsp)
movsd %xmm1, 0x18(%rsp)
movsd %xmm1, 0x1030(%rsp)
testl %r9d, %r9d
jle 0x4e27
leal (%r8,%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, 0x834(%rsp,%rdx)
movl %eax, 0x34(%rsp,%rdx)
movsd %xmm2, 0x1038(%rsp,%rdx,2)
movl %ebp, 0x838(%rsp,%rdx)
movl %ebx, 0x38(%rsp,%rdx)
movsd %xmm2, 0x1040(%rsp,%rdx,2)
addq $0x8, %rdx
cmpl %edx, %ecx
jne 0x4df7
movq %r8, 0x10(%rsp)
movsd %xmm2, 0x8(%rsp)
leal 0x1(,%r12,2), %esi
leaq 0x830(%rsp), %rdx
leaq 0x30(%rsp), %rcx
leaq 0x1030(%rsp), %r8
movaps 0x20(%rsp), %xmm0
callq 0x420c
movaps 0x5490(%rip), %xmm0     # 0xa2f0
xorps 0x20(%rsp), %xmm0
callq 0x5359
movsd 0xa5f6(%rip), %xmm0     # 0xf468
mulsd 0x53ee(%rip), %xmm0     # 0xa268
movsd %xmm0, 0xa5e6(%rip)     # 0xf468
movabsq $0x4000000000000000, %rdx # imm = 0x4000000000000000
movq %rdx, 0xa58d(%rip)      # 0xf420
movl 0x1aa37(%rip), %eax     # 0x1f8d0
cmpq $0x1fe, %rax            # imm = 0x1FE
ja 0x4eb5
leal 0x1(%rax), %ecx
movl %ecx, 0x1aa26(%rip)     # 0x1f8d0
leaq 0x1aa2f(%rip), %rcx     # 0x1f8e0
movq %rdx, (%rcx,%rax,8)
movsd 0x18(%rsp), %xmm0
movl %r14d, %edi
movl %ebp, %esi
movl %ebx, %edx
callq *0xa580(%rip)           # 0xf448
leal -0x1(%r12), %r15d
cmpl $0x2, %r12d
movsd 0x8(%rsp), %xmm0
jl 0x4f17
movq 0x10(%rsp), %rax
leal (%rax,%rbx), %r12d
movl %r15d, %r13d
movsd 0x8(%rsp), %xmm0
movl %r14d, %edi
movl %ebp, %esi
movl %r12d, %edx
callq *0xa54f(%rip)           # 0xf448
movsd 0x8(%rsp), %xmm0
movl %r14d, %edi
movl %ebp, %esi
movl %ebx, %edx
callq *0xa53c(%rip)           # 0xf448
movsd 0x8(%rsp), %xmm0
decl %r13d
jne 0x4ee5
movq 0x10(%rsp), %rdx
addl %ebx, %edx
movl %r14d, %edi
movl %ebp, %esi
callq *0xa51f(%rip)           # 0xf448
movapd 0x20(%rsp), %xmm2
subsd 0x18(%rsp), %xmm2
cvtsi2sd %r15d, %xmm1
movsd 0x5386(%rip), %xmm0     # 0xa2c8
movsd 0x8(%rsp), %xmm3
mulsd %xmm3, %xmm0
mulsd %xmm1, %xmm0
addsd %xmm2, %xmm0
subsd %xmm3, %xmm0
movl %r14d, %edi
movl %ebp, %esi
movl %ebx, %edx
callq *0xa4e3(%rip)           # 0xf448
movsd 0xa4fb(%rip), %xmm0     # 0xf468
addsd %xmm0, %xmm0
movsd %xmm0, 0xa4ef(%rip)     # 0xf468
movabsq $0x4000000000000000, %rdx # imm = 0x4000000000000000
movq %rdx, 0xa496(%rip)      # 0xf420
movl 0x1a940(%rip), %eax     # 0x1f8d0
cmpq $0x1fe, %rax            # imm = 0x1FE
ja 0x4fac
leal 0x1(%rax), %ecx
movl %ecx, 0x1a92f(%rip)     # 0x1f8d0
leaq 0x1a938(%rip), %rcx     # 0x1f8e0
movq %rdx, (%rcx,%rax,8)
addq $0x2038, %rsp           # imm = 0x2038
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq