// File: /workspace/github_c_makefile_star2_O0/phoboslab[P]pl_mpeg/./pl_mpeg.h
// Function: plm_decode
void plm_decode(plm_t *self, double tick) {
	if (!plm_init_decoders(self)) {
		return;
	}

	int decode_video = (self->video_decode_callback && self->video_packet_type);
	int decode_audio = (self->audio_decode_callback && self->audio_packet_type);

	if (!decode_video && !decode_audio) {
		// Nothing to do here
		return;
	}

	int did_decode = FALSE;
	int decode_video_failed = FALSE;
	int decode_audio_failed = FALSE;

	double video_target_time = self->time + tick;
	double audio_target_time = self->time + tick + self->audio_lead_time;

	do {
		did_decode = FALSE;
		
		if (decode_video && plm_video_get_time(self->video_decoder) < video_target_time) {
			plm_frame_t *frame = plm_video_decode(self->video_decoder);
			if (frame) {
				self->video_decode_callback(self, frame, self->video_decode_callback_user_data);
				did_decode = TRUE;
			}
			else {
				decode_video_failed = TRUE;
			}
		}

		if (decode_audio && plm_audio_get_time(self->audio_decoder) < audio_target_time) {
			plm_samples_t *samples = plm_audio_decode(self->audio_decoder);
			if (samples) {
				self->audio_decode_callback(self, samples, self->audio_decode_callback_user_data);
				did_decode = TRUE;
			}
			else {
				decode_audio_failed = TRUE;
			}
		}
	} while (did_decode);
	
	// Did all sources we wanted to decode fail and the demuxer is at the end?
	if (
		(!decode_video || decode_video_failed) && 
		(!decode_audio || decode_audio_failed) &&
		plm_demux_has_ended(self->demux)
	) {
		plm_handle_end(self);
		return;
	}

	self->time += tick;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movq %rdi, -0x8(%rbp)
movsd %xmm0, -0x10(%rbp)
movq -0x8(%rbp), %rdi
callq 0x2720
cmpl $0x0, %eax
jne 0x3b14
jmp 0x3cdf
movq -0x8(%rbp), %rcx
xorl %eax, %eax
cmpq $0x0, 0x60(%rcx)
movb %al, -0x49(%rbp)
je 0x3b32
movq -0x8(%rbp), %rax
cmpl $0x0, 0x20(%rax)
setne %al
movb %al, -0x49(%rbp)
movb -0x49(%rbp), %al
andb $0x1, %al
movzbl %al, %eax
movl %eax, -0x14(%rbp)
movq -0x8(%rbp), %rcx
xorl %eax, %eax
cmpq $0x0, 0x70(%rcx)
movb %al, -0x4a(%rbp)
je 0x3b5b
movq -0x8(%rbp), %rax
cmpl $0x0, 0x40(%rax)
setne %al
movb %al, -0x4a(%rbp)
movb -0x4a(%rbp), %al
andb $0x1, %al
movzbl %al, %eax
movl %eax, -0x18(%rbp)
cmpl $0x0, -0x14(%rbp)
jne 0x3b77
cmpl $0x0, -0x18(%rbp)
jne 0x3b77
jmp 0x3cdf
movl $0x0, -0x1c(%rbp)
movl $0x0, -0x20(%rbp)
movl $0x0, -0x24(%rbp)
movq -0x8(%rbp), %rax
movsd 0x8(%rax), %xmm0
addsd -0x10(%rbp), %xmm0
movsd %xmm0, -0x30(%rbp)
movq -0x8(%rbp), %rax
movsd 0x8(%rax), %xmm0
addsd -0x10(%rbp), %xmm0
movq -0x8(%rbp), %rax
addsd 0x48(%rax), %xmm0
movsd %xmm0, -0x38(%rbp)
movl $0x0, -0x1c(%rbp)
cmpl $0x0, -0x14(%rbp)
je 0x3c27
movq -0x8(%rbp), %rax
movq 0x30(%rax), %rdi
callq 0x3cf0
movaps %xmm0, %xmm1
movsd -0x30(%rbp), %xmm0
ucomisd %xmm1, %xmm0
jbe 0x3c27
movq -0x8(%rbp), %rax
movq 0x30(%rax), %rdi
callq 0x3d10
movq %rax, -0x40(%rbp)
cmpq $0x0, -0x40(%rbp)
je 0x3c1e
movq -0x8(%rbp), %rax
movq 0x60(%rax), %rax
movq -0x8(%rbp), %rdi
movq -0x40(%rbp), %rsi
movq -0x8(%rbp), %rcx
movq 0x68(%rcx), %rdx
callq *%rax
movl $0x1, -0x1c(%rbp)
jmp 0x3c25
movl $0x1, -0x20(%rbp)
jmp 0x3c27
cmpl $0x0, -0x18(%rbp)
je 0x3c8c
movq -0x8(%rbp), %rax
movq 0x58(%rax), %rdi
callq 0x3f00
movaps %xmm0, %xmm1
movsd -0x38(%rbp), %xmm0
ucomisd %xmm1, %xmm0
jbe 0x3c8c
movq -0x8(%rbp), %rax
movq 0x58(%rax), %rdi
callq 0x3f20
movq %rax, -0x48(%rbp)
cmpq $0x0, -0x48(%rbp)
je 0x3c83
movq -0x8(%rbp), %rax
movq 0x70(%rax), %rax
movq -0x8(%rbp), %rdi
movq -0x48(%rbp), %rsi
movq -0x8(%rbp), %rcx
movq 0x78(%rcx), %rdx
callq *%rax
movl $0x1, -0x1c(%rbp)
jmp 0x3c8a
movl $0x1, -0x24(%rbp)
jmp 0x3c8c
jmp 0x3c8e
cmpl $0x0, -0x1c(%rbp)
jne 0x3bbb
cmpl $0x0, -0x14(%rbp)
je 0x3ca4
cmpl $0x0, -0x20(%rbp)
je 0x3ccc
cmpl $0x0, -0x18(%rbp)
je 0x3cb0
cmpl $0x0, -0x24(%rbp)
je 0x3ccc
movq -0x8(%rbp), %rax
movq (%rax), %rdi
callq 0x4020
cmpl $0x0, %eax
je 0x3ccc
movq -0x8(%rbp), %rdi
callq 0x4040
jmp 0x3cdf
movsd -0x10(%rbp), %xmm0
movq -0x8(%rbp), %rax
addsd 0x8(%rax), %xmm0
movsd %xmm0, 0x8(%rax)
addq $0x50, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)