// File: /workspace/github_c_makefile_star2_O0/pipde[P]deos-songlib/lib/songlib.c
// Function: getNumberedSampleSet
static SAMPLE_SET *
getNumberedSampleSet(int inst, int baseNote)
    {
    int spot;
    double factor;
    SAMPLE_SET *ss = 0;

    if (baseNote < 0 || baseNote >= OCTAVES * NOTES)
        Fatal("pitch out of range, inst %d, note %d\n",inst,baseNote);
       
    /* see if the note exists */

    if (scale[inst][baseNote] != 0) return scale[inst][baseNote];

    /* it doesn't, so force a read of the closest note */

    readClosestNote(inst,baseNote);

    /* see if the note exists now */

    if (scale[inst][baseNote] != 0) return scale[inst][baseNote];

    /* it doesn't, so find the closest note and pitch shift it */

    spot = findClosestNote(inst,baseNote);

    factor = pow(SEMITONE,baseNote-spot);

    dDebug("factor was %g\n", factor);

    ss = scale[inst][spot];

    /*
    printf("generating %s%s%d (using %s%s%d)\n",
            InstrumentBase[inst],
            NoteNames[baseNote % NOTES],baseNote / NOTES,
            InstrumentBase[inst],
            NoteNames[spot%NOTES],spot/NOTES
            );
    */

    originals[inst][baseNote] = 0;
    
    ss = resampleSet(ss,factor);
    //printf ("    SUCCESS!\n");
    setNumberedSampleSet(inst, baseNote, ss);

    return ss;
    }

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movl %edi, -0xc(%rbp)
movl %esi, -0x10(%rbp)
movq $0x0, -0x28(%rbp)
cmpl $0x0, -0x10(%rbp)
jl 0x7415
cmpl $0x84, -0x10(%rbp)
jl 0x7429
movl -0xc(%rbp), %esi
movl -0x10(%rbp), %edx
leaq 0x626a(%rip), %rdi      # 0xd68c
movb $0x0, %al
callq 0x8c70
movslq -0xc(%rbp), %rcx
leaq 0x1038c(%rip), %rax     # 0x177c0
imulq $0x420, %rcx, %rcx      # imm = 0x420
addq %rcx, %rax
movslq -0x10(%rbp), %rcx
cmpq $0x0, (%rax,%rcx,8)
je 0x746f
movslq -0xc(%rbp), %rcx
leaq 0x1036c(%rip), %rax     # 0x177c0
imulq $0x420, %rcx, %rcx      # imm = 0x420
addq %rcx, %rax
movslq -0x10(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq %rax, -0x8(%rbp)
jmp 0x7554
movl -0xc(%rbp), %edi
movl -0x10(%rbp), %esi
callq 0x8380
movslq -0xc(%rbp), %rcx
leaq 0x1033b(%rip), %rax     # 0x177c0
imulq $0x420, %rcx, %rcx      # imm = 0x420
addq %rcx, %rax
movslq -0x10(%rbp), %rcx
cmpq $0x0, (%rax,%rcx,8)
je 0x74c0
movslq -0xc(%rbp), %rcx
leaq 0x1031b(%rip), %rax     # 0x177c0
imulq $0x420, %rcx, %rcx      # imm = 0x420
addq %rcx, %rax
movslq -0x10(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq %rax, -0x8(%rbp)
jmp 0x7554
movl -0xc(%rbp), %edi
movl -0x10(%rbp), %esi
callq 0x8480
movl %eax, -0x14(%rbp)
movl -0x10(%rbp), %eax
subl -0x14(%rbp), %eax
cvtsi2sd %eax, %xmm1
movsd 0x5e98(%rip), %xmm0     # 0xd378
callq 0x2080
movsd %xmm0, -0x20(%rbp)
movslq -0xc(%rbp), %rcx
leaq 0x102cb(%rip), %rax     # 0x177c0
imulq $0x420, %rcx, %rcx      # imm = 0x420
addq %rcx, %rax
movslq -0x14(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq %rax, -0x28(%rbp)
movslq -0xc(%rbp), %rcx
leaq 0xb02a(%rip), %rax      # 0x12540
imulq $0x210, %rcx, %rcx      # imm = 0x210
addq %rcx, %rax
movslq -0x10(%rbp), %rcx
movl $0x0, (%rax,%rcx,4)
movq -0x28(%rbp), %rdi
movsd -0x20(%rbp), %xmm0
callq 0x8540
movq %rax, -0x28(%rbp)
movl -0xc(%rbp), %edi
movl -0x10(%rbp), %esi
movq -0x28(%rbp), %rdx
callq 0x7280
movq -0x28(%rbp), %rax
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x30, %rsp
popq %rbp
retq
nop