// File: /workspace/github_c_makefile_star2_O1/jsummers[P]deark/modules/dlmaker.c
// Function: de_run_dlmaker
static void de_run_dlmaker(deark *c, de_module_params *mparams)
{
	lctx *d = NULL;
	i64 pos = 0;
	i64 k;
	i64 anim_cmds_size;
	int saved_indent_level;

	de_dbg_indent_save(c, &saved_indent_level);
	d = de_malloc(c, sizeof(lctx));
	d->input_encoding = de_get_input_encoding(c, NULL, DE_ENCODING_CP437);
	d->input_encoding = DE_EXTENC_MAKE(d->input_encoding, DE_ENCSUBTYPE_HYBRID);
	d->v12.opt_montage = de_get_ext_option_bool(c, "dlmaker:montage", 0);

	d->fi = de_finfo_create(c);
	d->fi->density.code = DE_DENSITY_UNK_UNITS;
	d->fi->density.xdens = 6.0;
	d->fi->density.ydens = 5.0;

	if(!do_read_header(c, d)) goto done;
	pos = d->hdr_size;

	if(d->ver==3) {
		for(k=0; k<d->num_images; k++) {
			i64 xsize, ysize;

			if(pos >= c->infile->len) goto done;
			de_dbg(c, "image #%u at %"I64_FMT, (UI)k, pos);
			de_dbg_indent(c, 1);
			xsize = de_getu16le_p(&pos);
			ysize = de_getu16le_p(&pos);
			de_dbg_dimensions(c, xsize, ysize);
			do_extract_v3_image(c, d, pos, xsize, ysize);
			pos += xsize*ysize;
			de_dbg_indent(c, -1);
		}
	}
	else {
		for(k=0; k<d->v12.num_screens; k++) {
			if(pos >= c->infile->len) goto done;
			de_dbg(c, "screen #%u at %"I64_FMT, (UI)k, pos);
			de_dbg_indent(c, 1);
			if(pos+V12_SCREEN_SIZE_IN_BYTES > c->infile->len) goto done;
			do_v12screen(c, d, pos);
			pos += V12_SCREEN_SIZE_IN_BYTES;
			de_dbg_indent(c, -1);
		}
	}

	anim_cmds_size = d->num_anim_code_units * d->anim_code_unit_size;
	de_dbg(c, "anim commands at %"I64_FMT", len=%"I64_FMT, pos, anim_cmds_size);
	pos += anim_cmds_size;
	if(d->ver==3) {
		do_audio(c, d, pos);
	}

done:
	de_dbg_indent_restore(c, saved_indent_level);
	if(d) {
		de_bitmap_destroy(d->v12.screen_img);
		de_bitmap_destroy(d->v12.img);
		de_finfo_destroy(c, d->fi);
		de_free(c, d);
	}
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movq %rdi, %r15
xorl %ebx, %ebx
movq %rbx, 0x20(%rsp)
leaq 0x34(%rsp), %rsi
callq 0xe958c
movl $0x470, %esi            # imm = 0x470
movq %r15, %rdi
callq 0xe969b
movq %rax, %r12
movq %rax, %r14
movq %r15, %rdi
xorl %esi, %esi
movl $0xd, %edx
callq 0xeb7d1
movzbl %al, %eax
orl $0x300, %eax            # imm = 0x300
movl %eax, (%r12)
leaq 0xc4f02(%rip), %rsi     # 0x122c3c
movq %r15, %rdi
xorl %edx, %edx
callq 0xea727
movl %eax, 0x8(%r12)
movq %r15, %rdi
callq 0xea9a9
movq %rax, 0x68(%r12)
movl $0x1, 0x78(%rax)
movabsq $0x4018000000000000, %rcx # imm = 0x4018000000000000
movq %rcx, 0x80(%rax)
movabsq $0x4014000000000000, %rcx # imm = 0x4014000000000000
movq %rcx, 0x88(%rax)
leaq 0x18(%rsp), %rsi
movq %rbx, (%rsi)
movq 0x18(%r15), %rdi
callq 0xef14d
movb %al, 0x4(%r12)
movzbl %al, %edx
leaq 0xd8c1b(%rip), %rsi     # 0x1369ba
movq %r15, %rdi
xorl %eax, %eax
callq 0xe9226
movzbl 0x4(%r12), %eax
leal -0x4(%rax), %ecx
cmpb $-0x3, %cl
jae 0x5de13
leaq 0xc4ecf(%rip), %rsi     # 0x122c8d
movq %r15, %rdi
xorl %eax, %eax
callq 0xe9df7
xorl %edi, %edi
callq 0xf6bb0
movl 0x34(%rsp), %esi
movq %r15, %rdi
callq 0xe9595
movq 0x30(%r14), %rdi
callq 0xf28d4
movq 0x38(%r14), %rdi
callq 0xf28d4
movq 0x68(%r14), %rsi
movq %r15, %rdi
callq 0xea9b3
movq %r15, %rdi
movq %r14, %rsi
callq 0xe9752
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %r12, %r13
cmpl $0x2, %eax
je 0x5de27
cmpl $0x1, %eax
jne 0x5de4f
movb $0x1, 0xc(%r14)
jmp 0x5de54
movq 0x18(%r15), %rdi
leaq 0x18(%rsp), %rsi
callq 0xef14d
movb %al, 0xc(%r14)
movzbl %al, %edx
leaq 0xc4e58(%rip), %rsi     # 0x122c9b
movq %r15, %rdi
xorl %eax, %eax
callq 0xe9226
jmp 0x5de54
incq 0x18(%rsp)
movb 0x4(%r14), %sil
cmpb $0x2, %sil
ja 0x5def6
movzbl 0xc(%r14), %eax
cmpq $0x2, %rax
ja 0x5e039
shll $0x3, %eax
leaq 0xc4f5d(%rip), %rcx     # 0x122dd8
movq (%rax,%rcx), %rcx
leaq 0xc4f6a(%rip), %rdx     # 0x122df0
movq (%rax,%rdx), %rdi
movq %rcx, 0x10(%r14)
movq %rdi, 0x18(%r14)
movl $0x140, %eax            # imm = 0x140
xorl %edx, %edx
idivq %rcx
movq %rax, %rcx
movl $0xc8, %eax
xorl %edx, %edx
idivq %rdi
imulq %rcx, %rax
movq %rax, 0x20(%r14)
cmpb $0x2, %sil
jne 0x5def6
movq %r15, %rdi
movl $0x1, %esi
callq 0xe9585
movq 0x10(%r14), %rsi
movq 0x18(%r14), %rdx
movq %r15, %rdi
callq 0xe9b05
movl 0x20(%r14), %edx
leaq 0xc4dec(%rip), %rsi     # 0x122ccb
movq %r15, %rdi
xorl %eax, %eax
callq 0xe9226
movq %r15, %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0xe9585
cmpb $0x3, 0x4(%r14)
jne 0x5df03
addq $0x32, 0x18(%rsp)
movq %r15, %rdi
callq 0xf6870
movq %rax, %r12
cmpb $0x3, 0x4(%r14)
movl $0x28, %eax
movq %r15, %rbx
movl $0x14, %r15d
cmoveq %rax, %r15
movq 0x18(%rsp), %rdx
movq %rbx, %rdi
movq %r14, %rsi
movq %r12, %rcx
movq %r15, %r8
callq 0x5e66d
movq %r12, %rdi
callq 0xf7557
leaq 0xc9fff(%rip), %rsi     # 0x127f49
movq %rbx, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0xe9226
addq %r15, 0x18(%rsp)
cmpb $0x1, 0x4(%r14)
je 0x5dfa2
movq %r12, %rdi
callq 0xf6883
movq 0x18(%rsp), %rdx
movq %rbx, %rdi
movq %r14, %rsi
movq %r12, %rcx
movq %r15, %r8
callq 0x5e66d
movq %r12, %rdi
callq 0xf7557
leaq 0xc4d4d(%rip), %rsi     # 0x122cdd
movq %rbx, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0xe9226
addq %r15, 0x18(%rsp)
cmpb $0x3, 0x4(%r14)
movq 0x18(%rbx), %rdi
movq %rbx, %r15
leaq 0x18(%rsp), %rsi
jne 0x5dfd3
callq 0xef1ed
movq %rax, 0x60(%r14)
leaq 0xc4d25(%rip), %rsi     # 0x122cea
movq %r15, %rdi
movl %eax, %edx
xorl %eax, %eax
callq 0xe9226
jmp 0x5e00e
callq 0xef14d
movzbl %al, %edx
movq %rdx, 0x28(%r14)
leaq 0xc4d13(%rip), %rsi     # 0x122cf9
movq %r15, %rdi
xorl %eax, %eax
callq 0xe9226
movq 0x20(%r14), %rdx
imulq 0x28(%r14), %rdx
movq %rdx, 0x60(%r14)
leaq 0xc4d05(%rip), %rsi     # 0x122d09
movq %r15, %rdi
xorl %eax, %eax
callq 0xe9226
movzbl 0x4(%r14), %eax
movq 0x18(%r15), %rdi
leaq 0x18(%rsp), %rsi
cmpl $0x3, %eax
je 0x5e032
cmpl $0x1, %eax
jne 0x5e045
callq 0xef1ed
movl $0x1, %ecx
jmp 0x5e04f
callq 0xef1ed
jmp 0x5e04a
leaq 0xc4c6d(%rip), %rsi     # 0x122cad
jmp 0x5ddbe
callq 0xef3a0
movl $0x2, %ecx
movq %rax, 0x48(%r14)
movq %rcx, 0x50(%r14)
leaq 0xc4cc8(%rip), %rsi     # 0x122d26
movq %r15, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0xe9226
cmpb $0x3, 0x4(%r14)
jne 0x5e098
movq 0x18(%r15), %rdi
leaq 0x18(%rsp), %rsi
callq 0xef1ed
movq %rax, 0x58(%r14)
leaq 0xc4cab(%rip), %rsi     # 0x122d36
movq %r15, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0xe9226
movq 0x18(%r15), %rsi
movq 0x18(%rsp), %rdx
movq %r13, %r9
addq $0x70, %r9
movl $0x0, 0x10(%rsp)
movl $0x2, 0x8(%rsp)
movq $0x100, (%rsp)          # imm = 0x100
movl $0x100, %ecx            # imm = 0x100
movl $0x3, %r8d
movq %r15, %rdi
movq %r9, 0x28(%rsp)
callq 0xf32f2
movl $0x300, %eax            # imm = 0x300
addq 0x18(%rsp), %rax
movq %rax, 0x18(%rsp)
movq %rax, 0x40(%r14)
movq %r12, %rdi
callq 0xf6bb0
movq 0x40(%r14), %rax
movq %rax, 0x20(%rsp)
cmpb $0x3, 0x4(%r14)
jne 0x5e227
cmpq $0x0, 0x60(%r14)
jle 0x5e3d3
xorl %ebp, %ebp
movq 0x20(%rsp), %rcx
movq 0x18(%r15), %rax
movq 0x18(%rax), %rax
cmpq %rax, %rcx
jge 0x5ddcf
movq %rax, 0x38(%rsp)
movq %r15, %rdi
leaq 0xc4b13(%rip), %rsi     # 0x122c4c
movl %ebp, %edx
movq %rcx, 0x40(%rsp)
xorl %eax, %eax
callq 0xe9226
movq %r15, %rdi
movl $0x1, %esi
callq 0xe9585
movq 0x18(%r15), %rdi
leaq 0x20(%rsp), %rbx
movq %rbx, %rsi
callq 0xef1ed
movq %rax, %r13
movq 0x18(%r15), %rdi
movq %rbx, %rsi
callq 0xef1ed
movq %rax, %r12
movq %r15, %rdi
movq %r13, %rsi
movq %rax, %rdx
callq 0xe9b05
movq 0x20(%rsp), %rbx
movq %r15, %rdi
movq %r13, %rsi
movq %r12, %rdx
callq 0xf241d
testl %eax, %eax
je 0x5e1e5
movq %r15, %rdi
movq %r13, %rsi
movq %r12, %rdx
movl $0x3, %ecx
callq 0xf2cab
movq %rbx, %rsi
movq %rax, %rbx
movq 0x18(%r15), %rdi
movl $0x0, (%rsp)
movl $0x8, %edx
movq %r13, %rcx
movq 0x28(%rsp), %r8
movq %rax, %r9
callq 0xf35b8
movq 0x68(%r14), %rsi
movq %rbx, %rdi
xorl %edx, %edx
callq 0xf2917
jmp 0x5e1e7
xorl %ebx, %ebx
movq %rbx, %rdi
callq 0xf28d4
imulq %r13, %r12
addq %r12, 0x20(%rsp)
movq %r15, %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0xe9585
movq 0x38(%rsp), %rax
cmpq %rax, 0x40(%rsp)
jge 0x5ddcf
incq %rbp
cmpq 0x60(%r14), %rbp
jl 0x5e114
jmp 0x5e3d3
cmpq $0x0, 0x28(%r14)
jle 0x5e3d3
xorl %r13d, %r13d
movq 0x20(%rsp), %rcx
movq 0x18(%r15), %rax
cmpq 0x18(%rax), %rcx
jge 0x5ddcf
movq %r15, %rdi
leaq 0xc4a0b(%rip), %rsi     # 0x122c5d
movl %r13d, %edx
xorl %eax, %eax
callq 0xe9226
movq %r15, %rdi
movl $0x1, %esi
callq 0xe9585
movq 0x20(%rsp), %rbp
leaq 0xfa00(%rbp), %rax
movq 0x18(%r15), %rcx
cmpq 0x18(%rcx), %rax
jg 0x5ddcf
movq %r15, %r12
movb $0x1, %bl
cmpq $0x2, 0x20(%r14)
jl 0x5e297
cmpl $0x0, 0x8(%r14)
setne %bl
cmpq $0x0, 0x30(%r14)
jne 0x5e2eb
movl $0x140, %esi            # imm = 0x140
movl $0xc8, %edx
movq %r12, %r15
movq %r12, %rdi
movl $0x3, %ecx
callq 0xf2cab
movq %rax, 0x30(%r14)
testb %bl, %bl
je 0x5e2e7
movq 0x18(%r15), %rdi
movl $0x0, (%rsp)
movl $0x8, %edx
movl $0x140, %ecx            # imm = 0x140
movq %rbp, %rsi
movq 0x28(%rsp), %r8
movq %rax, %r9
callq 0xf35b8
jmp 0x5e316
movb $0x1, 0x38(%rax)
movq 0x18(%r12), %rdi
movq 0x30(%r14), %r9
movl $0x0, (%rsp)
movl $0x8, %edx
movl $0x140, %ecx            # imm = 0x140
movq %rbp, %rsi
movq 0x28(%rsp), %r8
callq 0xf35b8
testb %bl, %bl
je 0x5e32a
movq 0x30(%r14), %rdi
movq 0x68(%r14), %rsi
xorl %edx, %edx
callq 0xf2917
jmp 0x5e3ad
cmpq $0x0, 0x38(%r14)
jne 0x5e34a
movq 0x10(%r14), %rsi
movq 0x18(%r14), %rdx
movq %r12, %rdi
movl $0x3, %ecx
callq 0xf2cab
movq %rax, 0x38(%r14)
cmpq $0x0, 0x20(%r14)
jle 0x5e3ad
xorl %r15d, %r15d
xorl %ebp, %ebp
xorl %ebx, %ebx
movq 0x30(%r14), %rdi
movq 0x38(%r14), %rsi
movq 0x10(%r14), %r8
movq 0x18(%r14), %r9
xorps %xmm0, %xmm0
movups %xmm0, (%rsp)
movl $0x0, 0x10(%rsp)
movq %rbp, %rdx
movq %r15, %rcx
callq 0xf3d2f
movq 0x38(%r14), %rdi
movq 0x68(%r14), %rsi
xorl %edx, %edx
callq 0xf2917
addq 0x10(%r14), %rbp
cmpq $0x140, %rbp            # imm = 0x140
jl 0x5e3a4
addq 0x18(%r14), %r15
xorl %ebp, %ebp
incq %rbx
cmpq 0x20(%r14), %rbx
jl 0x5e358
addq $0xfa00, 0x20(%rsp)     # imm = 0xFA00
movq %r12, %r15
movq %r12, %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0xe9585
incq %r13
cmpq 0x28(%r14), %r13
jl 0x5e235
movq 0x50(%r14), %rbx
imulq 0x48(%r14), %rbx
movq 0x20(%rsp), %rdx
leaq 0xc4887(%rip), %rsi     # 0x122c6f
movq %r15, %rdi
movq %rbx, %rcx
xorl %eax, %eax
callq 0xe9226
addq 0x20(%rsp), %rbx
movq %rbx, 0x20(%rsp)
cmpb $0x3, 0x4(%r14)
jne 0x5ddcf
movq %rbx, 0x18(%rsp)
cmpq $0x0, 0x58(%r14)
movq %r15, %r13
jle 0x5e511
xorl %ebx, %ebx
movq 0x18(%rsp), %rdx
leaq 0x5(%rdx), %rax
movq 0x18(%r13), %rcx
cmpq 0x18(%rcx), %rax
jg 0x5e511
movq %r13, %rdi
leaq 0xc4910(%rip), %rsi     # 0x122d50
xorl %eax, %eax
callq 0xe9226
movq %r13, %rdi
movl $0x1, %esi
callq 0xe9585
movq 0x18(%r13), %rdi
leaq 0x18(%rsp), %rsi
callq 0xef3a0
movq %rax, %rbp
movq %r13, %rdi
leaq 0xe6d66(%rip), %rsi     # 0x1451d5
movq %rax, %rdx
xorl %eax, %eax
callq 0xe9226
movq 0x18(%rsp), %r15
leaq 0x1(%r15), %rax
movq %rax, 0x18(%rsp)
cmpq $0x1b, %rbp
jl 0x5e4e7
leaq (%r15,%rbp), %rax
incq %rax
movq 0x18(%r13), %rcx
movl $0x0, %r12d
cmpq 0x18(%rcx), %rax
jg 0x5e4ea
movq %r13, %rdi
leaq 0xc48b9(%rip), %rsi     # 0x122d67
xorl %edx, %edx
xorl %ecx, %ecx
callq 0xf037a
movq %rax, %r12
movl $0x14, %edx
movq %rax, %rdi
leaq 0xc48a2(%rip), %rsi     # 0x122d6b
callq 0xefb82
movq 0x18(%r13), %rdi
addq $0x15, %r15
leaq -0x14(%rbp), %rdx
movq %r15, %rsi
movq %r12, %rcx
callq 0xefabc
jmp 0x5e4ea
xorl %r12d, %r12d
movq %r12, %rdi
callq 0xf0b13
movq %r13, %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0xe9585
addq %rbp, 0x18(%rsp)
incq %rbx
cmpq 0x58(%r14), %rbx
jl 0x5e41f
movq %r13, %r15
jmp 0x5ddcf