// File: /workspace/github_c_makefile_star2_O1/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
xorl %eax, %eax
cmpl $0x3, 0x1c(%rdi)
setne %al
movslq 0x10(%rdi), %rcx
shll $0x4, %eax
leaq 0x3303(%rip), %rdx      # 0xa620
addq %rax, %rdx
movzbl (%rcx,%rdx), %eax
movslq 0xc(%rdi), %rcx
leaq (%rax,%rax,2), %rax
leaq 0x2ef5(%rip), %rdx      # 0xa228
addq %rax, %rdx
movzbl (%rcx,%rdx), %ecx
movl %ecx, %r15d
movq %r15, 0x30(%rsp)
andl $0x3f, %r15d
cmpl %r15d, 0x20(%rdi)
jle 0x7350
movl %r15d, 0x20(%rbx)
shrl $0x6, %ecx
movl 0x20(%rbx), %eax
testl %eax, %eax
movq %r15, 0x10(%rsp)
jle 0x740c
movq %rcx, 0x18(%rsp)
shll $0x5, %ecx
movq %rcx, 0x8(%rsp)
leaq 0x2ec9(%rip), %r13      # 0xa240
xorl %r14d, %r14d
movq 0x8(%rsp), %rax
addq %r14, %rax
leaq 0x3057(%rip), %rcx      # 0xa3e0
movzbl (%rcx,%rax), %ebp
movl %ebp, %r12d
andl $0xf, %r12d
movq 0x30(%rbx), %rdi
shrl $0x4, %ebp
movl %ebp, %esi
callq 0x43f5
cltq
shll $0x4, %r12d
leaq 0x3091(%rip), %rcx      # 0xa440
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 0x43f5
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 0x737a
movq 0x10(%rsp), %r15
movq 0x18(%rsp), %rcx
subl %eax, %r15d
jle 0x7485
cltq
shll $0x5, %ecx
leaq 0x2fc3(%rip), %r14      # 0xa3e0
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 0x43f5
cltq
shll $0x4, %ebp
leaq 0x2fed(%rip), %rcx      # 0xa440
addq %rcx, %rbp
movzbl (%rax,%rbp), %eax
testl %eax, %eax
leaq 0x2ddd(%rip), %rcx      # 0xa240
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 0x7431
xorl %eax, %eax
cmpl $0x3, 0x1c(%rbx)
setne %cl
cmpl $0x0, 0x10(%rsp)
je 0x765d
movb %cl, %al
incl %eax
movl %eax, %ebp
xorl %r14d, %r14d
movq %rbp, %r15
movq %r14, %r12
cmpq $0x0, 0x40(%rbx,%r12,8)
je 0x74c6
movq 0x30(%rbx), %rdi
movl $0x2, %esi
callq 0x43f5
movb %al, 0x240(%rbx,%r12)
addq $0x20, %r12
decq %r15
jne 0x74a8
cmpl $0x3, 0x1c(%rbx)
jne 0x74e5
movb 0x240(%rbx,%r14), %al
movb %al, 0x260(%rbx,%r14)
incq %r14
cmpq 0x10(%rsp), %r14
jne 0x74a2
leaq 0x280(%rbx), %rax
movq %rax, 0x40(%rsp)
leaq 0x400(%rbx), %rax
movq %rax, 0x38(%rsp)
movl 0x10(%rsp), %eax
movq %rax, 0x20(%rsp)
movl $0x240, %r14d           # imm = 0x240
movl $0x288, %eax            # imm = 0x288
xorl %r12d, %r12d
leaq 0x1b6b(%rip), %r13      # 0x9090
movq %rbp, 0x48(%rsp)
movq %rbp, %r15
movq %rax, 0x18(%rsp)
movq %rax, %rbp
movq %r14, 0x8(%rsp)
cmpq $0x0, -0x11c0(%rbx,%r14,8)
je 0x75f3
movzbl (%rbx,%r14), %eax
cmpq $0x3, %rax
ja 0x75f3
movslq (%r13,%rax,4), %rax
addq %r13, %rax
jmpq *%rax
movq 0x30(%rbx), %rdi
movl $0x6, %esi
callq 0x43f5
movl %eax, -0x8(%rbx,%rbp)
movq 0x30(%rbx), %rdi
movl $0x6, %esi
callq 0x43f5
movl %eax, -0x4(%rbx,%rbp)
jmp 0x75e2
movq 0x30(%rbx), %rdi
movl $0x6, %esi
callq 0x43f5
movl %eax, (%rbx,%rbp)
movl %eax, -0x4(%rbx,%rbp)
movl %eax, -0x8(%rbx,%rbp)
jmp 0x75f3
movq 0x30(%rbx), %rdi
movl $0x6, %esi
callq 0x43f5
movl %eax, -0x8(%rbx,%rbp)
movq 0x30(%rbx), %rdi
movl $0x6, %esi
callq 0x43f5
movl %eax, (%rbx,%rbp)
movl %eax, -0x4(%rbx,%rbp)
jmp 0x75f3
movq 0x30(%rbx), %rdi
movl $0x6, %esi
callq 0x43f5
movl %eax, -0x4(%rbx,%rbp)
movl %eax, -0x8(%rbx,%rbp)
movq 0x30(%rbx), %rdi
movl $0x6, %esi
callq 0x43f5
movl %eax, (%rbx,%rbp)
addq $0x20, %r14
addq $0x180, %rbp            # imm = 0x180
decq %r15
jne 0x753a
cmpl $0x3, 0x1c(%rbx)
jne 0x7639
leaq (,%r12,4), %rax
leaq (%rax,%rax,2), %rax
movq 0x40(%rsp), %rdx
movl (%rdx,%rax), %ecx
movq 0x38(%rsp), %rsi
movl %ecx, (%rsi,%rax)
movl 0x4(%rdx,%rax), %ecx
movl %ecx, 0x4(%rsi,%rax)
movl 0x8(%rdx,%rax), %ecx
movl %ecx, 0x8(%rsi,%rax)
incq %r12
movq 0x8(%rsp), %r14
incq %r14
movq 0x18(%rsp), %rax
addq $0xc, %rax
cmpq 0x20(%rsp), %r12
movq 0x48(%rsp), %rbp
jne 0x752a
leaq 0x580(%rbx), %rax
movq %rax, 0x48(%rsp)
leaq 0x3c90(%rbx), %rax
movq %rax, 0x18(%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 %ecx, %ecx
movl %eax, 0x2c(%rsp)
xorl %eax, %eax
movl %eax, 0x38(%rsp)
movq %rcx, 0x20(%rsp)
movl 0x20(%rbx), %r14d
testl %r14d, %r14d
movl 0x2c(%rsp), %r12d
jle 0x76f6
xorl %r15d, %r15d
movq %rbx, %rdi
xorl %esi, %esi
movl %r15d, %edx
movl %r12d, %ecx
callq 0x7a46
movq %rbx, %rdi
movl $0x1, %esi
movl %r15d, %edx
movl %r12d, %ecx
callq 0x7a46
incl %r15d
movl 0x20(%rbx), %r14d
cmpl %r14d, %r15d
jl 0x76c7
movq 0x10(%rsp), %rcx
cmpl %ecx, %r14d
jge 0x7747
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 0x7a46
movq 0x10(%rsp), %rcx
movl -0x188(%r15), %eax
movl %eax, -0x8(%r15)
movq -0x184(%r15), %rax
movq %rax, -0x4(%r15)
addq $0xc, %r15
incl %r14d
cmpl %r14d, %ecx
jne 0x7710
movq 0x50(%rsp), %rax
cmpl $0x1f, %ecx
movq 0x30(%rsp), %rcx
movl $0x0, %edx
ja 0x777e
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 0x775b
movq 0x20(%rsp), %r15
movl %r15d, %eax
addl %r15d, %r15d
movl $0x0, 0x8(%rsp)
movq %rax, %rcx
movq %rcx, 0x20(%rsp)
movl 0x24(%rbx), %eax
movl $0x3c0, %ecx            # imm = 0x3C0
addl %ecx, %eax
andl $0x3ff, %eax            # imm = 0x3FF
movl %eax, 0x24(%rbx)
movq %r15, 0x40(%rsp)
movq 0x18(%rsp), %r12
xorl %r14d, %r14d
leaq (%r14,%r14,2), %rdi
shlq $0x7, %rdi
addq 0x48(%rsp), %rdi
movq %r14, %rdx
shlq $0xc, %rdx
addq 0x18(%rsp), %rdx
movl 0x24(%rbx), %ecx
movl 0x8(%rsp), %esi
callq 0x7bd0
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, %edi
subl %eax, %edi
sarl %edi
sarl %ecx
movl $0x200, %eax            # imm = 0x200
subl %ecx, %eax
movslq %edi, %rdx
movslq %eax, %rcx
leaq (,%rcx,4), %rdi
addq %r13, %rdi
leaq (%r12,%rdx,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 0x7834
leal (%rdx,%rsi), %edi
addl $0x60, %edi
addl %esi, %eax
addl $0x20, %eax
leaq (%rdx,%rsi), %r8
decq %r8
cmpq $0x39f, %r8             # imm = 0x39F
jl 0x781d
addq %rsi, %rdx
movl $0x400, %edi            # imm = 0x400
subq %rdx, %rdi
addq %rsi, %rcx
addq $-0x1c0, %rcx           # imm = 0xFE40
movss 0x2c0e(%rip), %xmm1     # 0xa4a0
movslq %edi, %rax
movslq %ecx, %rcx
leaq (,%rcx,4), %rsi
addq %r13, %rsi
leaq (%r12,%rax,4), %rdi
xorl %edx, %edx
movss (%rsi,%rdx,4), %xmm0
mulss (%rdi,%rdx,4), %xmm0
addss 0x5c90(%rbx,%rdx,4), %xmm0
movss %xmm0, 0x5c90(%rbx,%rdx,4)
incq %rdx
cmpq $0x20, %rdx
jne 0x78a9
leaq (%rax,%rdx), %rdi
addq $0x60, %rdi
addq %rdx, %rcx
addq $0x20, %rcx
addq %rdx, %rax
decq %rax
cmpq $0x39f, %rax            # imm = 0x39F
jl 0x7892
xorl %eax, %eax
movss 0x5c90(%rbx,%rax,2), %xmm0
divss %xmm1, %xmm0
leal (%r15,%rax), %ecx
movslq %ecx, %rcx
movss %xmm0, 0x88c(%rbx,%rcx,4)
addq $0x2, %rax
cmpq $0x40, %rax
jne 0x78ed
leaq 0x1(%r14), %rax
addq $0x1000, %r12           # imm = 0x1000
incq %r15
testq %r14, %r14
movq %rax, %r14
je 0x77b8
movq 0x20(%rsp), %rcx
addq $0x20, %rcx
movl 0x8(%rsp), %eax
incl %eax
movq 0x40(%rsp), %r15
addq $0x40, %r15
movl %eax, 0x8(%rsp)
cmpl $0x3, %eax
jne 0x7794
movl 0x38(%rsp), %eax
incl %eax
cmpl $0x4, %eax
jne 0x76ad
movl 0x2c(%rsp), %eax
incl %eax
cmpl $0x3, %eax
jne 0x76a7
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