LLM4Binary/decompile-bench-makefile huggingface dataset:
// File: /workspace/github_c_makefile_star2_O2/phoboslab[P]pl_mpeg/./pl_mpeg.h
// Function: plm_demux_get_duration
double plm_demux_get_duration(plm_demux_t *self, int type) {
	size_t file_size = plm_buffer_get_size(self->buffer);

	if (
		self->duration != PLM_PACKET_INVALID_TS &&
		self->last_file_size == file_size
	) {
		return self->duration;
	}

	size_t previous_pos = plm_buffer_tell(self->buffer);
	int previous_start_code = self->start_code;
	
	// Find last video PTS. Start searching 64kb from the end and go further 
	// back if needed.
	long start_range = 64 * 1024;
	long max_range = 4096 * 1024;
	for (long range = start_range; range <= max_range; range *= 2) {
		long seek_pos = file_size - range;
		if (seek_pos < 0) {
			seek_pos = 0;
			range = max_range; // Make sure to bail after this round
		}
		plm_demux_buffer_seek(self, seek_pos);
		self->current_packet.length = 0;

		double last_pts = PLM_PACKET_INVALID_TS;
		plm_packet_t *packet = NULL;
		while ((packet = plm_demux_decode(self))) {
			if (packet->pts != PLM_PACKET_INVALID_TS && packet->type == type) {
				last_pts = packet->pts;
			}
		}
		if (last_pts != PLM_PACKET_INVALID_TS) {
			self->duration = last_pts - plm_demux_get_start_time(self, type);
			break;
		}
	}

	plm_demux_buffer_seek(self, previous_pos);
	self->start_code = previous_start_code;
	self->last_file_size = file_size;
	return self->duration;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movl %esi, %ebp
movq %rdi, %rbx
movq (%rdi), %rdi
xorl %eax, %eax
cmpl $0x0, 0x60(%rdi)
sete %al
movq 0x10(%rdi,%rax,8), %r14
movsd 0x30(%rbx), %xmm0
ucomisd 0x54ec(%rip), %xmm0     # 0x81e0
jne 0x2cf8
jnp 0x2d02
cmpq %r14, 0x18(%rbx)
je 0x2dd1
callq 0x3b67
movq %rax, 0x10(%rsp)
movl 0x38(%rbx), %eax
movl %eax, 0x4(%rsp)
movl $0x10000, %r13d         # imm = 0x10000
movl $0x800000, %r12d        # imm = 0x800000
cmpq $0x400000, %r13         # imm = 0x400000
ja 0x2db4
movq %r14, %r15
subq %r13, %r15
testq %r15, %r15
movl $0x0, %esi
cmovgq %r15, %rsi
movq %rbx, %rdi
callq 0x3eb7
andq $0x0, 0x60(%rbx)
movsd 0x548d(%rip), %xmm0     # 0x81e0
movsd %xmm0, 0x8(%rsp)
movq %rbx, %rdi
callq 0x32bc
testq %rax, %rax
je 0x2d7d
movsd 0x8(%rax), %xmm0
ucomisd 0x546d(%rip), %xmm0     # 0x81e0
jne 0x2d77
jnp 0x2d59
cmpl %ebp, (%rax)
jne 0x2d59
jmp 0x2d53
movsd 0x8(%rsp), %xmm0
ucomisd 0x5455(%rip), %xmm0     # 0x81e0
jne 0x2d9b
jp 0x2d9b
addq %r13, %r13
testq %r15, %r15
cmovsq %r12, %r13
jmp 0x2d1f
movq %rbx, %rdi
movl %ebp, %esi
callq 0x3549
movsd 0x8(%rsp), %xmm1
subsd %xmm0, %xmm1
movsd %xmm1, 0x30(%rbx)
movq %rbx, %rdi
movq 0x10(%rsp), %rsi
callq 0x3eb7
movl 0x4(%rsp), %eax
movl %eax, 0x38(%rbx)
movq %r14, 0x18(%rbx)
movsd 0x30(%rbx), %xmm0
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/phoboslab[P]pl_mpeg/./pl_mpeg.h
// Function: plm_rewind
void plm_rewind(plm_t *self) {
	if (self->video_decoder) {
		plm_video_rewind(self->video_decoder);
	}

	if (self->audio_decoder) {
		plm_audio_rewind(self->audio_decoder);
	}

	plm_demux_rewind(self->demux);
	self->time = 0;
	self->has_ended = FALSE;
}

// Assembly:
pushq %rbx
movq %rdi, %rbx
movq 0x30(%rdi), %rdi
testq %rdi, %rdi
je 0x2df2
callq 0x2e13
movq 0x58(%rbx), %rdi
testq %rdi, %rdi
je 0x2e00
callq 0x2e39
movq (%rbx), %rdi
callq 0x2e54
andq $0x0, 0x8(%rbx)
andl $0x0, 0x10(%rbx)
popq %rbx
retq
// File: /workspace/github_c_makefile_star2_O2/phoboslab[P]pl_mpeg/./pl_mpeg.h
// Function: plm_video_rewind
void plm_video_rewind(plm_video_t *self) {
	plm_buffer_rewind(self->buffer);
	self->time = 0;
	self->frames_decoded = 0;
	self->has_reference_frame = FALSE;
	self->start_code = -1;
}

// Assembly:
pushq %rbx
movq %rdi, %rbx
movq 0xa0(%rdi), %rdi
callq 0x3b14
andq $0x0, 0x10(%rbx)
andl $0x0, 0x18(%rbx)
andl $0x0, 0x2f8(%rbx)
orl $-0x1, 0x40(%rbx)
popq %rbx
retq
// File: /workspace/github_c_makefile_star2_O2/phoboslab[P]pl_mpeg/./pl_mpeg.h
// Function: plm_audio_rewind
void plm_audio_rewind(plm_audio_t *self) {
	plm_buffer_rewind(self->buffer);
	self->time = 0;
	self->samples_decoded = 0;
	self->next_frame_data_size = 0;
}

// Assembly:
pushq %rbx
movq %rdi, %rbx
movq 0x30(%rdi), %rdi
callq 0x3b14
andq $0x0, (%rbx)
andl $0x0, 0x8(%rbx)
andl $0x0, 0x28(%rbx)
popq %rbx
retq
// File: /workspace/github_c_makefile_star2_O2/phoboslab[P]pl_mpeg/./pl_mpeg.h
// Function: plm_demux_rewind
void plm_demux_rewind(plm_demux_t *self) {
	plm_buffer_rewind(self->buffer);
	self->current_packet.length = 0;
	self->next_packet.length = 0;
	self->start_code = -1;
}

// Assembly:
pushq %rbx
movq %rdi, %rbx
movq (%rdi), %rdi
callq 0x3b14
andq $0x0, 0x60(%rbx)
andq $0x0, 0x80(%rbx)
orl $-0x1, 0x38(%rbx)
popq %rbx
retq
// File: /workspace/github_c_makefile_star2_O2/phoboslab[P]pl_mpeg/./pl_mpeg.h
// Function: plm_video_decode
plm_frame_t *plm_video_decode(plm_video_t *self) {
	if (!plm_video_has_header(self)) {
		return NULL;
	}
	
	plm_frame_t *frame = NULL;
	do {
		if (self->start_code != PLM_START_PICTURE) {
			self->start_code = plm_buffer_find_start_code(self->buffer, PLM_START_PICTURE);
			
			if (self->start_code == -1) {
				// If we reached the end of the file and the previously decoded
				// frame was a reference frame, we still have to return it.
				if (
					self->has_reference_frame &&
					!self->assume_no_b_frames &&
					plm_buffer_has_ended(self->buffer) && (
						self->picture_type == PLM_VIDEO_PICTURE_TYPE_INTRA ||
						self->picture_type == PLM_VIDEO_PICTURE_TYPE_PREDICTIVE
					)
				) {
					self->has_reference_frame = FALSE;
					frame = &self->frame_backward;
					break;
				}

				return NULL;
			}
		}

		// Make sure we have a full picture in the buffer before attempting to
		// decode it. Sadly, this can only be done by seeking for the start code
		// of the next picture. Also, if we didn't find the start code for the
		// next picture, but the source has ended, we assume that this last
		// picture is in the buffer.
		if (
			plm_buffer_has_start_code(self->buffer, PLM_START_PICTURE) == -1 &&
			!plm_buffer_has_ended(self->buffer)
		) {
			return NULL;
		}
		plm_buffer_discard_read_bytes(self->buffer);
		
		plm_video_decode_picture(self);

		if (self->assume_no_b_frames) {
			frame = &self->frame_backward;
		}
		else if (self->picture_type == PLM_VIDEO_PICTURE_TYPE_B) {
			frame = &self->frame_current;
		}
		else if (self->has_reference_frame) {
			frame = &self->frame_forward;
		}
		else {
			self->has_reference_frame = TRUE;
		}
	} while (!frame);
	
	frame->time = self->time;
	self->frames_decoded++;
	self->time = (double)self->frames_decoded / self->framerate;
	
	return frame;
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq %rdi, %rbx
callq 0x29a3
testl %eax, %eax
je 0x30b0
xorl %r14d, %r14d
cmpl $0x0, 0x40(%rbx)
je 0x303b
movq 0xa0(%rbx), %rdi
xorl %esi, %esi
callq 0x3d76
movl %eax, 0x40(%rbx)
cmpl $-0x1, %eax
je 0x309e
movq 0xa0(%rbx), %rdi
xorl %esi, %esi
callq 0x3d98
movq 0xa0(%rbx), %rdi
cmpl $-0x1, %eax
jne 0x305f
cmpl $0x0, 0x24(%rdi)
je 0x30fb
callq 0x3ac6
movq %rbx, %rdi
callq 0x42a9
cmpl $0x0, 0x2fc(%rbx)
jne 0x30d3
cmpl $0x3, 0x44(%rbx)
je 0x3090
cmpl $0x0, 0x2f8(%rbx)
jne 0x3097
movl $0x1, 0x2f8(%rbx)
jmp 0x301f
movl $0xb0, %eax
jmp 0x30d8
movl $0xf0, %eax
jmp 0x30d8
cmpl $0x0, 0x2f8(%rbx)
je 0x30b0
cmpl $0x0, 0x2fc(%rbx)
je 0x30b5
xorl %r14d, %r14d
jmp 0x30fb
movq 0xa0(%rbx), %rax
cmpl $0x0, 0x24(%rax)
je 0x30b0
movl 0x44(%rbx), %eax
decl %eax
cmpl $0x1, %eax
ja 0x30b0
andl $0x0, 0x2f8(%rbx)
movl $0x130, %eax            # imm = 0x130
leaq (%rbx,%rax), %r14
movsd 0x10(%rbx), %xmm0
movsd %xmm0, (%rbx,%rax)
movl 0x18(%rbx), %eax
incl %eax
cvtsi2sd %eax, %xmm0
movl %eax, 0x18(%rbx)
divsd (%rbx), %xmm0
movsd %xmm0, 0x10(%rbx)
movq %r14, %rax
addq $0x8, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_c_makefile_star2_O2/phoboslab[P]pl_mpeg/./pl_mpeg.h
// Function: plm_audio_decode
plm_samples_t *plm_audio_decode(plm_audio_t *self) {
	// Do we have at least enough information to decode the frame header?
	if (!self->next_frame_data_size) {
		if (!plm_buffer_has(self->buffer, 48)) {
			return NULL;
		}
		self->next_frame_data_size = plm_audio_decode_header(self);
	}

	if (
		self->next_frame_data_size == 0 ||
		!plm_buffer_has(self->buffer, self->next_frame_data_size << 3)
	) {
		return NULL;
	}

	plm_audio_decode_frame(self);
	self->next_frame_data_size = 0;
	
	self->samples.time = self->time;

	self->samples_decoded += PLM_AUDIO_SAMPLES_PER_FRAME;
	self->time = (double)self->samples_decoded / 
		(double)PLM_AUDIO_SAMPLE_RATE[self->samplerate_index];
	
	return &self->samples;
}

// Assembly:
pushq %rbx
movq %rdi, %rbx
movl 0x28(%rdi), %eax
testl %eax, %eax
je 0x3174
movq 0x30(%rbx), %rdi
shll $0x3, %eax
movslq %eax, %rsi
callq 0x3b9d
testl %eax, %eax
je 0x3193
movq %rbx, %rdi
callq 0x6752
andl $0x0, 0x28(%rbx)
movsd (%rbx), %xmm0
leaq 0x880(%rbx), %rax
movsd %xmm0, 0x880(%rbx)
movl $0x480, %ecx            # imm = 0x480
addl 0x8(%rbx), %ecx
cvtsi2sd %ecx, %xmm0
movl %ecx, 0x8(%rbx)
movslq 0xc(%rbx), %rcx
leaq 0x506e(%rip), %rdx      # 0x81d0
movzwl (%rdx,%rcx,2), %ecx
cvtsi2sd %ecx, %xmm1
divsd %xmm1, %xmm0
movsd %xmm0, (%rbx)
jmp 0x3195
movq 0x30(%rbx), %rdi
pushq $0x30
popq %rsi
callq 0x3b9d
testl %eax, %eax
je 0x3193
movq %rbx, %rdi
callq 0x6596
movl %eax, 0x28(%rbx)
testl %eax, %eax
jne 0x3116
xorl %eax, %eax
popq %rbx
retq
// File: /workspace/github_c_makefile_star2_O2/phoboslab[P]pl_mpeg/./pl_mpeg.h
// Function: plm_decode_video
plm_frame_t *plm_decode_video(plm_t *self) {
	if (!plm_init_decoders(self)) {
		return NULL;
	}

	if (!self->video_packet_type) {
		return NULL;
	}

	plm_frame_t *frame = plm_video_decode(self->video_decoder);
	if (frame) {
		self->time = frame->time;
	}
	else if (plm_demux_has_ended(self->demux)) {
		plm_handle_end(self);
	}
	return frame;
}

// Assembly:
pushq %rbx
movq %rdi, %rbx
callq 0x253e
testl %eax, %eax
je 0x31f0
cmpl $0x0, 0x20(%rbx)
je 0x31f0
movq 0x30(%rbx), %rdi
callq 0x3008
testq %rax, %rax
je 0x31dc
movsd (%rax), %xmm0
movsd %xmm0, 0x8(%rbx)
jmp 0x31f2
movq (%rbx), %rax
movq (%rax), %rax
cmpl $0x0, 0x24(%rax)
je 0x31f0
movq %rbx, %rdi
callq 0x319e
xorl %eax, %eax
popq %rbx
retq
// File: /workspace/github_c_makefile_star2_O2/phoboslab[P]pl_mpeg/./pl_mpeg.h
// Function: plm_decode_audio
plm_samples_t *plm_decode_audio(plm_t *self) {
	if (!plm_init_decoders(self)) {
		return NULL;
	}

	if (!self->audio_packet_type) {
		return NULL;
	}

	plm_samples_t *samples = plm_audio_decode(self->audio_decoder);
	if (samples) {
		self->time = samples->time;
	}
	else if (plm_demux_has_ended(self->demux)) {
		plm_handle_end(self);
	}
	return samples;
}

// Assembly:
pushq %rbx
movq %rdi, %rbx
callq 0x253e
testl %eax, %eax
je 0x3234
cmpl $0x0, 0x40(%rbx)
je 0x3234
movq 0x58(%rbx), %rdi
callq 0x310b
testq %rax, %rax
je 0x3220
movsd (%rax), %xmm0
movsd %xmm0, 0x8(%rbx)
jmp 0x3236
movq (%rbx), %rax
movq (%rax), %rax
cmpl $0x0, 0x24(%rax)
je 0x3234
movq %rbx, %rdi
callq 0x319e
xorl %eax, %eax
popq %rbx
retq
// File: /workspace/github_c_makefile_star2_O2/phoboslab[P]pl_mpeg/./pl_mpeg.h
// Function: plm_read_packets
void plm_read_packets(plm_t *self, int requested_type) {
	plm_packet_t *packet;
	while ((packet = plm_demux_decode(self->demux))) {
		if (packet->type == self->video_packet_type) {
			plm_buffer_write(self->video_buffer, packet->data, packet->length);
		}
		else if (packet->type == self->audio_packet_type) {
			plm_buffer_write(self->audio_buffer, packet->data, packet->length);
		}

		if (packet->type == requested_type) {
			return;
		}
	}

	if (plm_demux_has_ended(self->demux)) {
		if (self->video_buffer) {
			plm_buffer_signal_end(self->video_buffer);
		}
		if (self->audio_buffer) {
			plm_buffer_signal_end(self->audio_buffer);
		}
	}
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
movl %esi, %ebp
movq %rdi, %rbx
leaq 0x50(%rdi), %r15
leaq 0x28(%rdi), %r12
movq (%rbx), %rdi
callq 0x32bc
testq %rax, %rax
je 0x3286
movq %rax, %r14
movl (%rax), %ecx
movq %r12, %rax
cmpl 0x20(%rbx), %ecx
je 0x326f
movq %r15, %rax
cmpl 0x40(%rbx), %ecx
jne 0x327f
movq (%rax), %rdi
movq 0x10(%r14), %rdx
movq 0x18(%r14), %rsi
callq 0x3368
cmpl %ebp, (%r14)
jne 0x324d
jmp 0x32b3
movq (%rbx), %rax
movq (%rax), %rax
cmpl $0x0, 0x24(%rax)
je 0x32b3
movq (%r12), %rax
testq %rax, %rax
je 0x32a3
movq 0x10(%rax), %rcx
movq %rcx, 0x18(%rax)
movq (%r15), %rax
testq %rax, %rax
je 0x32b3
movq 0x10(%rax), %rcx
movq %rcx, 0x18(%rax)
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/phoboslab[P]pl_mpeg/./pl_mpeg.h
// Function: plm_demux_decode
plm_packet_t *plm_demux_decode(plm_demux_t *self) {
	if (!plm_demux_has_headers(self)) {
		return NULL;
	}

	if (self->current_packet.length) {
		size_t bits_till_next_packet = self->current_packet.length << 3;
		if (!plm_buffer_has(self->buffer, bits_till_next_packet)) {
			return NULL;
		}
		plm_buffer_skip(self->buffer, bits_till_next_packet);
		self->current_packet.length = 0;
	}

	// Pending packet waiting for data?
	if (self->next_packet.length) {
		return plm_demux_get_packet(self);
	}

	// Pending packet waiting for header?
	if (self->start_code != -1) {
		return plm_demux_decode_packet(self, self->start_code);
	}

	do {
		self->start_code = plm_buffer_next_start_code(self->buffer);
		if (
			self->start_code == PLM_DEMUX_PACKET_VIDEO_1 || 
			self->start_code == PLM_DEMUX_PACKET_PRIVATE || (
				self->start_code >= PLM_DEMUX_PACKET_AUDIO_1 && 
				self->start_code <= PLM_DEMUX_PACKET_AUDIO_4
			)
		) {
			return plm_demux_decode_packet(self, self->start_code);
		}
	} while (self->start_code != -1);

	return NULL;
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq %rdi, %rbx
callq 0x2619
testl %eax, %eax
je 0x335e
movq 0x60(%rbx), %r14
testq %r14, %r14
je 0x32fc
shlq $0x3, %r14
movq (%rbx), %rdi
movq %r14, %rsi
callq 0x3b9d
testl %eax, %eax
je 0x335e
movq (%rbx), %rdi
movq %r14, %rsi
callq 0x3c94
andq $0x0, 0x60(%rbx)
cmpq $0x0, 0x80(%rbx)
je 0x3315
movq %rbx, %rdi
addq $0x8, %rsp
popq %rbx
popq %r14
jmp 0x3fd1
movl 0x38(%rbx), %esi
cmpl $-0x1, %esi
je 0x3334
movq %rbx, %rdi
jmp 0x3352
movl %eax, %ecx
andl $-0x4, %ecx
cmpl $0xc0, %ecx
je 0x334d
cmpl $-0x1, %eax
je 0x335e
movq (%rbx), %rdi
callq 0x3d0c
movl %eax, 0x38(%rbx)
cmpl $0xbd, %eax
je 0x334d
cmpl $0xe0, %eax
jne 0x3322
movq %rbx, %rdi
movl %eax, %esi
addq $0x8, %rsp
popq %rbx
popq %r14
jmp 0x3ed6
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_c_makefile_star2_O2/phoboslab[P]pl_mpeg/./pl_mpeg.h
// Function: plm_buffer_write
size_t plm_buffer_write(plm_buffer_t *self, uint8_t *bytes, size_t length) {
	if (self->mode == PLM_BUFFER_MODE_FIXED_MEM) {
		return 0;
	}

	if (self->discard_read_bytes) {
		// This should be a ring buffer, but instead it just shifts all unread 
		// data to the beginning of the buffer and appends new data at the end. 
		// Seems to be good enough.

		plm_buffer_discard_read_bytes(self);
		if (self->mode == PLM_BUFFER_MODE_RING) {
			self->total_size = 0;
		}
	}

	// Do we have to resize to fit the new data?
	size_t bytes_available = self->capacity - self->length;
	if (bytes_available < length) {
		size_t new_size = self->capacity;
		do {
			new_size *= 2;
		} while (new_size - self->length < length);
		self->bytes = (uint8_t *)PLM_REALLOC(self->bytes, new_size);
		self->capacity = new_size;
	}

	memcpy(self->bytes + self->length, bytes, length);
	self->length += length;
	self->has_ended = FALSE;
	return length;
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
pushq %rax
cmpl $0x1, 0x60(%rdi)
jne 0x337a
xorl %ebx, %ebx
jmp 0x33f3
movq %rdx, %rbx
movq %rsi, %r15
movq %rdi, %r14
cmpl $0x0, 0x20(%rdi)
je 0x339d
movq %r14, %rdi
callq 0x3ac6
cmpl $0x2, 0x60(%r14)
jne 0x339d
andq $0x0, 0x18(%r14)
movq 0x8(%r14), %r12
movq 0x10(%r14), %rdi
movq %r12, %rax
subq %rdi, %rax
cmpq %rbx, %rax
jae 0x33d8
addq %r12, %r12
movq %r12, %rax
subq %rdi, %rax
cmpq %rbx, %rax
jb 0x33b0
movq 0x58(%r14), %rdi
movq %r12, %rsi
callq 0x2260
movq %rax, 0x58(%r14)
movq %r12, 0x8(%r14)
movq 0x10(%r14), %rdi
jmp 0x33dc
movq 0x58(%r14), %rax
addq %rax, %rdi
movq %r15, %rsi
movq %rbx, %rdx
callq 0x2140
addq %rbx, 0x10(%r14)
andl $0x0, 0x24(%r14)
movq %rbx, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O2/phoboslab[P]pl_mpeg/./pl_mpeg.h
// Function: plm_seek_frame
plm_frame_t *plm_seek_frame(plm_t *self, double time, int seek_exact) {
	if (!plm_init_decoders(self)) {
		return NULL;
	}

	if (!self->video_packet_type) {
		return NULL;
	}

	int type = self->video_packet_type;

	double start_time = plm_demux_get_start_time(self->demux, type);
	double duration = plm_demux_get_duration(self->demux, type);

	if (time < 0) {
		time = 0;
	}
	else if (time > duration) {
		time = duration;
	}
	
	plm_packet_t *packet = plm_demux_seek(self->demux, time, type, TRUE);
	if (!packet) {
		return NULL;
	}

	// Disable writing to the audio buffer while decoding video
	int previous_audio_packet_type = self->audio_packet_type;
	self->audio_packet_type = 0;

	// Clear video buffer and decode the found packet
	plm_video_rewind(self->video_decoder);
	plm_video_set_time(self->video_decoder, packet->pts - start_time);
	plm_buffer_write(self->video_buffer, packet->data, packet->length);
	plm_frame_t *frame = plm_video_decode(self->video_decoder);	

	// If we want to seek to an exact frame, we have to decode all frames
	// on top of the intra frame we just jumped to.
	if (seek_exact) {
		while (frame && frame->time < time) {
			frame = plm_video_decode(self->video_decoder);
		}
	}

	// Enable writing to the audio buffer again?
	self->audio_packet_type = previous_audio_packet_type;

	if (frame) {
		self->time = frame->time;
	}

	self->has_ended = FALSE;
	return frame;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
subq $0x18, %rsp
movl %esi, %ebp
movsd %xmm0, 0x8(%rsp)
movq %rdi, %rbx
callq 0x253e
testl %eax, %eax
je 0x351a
movl 0x20(%rbx), %r14d
testl %r14d, %r14d
je 0x351a
movq (%rbx), %rdi
movl %r14d, %esi
callq 0x3549
movsd %xmm0, 0x10(%rsp)
movq (%rbx), %rdi
movl %r14d, %esi
callq 0x2cc3
xorpd %xmm1, %xmm1
movsd 0x8(%rsp), %xmm2
ucomisd %xmm2, %xmm1
ja 0x3474
ucomisd %xmm0, %xmm2
movapd %xmm2, %xmm1
jbe 0x3474
movapd %xmm0, %xmm1
movq (%rbx), %rdi
pushq $0x1
popq %rdx
movsd %xmm1, 0x8(%rsp)
movapd %xmm1, %xmm0
movl %r14d, %esi
callq 0x35ca
testq %rax, %rax
je 0x351a
movq %rax, %r14
movl 0x40(%rbx), %r15d
andl $0x0, 0x40(%rbx)
movq 0x30(%rbx), %rdi
callq 0x2e13
movq 0x30(%rbx), %rax
movsd 0x8(%r14), %xmm0
subsd 0x10(%rsp), %xmm0
movsd (%rax), %xmm1
mulsd %xmm0, %xmm1
cvttsd2si %xmm1, %ecx
movl %ecx, 0x18(%rax)
movsd %xmm0, 0x10(%rax)
movq 0x28(%rbx), %rdi
movq 0x10(%r14), %rdx
movq 0x18(%r14), %rsi
callq 0x3368
movq 0x30(%rbx), %rdi
callq 0x3008
testl %ebp, %ebp
sete %cl
testq %rax, %rax
sete %dl
orb %cl, %dl
jne 0x351e
movsd (%rax), %xmm0
movsd 0x8(%rsp), %xmm1
ucomisd %xmm0, %xmm1
jbe 0x3531
movq 0x30(%rbx), %rdi
callq 0x3008
testq %rax, %rax
jne 0x34f6
movl %r15d, 0x40(%rbx)
jmp 0x352d
xorl %eax, %eax
jmp 0x353e
movl %r15d, 0x40(%rbx)
testq %rax, %rax
je 0x352d
movsd (%rax), %xmm0
jmp 0x3535
xorl %eax, %eax
jmp 0x353a
movl %r15d, 0x40(%rbx)
movsd %xmm0, 0x8(%rbx)
andl $0x0, 0x10(%rbx)
addq $0x18, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/phoboslab[P]pl_mpeg/./pl_mpeg.h
// Function: plm_demux_get_start_time
double plm_demux_get_start_time(plm_demux_t *self, int type) {
	if (self->start_time != PLM_PACKET_INVALID_TS) {
		return self->start_time;
	}

	int previous_pos = plm_buffer_tell(self->buffer);
	int previous_start_code = self->start_code;
	
	// Find first video PTS
	plm_demux_rewind(self);
	do {
		plm_packet_t *packet = plm_demux_decode(self);
		if (!packet) {
			break;
		}
		if (packet->type == type) {
			self->start_time = packet->pts;
		}
	} while (self->start_time == PLM_PACKET_INVALID_TS);

	plm_demux_buffer_seek(self, previous_pos);
	self->start_code = previous_start_code;
	return self->start_time;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movsd 0x28(%rdi), %xmm0
ucomisd 0x4c83(%rip), %xmm0     # 0x81e0
jne 0x35bf
jp 0x35bf
movl %esi, %ebp
movq %rdi, %rbx
movq (%rdi), %rdi
callq 0x3b67
movq %rax, %r14
movl 0x38(%rbx), %r15d
movq %rbx, %rdi
callq 0x2e54
movq %rbx, %rdi
callq 0x32bc
testq %rax, %rax
je 0x35ab
cmpl %ebp, (%rax)
jne 0x359a
movsd 0x8(%rax), %xmm0
movsd %xmm0, 0x28(%rbx)
jmp 0x359f
movsd 0x28(%rbx), %xmm0
ucomisd 0x4c39(%rip), %xmm0     # 0x81e0
jne 0x35ab
jnp 0x357d
movslq %r14d, %rsi
movq %rbx, %rdi
callq 0x3eb7
movl %r15d, 0x38(%rbx)
movsd 0x28(%rbx), %xmm0
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/phoboslab[P]pl_mpeg/./pl_mpeg.h
// Function: plm_seek
int plm_seek(plm_t *self, double time, int seek_exact) {
	plm_frame_t *frame = plm_seek_frame(self, time, seek_exact);
	
	if (!frame) {
		return FALSE;
	}

	if (self->video_decode_callback) {
		self->video_decode_callback(self, frame, self->video_decode_callback_user_data);	
	}

	// If audio is not enabled we are done here.
	if (!self->audio_packet_type) {
		return TRUE;
	}

	// Sync up Audio. This demuxes more packets until the first audio packet
	// with a PTS greater than the current time is found. plm_decode() is then
	// called to decode enough audio data to satisfy the audio_lead_time.

	double start_time = plm_demux_get_start_time(self->demux, self->video_packet_type);
	plm_audio_rewind(self->audio_decoder);

	plm_packet_t *packet = NULL;
	while ((packet = plm_demux_decode(self->demux))) {
		if (packet->type == self->video_packet_type) {
			plm_buffer_write(self->video_buffer, packet->data, packet->length);
		}
		else if (
			packet->type == self->audio_packet_type &&
			packet->pts - start_time > self->time
		) {
			plm_audio_set_time(self->audio_decoder, packet->pts - start_time);
			plm_buffer_write(self->audio_buffer, packet->data, packet->length);
			plm_decode(self, 0);
			break;
		}
	}	
	
	return TRUE;
}

// Assembly:
pushq %rbp
pushq %rbx
pushq %rax
movq %rdi, %rbx
callq 0x340b
testq %rax, %rax
je 0x39a0
movq 0x60(%rbx), %rcx
testq %rcx, %rcx
je 0x38f8
movq 0x68(%rbx), %rdx
movq %rbx, %rdi
movq %rax, %rsi
callq *%rcx
pushq $0x1
popq %rbp
cmpl $0x0, 0x40(%rbx)
je 0x39a2
movq (%rbx), %rdi
movl 0x20(%rbx), %esi
callq 0x3549
movsd %xmm0, (%rsp)
movq 0x58(%rbx), %rdi
callq 0x2e39
movq (%rbx), %rdi
callq 0x32bc
testq %rax, %rax
je 0x39a2
movl (%rax), %ecx
cmpl 0x20(%rbx), %ecx
jne 0x3945
movq 0x28(%rbx), %rdi
movq 0x10(%rax), %rdx
movq 0x18(%rax), %rsi
callq 0x3368
jmp 0x391e
cmpl 0x40(%rbx), %ecx
jne 0x391e
movsd 0x8(%rax), %xmm0
subsd (%rsp), %xmm0
ucomisd 0x8(%rbx), %xmm0
jbe 0x391e
movq 0x58(%rbx), %rcx
movslq 0xc(%rcx), %rdx
leaq 0x4866(%rip), %rsi      # 0x81d0
movzwl (%rsi,%rdx,2), %edx
cvtsi2sd %edx, %xmm1
mulsd %xmm0, %xmm1
cvttsd2si %xmm1, %edx
movl %edx, 0x8(%rcx)
movsd %xmm0, (%rcx)
movq 0x50(%rbx), %rdi
movq 0x10(%rax), %rdx
movq 0x18(%rax), %rsi
callq 0x3368
xorpd %xmm0, %xmm0
movq %rbx, %rdi
callq 0x2e91
jmp 0x39a2
xorl %ebp, %ebp
movl %ebp, %eax
addq $0x8, %rsp
popq %rbx
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/phoboslab[P]pl_mpeg/./pl_mpeg.h
// Function: plm_buffer_load_file_callback
void plm_buffer_load_file_callback(plm_buffer_t *self, void *user) {
	PLM_UNUSED(user);
	
	if (self->discard_read_bytes) {
		plm_buffer_discard_read_bytes(self);
	}

	size_t bytes_available = self->capacity - self->length;
	size_t bytes_read = fread(self->bytes + self->length, 1, bytes_available, self->fh);
	self->length += bytes_read;

	if (bytes_read == 0) {
		self->has_ended = TRUE;
	}
}

// Assembly:
pushq %rbx
movq %rdi, %rbx
cmpl $0x0, 0x20(%rdi)
je 0x39e0
movq %rbx, %rdi
callq 0x3ac6
movq 0x8(%rbx), %rdx
movq 0x10(%rbx), %rdi
subq %rdi, %rdx
addq 0x58(%rbx), %rdi
movq 0x30(%rbx), %rcx
pushq $0x1
popq %rsi
callq 0x2220
addq %rax, 0x10(%rbx)
testq %rax, %rax
jne 0x3a0b
movl $0x1, 0x24(%rbx)
popq %rbx
retq
// File: /workspace/github_c_makefile_star2_O2/phoboslab[P]pl_mpeg/./pl_mpeg.h
// Function: plm_buffer_create_with_callbacks
plm_buffer_t *plm_buffer_create_with_callbacks(
	plm_buffer_load_callback load_callback,
	plm_buffer_seek_callback seek_callback,
	plm_buffer_tell_callback tell_callback,
	size_t length,
	void *user
) {
	plm_buffer_t *self = plm_buffer_create_with_capacity(PLM_BUFFER_DEFAULT_SIZE);
	self->mode = PLM_BUFFER_MODE_FILE;
	self->total_size = length;
	self->load_callback = load_callback;
	self->seek_callback = seek_callback;
	self->tell_callback = tell_callback;
	self->load_callback_user_data = user;
	return self;
}

// Assembly:
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
movq %r8, %rbx
movq %rcx, %r14
movq %rdx, %r15
movq %rsi, %r12
movq %rdi, %r13
movl $0x20000, %edi          # imm = 0x20000
callq 0x277f
andl $0x0, 0x60(%rax)
movq %r14, 0x18(%rax)
movq %r13, 0x38(%rax)
movq %r12, 0x40(%rax)
movq %r15, 0x48(%rax)
movq %rbx, 0x50(%rax)
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O2/phoboslab[P]pl_mpeg/./pl_mpeg.h
// Function: plm_buffer_create_for_appending
plm_buffer_t *plm_buffer_create_for_appending(size_t initial_capacity) {
	plm_buffer_t *self = plm_buffer_create_with_capacity(initial_capacity);
	self->mode = PLM_BUFFER_MODE_APPEND;
	self->discard_read_bytes = FALSE;
	return self;
}

// Assembly:
pushq %rax
callq 0x277f
movl $0x3, 0x60(%rax)
andl $0x0, 0x20(%rax)
popq %rcx
retq
// File: /workspace/github_c_makefile_star2_O2/phoboslab[P]pl_mpeg/./pl_mpeg.h
// Function: plm_buffer_destroy
void plm_buffer_destroy(plm_buffer_t *self) {
#ifndef PLM_NO_STDIO
	if (self->fh && self->close_when_done) {
		fclose(self->fh);
	}
#endif
	if (self->free_when_done) {
		PLM_FREE(self->bytes);
	}
	PLM_FREE(self);
}

// Assembly:
pushq %rbx
movq %rdi, %rbx
movq 0x30(%rdi), %rdi
testq %rdi, %rdi
je 0x3a90
cmpl $0x0, 0x2c(%rbx)
je 0x3a90
callq 0x2170
cmpl $0x0, 0x28(%rbx)
je 0x3a9f
movq 0x58(%rbx), %rdi
callq 0x21c0
movq %rbx, %rdi
popq %rbx
jmp 0x21c0
// File: /workspace/github_c_makefile_star2_O2/phoboslab[P]pl_mpeg/./pl_mpeg.h
// Function: plm_buffer_discard_read_bytes
void plm_buffer_discard_read_bytes(plm_buffer_t *self) {
	size_t byte_pos = self->bit_index >> 3;
	if (byte_pos == self->length) {
		self->bit_index = 0;
		self->length = 0;
	}
	else if (byte_pos > 0) {
		memmove(self->bytes, self->bytes + byte_pos, self->length - byte_pos);
		self->bit_index -= byte_pos << 3;
		self->length -= byte_pos;
	}
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
movq %rdi, %rbx
movq (%rdi), %r15
movq 0x10(%rdi), %rdx
movq %r15, %r14
shrq $0x3, %r14
subq %r14, %rdx
jne 0x3ae9
andq $0x0, (%rbx)
xorl %eax, %eax
jmp 0x3b0a
cmpq $0x8, %r15
jb 0x3b0e
movq 0x58(%rbx), %rdi
leaq (%rdi,%r14), %rsi
callq 0x2250
andq $-0x8, %r15
subq %r15, (%rbx)
movq 0x10(%rbx), %rax
subq %r14, %rax
movq %rax, 0x10(%rbx)
popq %rbx
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O2/phoboslab[P]pl_mpeg/./pl_mpeg.h
// Function: plm_buffer_seek
void plm_buffer_seek(plm_buffer_t *self, size_t pos) {
	self->has_ended = FALSE;

	if (self->seek_callback) {
		self->seek_callback(self, pos, self->load_callback_user_data);
		self->bit_index = 0;
		self->length = 0;
	}
	else if (self->mode == PLM_BUFFER_MODE_RING) {
		if (pos != 0) {
			// Seeking to non-0 is forbidden for dynamic-mem buffers
			return; 
		}
		self->bit_index = 0;
		self->length = 0;
		self->total_size = 0;
	}
	else if (pos < self->length) {
		self->bit_index = pos << 3;
	}
}

// Assembly:
pushq %rbx
movq %rdi, %rbx
andl $0x0, 0x24(%rdi)
movq 0x40(%rdi), %rax
testq %rax, %rax
je 0x3b40
movq 0x50(%rbx), %rdx
movq %rbx, %rdi
callq *%rax
andq $0x0, (%rbx)
andq $0x0, 0x10(%rbx)
popq %rbx
retq
cmpl $0x2, 0x60(%rbx)
jne 0x3b58
testq %rsi, %rsi
jne 0x3b3e
andq $0x0, (%rbx)
xorps %xmm0, %xmm0
movups %xmm0, 0x10(%rbx)
jmp 0x3b3e
cmpq %rsi, 0x10(%rbx)
jbe 0x3b3e
shlq $0x3, %rsi
movq %rsi, (%rbx)
jmp 0x3b3e
// File: /workspace/github_c_makefile_star2_O2/phoboslab[P]pl_mpeg/./pl_mpeg.h
// Function: plm_buffer_has
int plm_buffer_has(plm_buffer_t *self, size_t count) {
	if (((self->length << 3) - self->bit_index) >= count) {
		return TRUE;
	}

	if (self->load_callback) {
		self->load_callback(self, self->load_callback_user_data);
		
		if (((self->length << 3) - self->bit_index) >= count) {
			return TRUE;
		}
	}	
	
	if (self->total_size != 0 && self->length == self->total_size) {
		self->has_ended = TRUE;
	}
	return FALSE;
}

// Assembly:
pushq %rbp
pushq %r14
pushq %rbx
movq 0x10(%rdi), %rax
leaq (,%rax,8), %rcx
subq (%rdi), %rcx
pushq $0x1
popq %rbp
cmpq %rsi, %rcx
jae 0x3c01
movq %rdi, %rbx
movq 0x38(%rdi), %rcx
testq %rcx, %rcx
je 0x3be4
movq %rsi, %r14
movq 0x50(%rbx), %rsi
movq %rbx, %rdi
callq *%rcx
movq 0x10(%rbx), %rax
leaq (,%rax,8), %rcx
subq (%rbx), %rcx
cmpq %r14, %rcx
jae 0x3c01
movq 0x18(%rbx), %rcx
testq %rcx, %rcx
sete %dl
cmpq %rcx, %rax
setne %al
xorl %ebp, %ebp
orb %dl, %al
jne 0x3c01
movl $0x1, 0x24(%rbx)
movl %ebp, %eax
popq %rbx
popq %r14
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/phoboslab[P]pl_mpeg/./pl_mpeg.h
// Function: plm_buffer_read
int plm_buffer_read(plm_buffer_t *self, int count) {
	if (!plm_buffer_has(self, count)) {
		return 0;
	}

	int value = 0;
	while (count) {
		int current_byte = self->bytes[self->bit_index >> 3];

		int remaining = 8 - (self->bit_index & 7); // Remaining bits in byte
		int read = remaining < count ? remaining : count; // Bits in self run
		int shift = remaining - read;
		int mask = (0xff >> (8 - read));

		value = (value << read) | ((current_byte & (mask << shift)) >> shift);

		self->bit_index += read;
		count -= read;
	}

	return value;
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movl %esi, %ebx
movq %rdi, %r14
movslq %esi, %rsi
callq 0x3b9d
testl %eax, %eax
je 0x3c7b
xorl %eax, %eax
pushq $0x8
popq %rdi
testl %ebx, %ebx
je 0x3c7d
movq (%r14), %r8
movq %r8, %r9
shrq $0x3, %r9
movl %r8d, %ecx
andl $0x7, %ecx
movl %edi, %edx
subl %ecx, %edx
cmpl %ebx, %edx
movl %ebx, %esi
cmovll %edx, %esi
subl %esi, %edx
movb $0x8, %cl
subb %sil, %cl
movl $0xff, %r10d
shrl %cl, %r10d
movl %esi, %ecx
shll %cl, %eax
movl %edx, %ecx
shll %cl, %r10d
movq 0x58(%r14), %rcx
movzbl (%rcx,%r9), %ecx
andl %ecx, %r10d
movl %edx, %ecx
shrl %cl, %r10d
orl %r10d, %eax
movslq %esi, %rcx
addq %rcx, %r8
movq %r8, (%r14)
subl %ecx, %ebx
jmp 0x3c22
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_c_makefile_star2_O2/phoboslab[P]pl_mpeg/./pl_mpeg.h
// Function: plm_buffer_skip_bytes
int plm_buffer_skip_bytes(plm_buffer_t *self, uint8_t v) {
	plm_buffer_align(self);
	int skipped = 0;
	while (plm_buffer_has(self, 8) && self->bytes[self->bit_index >> 3] == v) {
		self->bit_index += 8;
		skipped++;
	}
	return skipped;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movl %esi, %ebx
movq %rdi, %r14
movq (%rdi), %rax
addq $0x7, %rax
andq $-0x8, %rax
movq %rax, (%rdi)
xorl %ebp, %ebp
pushq $0x8
popq %r15
movq %r14, %rdi
movq %r15, %rsi
callq 0x3b9d
testl %eax, %eax
je 0x3cff
movq (%r14), %rax
movq 0x58(%r14), %rcx
movq %rax, %rdx
shrq $0x3, %rdx
cmpb %bl, (%rcx,%rdx)
jne 0x3cff
addq $0x8, %rax
movq %rax, (%r14)
incl %ebp
jmp 0x3cd2
movl %ebp, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/phoboslab[P]pl_mpeg/./pl_mpeg.h
// Function: plm_buffer_next_start_code
int plm_buffer_next_start_code(plm_buffer_t *self) {
	plm_buffer_align(self);

	while (plm_buffer_has(self, (5 << 3))) {
		size_t byte_index = (self->bit_index) >> 3;
		if (
			self->bytes[byte_index] == 0x00 &&
			self->bytes[byte_index + 1] == 0x00 &&
			self->bytes[byte_index + 2] == 0x01
		) {
			self->bit_index = (byte_index + 4) << 3;
			return self->bytes[byte_index + 3];
		}
		self->bit_index += 8;
	}
	return -1;
}

// Assembly:
pushq %rbp
pushq %r14
pushq %rbx
movq %rdi, %rbx
movq (%rdi), %rax
addq $0x7, %rax
andq $-0x8, %rax
pushq $0x28
popq %r14
pushq $-0x1
popq %rbp
movq %rax, (%rbx)
movq %rbx, %rdi
movq %r14, %rsi
callq 0x3b9d
testl %eax, %eax
je 0x3d6f
movq (%rbx), %rax
movq 0x58(%rbx), %rcx
movq %rax, %rdx
shrq $0x3, %rdx
cmpb $0x0, (%rcx,%rdx)
jne 0x3d59
cmpb $0x0, 0x1(%rcx,%rdx)
jne 0x3d59
cmpb $0x1, 0x2(%rcx,%rdx)
je 0x3d5f
addq $0x8, %rax
jmp 0x3d25
andq $-0x8, %rax
addq $0x20, %rax
movq %rax, (%rbx)
movzbl 0x3(%rcx,%rdx), %ebp
movl %ebp, %eax
popq %rbx
popq %r14
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/phoboslab[P]pl_mpeg/./pl_mpeg.h
// Function: plm_buffer_find_start_code
int plm_buffer_find_start_code(plm_buffer_t *self, int code) {
	int current = 0;
	while (TRUE) {
		current = plm_buffer_next_start_code(self);
		if (current == code || current == -1) {
			return current;
		}
	}
	return -1;
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movl %esi, %ebx
movq %rdi, %r14
movq %r14, %rdi
callq 0x3d0c
cmpl %ebx, %eax
je 0x3d90
cmpl $-0x1, %eax
jne 0x3d7f
addq $0x8, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_c_makefile_star2_O2/phoboslab[P]pl_mpeg/./pl_mpeg.h
// Function: plm_buffer_has_start_code
int plm_buffer_has_start_code(plm_buffer_t *self, int code) {
	size_t previous_bit_index = self->bit_index;
	int previous_discard_read_bytes = self->discard_read_bytes;
	
	self->discard_read_bytes = FALSE;
	int current = plm_buffer_find_start_code(self, code);

	self->bit_index = previous_bit_index;
	self->discard_read_bytes = previous_discard_read_bytes;
	return current;
}

// Assembly:
pushq %rbp
pushq %r14
pushq %rbx
movq %rdi, %rbx
movq (%rdi), %r14
movl 0x20(%rdi), %ebp
andl $0x0, 0x20(%rdi)
callq 0x3d76
movq %r14, (%rbx)
movl %ebp, 0x20(%rbx)
popq %rbx
popq %r14
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/phoboslab[P]pl_mpeg/./pl_mpeg.h
// Function: plm_buffer_peek_non_zero
int plm_buffer_peek_non_zero(plm_buffer_t *self, int bit_count) {
	if (!plm_buffer_has(self, bit_count)) {
		return FALSE;
	}

	int val = plm_buffer_read(self, bit_count);
	self->bit_index -= bit_count;
	return val != 0;
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq %rdi, %rbx
movslq %esi, %r14
movq %r14, %rsi
callq 0x3b9d
testl %eax, %eax
je 0x3de8
movq %rbx, %rdi
movl %r14d, %esi
callq 0x3c08
subq %r14, (%rbx)
movl %eax, %ecx
xorl %eax, %eax
testl %ecx, %ecx
setne %al
jmp 0x3dea
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_c_makefile_star2_O2/phoboslab[P]pl_mpeg/./pl_mpeg.h
// Function: plm_buffer_read_vlc
int16_t plm_buffer_read_vlc(plm_buffer_t *self, const plm_vlc_t *table) {
	plm_vlc_t state = {0, 0};
	do {
		state = table[state.index + plm_buffer_read(self, 1)];
	} while (state.index > 0);
	return state.value;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movq %rsi, %rbx
movq %rdi, %r14
xorl %eax, %eax
pushq $0x1
popq %rbp
movzwl %ax, %r15d
movq %r14, %rdi
movl %ebp, %esi
callq 0x3c08
addl %r15d, %eax
movslq %eax, %rcx
movzwl (%rbx,%rcx,4), %eax
testw %ax, %ax
jg 0x3e04
movzwl 0x2(%rbx,%rcx,4), %eax
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/phoboslab[P]pl_mpeg/./pl_mpeg.h
// Function: plm_demux_decode_time
double plm_demux_decode_time(plm_demux_t *self) {
	int64_t clock = plm_buffer_read(self->buffer, 3) << 30;
	plm_buffer_skip(self->buffer, 1);
	clock |= plm_buffer_read(self->buffer, 15) << 15;
	plm_buffer_skip(self->buffer, 1);
	clock |= plm_buffer_read(self->buffer, 15);
	plm_buffer_skip(self->buffer, 1);
	return (double)clock / 90000.0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
movq %rdi, %rbx
movq (%rdi), %rdi
pushq $0x3
popq %rsi
callq 0x3c08
movl %eax, %ebp
shll $0x1e, %ebp
movq (%rbx), %rdi
pushq $0x1
popq %r14
movq %r14, %rsi
callq 0x3c94
movq (%rbx), %rdi
pushq $0xf
popq %r15
movl %r15d, %esi
callq 0x3c08
movl %eax, %r12d
shll $0xf, %r12d
orl %ebp, %r12d
movq (%rbx), %rdi
movq %r14, %rsi
callq 0x3c94
movq (%rbx), %rdi
movl %r15d, %esi
callq 0x3c08
movl %eax, %ebp
orl %r12d, %ebp
movq (%rbx), %rdi
movq %r14, %rsi
callq 0x3c94
cvtsi2sd %ebp, %xmm0
divsd 0x4342(%rip), %xmm0     # 0x81f0
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/phoboslab[P]pl_mpeg/./pl_mpeg.h
// Function: plm_demux_buffer_seek
void plm_demux_buffer_seek(plm_demux_t *self, size_t pos) {
	plm_buffer_seek(self->buffer, pos);
	self->current_packet.length = 0;
	self->next_packet.length = 0;
	self->start_code = -1;
}

// Assembly:
pushq %rbx
movq %rdi, %rbx
movq (%rdi), %rdi
callq 0x3b1b
andq $0x0, 0x60(%rbx)
andq $0x0, 0x80(%rbx)
orl $-0x1, 0x38(%rbx)
popq %rbx
retq
// File: /workspace/github_c_makefile_star2_O2/phoboslab[P]pl_mpeg/./pl_mpeg.h
// Function: plm_demux_decode_packet
plm_packet_t *plm_demux_decode_packet(plm_demux_t *self, int type) {
	if (!plm_buffer_has(self->buffer, 16 << 3)) {
		return NULL;
	}

	self->start_code = -1;

	self->next_packet.type = type;
	self->next_packet.length = plm_buffer_read(self->buffer, 16);
	self->next_packet.length -= plm_buffer_skip_bytes(self->buffer, 0xff); // stuffing

	// skip P-STD
	if (plm_buffer_read(self->buffer, 2) == 0x01) {
		plm_buffer_skip(self->buffer, 16);
		self->next_packet.length -= 2;
	}

	int pts_dts_marker = plm_buffer_read(self->buffer, 2);
	if (pts_dts_marker == 0x03) {
		self->next_packet.pts = plm_demux_decode_time(self);
		self->last_decoded_pts = self->next_packet.pts;
		plm_buffer_skip(self->buffer, 40); // skip dts
		self->next_packet.length -= 10;
	}
	else if (pts_dts_marker == 0x02) {
		self->next_packet.pts = plm_demux_decode_time(self);
		self->last_decoded_pts = self->next_packet.pts;
		self->next_packet.length -= 5;
	}
	else if (pts_dts_marker == 0x00) {
		self->next_packet.pts = PLM_PACKET_INVALID_TS;
		plm_buffer_skip(self->buffer, 4);
		self->next_packet.length -= 1;
	}
	else {
		return NULL; // invalid
	}
	
	return plm_demux_get_packet(self);
}

// Assembly:
pushq %rbp
pushq %rbx
pushq %rax
movl %esi, %ebp
movq %rdi, %rbx
movq (%rdi), %rdi
movl $0x80, %esi
callq 0x3b9d
testl %eax, %eax
je 0x3f81
orl $-0x1, 0x38(%rbx)
movl %ebp, 0x70(%rbx)
movq (%rbx), %rdi
pushq $0x10
popq %rsi
callq 0x3c08
cltq
movq %rax, 0x80(%rbx)
movq (%rbx), %rdi
movl $0xff, %esi
callq 0x3cb2
cltq
subq %rax, 0x80(%rbx)
movq (%rbx), %rdi
pushq $0x2
popq %rsi
callq 0x3c08
cmpl $0x1, %eax
jne 0x3f47
movq (%rbx), %rdi
pushq $0x10
popq %rsi
callq 0x3c94
addq $-0x2, 0x80(%rbx)
movq (%rbx), %rdi
pushq $0x2
popq %rsi
callq 0x3c08
testl %eax, %eax
je 0x3fa0
cmpl $0x2, %eax
je 0x3f8a
cmpl $0x3, %eax
jne 0x3f81
movq %rbx, %rdi
callq 0x3e39
movsd %xmm0, 0x78(%rbx)
movsd %xmm0, 0x20(%rbx)
movq (%rbx), %rdi
pushq $0x28
popq %rsi
callq 0x3c94
pushq $-0xa
jmp 0x3fbb
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %rbp
retq
movq %rbx, %rdi
callq 0x3e39
movsd %xmm0, 0x78(%rbx)
movsd %xmm0, 0x20(%rbx)
pushq $-0x5
jmp 0x3fbb
movabsq $-0x4010000000000000, %rax # imm = 0xBFF0000000000000
movq %rax, 0x78(%rbx)
movq (%rbx), %rdi
pushq $0x4
popq %rsi
callq 0x3c94
pushq $-0x1
popq %rax
addq %rax, 0x80(%rbx)
movq %rbx, %rdi
addq $0x8, %rsp
popq %rbx
popq %rbp
jmp 0x3fd1
// File: /workspace/github_c_makefile_star2_O2/phoboslab[P]pl_mpeg/./pl_mpeg.h
// Function: plm_demux_get_packet
plm_packet_t *plm_demux_get_packet(plm_demux_t *self) {
	if (!plm_buffer_has(self->buffer, self->next_packet.length << 3)) {
		return NULL;
	}

	self->current_packet.data = self->buffer->bytes + (self->buffer->bit_index >> 3);
	self->current_packet.length = self->next_packet.length;
	self->current_packet.type = self->next_packet.type;
	self->current_packet.pts = self->next_packet.pts;

	self->next_packet.length = 0;
	return &self->current_packet;
}

// Assembly:
pushq %rbx
movq %rdi, %rbx
movq (%rdi), %rdi
movq 0x80(%rbx), %rsi
shlq $0x3, %rsi
callq 0x3b9d
testl %eax, %eax
je 0x4027
movq (%rbx), %rax
movq (%rax), %rcx
shrq $0x3, %rcx
addq 0x58(%rax), %rcx
leaq 0x50(%rbx), %rax
movq %rcx, 0x68(%rbx)
movq 0x80(%rbx), %rcx
movq %rcx, 0x60(%rbx)
movl 0x70(%rbx), %ecx
movl %ecx, 0x50(%rbx)
movsd 0x78(%rbx), %xmm0
movsd %xmm0, 0x58(%rbx)
andq $0x0, 0x80(%rbx)
jmp 0x4029
xorl %eax, %eax
popq %rbx
retq
// File: /workspace/github_c_makefile_star2_O2/phoboslab[P]pl_mpeg/./pl_mpeg.h
// Function: plm_video_init_frame
void plm_video_init_frame(plm_video_t *self, plm_frame_t *frame, uint8_t *base) {
	size_t luma_plane_size = self->luma_width * self->luma_height;
	size_t chroma_plane_size = self->chroma_width * self->chroma_height;

	frame->width = self->width;
	frame->height = self->height;
	frame->y.width = self->luma_width;
	frame->y.height = self->luma_height;
	frame->y.data = base;

	frame->cr.width = self->chroma_width;
	frame->cr.height = self->chroma_height;
	frame->cr.data = base + luma_plane_size;

	frame->cb.width = self->chroma_width;
	frame->cb.height = self->chroma_height;
	frame->cb.data = base + luma_plane_size + chroma_plane_size;
}

// Assembly:
movq 0x30(%rdi), %rax
movq %rax, %xmm0
pshufd $0x55, %xmm0, %xmm1     # xmm1 = xmm0[1,1,1,1]
movd %xmm1, %ecx
imull %eax, %ecx
movslq %ecx, %rax
movl 0x38(%rdi), %ecx
movl 0x3c(%rdi), %r8d
movq 0x1c(%rdi), %xmm1
punpcklqdq %xmm0, %xmm1    # xmm1 = xmm1[0],xmm0[0]
movdqu %xmm1, 0x8(%rsi)
movq %rdx, 0x18(%rsi)
movl %ecx, 0x20(%rsi)
movl %r8d, 0x24(%rsi)
addq %rdx, %rax
movq %rax, 0x28(%rsi)
movl %ecx, 0x30(%rsi)
movl %r8d, 0x34(%rsi)
imull %ecx, %r8d
movslq %r8d, %rcx
addq %rcx, %rax
movq %rax, 0x38(%rsi)
retq
// File: /workspace/github_c_makefile_star2_O2/phoboslab[P]pl_mpeg/./pl_mpeg.h
// Function: plm_video_decode_slice
void plm_video_decode_slice(plm_video_t *self, int slice) {
	self->slice_begin = TRUE;
	self->macroblock_address = (slice - 1) * self->mb_width - 1;

	// Reset motion vectors and DC predictors
	self->motion_backward.h = self->motion_forward.h = 0;
	self->motion_backward.v = self->motion_forward.v = 0;
	self->dc_predictor[0] = 128;
	self->dc_predictor[1] = 128;
	self->dc_predictor[2] = 128;

	self->quantizer_scale = plm_buffer_read(self->buffer, 5);

	// Skip extra
	while (plm_buffer_read(self->buffer, 1)) {
		plm_buffer_skip(self->buffer, 8);
	}

	do {
		plm_video_decode_macroblock(self);
	} while (
		self->macroblock_address < self->mb_size - 1 &&
		plm_buffer_peek_non_zero(self->buffer, 23)
	);
}

// Assembly:
pushq %rbp
pushq %r14
pushq %rbx
movq %rdi, %rbx
movl $0x1, 0x78(%rdi)
decl %esi
imull 0x24(%rdi), %esi
decl %esi
movl %esi, 0x7c(%rdi)
andq $0x0, 0x54(%rdi)
andq $0x0, 0x68(%rdi)
movabsq $0x8000000080, %rax     # imm = 0x8000000080
movq %rax, 0x90(%rdi)
movl $0x80, 0x98(%rdi)
movq 0xa0(%rdi), %rdi
pushq $0x5
popq %rsi
callq 0x3c08
movl %eax, 0x74(%rbx)
pushq $0x1
popq %rbp
pushq $0x8
popq %r14
movq 0xa0(%rbx), %rdi
movl %ebp, %esi
callq 0x3c08
testl %eax, %eax
je 0x455d
movq 0xa0(%rbx), %rdi
movq %r14, %rsi
callq 0x3c94
jmp 0x453a
pushq $0x17
popq %rbp
movq %rbx, %rdi
callq 0x4589
movl 0x2c(%rbx), %eax
decl %eax
cmpl %eax, 0x7c(%rbx)
jge 0x4584
movq 0xa0(%rbx), %rdi
movl %ebp, %esi
callq 0x3db9
testl %eax, %eax
jne 0x4560
popq %rbx
popq %r14
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/phoboslab[P]pl_mpeg/./pl_mpeg.h
// Function: plm_video_predict_macroblock
void plm_video_predict_macroblock(plm_video_t *self) {
	int fw_h = self->motion_forward.h;
	int fw_v = self->motion_forward.v;

	if (self->motion_forward.full_px) {
		fw_h <<= 1;
		fw_v <<= 1;
	}

	if (self->picture_type == PLM_VIDEO_PICTURE_TYPE_B) {
		int bw_h = self->motion_backward.h;
		int bw_v = self->motion_backward.v;

		if (self->motion_backward.full_px) {
			bw_h <<= 1;
			bw_v <<= 1;
		}

		if (self->motion_forward.is_set) {
			plm_video_copy_macroblock(self, &self->frame_forward, fw_h, fw_v);
			if (self->motion_backward.is_set) {
				plm_video_interpolate_macroblock(self, &self->frame_backward, bw_h, bw_v);
			}
		}
		else {
			plm_video_copy_macroblock(self, &self->frame_backward, bw_h, bw_v);
		}
	}
	else {
		plm_video_copy_macroblock(self, &self->frame_forward, fw_h, fw_v);
	}
}

// Assembly:
pushq %rbp
pushq %r14
pushq %rbx
movq %rdi, %rbx
movl 0x54(%rdi), %edx
movl 0x58(%rdi), %eax
cmpl $0x0, 0x48(%rdi)
setne %cl
shll %cl, %edx
shll %cl, %eax
cmpl $0x3, 0x44(%rdi)
jne 0x47ca
movl 0x68(%rbx), %r14d
movl 0x6c(%rbx), %ebp
cmpl $0x0, 0x5c(%rbx)
setne %cl
shll %cl, %r14d
shll %cl, %ebp
cmpl $0x0, 0x4c(%rbx)
je 0x47d8
leaq 0xf0(%rbx), %rsi
movq %rbx, %rdi
movl %eax, %ecx
callq 0x4d56
cmpl $0x0, 0x60(%rbx)
je 0x47f0
leaq 0x130(%rbx), %rsi
movq %rbx, %rdi
movl %r14d, %edx
movl %ebp, %ecx
popq %rbx
popq %r14
popq %rbp
jmp 0x4df2
leaq 0xf0(%rbx), %rsi
movq %rbx, %rdi
movl %eax, %ecx
jmp 0x47e7
leaq 0x130(%rbx), %rsi
movq %rbx, %rdi
movl %r14d, %edx
movl %ebp, %ecx
popq %rbx
popq %r14
popq %rbp
jmp 0x4d56
popq %rbx
popq %r14
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/phoboslab[P]pl_mpeg/./pl_mpeg.h
// Function: plm_video_decode_motion_vectors
void plm_video_decode_motion_vectors(plm_video_t *self) {

	// Forward
	if (self->motion_forward.is_set) {
		int r_size = self->motion_forward.r_size;
		self->motion_forward.h = plm_video_decode_motion_vector(self, r_size, self->motion_forward.h);
		self->motion_forward.v = plm_video_decode_motion_vector(self, r_size, self->motion_forward.v);
	}
	else if (self->picture_type == PLM_VIDEO_PICTURE_TYPE_PREDICTIVE) {
		// No motion information in P-picture, reset vectors
		self->motion_forward.h = 0;
		self->motion_forward.v = 0;
	}

	if (self->motion_backward.is_set) {
		int r_size = self->motion_backward.r_size;
		self->motion_backward.h = plm_video_decode_motion_vector(self, r_size, self->motion_backward.h);
		self->motion_backward.v = plm_video_decode_motion_vector(self, r_size, self->motion_backward.v);
	}
}

// Assembly:
pushq %rbp
pushq %rbx
pushq %rax
movq %rdi, %rbx
cmpl $0x0, 0x4c(%rdi)
je 0x4826
movl 0x50(%rbx), %ebp
movl 0x54(%rbx), %edx
movq %rbx, %rdi
movl %ebp, %esi
callq 0x4cc5
movl %eax, 0x54(%rbx)
movl 0x58(%rbx), %edx
movq %rbx, %rdi
movl %ebp, %esi
callq 0x4cc5
movl %eax, 0x58(%rbx)
jmp 0x4831
cmpl $0x2, 0x44(%rbx)
jne 0x4831
andq $0x0, 0x54(%rbx)
cmpl $0x0, 0x60(%rbx)
je 0x485a
movl 0x64(%rbx), %ebp
movl 0x68(%rbx), %edx
movq %rbx, %rdi
movl %ebp, %esi
callq 0x4cc5
movl %eax, 0x68(%rbx)
movl 0x6c(%rbx), %edx
movq %rbx, %rdi
movl %ebp, %esi
callq 0x4cc5
movl %eax, 0x6c(%rbx)
addq $0x8, %rsp
popq %rbx
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/phoboslab[P]pl_mpeg/./pl_mpeg.h
// Function: plm_video_decode_motion_vector
int plm_video_decode_motion_vector(plm_video_t *self, int r_size, int motion) {
	int fscale = 1 << r_size;
	int m_code = plm_buffer_read_vlc(self->buffer, PLM_VIDEO_MOTION);
	int r = 0;
	int d;

	if ((m_code != 0) && (fscale != 1)) {
		r = plm_buffer_read(self->buffer, r_size);
		d = ((abs(m_code) - 1) << r_size) + r + 1;
		if (m_code < 0) {
			d = -d;
		}
	}
	else {
		d = m_code;
	}

	motion += d;
	if (motion > (fscale << 4) - 1) {
		motion -= fscale << 5;
	}
	else if (motion < (int)((unsigned)(-fscale) << 4)) {
		motion += fscale << 5;
	}

	return motion;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movl %edx, %r14d
movl %esi, %ebp
movq %rdi, %r15
movq 0xa0(%rdi), %rdi
leaq 0x39ee(%rip), %rsi      # 0x86d0
callq 0x3df2
movswl %ax, %ebx
testw %bx, %bx
sete %al
testl %ebp, %ebp
sete %cl
orb %al, %cl
jne 0x4d23
movq 0xa0(%r15), %rdi
movl %ebp, %esi
callq 0x3c08
movl %ebx, %edx
negl %edx
cmovsl %ebx, %edx
decl %edx
movl %ebp, %ecx
shll %cl, %edx
testw %bx, %bx
leal (%rax,%rdx), %ebx
leal 0x1(%rax,%rdx), %eax
notl %ebx
cmovnsl %eax, %ebx
addl %r14d, %ebx
pushq $0x10
popq %rax
movl %ebp, %ecx
shll %cl, %eax
cmpl %eax, %ebx
jge 0x4d40
pushq $-0x10
popq %rax
movl %ebp, %ecx
shll %cl, %eax
cmpl %eax, %ebx
jge 0x4d49
pushq $0x20
jmp 0x4d42
pushq $-0x20
popq %rax
movl %ebp, %ecx
shll %cl, %eax
addl %eax, %ebx
movl %ebx, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq