// File: /workspace/github_c_makefile_star2_O0/pipde[P]deos-songlib/lib/wave.c
// Function: readWaveHeader
void
readWaveHeader(WAVE *w,FILE *in)
    {
    w->ID = readByteString(in,4,ALLOCATE);
    //fprintf(stderr,"id is %s\n",w->ID);

    w->ChunkSize = readByteInt(in,4);
    //fprintf(stderr,"chunk size is %ld\n",w->ChunkSize);

    w->Format = readByteString(in,4,ALLOCATE);
    //fprintf(stderr,"format is %s\n",w->Format);

    while (!feof(in))
        {
        if (isID(in,"FMT "))
            {
            skip(in,4);
            break;
            }
        if (isID(in,"fmt "))
            {
            skip(in,4);
            break;
            }
        skip(in,1);
        }
            
    w->Subchunk1Size = readByteInt(in,4);
    //fprintf(stderr,"subchunk 1 size is %ld\n",w->Subchunk1Size);

    w->AudioFormat = readByteInt(in,2);
    //fprintf(stderr,"audio format is %d\n",w->AudioFormat);

    w->NumChannels = readByteInt(in,2);
    //fprintf(stderr,"# channels is %d\n",w->NumChannels);

    if (w->NumChannels == 0) w->NumChannels = 1;

    w->SampleRate = readByteInt(in,4);
    //fprintf(stderr,"sample rate is %d\n",w->SampleRate);

    w->ByteRate = readByteInt(in,4);
    //fprintf(stderr,"byte rate is %d\n",w->ByteRate);

    w->BlockAlign = readByteInt(in,2);
    //fprintf(stderr,"block align is %d\n",w->BlockAlign);

    w->BitsPerSample = readByteInt(in,2);
    //fprintf(stderr,"bits per sample is %d\n",w->BitsPerSample);

    if (w->BitsPerSample == 0) w->BitsPerSample = 16;

    while (!feof(in))
        {
        if (isID(in,"DATA"))
            {
            skip(in,4);
            break;
            }
        if (isID(in,"data"))
            {
            skip(in,4);
            break;
            }
        skip(in,1);
        }

    w->Subchunk2Size = readByteInt(in,4);
    //fprintf(stderr,"subchunk 2 size is %ld\n",w->Subchunk2Size);
            
    /* derived values */

    w->sampleCount = w->Subchunk2Size / (w->BitsPerSample / 8)
        / w->NumChannels;

    //fprintf(stderr,"sample count is %d\n",w->sampleCount);

    w->sampleWidth = w->BitsPerSample / 8;
    w->maxAmp = (int) pow(2,w->BitsPerSample - 1);
    }

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x10(%rbp), %rdi
movl $0x4, %esi
movl $0x1, %edx
callq 0x2980
movq %rax, %rcx
movq -0x8(%rbp), %rax
movq %rcx, (%rax)
movq -0x10(%rbp), %rdi
movl $0x4, %esi
callq 0x2a10
movslq %eax, %rcx
movq -0x8(%rbp), %rax
movq %rcx, 0x20(%rax)
movq -0x10(%rbp), %rdi
movl $0x4, %esi
movl $0x1, %edx
callq 0x2980
movq %rax, %rcx
movq -0x8(%rbp), %rax
movq %rcx, 0x8(%rax)
movq -0x10(%rbp), %rdi
callq 0x10e0
cmpl $0x0, %eax
setne %al
xorb $-0x1, %al
testb $0x1, %al
jne 0x273b
jmp 0x2795
movq -0x10(%rbp), %rdi
leaq 0x1f1b(%rip), %rsi      # 0x4661
callq 0x2a50
cmpl $0x0, %eax
je 0x2760
movq -0x10(%rbp), %rdi
movl $0x4, %esi
callq 0x2af0
jmp 0x2795
movq -0x10(%rbp), %rdi
leaq 0x1efb(%rip), %rsi      # 0x4666
callq 0x2a50
cmpl $0x0, %eax
je 0x2785
movq -0x10(%rbp), %rdi
movl $0x4, %esi
callq 0x2af0
jmp 0x2795
movq -0x10(%rbp), %rdi
movl $0x1, %esi
callq 0x2af0
jmp 0x2724
movq -0x10(%rbp), %rdi
movl $0x4, %esi
callq 0x2a10
movslq %eax, %rcx
movq -0x8(%rbp), %rax
movq %rcx, 0x28(%rax)
movq -0x10(%rbp), %rdi
movl $0x2, %esi
callq 0x2a10
movl %eax, %ecx
movq -0x8(%rbp), %rax
movl %ecx, 0x30(%rax)
movq -0x10(%rbp), %rdi
movl $0x2, %esi
callq 0x2a10
movl %eax, %ecx
movq -0x8(%rbp), %rax
movl %ecx, 0x34(%rax)
movq -0x8(%rbp), %rax
cmpl $0x0, 0x34(%rax)
jne 0x27f1
movq -0x8(%rbp), %rax
movl $0x1, 0x34(%rax)
movq -0x10(%rbp), %rdi
movl $0x4, %esi
callq 0x2a10
movl %eax, %ecx
movq -0x8(%rbp), %rax
movl %ecx, 0x38(%rax)
movq -0x10(%rbp), %rdi
movl $0x4, %esi
callq 0x2a10
movl %eax, %ecx
movq -0x8(%rbp), %rax
movl %ecx, 0x3c(%rax)
movq -0x10(%rbp), %rdi
movl $0x2, %esi
callq 0x2a10
movl %eax, %ecx
movq -0x8(%rbp), %rax
movl %ecx, 0x40(%rax)
movq -0x10(%rbp), %rdi
movl $0x2, %esi
callq 0x2a10
movl %eax, %ecx
movq -0x8(%rbp), %rax
movl %ecx, 0x44(%rax)
movq -0x8(%rbp), %rax
cmpl $0x0, 0x44(%rax)
jne 0x2862
movq -0x8(%rbp), %rax
movl $0x10, 0x44(%rax)
jmp 0x2864
movq -0x10(%rbp), %rdi
callq 0x10e0
cmpl $0x0, %eax
setne %al
xorb $-0x1, %al
testb $0x1, %al
jne 0x287b
jmp 0x28d5
movq -0x10(%rbp), %rdi
leaq 0x1de5(%rip), %rsi      # 0x466b
callq 0x2a50
cmpl $0x0, %eax
je 0x28a0
movq -0x10(%rbp), %rdi
movl $0x4, %esi
callq 0x2af0
jmp 0x28d5
movq -0x10(%rbp), %rdi
leaq 0x1dc5(%rip), %rsi      # 0x4670
callq 0x2a50
cmpl $0x0, %eax
je 0x28c5
movq -0x10(%rbp), %rdi
movl $0x4, %esi
callq 0x2af0
jmp 0x28d5
movq -0x10(%rbp), %rdi
movl $0x1, %esi
callq 0x2af0
jmp 0x2864
movq -0x10(%rbp), %rdi
movl $0x4, %esi
callq 0x2a10
movslq %eax, %rcx
movq -0x8(%rbp), %rax
movq %rcx, 0x48(%rax)
movq -0x8(%rbp), %rax
movq 0x48(%rax), %rax
movq %rax, -0x18(%rbp)
movq -0x8(%rbp), %rax
movl 0x44(%rax), %eax
movl $0x8, %ecx
cltd
idivl %ecx
movl %eax, %ecx
movq -0x18(%rbp), %rax
movslq %ecx, %rcx
cqto
idivq %rcx
movq -0x8(%rbp), %rcx
movslq 0x34(%rcx), %rcx
cqto
idivq %rcx
movl %eax, %ecx
movq -0x8(%rbp), %rax
movl %ecx, 0x78(%rax)
movq -0x8(%rbp), %rax
movl 0x44(%rax), %eax
movl $0x8, %ecx
cltd
idivl %ecx
movl %eax, %ecx
movq -0x8(%rbp), %rax
movl %ecx, 0x7c(%rax)
movq -0x8(%rbp), %rax
movl 0x44(%rax), %eax
subl $0x1, %eax
cvtsi2sd %eax, %xmm1
movsd 0x174d(%rip), %xmm0     # 0x40a8
callq 0x1070
cvttsd2si %xmm0, %ecx
movq -0x8(%rbp), %rax
movl %ecx, 0x80(%rax)
addq $0x20, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)