// File: /workspace/github_c_makefile_star2_O0/pipde[P]deos-songlib/utils/extract/extract.c
// Function: writeNote
static void
writeNote(int* data,int size,WAVE *w)
    {
    int i;
    FILE *fp;
    char buffer[512];

    //printf("Note is %d\n",Note);
    if (Repeats == 1)
        snprintf(buffer,sizeof(buffer),"%s%d_%d.rra",
            Base,TakeNumber,Note);
    else
        snprintf(buffer,sizeof(buffer),"%s%d_%d.rra",
            Base,TakeNumber + Note % Repeats,Note / Repeats);

    fp = OpenFile(buffer,"w");

    //printf("extracting note to %s...\n",buffer);

    fprintf(fp,"RRAUDIO\n");
    fprintf(fp,"channels: 1\n");
    fprintf(fp,"sampleRate: %d\n",w->SampleRate);
    fprintf(fp,"bitsPerSample: %d\n",w->BitsPerSample);
    fprintf(fp,"samples: %d\n",size);
    fprintf(fp,"%%%%\n");

    double gain = 0.1;
    double amplitude = 1.0;
    for (i = 0; i < size; ++i)
        {
        fprintf(fp,"%d\n",(int)((1 - amplitude) * data[i]));
        amplitude = amplitude * gain;
        }

    fclose(fp);

    ++Note;
    }

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x240, %rsp            # imm = 0x240
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movq %rdx, -0x18(%rbp)
cmpl $0x1, 0x562b(%rip)      # 0x7108
jne 0x1b10
leaq -0x230(%rbp), %rdi
movq 0x55fb(%rip), %rcx      # 0x70e8
movl 0x5624(%rip), %r8d      # 0x7118
movl 0x5631(%rip), %r9d      # 0x712c
movl $0x200, %esi            # imm = 0x200
leaq 0x264e(%rip), %rdx      # 0x4155
movb $0x0, %al
callq 0x10b0
jmp 0x1b58
leaq -0x230(%rbp), %rdi
movq 0x55ca(%rip), %rcx      # 0x70e8
movl 0x55f3(%rip), %r8d      # 0x7118
movl 0x5601(%rip), %eax      # 0x712c
cltd
idivl 0x55d6(%rip)            # 0x7108
addl %edx, %r8d
movl 0x55f1(%rip), %eax      # 0x712c
cltd
idivl 0x55c6(%rip)            # 0x7108
movl %eax, %r9d
movl $0x200, %esi            # imm = 0x200
leaq 0x2604(%rip), %rdx      # 0x4155
movb $0x0, %al
callq 0x10b0
leaq -0x230(%rbp), %rdi
leaq 0x25a2(%rip), %rsi      # 0x4108
callq 0x1df0
movq %rax, -0x28(%rbp)
movq -0x28(%rbp), %rdi
leaq 0x25e7(%rip), %rsi      # 0x4161
movb $0x0, %al
callq 0x10d0
movq -0x28(%rbp), %rdi
leaq 0x25de(%rip), %rsi      # 0x416a
movb $0x0, %al
callq 0x10d0
movq -0x28(%rbp), %rdi
movq -0x18(%rbp), %rax
movl 0x38(%rax), %edx
leaq 0x25d2(%rip), %rsi      # 0x4177
movb $0x0, %al
callq 0x10d0
movq -0x28(%rbp), %rdi
movq -0x18(%rbp), %rax
movl 0x44(%rax), %edx
leaq 0x25c9(%rip), %rsi      # 0x4187
movb $0x0, %al
callq 0x10d0
movq -0x28(%rbp), %rdi
movl -0xc(%rbp), %edx
leaq 0x25c7(%rip), %rsi      # 0x419a
movb $0x0, %al
callq 0x10d0
movq -0x28(%rbp), %rdi
leaq 0x25c2(%rip), %rsi      # 0x41a7
movb $0x0, %al
callq 0x10d0
movsd 0x24cc(%rip), %xmm0     # 0x40c0
movsd %xmm0, -0x238(%rbp)
movsd 0x248c(%rip), %xmm0     # 0x4090
movsd %xmm0, -0x240(%rbp)
movl $0x0, -0x1c(%rbp)
movl -0x1c(%rbp), %eax
cmpl -0xc(%rbp), %eax
jge 0x1c75
movq -0x28(%rbp), %rdi
movsd 0x2469(%rip), %xmm0     # 0x4090
subsd -0x240(%rbp), %xmm0
movq -0x8(%rbp), %rax
movslq -0x1c(%rbp), %rcx
cvtsi2sdl (%rax,%rcx,4), %xmm1
mulsd %xmm1, %xmm0
cvttsd2si %xmm0, %edx
leaq 0x29ed(%rip), %rsi      # 0x4638
movb $0x0, %al
callq 0x10d0
movsd -0x240(%rbp), %xmm0
mulsd -0x238(%rbp), %xmm0
movsd %xmm0, -0x240(%rbp)
movl -0x1c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c(%rbp)
jmp 0x1c13
movq -0x28(%rbp), %rdi
callq 0x1080
movl 0x54a8(%rip), %eax      # 0x712c
addl $0x1, %eax
movl %eax, 0x549f(%rip)      # 0x712c
addq $0x240, %rsp            # imm = 0x240
popq %rbp
retq
nopw %cs:(%rax,%rax)