// File: /workspace/github_c_makefile_star2_O1/phoboslab[P]pl_mpeg/./pl_mpeg.h
// Function: plm_demux_has_headers
int plm_demux_has_headers(plm_demux_t *self) {
	if (self->has_headers) {
		return TRUE;
	}

	// Decode pack header
	if (!self->has_pack_header) {
		if (
			self->start_code != PLM_START_PACK &&
			plm_buffer_find_start_code(self->buffer, PLM_START_PACK) == -1
		) {
			return FALSE;
		}

		self->start_code = PLM_START_PACK;
		if (!plm_buffer_has(self->buffer, 64)) {
			return FALSE;
		}
		self->start_code = -1;

		if (plm_buffer_read(self->buffer, 4) != 0x02) {
			return FALSE;
		}

		self->system_clock_ref = plm_demux_decode_time(self);
		plm_buffer_skip(self->buffer, 1);
		plm_buffer_skip(self->buffer, 22); // mux_rate * 50
		plm_buffer_skip(self->buffer, 1);

		self->has_pack_header = TRUE;
	}

	// Decode system header
	if (!self->has_system_header) {
		if (
			self->start_code != PLM_START_SYSTEM &&
			plm_buffer_find_start_code(self->buffer, PLM_START_SYSTEM) == -1
		) {
			return FALSE;
		}

		self->start_code = PLM_START_SYSTEM;
		if (!plm_buffer_has(self->buffer, 56)) {
			return FALSE;
		}
		self->start_code = -1;

		plm_buffer_skip(self->buffer, 16); // header_length
		plm_buffer_skip(self->buffer, 24); // rate bound
		self->num_audio_streams = plm_buffer_read(self->buffer, 6);
		plm_buffer_skip(self->buffer, 5); // misc flags
		self->num_video_streams = plm_buffer_read(self->buffer, 5);

		self->has_system_header = TRUE;
	}

	self->has_headers = TRUE;
	return TRUE;
}

// Assembly:
pushq %rbp
pushq %r14
pushq %rbx
movl $0x1, %ebp
cmpl $0x0, 0x44(%rdi)
jne 0x2a3d
movq %rdi, %rbx
cmpl $0x0, 0x3c(%rdi)
je 0x2985
cmpl $0x0, 0x40(%rbx)
jne 0x2974
cmpl $0xbb, 0x38(%rbx)
je 0x28e2
movq (%rbx), %r14
movq %r14, %rdi
callq 0x4500
cmpl $-0x1, %eax
je 0x2a3b
cmpl $0xbb, %eax
jne 0x28ca
movl $0xbb, 0x38(%rbx)
movq (%rbx), %rdi
movl $0x38, %esi
callq 0x4392
testl %eax, %eax
je 0x2a3b
movl $0xffffffff, 0x38(%rbx) # imm = 0xFFFFFFFF
movq (%rbx), %r14
movl $0x10, %esi
movq %r14, %rdi
callq 0x4392
testl %eax, %eax
je 0x291d
addq $0x10, (%r14)
movq (%rbx), %r14
movl $0x18, %esi
movq %r14, %rdi
callq 0x4392
testl %eax, %eax
je 0x2935
addq $0x18, (%r14)
movq (%rbx), %rdi
movl $0x6, %esi
callq 0x43f5
movl %eax, 0x48(%rbx)
movq (%rbx), %r14
movl $0x5, %esi
movq %r14, %rdi
callq 0x4392
testl %eax, %eax
je 0x295d
addq $0x5, (%r14)
movq (%rbx), %rdi
movl $0x5, %esi
callq 0x43f5
movl %eax, 0x4c(%rbx)
movl $0x1, 0x40(%rbx)
movl $0x1, 0x44(%rbx)
movl $0x1, %ebp
jmp 0x2a3d
cmpl $0xba, 0x38(%rbx)
je 0x29a9
movq (%rbx), %r14
movq %r14, %rdi
callq 0x4500
cmpl $-0x1, %eax
je 0x2a3b
cmpl $0xba, %eax
jne 0x2991
movl $0xba, 0x38(%rbx)
movq (%rbx), %rdi
movl $0x40, %esi
callq 0x4392
xorl %ebp, %ebp
testl %eax, %eax
je 0x2a3d
movl $0xffffffff, 0x38(%rbx) # imm = 0xFFFFFFFF
movq (%rbx), %rdi
movl $0x4, %esi
callq 0x43f5
cmpl $0x2, %eax
jne 0x2a3d
movq %rbx, %rdi
callq 0x4678
movsd %xmm0, 0x10(%rbx)
movq (%rbx), %r14
movl $0x1, %esi
movq %r14, %rdi
callq 0x4392
testl %eax, %eax
je 0x2a00
incq (%r14)
movq (%rbx), %r14
movl $0x16, %esi
movq %r14, %rdi
callq 0x4392
testl %eax, %eax
je 0x2a18
addq $0x16, (%r14)
movq (%rbx), %r14
movl $0x1, %esi
movq %r14, %rdi
callq 0x4392
testl %eax, %eax
je 0x2a2f
incq (%r14)
movl $0x1, 0x3c(%rbx)
jmp 0x28b4
xorl %ebp, %ebp
movl %ebp, %eax
popq %rbx
popq %r14
popq %rbp
retq