// File: /workspace/github_c_makefile_star2_O2/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, %rbp
andq $0x0, 0x20(%rsp)
leaq 0x3c(%rsp), %rsi
callq 0xdebae
movl $0x470, %esi            # imm = 0x470
movq %rbp, %rdi
callq 0xdecaf
movq %rax, %rbx
movq %rax, %r14
pushq $0xd
popq %rdx
movq %rbp, %rdi
xorl %esi, %esi
callq 0xe08d2
movzbl %al, %eax
orl $0x300, %eax            # imm = 0x300
movl %eax, (%rbx)
leaq 0xbb2f7(%rip), %rsi     # 0x115ca0
movq %rbp, %rdi
xorl %edx, %edx
callq 0xdfae5
movl %eax, 0x8(%rbx)
movq %rbp, %rdi
callq 0xdfd1a
movq %rax, 0x68(%rbx)
movl $0x1, 0x78(%rax)
movaps 0xbb2a0(%rip), %xmm0    # 0x115c70
movups %xmm0, 0x80(%rax)
leaq 0x18(%rsp), %rsi
andq $0x0, (%rsi)
movq 0x18(%rbp), %rdi
callq 0xe3f2a
movb %al, 0x4(%rbx)
movzbl %al, %edx
leaq 0xcf08e(%rip), %rsi     # 0x129a84
movq %rbp, %rdi
xorl %eax, %eax
callq 0xde896
movzbl 0x4(%rbx), %eax
leal -0x4(%rax), %ecx
cmpb $-0x3, %cl
jae 0x5aa68
leaq 0xbb2de(%rip), %rsi     # 0x115cf1
movq %rbp, %rdi
xorl %eax, %eax
callq 0xdf2a5
xorl %edi, %edi
callq 0xeaf3c
movl 0x3c(%rsp), %esi
movq %rbp, %rdi
callq 0xdebb7
movq 0x30(%r14), %rdi
callq 0xe7084
movq 0x38(%r14), %rdi
callq 0xe7084
movq 0x68(%r14), %rsi
movq %rbp, %rdi
callq 0xdfd24
movq %rbp, %rdi
movq %r14, %rsi
callq 0xded32
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rbx, %r13
pushq $0x64
popq %rbx
cmpl $0x2, %eax
je 0x5aafb
cmpl $0x1, %eax
jne 0x5ab60
movb $0x1, 0xc(%r14)
movl $0xa0, %esi
xorl %ecx, %ecx
movq %rsi, 0x10(%r14)
movq %rbx, 0x18(%r14)
movw $0x140, %ax             # imm = 0x140
xorl %edx, %edx
divw %si
movzwl %ax, %edx
movb $-0x38, %al
movzbl %al, %eax
divb %bl
movzbl %al, %eax
imulq %rdx, %rax
movq %rax, 0x20(%r14)
testb %cl, %cl
je 0x5ab71
pushq $0x1
popq %rsi
movq %rbp, %rdi
callq 0xdeba7
movq 0x10(%r14), %rsi
movq 0x18(%r14), %rdx
movq %rbp, %rdi
callq 0xdf038
movl 0x20(%r14), %edx
leaq 0xbb24f(%rip), %rsi     # 0x115d2f
movq %rbp, %rdi
xorl %eax, %eax
callq 0xde896
pushq $-0x1
popq %rsi
movq %rbp, %rdi
callq 0xdeba7
movb 0x4(%r14), %al
jmp 0x5ab55
movq 0x18(%rbp), %rdi
leaq 0x18(%rsp), %rsi
callq 0xe3f2a
movb %al, 0xc(%r14)
movzbl %al, %edx
leaq 0xbb1e8(%rip), %rsi     # 0x115cff
movq %rbp, %rdi
xorl %eax, %eax
callq 0xde896
movb 0x4(%r14), %al
cmpb $0x2, %al
ja 0x5ab55
movzbl 0xc(%r14), %eax
sete %cl
testl %eax, %eax
je 0x5b138
cmpl $0x2, %eax
je 0x5b12d
cmpl $0x1, %eax
jne 0x5b147
movl $0xa0, %esi
jmp 0x5aa8c
cmpb $0x3, %al
jne 0x5ab71
movq 0x18(%rsp), %rax
jmp 0x5ab68
movq 0x18(%rsp), %rax
incq %rax
addq $0x32, %rax
movq %rax, 0x18(%rsp)
movq %rbp, %rdi
callq 0xeac74
movq %rax, %r12
cmpb $0x3, 0x4(%r14)
pushq $0x28
popq %rax
pushq $0x14
popq %r15
cmoveq %rax, %r15
movq 0x18(%rsp), %rdx
movq %rbp, %rdi
movq %r14, %rsi
movq %r12, %rcx
movq %r15, %r8
callq 0x5b294
movq %r12, %rdi
callq 0xeb877
leaq 0xc0388(%rip), %rsi     # 0x11af39
movq %rbp, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0xde896
addq %r15, 0x18(%rsp)
cmpb $0x1, 0x4(%r14)
je 0x5ac37
movq %r12, %rdi
callq 0xeac85
movq 0x18(%rsp), %rdx
movq %rbp, %rdi
movq %r14, %rsi
movq %r12, %rcx
movq %r15, %r8
callq 0x5b294
movq %r12, %rdi
callq 0xeb877
leaq 0xbb14a(%rip), %rsi     # 0x115d41
movq %rbp, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0xde896
addq %r15, 0x18(%rsp)
cmpb $0x3, 0x4(%r14)
jne 0x5ac37
movq 0x18(%rbp), %rdi
leaq 0x18(%rsp), %rsi
callq 0xe3fc4
movq %rax, 0x60(%r14)
leaq 0xbb125(%rip), %rsi     # 0x115d4e
movq %rbp, %rdi
movl %eax, %edx
xorl %eax, %eax
callq 0xde896
jmp 0x5ac7b
movq 0x18(%rbp), %rdi
leaq 0x18(%rsp), %rsi
callq 0xe3f2a
movzbl %al, %edx
movq %rdx, 0x28(%r14)
leaq 0xbb10a(%rip), %rsi     # 0x115d5d
movq %rbp, %rdi
xorl %eax, %eax
callq 0xde896
movq 0x20(%r14), %rdx
imulq 0x28(%r14), %rdx
movq %rdx, 0x60(%r14)
leaq 0xbb0fc(%rip), %rsi     # 0x115d6d
movq %rbp, %rdi
xorl %eax, %eax
callq 0xde896
movzbl 0x4(%r14), %eax
movq 0x18(%rbp), %rdi
pushq $0x2
popq %rbx
leaq 0x18(%rsp), %rsi
cmpl $0x3, %eax
je 0x5aca0
cmpl $0x1, %eax
jne 0x5aca7
callq 0xe3fc4
pushq $0x1
popq %rbx
jmp 0x5acac
callq 0xe3fc4
jmp 0x5acac
callq 0xe40bf
movq %rax, 0x48(%r14)
movq %rbx, 0x50(%r14)
leaq 0xbb0cf(%rip), %rsi     # 0x115d8a
movq %rbp, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0xde896
cmpb $0x3, 0x4(%r14)
jne 0x5acf5
movq 0x18(%rbp), %rdi
leaq 0x18(%rsp), %rsi
callq 0xe3fc4
movq %rax, 0x58(%r14)
leaq 0xbb0b2(%rip), %rsi     # 0x115d9a
movq %rbp, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0xde896
movq 0x18(%rbp), %rsi
movq 0x18(%rsp), %rdx
movq %r13, %r9
addq $0x70, %r9
andl $0x0, 0x10(%rsp)
movl $0x2, 0x8(%rsp)
movq $0x100, (%rsp)          # imm = 0x100
pushq $0x3
popq %r8
movl $0x100, %ecx            # imm = 0x100
movq %rbp, %rdi
movq %r9, 0x30(%rsp)
callq 0xe79ca
movl $0x300, %eax            # imm = 0x300
addq 0x18(%rsp), %rax
movq %rax, 0x18(%rsp)
movq %rax, 0x40(%r14)
movq %r12, %rdi
callq 0xeaf3c
movq 0x40(%r14), %r12
movq %r12, 0x20(%rsp)
cmpb $0x3, 0x4(%r14)
movq %rbp, 0x28(%rsp)
jne 0x5ae61
xorl %edx, %edx
movq 0x28(%rsp), %rbp
movq 0x20(%rsp), %r12
cmpq 0x60(%r14), %rdx
jge 0x5afe8
movq 0x18(%rbp), %rax
cmpq 0x18(%rax), %r12
jge 0x5aa24
movq %rbp, %rdi
leaq 0xbaf1e(%rip), %rsi     # 0x115cb0
movq %rdx, 0x40(%rsp)
movq %r12, %rcx
xorl %eax, %eax
callq 0xde896
movq %rbp, %rdi
pushq $0x1
popq %rsi
callq 0xdeba7
movq 0x18(%rbp), %rdi
leaq 0x20(%rsp), %rbx
movq %rbx, %rsi
callq 0xe3fc4
movq %rax, %r12
movq 0x18(%rbp), %rdi
movq %rbx, %rsi
callq 0xe3fc4
movq %rax, %r15
movq %rbp, %rdi
movq %r12, %rsi
movq %rax, %rdx
callq 0xdf038
movq 0x20(%rsp), %r13
movq %rbp, %rdi
movq %r12, %rsi
movq %r15, %rdx
callq 0xe6be1
testl %eax, %eax
je 0x5ae36
movq %rbp, %rdi
movq %r12, %rsi
movq %r15, %rdx
pushq $0x3
popq %rcx
callq 0xe7437
movq %rax, %rbx
movq 0x18(%rbp), %rdi
andl $0x0, (%rsp)
movq %r13, %rsi
pushq $0x8
popq %rdx
movq %r12, %rcx
movq 0x30(%rsp), %r8
movq %rax, %r9
callq 0xe7cbc
movq 0x68(%r14), %rsi
movq %rbx, %rdi
xorl %edx, %edx
callq 0xe70ab
jmp 0x5ae38
xorl %ebx, %ebx
movq %rbx, %rdi
callq 0xe7084
imulq %r12, %r15
addq %r15, 0x20(%rsp)
movq %rbp, %rdi
pushq $-0x1
popq %rsi
callq 0xdeba7
movq 0x40(%rsp), %rdx
incq %rdx
jmp 0x5ad6b
xorl %r13d, %r13d
cmpq 0x28(%r14), %r13
jge 0x5afed
movq 0x18(%rbp), %rax
cmpq 0x18(%rax), %r12
jge 0x5aa24
movq %rbp, %rdi
leaq 0xbae3b(%rip), %rsi     # 0x115cc1
movl %r13d, %edx
movq %r12, %rcx
xorl %eax, %eax
callq 0xde896
movq %rbp, %rdi
pushq $0x1
popq %rsi
callq 0xdeba7
leaq 0xfa00(%r12), %rbx
movq 0x18(%rbp), %rdi
cmpq 0x18(%rdi), %rbx
jg 0x5aa24
movb $0x1, %bpl
cmpq $0x2, 0x20(%r14)
jl 0x5aec7
cmpl $0x0, 0x8(%r14)
setne %bpl
movq 0x30(%r14), %r9
testq %r9, %r9
jne 0x5af1e
movl $0x140, %esi            # imm = 0x140
movl $0xc8, %edx
movq 0x28(%rsp), %r15
movq %r15, %rdi
pushq $0x3
popq %rcx
callq 0xe7437
movq %rax, %r9
movq %rax, 0x30(%r14)
testb %bpl, %bpl
je 0x5af15
movq 0x18(%r15), %rdi
andl $0x0, (%rsp)
movl $0x140, %ecx            # imm = 0x140
movq %r12, %rsi
pushq $0x8
popq %rdx
movq 0x30(%rsp), %r8
callq 0xe7cbc
jmp 0x5af3c
movb $0x1, 0x38(%r9)
movq 0x18(%r15), %rdi
andl $0x0, (%rsp)
movl $0x140, %ecx            # imm = 0x140
movq %r12, %rsi
pushq $0x8
popq %rdx
movq 0x30(%rsp), %r8
callq 0xe7cbc
testb %bpl, %bpl
je 0x5af6b
movq 0x30(%r14), %rdi
movq 0x68(%r14), %rsi
xorl %edx, %edx
callq 0xe70ab
movq %rbx, 0x20(%rsp)
movq 0x28(%rsp), %rbp
movq %rbp, %rdi
pushq $-0x1
popq %rsi
callq 0xdeba7
incq %r13
movq %rbx, %r12
jmp 0x5ae64
cmpq $0x0, 0x38(%r14)
jne 0x5af8b
movq 0x10(%r14), %rsi
movq 0x18(%r14), %rdx
movq 0x28(%rsp), %rdi
pushq $0x3
popq %rcx
callq 0xe7437
movq %rax, 0x38(%r14)
xorl %ebp, %ebp
xorl %r12d, %r12d
xorl %r15d, %r15d
cmpq 0x20(%r14), %rbp
jge 0x5af4b
movq 0x30(%r14), %rdi
movq 0x38(%r14), %rsi
movq 0x10(%r14), %r8
movq 0x18(%r14), %r9
xorps %xmm0, %xmm0
movups %xmm0, (%rsp)
andl $0x0, 0x10(%rsp)
movq %r12, %rdx
movq %r15, %rcx
callq 0xe8314
movq 0x38(%r14), %rdi
movq 0x68(%r14), %rsi
xorl %edx, %edx
callq 0xe70ab
addq 0x10(%r14), %r12
cmpq $0x140, %r12            # imm = 0x140
jl 0x5afe3
addq 0x18(%r14), %r15
xorl %r12d, %r12d
incq %rbp
jmp 0x5af93
movq 0x28(%rsp), %rbp
movq 0x50(%r14), %r15
imulq 0x48(%r14), %r15
leaq 0xbacd6(%rip), %rsi     # 0x115cd3
movq %rbp, %rdi
movq %r12, %rdx
movq %r15, %rcx
xorl %eax, %eax
callq 0xde896
addq 0x20(%rsp), %r15
movq %r15, 0x20(%rsp)
cmpb $0x3, 0x4(%r14)
jne 0x5aa24
leaq 0x18(%rsp), %rax
movq %r15, (%rax)
xorl %ebx, %ebx
movq %rbp, %r12
cmpq 0x58(%r14), %rbx
jge 0x5b125
leaq 0x5(%r15), %rax
movq 0x18(%r12), %rcx
cmpq 0x18(%rcx), %rax
jg 0x5b125
movq %r12, %rdi
leaq 0xbad5e(%rip), %rsi     # 0x115db4
movq %r15, %rdx
xorl %eax, %eax
callq 0xde896
movq %r12, %rdi
pushq $0x1
popq %rsi
callq 0xdeba7
movq 0x18(%r12), %rdi
leaq 0x18(%rsp), %rsi
callq 0xe40bf
movq %rax, %r15
movq %r12, %rdi
leaq 0xdd1de(%rip), %rsi     # 0x138265
movq %rax, %rdx
xorl %eax, %eax
callq 0xde896
movq 0x18(%rsp), %r13
leaq 0x1(%r13), %rax
movq %rax, 0x18(%rsp)
cmpq $0x1b, %r15
jl 0x5b0fe
leaq (%r15,%r13), %rax
incq %rax
movq 0x18(%r12), %rcx
movl $0x0, %ebp
cmpq 0x18(%rcx), %rax
jg 0x5b100
movq %r12, %rdi
leaq 0xbad05(%rip), %rsi     # 0x115dcb
xorl %edx, %edx
xorl %ecx, %ecx
callq 0xe4e62
movq %rax, %rbp
movq %rax, %rdi
leaq 0xbacf3(%rip), %rsi     # 0x115dcf
pushq $0x14
popq %rdx
callq 0xe46ba
movq 0x18(%r12), %rdi
addq $0x15, %r13
leaq -0x14(%r15), %rdx
movq %r13, %rsi
movq %rbp, %rcx
callq 0xe45f4
jmp 0x5b100
xorl %ebp, %ebp
movq %rbp, %rdi
callq 0xe5591
movq %r12, %rdi
pushq $-0x1
popq %rsi
callq 0xdeba7
addq 0x18(%rsp), %r15
movq %r15, 0x18(%rsp)
incq %rbx
jmp 0x5b02f
movq %r12, %rbp
jmp 0x5aa24
pushq $0x32
popq %rbx
pushq $0x50
popq %rsi
jmp 0x5aa8c
movl $0xc8, %ebx
movl $0x140, %esi            # imm = 0x140
jmp 0x5aa8c
leaq 0xbabc3(%rip), %rsi     # 0x115d11
jmp 0x5aa13