// File: /workspace/github_c_makefile_star2_O3/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 0x2951
movq %rdi, %rbx
cmpl $0x0, 0x3c(%rdi)
je 0x2899
cmpl $0x0, 0x40(%rbx)
jne 0x2888
cmpl $0xbb, 0x38(%rbx)
je 0x27f6
movq (%rbx), %r14
movq %r14, %rdi
callq 0x4320
cmpl $-0x1, %eax
je 0x294f
cmpl $0xbb, %eax
jne 0x27de
movl $0xbb, 0x38(%rbx)
movq (%rbx), %rdi
movl $0x38, %esi
callq 0x41a8
testl %eax, %eax
je 0x294f
movl $0xffffffff, 0x38(%rbx) # imm = 0xFFFFFFFF
movq (%rbx), %r14
movl $0x10, %esi
movq %r14, %rdi
callq 0x41a8
testl %eax, %eax
je 0x2831
addq $0x10, (%r14)
movq (%rbx), %r14
movl $0x18, %esi
movq %r14, %rdi
callq 0x41a8
testl %eax, %eax
je 0x2849
addq $0x18, (%r14)
movq (%rbx), %rdi
movl $0x6, %esi
callq 0x4215
movl %eax, 0x48(%rbx)
movq (%rbx), %r14
movl $0x5, %esi
movq %r14, %rdi
callq 0x41a8
testl %eax, %eax
je 0x2871
addq $0x5, (%r14)
movq (%rbx), %rdi
movl $0x5, %esi
callq 0x4215
movl %eax, 0x4c(%rbx)
movl $0x1, 0x40(%rbx)
movl $0x1, 0x44(%rbx)
movl $0x1, %ebp
jmp 0x2951
cmpl $0xba, 0x38(%rbx)
je 0x28bd
movq (%rbx), %r14
movq %r14, %rdi
callq 0x4320
cmpl $-0x1, %eax
je 0x294f
cmpl $0xba, %eax
jne 0x28a5
movl $0xba, 0x38(%rbx)
movq (%rbx), %rdi
movl $0x40, %esi
callq 0x41a8
xorl %ebp, %ebp
testl %eax, %eax
je 0x2951
movl $0xffffffff, 0x38(%rbx) # imm = 0xFFFFFFFF
movq (%rbx), %rdi
movl $0x4, %esi
callq 0x4215
cmpl $0x2, %eax
jne 0x2951
movq %rbx, %rdi
callq 0x4498
movsd %xmm0, 0x10(%rbx)
movq (%rbx), %r14
movl $0x1, %esi
movq %r14, %rdi
callq 0x41a8
testl %eax, %eax
je 0x2914
incq (%r14)
movq (%rbx), %r14
movl $0x16, %esi
movq %r14, %rdi
callq 0x41a8
testl %eax, %eax
je 0x292c
addq $0x16, (%r14)
movq (%rbx), %r14
movl $0x1, %esi
movq %r14, %rdi
callq 0x41a8
testl %eax, %eax
je 0x2943
incq (%r14)
movl $0x1, 0x3c(%rbx)
jmp 0x27c8
xorl %ebp, %ebp
movl %ebp, %eax
popq %rbx
popq %r14
popq %rbp
retq