// File: /workspace/github_c_makefile_star2_O2/jonof[P]jftekwar/libsmacker/smacker.c
// Function: smk_close
void smk_close(smk s)
{
	unsigned long u;

	if (s == NULL) {
		fputs("libsmacker::smk_close() - ERROR: smk is NULL\n", stderr);
		return;
	}

	/* free video sub-components */
	for (u = 0; u < 4; u ++) {
		if (s->video.tree[u].tree) free(s->video.tree[u].tree);
	}

	smk_free(s->video.frame);

	/* free audio sub-components */
	for (u = 0; u < 7; u++) {
		if (s->audio[u].buffer)
			smk_free(s->audio[u].buffer);
	}

	smk_free(s->keyframe);
	smk_free(s->frame_type);

	if (s->mode == SMK_MODE_DISK) {
		/* disk-mode */
		if (s->source.file.fp)
			fclose(s->source.file.fp);

		smk_free(s->source.file.chunk_offset);
	} else {
		/* mem-mode */
		if (s->source.chunk_data != NULL) {
			for (u = 0; u < (s->f + s->ring_frame); u++)
				smk_free(s->source.chunk_data[u]);

			smk_free(s->source.chunk_data);
		}
	}

	smk_free(s->chunk_size);
	smk_free(s);
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
testq %rdi, %rdi
je 0x2c56b
movq %rdi, %rbx
movl $0x90, %r14d
cmpq $0xf0, %r14
je 0x2c44c
movq (%rbx,%r14), %rdi
callq 0x8270
addq $0x18, %r14
jmp 0x2c434
movq 0x3f0(%rbx), %rdi
testq %rdi, %rdi
je 0x2c5a5
callq 0x8270
andq $0x0, 0x3f0(%rbx)
movl $0x418, %r14d           # imm = 0x418
cmpq $0x568, %r14            # imm = 0x568
je 0x2c491
movq (%rbx,%r14), %rdi
testq %rdi, %rdi
je 0x2c48b
callq 0x8270
andq $0x0, (%rbx,%r14)
addq $0x30, %r14
jmp 0x2c46f
movq 0x40(%rbx), %rdi
testq %rdi, %rdi
je 0x2c5c4
callq 0x8270
andq $0x0, 0x40(%rbx)
movq 0x48(%rbx), %rdi
testq %rdi, %rdi
je 0x2c5e3
callq 0x8270
andq $0x0, 0x48(%rbx)
cmpb $0x0, (%rbx)
movq 0x28(%rbx), %rdi
je 0x2c528
testq %rdi, %rdi
je 0x2c54c
leaq 0x28(%rbx), %r14
xorl %r15d, %r15d
movzbl 0x18(%rbx), %eax
addq 0x10(%rbx), %rax
movq 0x28(%rbx), %rdi
cmpq %rax, %r15
jae 0x2c504
movq (%rdi,%r15,8), %rdi
testq %rdi, %rdi
je 0x2c586
callq 0x8270
movq (%r14), %rax
andq $0x0, (%rax,%r15,8)
incq %r15
jmp 0x2c4d4
testq %rdi, %rdi
jne 0x2c543
leaq 0x68e3a(%rip), %rdi     # 0x9534a
leaq 0x68dbc(%rip), %rsi     # 0x952d3
leaq 0x68dca(%rip), %rcx     # 0x952e8
movl $0x3cf, %edx            # imm = 0x3CF
callq 0x8240
testq %rdi, %rdi
je 0x2c532
callq 0x8640
movq 0x30(%rbx), %rdi
testq %rdi, %rdi
je 0x2c621
leaq 0x30(%rbx), %r14
callq 0x8270
andq $0x0, (%r14)
movq 0x38(%rbx), %rdi
testq %rdi, %rdi
je 0x2c602
callq 0x8270
movq %rbx, %rdi
popq %rbx
popq %r14
popq %r15
jmp 0x8270
movq 0x9aa26(%rip), %rax     # 0xc6f98
movq (%rax), %rsi
leaq 0x68d1a(%rip), %rdi     # 0x95296
popq %rbx
popq %r14
popq %r15
jmp 0x8470
leaq 0x68da5(%rip), %rdi     # 0x95332
leaq 0x68d3f(%rip), %rsi     # 0x952d3
leaq 0x68d4d(%rip), %rcx     # 0x952e8
movl $0x3cd, %edx            # imm = 0x3CD
callq 0x8240
leaq 0x68d18(%rip), %rdi     # 0x952c4
leaq 0x68d20(%rip), %rsi     # 0x952d3
leaq 0x68d2e(%rip), %rcx     # 0x952e8
movl $0x3b8, %edx            # imm = 0x3B8
callq 0x8240
leaq 0x68d31(%rip), %rdi     # 0x952fc
leaq 0x68d01(%rip), %rsi     # 0x952d3
leaq 0x68d0f(%rip), %rcx     # 0x952e8
movl $0x3c0, %edx            # imm = 0x3C0
callq 0x8240
leaq 0x68d1e(%rip), %rdi     # 0x95308
leaq 0x68ce2(%rip), %rsi     # 0x952d3
leaq 0x68cf0(%rip), %rcx     # 0x952e8
movl $0x3c1, %edx            # imm = 0x3C1
callq 0x8240
leaq 0x68d56(%rip), %rdi     # 0x9535f
leaq 0x68cc3(%rip), %rsi     # 0x952d3
leaq 0x68cd1(%rip), %rcx     # 0x952e8
movl $0x3d3, %edx            # imm = 0x3D3
callq 0x8240
leaq 0x68cee(%rip), %rdi     # 0x95316
leaq 0x68ca4(%rip), %rsi     # 0x952d3
leaq 0x68cb2(%rip), %rcx     # 0x952e8
movl $0x3c8, %edx            # imm = 0x3C8
callq 0x8240