// File: /workspace/github_c_makefile_star2_O0/archer1357[P]Offline-Raytracer/avilib.c
// Function: AVI_read_audio_chunk
long AVI_read_audio_chunk(avi_t *AVI, char *audbuf)
{
   long pos, left;

   if(AVI->mode==AVI_MODE_WRITE) { AVI_errno = AVI_ERR_NOT_PERM; return -1; }
   if(!AVI->track[AVI->aptr].audio_index)         { AVI_errno = AVI_ERR_NO_IDX;   return -1; }

   if (AVI->track[AVI->aptr].audio_index[AVI->track[AVI->aptr].audio_posc].len == 0) return 0;
   left = AVI->track[AVI->aptr].audio_index[AVI->track[AVI->aptr].audio_posc].len - AVI->track[AVI->aptr].audio_posb;

   if (audbuf == NULL) return left;

   if(left==0) return 0;

   pos = AVI->track[AVI->aptr].audio_index[AVI->track[AVI->aptr].audio_posc].pos + AVI->track[AVI->aptr].audio_posb;
   lseek(AVI->fdes, pos, SEEK_SET);
   if (avi_read(AVI->fdes,audbuf,left) != left)
   {
      AVI_errno = AVI_ERR_READ;
      return -1;
   }
   AVI->track[AVI->aptr].audio_posc++;
   AVI->track[AVI->aptr].audio_posb = 0;

   return left;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq -0x10(%rbp), %rax
cmpq $0x0, 0x8(%rax)
jne 0x407a53
movq $0x7, 0x120eea(%rip) # 0x528930
movq $-0x1, -0x8(%rbp)
jmp 0x407c68
movq -0x10(%rbp), %rax
addq $0x60, %rax
movq -0x10(%rbp), %rcx
movslq 0x43c(%rcx), %rcx
imulq $0x70, %rcx, %rcx
addq %rcx, %rax
cmpq $0x0, 0x68(%rax)
jne 0x407a8c
movq $0xd, 0x120eb1(%rip) # 0x528930
movq $-0x1, -0x8(%rbp)
jmp 0x407c68
movq -0x10(%rbp), %rax
addq $0x60, %rax
movq -0x10(%rbp), %rcx
movslq 0x43c(%rcx), %rcx
imulq $0x70, %rcx, %rcx
addq %rcx, %rax
movq 0x68(%rax), %rax
movq -0x10(%rbp), %rcx
addq $0x60, %rcx
movq -0x10(%rbp), %rdx
movslq 0x43c(%rdx), %rdx
imulq $0x70, %rdx, %rdx
addq %rdx, %rcx
imulq $0x18, 0x48(%rcx), %rcx
addq %rcx, %rax
cmpq $0x0, 0x8(%rax)
jne 0x407ae0
movq $0x0, -0x8(%rbp)
jmp 0x407c68
movq -0x10(%rbp), %rax
addq $0x60, %rax
movq -0x10(%rbp), %rcx
movslq 0x43c(%rcx), %rcx
imulq $0x70, %rcx, %rcx
addq %rcx, %rax
movq 0x68(%rax), %rax
movq -0x10(%rbp), %rcx
addq $0x60, %rcx
movq -0x10(%rbp), %rdx
movslq 0x43c(%rdx), %rdx
imulq $0x70, %rdx, %rdx
addq %rdx, %rcx
imulq $0x18, 0x48(%rcx), %rcx
addq %rcx, %rax
movq 0x8(%rax), %rax
movq -0x10(%rbp), %rcx
addq $0x60, %rcx
movq -0x10(%rbp), %rdx
movslq 0x43c(%rdx), %rdx
imulq $0x70, %rdx, %rdx
addq %rdx, %rcx
subq 0x50(%rcx), %rax
movq %rax, -0x28(%rbp)
cmpq $0x0, -0x18(%rbp)
jne 0x407b5a
movq -0x28(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0x407c68
cmpq $0x0, -0x28(%rbp)
jne 0x407b6e
movq $0x0, -0x8(%rbp)
jmp 0x407c68
movq -0x10(%rbp), %rax
addq $0x60, %rax
movq -0x10(%rbp), %rcx
movslq 0x43c(%rcx), %rcx
imulq $0x70, %rcx, %rcx
addq %rcx, %rax
movq 0x68(%rax), %rax
movq -0x10(%rbp), %rcx
addq $0x60, %rcx
movq -0x10(%rbp), %rdx
movslq 0x43c(%rdx), %rdx
imulq $0x70, %rdx, %rdx
addq %rdx, %rcx
imulq $0x18, 0x48(%rcx), %rcx
addq %rcx, %rax
movq (%rax), %rax
movq -0x10(%rbp), %rcx
addq $0x60, %rcx
movq -0x10(%rbp), %rdx
movslq 0x43c(%rdx), %rdx
imulq $0x70, %rdx, %rdx
addq %rdx, %rcx
addq 0x50(%rcx), %rax
movq %rax, -0x20(%rbp)
movq -0x10(%rbp), %rax
movq (%rax), %rax
movl %eax, %edi
movq -0x20(%rbp), %rsi
xorl %edx, %edx
callq 0x48fba0
movq -0x10(%rbp), %rax
movq (%rax), %rax
movl %eax, %edi
movq -0x18(%rbp), %rsi
movq -0x28(%rbp), %rdx
callq 0x406dc0
cmpq -0x28(%rbp), %rax
je 0x407c18
movq $0x3, 0x120d22(%rip) # 0x528930
movq $-0x1, -0x8(%rbp)
jmp 0x407c68
movq -0x10(%rbp), %rax
addq $0x60, %rax
movq -0x10(%rbp), %rcx
movslq 0x43c(%rcx), %rcx
imulq $0x70, %rcx, %rcx
addq %rcx, %rax
movq 0x48(%rax), %rcx
addq $0x1, %rcx
movq %rcx, 0x48(%rax)
movq -0x10(%rbp), %rax
addq $0x60, %rax
movq -0x10(%rbp), %rcx
movslq 0x43c(%rcx), %rcx
imulq $0x70, %rcx, %rcx
addq %rcx, %rax
movq $0x0, 0x50(%rax)
movq -0x28(%rbp), %rax
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x30, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)