// File: /workspace/github_c_makefile_star2_O0/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 %rbp
movq %rsp, %rbp
subq $0x10, %rsp
movq %rdi, -0x8(%rbp)
cmpq $0x0, -0x8(%rbp)
jne 0x463fe
movq 0xd2bee(%rip), %rax     # 0x118fd8
movq (%rax), %rsi
leaq 0xa6e92(%rip), %rdi     # 0xed286
callq 0x8430
jmp 0x467ad
movq $0x0, -0x10(%rbp)
cmpq $0x4, -0x10(%rbp)
jae 0x46453
movq -0x8(%rbp), %rax
addq $0x50, %rax
addq $0x40, %rax
imulq $0x18, -0x10(%rbp), %rcx
addq %rcx, %rax
cmpq $0x0, (%rax)
je 0x46443
movq -0x8(%rbp), %rax
addq $0x50, %rax
addq $0x40, %rax
imulq $0x18, -0x10(%rbp), %rcx
addq %rcx, %rax
movq (%rax), %rdi
callq 0x8260
jmp 0x46445
movq -0x10(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x10(%rbp)
jmp 0x46406
movq -0x8(%rbp), %rax
cmpq $0x0, 0x3f0(%rax)
je 0x46463
jmp 0x46482
leaq 0xa6e4a(%rip), %rdi     # 0xed2b4
leaq 0xa6e52(%rip), %rsi     # 0xed2c3
movl $0x3b8, %edx            # imm = 0x3B8
leaq 0xa6e5b(%rip), %rcx     # 0xed2d8
callq 0x8230
movq -0x8(%rbp), %rax
movq 0x3f0(%rax), %rdi
callq 0x8260
movq -0x8(%rbp), %rax
movq $0x0, 0x3f0(%rax)
movq $0x0, -0x10(%rbp)
cmpq $0x7, -0x10(%rbp)
jae 0x4654f
movq -0x8(%rbp), %rax
addq $0x3f8, %rax            # imm = 0x3F8
imulq $0x30, -0x10(%rbp), %rcx
addq %rcx, %rax
cmpq $0x0, 0x20(%rax)
je 0x4653c
movq -0x8(%rbp), %rax
addq $0x3f8, %rax            # imm = 0x3F8
imulq $0x30, -0x10(%rbp), %rcx
addq %rcx, %rax
cmpq $0x0, 0x20(%rax)
je 0x464e8
jmp 0x46507
leaq 0xa6dfd(%rip), %rdi     # 0xed2ec
leaq 0xa6dcd(%rip), %rsi     # 0xed2c3
movl $0x3bd, %edx            # imm = 0x3BD
leaq 0xa6dd6(%rip), %rcx     # 0xed2d8
callq 0x8230
movq -0x8(%rbp), %rax
addq $0x3f8, %rax            # imm = 0x3F8
imulq $0x30, -0x10(%rbp), %rcx
addq %rcx, %rax
movq 0x20(%rax), %rdi
callq 0x8260
movq -0x8(%rbp), %rax
addq $0x3f8, %rax            # imm = 0x3F8
imulq $0x30, -0x10(%rbp), %rcx
addq %rcx, %rax
movq $0x0, 0x20(%rax)
jmp 0x4653e
movq -0x10(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x10(%rbp)
jmp 0x464a9
movq -0x8(%rbp), %rax
cmpq $0x0, 0x40(%rax)
je 0x4655c
jmp 0x4657b
leaq 0xa6d9c(%rip), %rdi     # 0xed2ff
leaq 0xa6d59(%rip), %rsi     # 0xed2c3
movl $0x3c0, %edx            # imm = 0x3C0
leaq 0xa6d62(%rip), %rcx     # 0xed2d8
callq 0x8230
movq -0x8(%rbp), %rax
movq 0x40(%rax), %rdi
callq 0x8260
movq -0x8(%rbp), %rax
movq $0x0, 0x40(%rax)
movq -0x8(%rbp), %rax
cmpq $0x0, 0x48(%rax)
je 0x465a1
jmp 0x465c0
leaq 0xa6d63(%rip), %rdi     # 0xed30b
leaq 0xa6d14(%rip), %rsi     # 0xed2c3
movl $0x3c1, %edx            # imm = 0x3C1
leaq 0xa6d1d(%rip), %rcx     # 0xed2d8
callq 0x8230
movq -0x8(%rbp), %rax
movq 0x48(%rax), %rdi
callq 0x8260
movq -0x8(%rbp), %rax
movq $0x0, 0x48(%rax)
movq -0x8(%rbp), %rax
movzbl (%rax), %eax
cmpl $0x0, %eax
jne 0x46647
movq -0x8(%rbp), %rax
cmpq $0x0, 0x28(%rax)
je 0x465fd
movq -0x8(%rbp), %rax
movq 0x28(%rax), %rdi
callq 0x85d0
movq -0x8(%rbp), %rax
cmpq $0x0, 0x30(%rax)
je 0x4660a
jmp 0x46629
leaq 0xa6d08(%rip), %rdi     # 0xed319
leaq 0xa6cab(%rip), %rsi     # 0xed2c3
movl $0x3c8, %edx            # imm = 0x3C8
leaq 0xa6cb4(%rip), %rcx     # 0xed2d8
callq 0x8230
movq -0x8(%rbp), %rax
movq 0x30(%rax), %rdi
callq 0x8260
movq -0x8(%rbp), %rax
movq $0x0, 0x30(%rax)
jmp 0x4672f
movq -0x8(%rbp), %rax
cmpq $0x0, 0x28(%rax)
je 0x4672d
movq $0x0, -0x10(%rbp)
movq -0x10(%rbp), %rax
movq -0x8(%rbp), %rcx
movq 0x10(%rcx), %rcx
movq -0x8(%rbp), %rdx
movzbl 0x18(%rdx), %edx
addq %rdx, %rcx
cmpq %rcx, %rax
jae 0x466e8
movq -0x8(%rbp), %rax
movq 0x28(%rax), %rax
movq -0x10(%rbp), %rcx
cmpq $0x0, (%rax,%rcx,8)
je 0x4668f
jmp 0x466ae
leaq 0xa6c9f(%rip), %rdi     # 0xed335
leaq 0xa6c26(%rip), %rsi     # 0xed2c3
movl $0x3cd, %edx            # imm = 0x3CD
leaq 0xa6c2f(%rip), %rcx     # 0xed2d8
callq 0x8230
movq -0x8(%rbp), %rax
movq 0x28(%rax), %rax
movq -0x10(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
callq 0x8260
movq -0x8(%rbp), %rax
movq 0x28(%rax), %rax
movq -0x10(%rbp), %rcx
movq $0x0, (%rax,%rcx,8)
movq -0x10(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x10(%rbp)
jmp 0x4665e
movq -0x8(%rbp), %rax
cmpq $0x0, 0x28(%rax)
je 0x466f5
jmp 0x46714
leaq 0xa6c51(%rip), %rdi     # 0xed34d
leaq 0xa6bc0(%rip), %rsi     # 0xed2c3
movl $0x3cf, %edx            # imm = 0x3CF
leaq 0xa6bc9(%rip), %rcx     # 0xed2d8
callq 0x8230
movq -0x8(%rbp), %rax
movq 0x28(%rax), %rdi
callq 0x8260
movq -0x8(%rbp), %rax
movq $0x0, 0x28(%rax)
jmp 0x4672f
movq -0x8(%rbp), %rax
cmpq $0x0, 0x38(%rax)
je 0x4673c
jmp 0x4675b
leaq 0xa6c1f(%rip), %rdi     # 0xed362
leaq 0xa6b79(%rip), %rsi     # 0xed2c3
movl $0x3d3, %edx            # imm = 0x3D3
leaq 0xa6b82(%rip), %rcx     # 0xed2d8
callq 0x8230
movq -0x8(%rbp), %rax
movq 0x38(%rax), %rdi
callq 0x8260
movq -0x8(%rbp), %rax
movq $0x0, 0x38(%rax)
cmpq $0x0, -0x8(%rbp)
je 0x4677d
jmp 0x4679c
leaq 0xa8fcb(%rip), %rdi     # 0xef74f
leaq 0xa6b38(%rip), %rsi     # 0xed2c3
movl $0x3d4, %edx            # imm = 0x3D4
leaq 0xa6b41(%rip), %rcx     # 0xed2d8
callq 0x8230
movq -0x8(%rbp), %rdi
callq 0x8260
movq $0x0, -0x8(%rbp)
addq $0x10, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)