// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x10, %rsp
movq %rdi, -0x10(%rbp)
movq -0x10(%rbp), %rax
cmpl $0x0, 0x44(%rax)
je 0x28a2
movl $0x1, -0x4(%rbp)
jmp 0x2a82
movq -0x10(%rbp), %rax
cmpl $0x0, 0x3c(%rax)
jne 0x2989
movq -0x10(%rbp), %rax
cmpl $0xba, 0x38(%rax)
je 0x28df
movq -0x10(%rbp), %rax
movq (%rax), %rdi
movl $0xba, %esi
callq 0x55f0
cmpl $-0x1, %eax
jne 0x28df
movl $0x0, -0x4(%rbp)
jmp 0x2a82
movq -0x10(%rbp), %rax
movl $0xba, 0x38(%rax)
movq -0x10(%rbp), %rax
movq (%rax), %rdi
movl $0x40, %esi
callq 0x5270
cmpl $0x0, %eax
jne 0x290c
movl $0x0, -0x4(%rbp)
jmp 0x2a82
movq -0x10(%rbp), %rax
movl $0xffffffff, 0x38(%rax) # imm = 0xFFFFFFFF
movq -0x10(%rbp), %rax
movq (%rax), %rdi
movl $0x4, %esi
callq 0x5320
cmpl $0x2, %eax
je 0x2939
movl $0x0, -0x4(%rbp)
jmp 0x2a82
movq -0x10(%rbp), %rdi
callq 0x57a0
movq -0x10(%rbp), %rax
movsd %xmm0, 0x10(%rax)
movq -0x10(%rbp), %rax
movq (%rax), %rdi
movl $0x1, %esi
callq 0x5450
movq -0x10(%rbp), %rax
movq (%rax), %rdi
movl $0x16, %esi
callq 0x5450
movq -0x10(%rbp), %rax
movq (%rax), %rdi
movl $0x1, %esi
callq 0x5450
movq -0x10(%rbp), %rax
movl $0x1, 0x3c(%rax)
movq -0x10(%rbp), %rax
cmpl $0x0, 0x40(%rax)
jne 0x2a70
movq -0x10(%rbp), %rax
cmpl $0xbb, 0x38(%rax)
je 0x29c6
movq -0x10(%rbp), %rax
movq (%rax), %rdi
movl $0xbb, %esi
callq 0x55f0
cmpl $-0x1, %eax
jne 0x29c6
movl $0x0, -0x4(%rbp)
jmp 0x2a82
movq -0x10(%rbp), %rax
movl $0xbb, 0x38(%rax)
movq -0x10(%rbp), %rax
movq (%rax), %rdi
movl $0x38, %esi
callq 0x5270
cmpl $0x0, %eax
jne 0x29f3
movl $0x0, -0x4(%rbp)
jmp 0x2a82
movq -0x10(%rbp), %rax
movl $0xffffffff, 0x38(%rax) # imm = 0xFFFFFFFF
movq -0x10(%rbp), %rax
movq (%rax), %rdi
movl $0x10, %esi
callq 0x5450
movq -0x10(%rbp), %rax
movq (%rax), %rdi
movl $0x18, %esi
callq 0x5450
movq -0x10(%rbp), %rax
movq (%rax), %rdi
movl $0x6, %esi
callq 0x5320
movl %eax, %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x48(%rax)
movq -0x10(%rbp), %rax
movq (%rax), %rdi
movl $0x5, %esi
callq 0x5450
movq -0x10(%rbp), %rax
movq (%rax), %rdi
movl $0x5, %esi
callq 0x5320
movl %eax, %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x4c(%rax)
movq -0x10(%rbp), %rax
movl $0x1, 0x40(%rax)
movq -0x10(%rbp), %rax
movl $0x1, 0x44(%rax)
movl $0x1, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x10, %rsp
popq %rbp
retq
nopl (%rax,%rax)