// File: /workspace/github_c_makefile_star2_O2/phoboslab[P]pl_mpeg/./pl_mpeg.h
// Function: plm_audio_decode_frame
void plm_audio_decode_frame(plm_audio_t *self) {
	// Prepare the quantizer table lookups
	int tab3 = 0;
	int sblimit = 0;
	
	int tab1 = (self->mode == PLM_AUDIO_MODE_MONO) ? 0 : 1;
	int tab2 = PLM_AUDIO_QUANT_LUT_STEP_1[tab1][self->bitrate_index];
	tab3 = QUANT_LUT_STEP_2[tab2][self->samplerate_index];
	sblimit = tab3 & 63;
	tab3 >>= 6;

	if (self->bound > sblimit) {
		self->bound = sblimit;
	}

	// Read the allocation information
	for (int sb = 0; sb < self->bound; sb++) {
		self->allocation[0][sb] = plm_audio_read_allocation(self, sb, tab3);
		self->allocation[1][sb] = plm_audio_read_allocation(self, sb, tab3);
	}

	for (int sb = self->bound; sb < sblimit; sb++) {
		self->allocation[0][sb] =
			self->allocation[1][sb] =
			plm_audio_read_allocation(self, sb, tab3);
	}

	// Read scale factor selector information
	int channels = (self->mode == PLM_AUDIO_MODE_MONO) ? 1 : 2;
	for (int sb = 0; sb < sblimit; sb++) {
		for (int ch = 0; ch < channels; ch++) {
			if (self->allocation[ch][sb]) {
				self->scale_factor_info[ch][sb] = plm_buffer_read(self->buffer, 2);
			}
		}
		if (self->mode == PLM_AUDIO_MODE_MONO) {
			self->scale_factor_info[1][sb] = self->scale_factor_info[0][sb];
		}
	}

	// Read scale factors
	for (int sb = 0; sb < sblimit; sb++) {
		for (int ch = 0; ch < channels; ch++) {
			if (self->allocation[ch][sb]) {
				int *sf = self->scale_factor[ch][sb];
				switch (self->scale_factor_info[ch][sb]) {
					case 0:
						sf[0] = plm_buffer_read(self->buffer, 6);
						sf[1] = plm_buffer_read(self->buffer, 6);
						sf[2] = plm_buffer_read(self->buffer, 6);
						break;
					case 1:
						sf[0] = 
						sf[1] = plm_buffer_read(self->buffer, 6);
						sf[2] = plm_buffer_read(self->buffer, 6);
						break;
					case 2:
						sf[0] = 
						sf[1] = 
						sf[2] = plm_buffer_read(self->buffer, 6);
						break;
					case 3:
						sf[0] = plm_buffer_read(self->buffer, 6);
						sf[1] = 
						sf[2] = plm_buffer_read(self->buffer, 6);
						break;
				}
			}
		}
		if (self->mode == PLM_AUDIO_MODE_MONO) {
			self->scale_factor[1][sb][0] = self->scale_factor[0][sb][0];
			self->scale_factor[1][sb][1] = self->scale_factor[0][sb][1];
			self->scale_factor[1][sb][2] = self->scale_factor[0][sb][2];
		}
	}

	// Coefficient input and reconstruction
	int out_pos = 0;
	for (int part = 0; part < 3; part++) {
		for (int granule = 0; granule < 4; granule++) {

			// Read the samples
			for (int sb = 0; sb < self->bound; sb++) {
				plm_audio_read_samples(self, 0, sb, part);
				plm_audio_read_samples(self, 1, sb, part);
			}
			for (int sb = self->bound; sb < sblimit; sb++) {
				plm_audio_read_samples(self, 0, sb, part);
				self->sample[1][sb][0] = self->sample[0][sb][0];
				self->sample[1][sb][1] = self->sample[0][sb][1];
				self->sample[1][sb][2] = self->sample[0][sb][2];
			}
			for (int sb = sblimit; sb < 32; sb++) {
				self->sample[0][sb][0] = 0;
				self->sample[0][sb][1] = 0;
				self->sample[0][sb][2] = 0;
				self->sample[1][sb][0] = 0;
				self->sample[1][sb][1] = 0;
				self->sample[1][sb][2] = 0;
			}

			// Synthesis loop
			for (int p = 0; p < 3; p++) {
				// Shifting step
				self->v_pos = (self->v_pos - 64) & 1023;

				for (int ch = 0; ch < 2; ch++) {
					plm_audio_idct36(self->sample[ch], p, self->V[ch], self->v_pos);

					// Build U, windowing, calculate output
					memset(self->U, 0, sizeof(self->U));

					int d_index = 512 - (self->v_pos >> 1);
					int v_index = (self->v_pos % 128) >> 1;
					while (v_index < 1024) {
						for (int i = 0; i < 32; ++i) {
							self->U[i] += self->D[d_index++] * self->V[ch][v_index++];
						}

						v_index += 128 - 32;
						d_index += 64 - 32;
					}

					d_index -= (512 - 32);
					v_index = (128 - 32 + 1024) - v_index;
					while (v_index < 1024) {
						for (int i = 0; i < 32; ++i) {
							self->U[i] += self->D[d_index++] * self->V[ch][v_index++];
						}

						v_index += 128 - 32;
						d_index += 64 - 32;
					}

					// Output samples
					#ifdef PLM_AUDIO_SEPARATE_CHANNELS
						float *out_channel = ch == 0
							? self->samples.left
							: self->samples.right;
						for (int j = 0; j < 32; j++) {
							out_channel[out_pos + j] = self->U[j] / -1090519040.0f;
						}
					#else
						for (int j = 0; j < 32; j++) {
							self->samples.interleaved[((out_pos + j) << 1) + ch] = 
								self->U[j] / -1090519040.0f;
						}
					#endif
				} // End of synthesis channel loop
				out_pos += 32;
			} // End of synthesis sub-block loop

		} // Decoding of the granule finished
	}

	plm_buffer_align(self->buffer);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x58, %rsp
movq %rdi, %rbx
movl 0x20(%rdi), %eax
xorl %ecx, %ecx
cmpl $0x3, 0x1c(%rdi)
setne %cl
movslq 0x10(%rdi), %rdx
shll $0x4, %ecx
leaq 0x3023(%rip), %rsi      # 0x97a0
addq %rcx, %rsi
movzbl (%rdx,%rsi), %ecx
movslq 0xc(%rdi), %rdx
leaq (%rcx,%rcx,2), %rcx
leaq 0x2c55(%rip), %rsi      # 0x93e8
addq %rcx, %rsi
movzbl (%rdx,%rsi), %r14d
movl %r14d, %ecx
andl $0x3f, %ecx
movq %rcx, 0x10(%rsp)
cmpl %ecx, %eax
jle 0x67b2
movq 0x10(%rsp), %rax
movl %eax, 0x20(%rbx)
shrl $0x6, %r14d
leaq 0x40(%rbx), %r13
xorl %r15d, %r15d
movslq %eax, %r12
cmpq %r12, %r15
jge 0x6814
movq %rbx, %rdi
movl %r15d, %esi
movl %r14d, %edx
callq 0x6d5d
movq %rax, 0x40(%rbx,%r15,8)
movq %rbx, %rdi
movl %r15d, %esi
movl %r14d, %edx
callq 0x6d5d
movq %rax, 0x140(%rbx,%r15,8)
incq %r15
movl 0x20(%rbx), %eax
jmp 0x67bd
movq %rbx, %rdi
movl %r12d, %esi
movl %r14d, %edx
callq 0x6d5d
movq %rax, 0x140(%rbx,%r12,8)
movq %rax, 0x40(%rbx,%r12,8)
incq %r12
cmpq 0x10(%rsp), %r12
jl 0x67f6
xorl %r14d, %r14d
cmpl $0x3, 0x1c(%rbx)
setne %r14b
incl %r14d
leaq 0x240(%rbx), %r12
movl 0x10(%rsp), %eax
movq %rax, 0x28(%rsp)
shll $0x5, %r14d
xorl %ecx, %ecx
pushq $0x2
popq %rbp
movq %r12, 0x20(%rsp)
movq %r13, 0x8(%rsp)
cmpq 0x28(%rsp), %rcx
je 0x68a2
movq %rcx, 0x18(%rsp)
xorl %r15d, %r15d
cmpq %r15, %r14
je 0x687d
cmpq $0x0, (%r13,%r15,8)
je 0x6877
movq 0x30(%rbx), %rdi
movl %ebp, %esi
callq 0x3c08
movb %al, (%r12,%r15)
addq $0x20, %r15
jmp 0x685b
cmpl $0x3, 0x1c(%rbx)
movq 0x18(%rsp), %rcx
jne 0x6896
movb 0x240(%rbx,%rcx), %al
movb %al, 0x260(%rbx,%rcx)
incq %rcx
addq $0x8, %r13
incq %r12
jmp 0x684c
leaq 0x280(%rbx), %rax
movq %rax, 0x38(%rsp)
leaq 0x400(%rbx), %rax
movq %rax, 0x30(%rsp)
leaq 0x288(%rbx), %r15
xorl %edi, %edi
pushq $0x6
popq %rbp
movq 0x8(%rsp), %r13
cmpq 0x28(%rsp), %rdi
je 0x69eb
movq %rdi, 0x8(%rsp)
movq %r15, 0x18(%rsp)
xorl %r12d, %r12d
cmpq %r12, %r14
je 0x69a8
cmpq $0x0, (%r13,%r12,8)
je 0x6998
movq 0x20(%rsp), %rax
movzbl (%rax,%r12), %eax
cmpq $0x3, %rax
ja 0x6998
leaq 0x192d(%rip), %rcx      # 0x8240
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq 0x30(%rbx), %rdi
movl %ebp, %esi
callq 0x3c08
movl %eax, -0x8(%r15)
movq 0x30(%rbx), %rdi
movl %ebp, %esi
callq 0x3c08
movl %eax, -0x4(%r15)
jmp 0x698a
movq 0x30(%rbx), %rdi
movl %ebp, %esi
callq 0x3c08
movl %eax, (%r15)
movl %eax, -0x4(%r15)
movl %eax, -0x8(%r15)
jmp 0x6998
movq 0x30(%rbx), %rdi
movl %ebp, %esi
callq 0x3c08
movl %eax, -0x8(%r15)
movq 0x30(%rbx), %rdi
movl %ebp, %esi
callq 0x3c08
movl %eax, (%r15)
movl %eax, -0x4(%r15)
jmp 0x6998
movq 0x30(%rbx), %rdi
movl %ebp, %esi
callq 0x3c08
movl %eax, -0x4(%r15)
movl %eax, -0x8(%r15)
movq 0x30(%rbx), %rdi
movl %ebp, %esi
callq 0x3c08
movl %eax, (%r15)
addq $0x20, %r12
addq $0x180, %r15            # imm = 0x180
jmp 0x68e3
cmpl $0x3, 0x1c(%rbx)
movq 0x8(%rsp), %rdi
jne 0x69d1
imulq $0xc, %rdi, %rax
movq 0x38(%rsp), %rdx
movq (%rdx,%rax), %rcx
movq 0x30(%rsp), %rsi
movq %rcx, (%rsi,%rax)
movl 0x8(%rdx,%rax), %ecx
movl %ecx, 0x8(%rsi,%rax)
incq %rdi
addq $0x8, %r13
movq 0x18(%rsp), %r15
addq $0xc, %r15
incq 0x20(%rsp)
jmp 0x68cb
leaq 0x580(%rbx), %rax
movq %rax, 0x18(%rsp)
leaq 0x3c90(%rbx), %rax
movq %rax, 0x20(%rsp)
leaq 0x5c90(%rbx), %r14
leaq 0x708(%rbx), %rax
movq %rax, 0x50(%rsp)
imulq $0xc, 0x10(%rsp), %rax
addq %rbx, %rax
addq $0x708, %rax            # imm = 0x708
movq %rax, 0x48(%rsp)
leaq 0x2c90(%rbx), %rbp
xorl %r13d, %r13d
xorl %eax, %eax
cmpl $0x3, %eax
je 0x6cdc
xorl %ecx, %ecx
movl %eax, 0x8(%rsp)
cmpl $0x4, %ecx
je 0x6cd5
movl %ecx, 0x44(%rsp)
xorl %r12d, %r12d
movslq 0x20(%rbx), %r15
cmpl %r15d, %r12d
jge 0x6a86
movq %rbx, %rdi
xorl %esi, %esi
movl %r12d, %edx
movl 0x8(%rsp), %ecx
callq 0x6db0
movq %rbx, %rdi
pushq $0x1
popq %rsi
movl %r12d, %edx
movl 0x8(%rsp), %ecx
callq 0x6db0
incl %r12d
jmp 0x6a55
imulq $0xc, %r15, %r12
addq 0x50(%rsp), %r12
cmpq 0x10(%rsp), %r15
jge 0x6ac9
movq %rbx, %rdi
xorl %esi, %esi
movl %r15d, %edx
movl 0x8(%rsp), %ecx
callq 0x6db0
movq -0x188(%r12), %rax
movq %rax, -0x8(%r12)
movl -0x180(%r12), %eax
movl %eax, (%r12)
incq %r15
addq $0xc, %r12
jmp 0x6a8f
movq 0x48(%rsp), %rax
movq 0x10(%rsp), %rcx
cmpq $0x20, %rcx
jae 0x6af9
andq $0x0, -0x188(%rax)
andl $0x0, -0x180(%rax)
andq $0x0, -0x8(%rax)
andl $0x0, (%rax)
incq %rcx
addq $0xc, %rax
jmp 0x6ad3
movl %r13d, %eax
addl %r13d, %r13d
xorl %esi, %esi
cmpl $0x3, %esi
je 0x6cc3
movq %rax, 0x30(%rsp)
movl 0x24(%rbx), %ecx
movl $0x3c0, %eax            # imm = 0x3C0
addl %eax, %ecx
andl $0x3ff, %ecx            # imm = 0x3FF
movl %ecx, 0x24(%rbx)
movq %r13, 0x38(%rsp)
movq %r13, %r12
movq 0x20(%rsp), %r13
xorl %r15d, %r15d
movl %esi, 0x28(%rsp)
cmpq $0x2, %r15
je 0x6caa
imulq $0x180, %r15, %rdi      # imm = 0x180
addq 0x18(%rsp), %rdi
movq %r15, %rdx
shlq $0xc, %rdx
addq 0x20(%rsp), %rdx
callq 0x6f29
xorps %xmm0, %xmm0
movups %xmm0, 0x70(%r14)
movups %xmm0, 0x60(%r14)
movups %xmm0, 0x50(%r14)
movups %xmm0, 0x40(%r14)
movups %xmm0, 0x30(%r14)
movups %xmm0, 0x20(%r14)
movups %xmm0, 0x10(%r14)
movups %xmm0, (%r14)
movl 0x24(%rbx), %ecx
movl %ecx, %eax
sarl %eax
movl $0x200, %esi            # imm = 0x200
subl %eax, %esi
movl %ecx, %eax
cltd
movl $0x80, %edi
idivl %edi
sarl %edx
cmpl $0x3ff, %edx            # imm = 0x3FF
jg 0x6bfb
movslq %esi, %rax
movslq %edx, %rdi
leaq (,%rdi,4), %rdi
addq %r13, %rdi
leaq (,%rax,4), %r8
addq %rbp, %r8
xorl %eax, %eax
cmpq $0x20, %rax
je 0x6bef
movss (%r8,%rax,4), %xmm0
mulss (%rdi,%rax,4), %xmm0
addss 0x5c90(%rbx,%rax,4), %xmm0
movss %xmm0, 0x5c90(%rbx,%rax,4)
incq %rax
jmp 0x6bc7
addl %eax, %edx
addl $0x60, %edx
addl %eax, %esi
addl $0x20, %esi
jmp 0x6ba1
addl $0xfffffe20, %esi       # imm = 0xFFFFFE20
movl $0x460, %eax            # imm = 0x460
subl %edx, %eax
movss 0x2a50(%rip), %xmm1     # 0x9660
cmpl $0x400, %eax            # imm = 0x400
jge 0x6c69
movslq %esi, %rdx
movslq %eax, %rdi
leaq (,%rdi,4), %rdi
addq %r13, %rdi
leaq (,%rdx,4), %r8
addq %rbp, %r8
xorl %edx, %edx
cmpq $0x20, %rdx
je 0x6c5d
movss (%r8,%rdx,4), %xmm0
mulss (%rdi,%rdx,4), %xmm0
addss 0x5c90(%rbx,%rdx,4), %xmm0
movss %xmm0, 0x5c90(%rbx,%rdx,4)
incq %rdx
jmp 0x6c35
addl %edx, %eax
addl $0x60, %eax
addl %edx, %esi
addl $0x20, %esi
jmp 0x6c10
xorl %eax, %eax
movl 0x28(%rsp), %esi
cmpq $0x40, %rax
je 0x6c98
movss 0x5c90(%rbx,%rax,2), %xmm0
divss %xmm1, %xmm0
leal (%r12,%rax), %edx
movslq %edx, %rdx
movss %xmm0, 0x88c(%rbx,%rdx,4)
addq $0x2, %rax
jmp 0x6c6f
incq %r15
addq $0x1000, %r13           # imm = 0x1000
incq %r12
jmp 0x6b36
movq 0x30(%rsp), %rax
addq $0x20, %rax
incl %esi
movq 0x38(%rsp), %r13
addq $0x40, %r13
jmp 0x6b01
movl 0x44(%rsp), %ecx
incl %ecx
movl %eax, %r13d
movl 0x8(%rsp), %eax
jmp 0x6a45
incl %eax
jmp 0x6a36
movq 0x30(%rbx), %rax
movq (%rax), %rcx
addq $0x7, %rcx
andq $-0x8, %rcx
movq %rcx, (%rax)
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq