// File: /workspace/github_c_makefile_star2_O3/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 0x351d(%rip), %rsi      # 0xa7e0
addq %rcx, %rsi
movzbl (%rdx,%rsi), %ecx
movslq 0xc(%rdi), %rdx
leaq (%rcx,%rcx,2), %rcx
leaq 0x314f(%rip), %rsi      # 0xa428
addq %rcx, %rsi
movzbl (%rdx,%rsi), %ecx
movl %ecx, %r15d
movq %r15, 0x30(%rsp)
andl $0x3f, %r15d
cmpl %r15d, %eax
jle 0x72f8
movl %r15d, 0x20(%rbx)
movl %r15d, %eax
shrl $0x6, %ecx
testl %eax, %eax
movq %r15, 0x8(%rsp)
jle 0x73b1
movq %rcx, 0x18(%rsp)
shll $0x5, %ecx
movq %rcx, 0x10(%rsp)
leaq 0x3124(%rip), %r13      # 0xa440
xorl %r14d, %r14d
movq 0x10(%rsp), %rax
addq %r14, %rax
leaq 0x32b2(%rip), %rcx      # 0xa5e0
movzbl (%rcx,%rax), %ebp
movl %ebp, %r12d
andl $0xf, %r12d
movq 0x30(%rbx), %rdi
shrl $0x4, %ebp
movl %ebp, %esi
callq 0x4215
cltq
shll $0x4, %r12d
leaq 0x32ec(%rip), %rcx      # 0xa640
addq %rcx, %r12
movzbl (%rax,%r12), %eax
testl %eax, %eax
leaq -0x4(%r13,%rax,4), %rax
movl $0x0, %r15d
cmoveq %r15, %rax
movq %rax, 0x40(%rbx,%r14,8)
movq 0x30(%rbx), %rdi
movl %ebp, %esi
callq 0x4215
cltq
movzbl (%rax,%r12), %eax
testl %eax, %eax
leaq -0x4(%r13,%rax,4), %rax
cmoveq %r15, %rax
movq %rax, 0x140(%rbx,%r14,8)
incq %r14
movslq 0x20(%rbx), %rax
cmpq %rax, %r14
jl 0x731f
movq 0x8(%rsp), %r15
movq 0x18(%rsp), %rcx
subl %eax, %r15d
jle 0x742a
cltq
shll $0x5, %ecx
leaq 0x321e(%rip), %r14      # 0xa5e0
addq %rcx, %r14
addq %rax, %r14
leaq (%rbx,%rax,8), %r12
addq $0x140, %r12            # imm = 0x140
xorl %r13d, %r13d
movzbl (%r14,%r13), %esi
movl %esi, %ebp
andl $0xf, %ebp
movq 0x30(%rbx), %rdi
shrl $0x4, %esi
callq 0x4215
cltq
shll $0x4, %ebp
leaq 0x3248(%rip), %rcx      # 0xa640
addq %rcx, %rbp
movzbl (%rax,%rbp), %eax
testl %eax, %eax
leaq 0x3038(%rip), %rcx      # 0xa440
leaq -0x4(%rcx,%rax,4), %rax
movl $0x0, %ecx
cmovneq %rax, %rcx
movq %rcx, (%r12,%r13,8)
movq %rcx, -0x100(%r12,%r13,8)
incq %r13
cmpl %r13d, %r15d
jne 0x73d6
xorl %eax, %eax
cmpl $0x3, 0x1c(%rbx)
setne %cl
cmpl $0x0, 0x8(%rsp)
je 0x760e
movb %cl, %al
incl %eax
movl %eax, %r13d
xorl %r14d, %r14d
movq %r13, %r15
movq %r14, %r12
cmpq $0x0, 0x40(%rbx,%r12,8)
je 0x746c
movq 0x30(%rbx), %rdi
movl $0x2, %esi
callq 0x4215
movb %al, 0x240(%rbx,%r12)
addq $0x20, %r12
decq %r15
jne 0x744e
cmpl $0x3, 0x1c(%rbx)
jne 0x748b
movb 0x240(%rbx,%r14), %al
movb %al, 0x260(%rbx,%r14)
incq %r14
cmpq 0x8(%rsp), %r14
jne 0x7448
movq %r13, 0x48(%rsp)
cmpl $0x0, 0x8(%rsp)
je 0x760e
leaq 0x280(%rbx), %rax
movq %rax, 0x20(%rsp)
leaq 0x400(%rbx), %rax
movq %rax, 0x38(%rsp)
movl 0x8(%rsp), %eax
movq %rax, 0x40(%rsp)
movl $0x240, %r14d           # imm = 0x240
movl $0x288, %r12d           # imm = 0x288
xorl %r13d, %r13d
leaq 0x1db4(%rip), %rbp      # 0x9290
movq 0x48(%rsp), %r15
movq %r12, 0x18(%rsp)
movq %r14, 0x10(%rsp)
cmpq $0x0, -0x11c0(%rbx,%r14,8)
je 0x75af
movzbl (%rbx,%r14), %eax
cmpq $0x3, %rax
ja 0x75af
movslq (%rbp,%rax,4), %rax
addq %rbp, %rax
jmpq *%rax
movq 0x30(%rbx), %rdi
movl $0x6, %esi
callq 0x4215
movl %eax, -0x8(%rbx,%r12)
movq 0x30(%rbx), %rdi
movl $0x6, %esi
callq 0x4215
movl %eax, -0x4(%rbx,%r12)
jmp 0x7571
movq 0x30(%rbx), %rdi
movl $0x6, %esi
callq 0x4215
movl %eax, (%rbx,%r12)
movl %eax, -0x4(%rbx,%r12)
movl %eax, -0x8(%rbx,%r12)
jmp 0x75af
movq 0x30(%rbx), %rdi
movl $0x6, %esi
callq 0x4215
movl %eax, -0x4(%rbx,%r12)
movl %eax, -0x8(%rbx,%r12)
movq 0x30(%rbx), %rdi
movl $0x6, %esi
callq 0x4215
movl %eax, (%rbx,%r12)
jmp 0x75af
movq 0x30(%rbx), %rdi
movl $0x6, %esi
callq 0x4215
movl %eax, -0x8(%rbx,%r12)
movq 0x30(%rbx), %rdi
movl $0x6, %esi
callq 0x4215
movl %eax, (%rbx,%r12)
movl %eax, -0x4(%rbx,%r12)
addq $0x20, %r14
addq $0x180, %r12            # imm = 0x180
decq %r15
jne 0x74eb
cmpl $0x3, 0x1c(%rbx)
jne 0x75ef
leaq (,%r13,4), %rax
leaq (%rax,%rax,2), %rax
movq 0x20(%rsp), %rdx
movq (%rdx,%rax), %rcx
movq 0x38(%rsp), %rsi
movq %rcx, (%rsi,%rax)
movl 0x8(%rdx,%rax), %ecx
movl %ecx, 0x8(%rsi,%rax)
incq %r13
movq 0x10(%rsp), %r14
incq %r14
movq 0x18(%rsp), %r12
addq $0xc, %r12
cmpq 0x40(%rsp), %r13
jne 0x74dc
leaq 0x580(%rbx), %rax
movq %rax, 0x48(%rsp)
leaq 0x3c90(%rbx), %rax
movq %rax, 0x40(%rsp)
leaq 0x5c90(%rbx), %rbp
movq 0x30(%rsp), %rax
andl $0x3f, %eax
leaq 0x708(%rbx), %rcx
movq %rcx, 0x30(%rsp)
shll $0x2, %eax
leaq (%rax,%rax,2), %rax
movq %rax, 0x50(%rsp)
leaq 0x2c90(%rbx), %r13
xorl %eax, %eax
xorl %edx, %edx
movl %eax, 0x2c(%rsp)
xorl %eax, %eax
movl %eax, 0x38(%rsp)
movq %rdx, 0x20(%rsp)
movl 0x20(%rbx), %r14d
testl %r14d, %r14d
movl 0x2c(%rsp), %r12d
jle 0x76a7
xorl %r15d, %r15d
movq %rbx, %rdi
xorl %esi, %esi
movl %r15d, %edx
movl %r12d, %ecx
callq 0x79f8
movq %rbx, %rdi
movl $0x1, %esi
movl %r15d, %edx
movl %r12d, %ecx
callq 0x79f8
incl %r15d
movl 0x20(%rbx), %r14d
cmpl %r14d, %r15d
jl 0x7678
movq 0x8(%rsp), %rcx
cmpl %ecx, %r14d
jge 0x76f7
movslq %r14d, %rax
leaq (%rax,%rax,2), %rax
movq 0x30(%rsp), %rcx
leaq (%rcx,%rax,4), %r15
movq %rbx, %rdi
xorl %esi, %esi
movl %r14d, %edx
movl %r12d, %ecx
callq 0x79f8
movq 0x8(%rsp), %rcx
movq -0x188(%r15), %rax
movq %rax, -0x8(%r15)
movl -0x180(%r15), %eax
movl %eax, (%r15)
addq $0xc, %r15
incl %r14d
cmpl %r14d, %ecx
jne 0x76c1
movq 0x50(%rsp), %rax
cmpl $0x1f, %ecx
movq 0x30(%rsp), %rcx
movl $0x0, %edx
ja 0x772e
movq %rdx, -0x188(%rcx,%rax)
movl %edx, -0x180(%rcx,%rax)
movq %rdx, -0x8(%rcx,%rax)
movl %edx, (%rcx,%rax)
addq $0xc, %rax
cmpq $0x180, %rax            # imm = 0x180
jne 0x770b
movq 0x20(%rsp), %rdx
movl %edx, %eax
movl 0x24(%rbx), %ecx
addl %edx, %edx
movl $0x0, 0x10(%rsp)
movl %edx, 0x18(%rsp)
movq %rax, %rdx
movq %rdx, 0x20(%rsp)
addl $0x3c0, %ecx            # imm = 0x3C0
andl $0x3ff, %ecx            # imm = 0x3FF
movl %ecx, 0x24(%rbx)
movb $0x1, %r12b
xorl %r14d, %r14d
leaq (%r14,%r14,2), %rdi
shlq $0x7, %rdi
addq 0x48(%rsp), %rdi
movq %r14, %r15
shlq $0xc, %r15
addq 0x40(%rsp), %r15
movl 0x10(%rsp), %esi
movq %r15, %rdx
callq 0x7b8e
xorps %xmm0, %xmm0
movups %xmm0, 0x70(%rbp)
movups %xmm0, 0x60(%rbp)
movups %xmm0, 0x50(%rbp)
movups %xmm0, 0x40(%rbp)
movups %xmm0, 0x30(%rbp)
movups %xmm0, 0x20(%rbp)
movups %xmm0, 0x10(%rbp)
movups %xmm0, (%rbp)
movl 0x24(%rbx), %ecx
leal 0x7f(%rcx), %eax
testl %ecx, %ecx
cmovnsl %ecx, %eax
andl $-0x80, %eax
movl %ecx, %r8d
subl %eax, %r8d
sarl %r8d
movl %ecx, %edx
sarl %edx
movl $0x200, %eax            # imm = 0x200
subl %edx, %eax
movslq %r8d, %rsi
movslq %eax, %rdx
leaq (,%rdx,4), %r8
addq %r13, %r8
leaq (%r15,%rsi,4), %r9
xorl %edi, %edi
movss (%r8,%rdi,4), %xmm0
mulss (%r9,%rdi,4), %xmm0
addss 0x5c90(%rbx,%rdi,4), %xmm0
movss %xmm0, 0x5c90(%rbx,%rdi,4)
incq %rdi
cmpq $0x20, %rdi
jne 0x77e4
leal (%rsi,%rdi), %r8d
addl $0x60, %r8d
addl %edi, %eax
addl $0x20, %eax
leaq (%rsi,%rdi), %r9
decq %r9
cmpq $0x39f, %r9             # imm = 0x39F
jl 0x77cd
addq %rdi, %rsi
movl $0x400, %r8d            # imm = 0x400
subq %rsi, %r8
addq %rdi, %rdx
addq $-0x1c0, %rdx           # imm = 0xFE40
movss 0x2e5a(%rip), %xmm1     # 0xa6a0
movslq %r8d, %rax
movslq %edx, %rdx
leaq (,%rdx,4), %rdi
addq %r13, %rdi
leaq (%r15,%rax,4), %r8
xorl %esi, %esi
movss (%rdi,%rsi,4), %xmm0
mulss (%r8,%rsi,4), %xmm0
addss 0x5c90(%rbx,%rsi,4), %xmm0
movss %xmm0, 0x5c90(%rbx,%rsi,4)
incq %rsi
cmpq $0x20, %rsi
jne 0x785d
leaq (%rax,%rsi), %r8
addq $0x60, %r8
addq %rsi, %rdx
addq $0x20, %rdx
addq %rsi, %rax
decq %rax
cmpq $0x39f, %rax            # imm = 0x39F
jl 0x7846
addl 0x18(%rsp), %r14d
xorl %eax, %eax
movss 0x5c90(%rbx,%rax,2), %xmm0
divss %xmm1, %xmm0
leal (%r14,%rax), %edx
movslq %edx, %rdx
movss %xmm0, 0x88c(%rbx,%rdx,4)
addq $0x2, %rax
cmpq $0x40, %rax
jne 0x78a7
movl $0x1, %r14d
testb $0x1, %r12b
movl $0x0, %r12d
jne 0x7763
movq 0x20(%rsp), %rdx
addq $0x20, %rdx
movl 0x10(%rsp), %eax
incl %eax
addl $0x40, 0x18(%rsp)
movl %eax, 0x10(%rsp)
cmpl $0x3, %eax
jne 0x7749
movl 0x38(%rsp), %eax
incl %eax
cmpl $0x4, %eax
jne 0x765e
movl 0x2c(%rsp), %eax
incl %eax
cmpl $0x3, %eax
jne 0x7658
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