// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x50, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq $0x0, -0x18(%rbp)
movq $0x0, -0x20(%rbp)
movq -0x8(%rbp), %rdi
leaq -0x34(%rbp), %rsi
callq 0x15b580
movq -0x8(%rbp), %rdi
movl $0x470, %esi            # imm = 0x470
callq 0x15b780
movq %rax, -0x18(%rbp)
movq -0x8(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
movl $0xd, %edx
callq 0x15e4a0
movl %eax, %ecx
movq -0x18(%rbp), %rax
movl %ecx, (%rax)
movq -0x18(%rbp), %rax
movl (%rax), %ecx
andl $0xff, %ecx
orl $0x300, %ecx            # imm = 0x300
movq -0x18(%rbp), %rax
movl %ecx, (%rax)
movq -0x8(%rbp), %rdi
leaq 0x1286f4(%rip), %rsi    # 0x1ae8b0
xorl %edx, %edx
callq 0x15cbc0
movl %eax, %ecx
movq -0x18(%rbp), %rax
movl %ecx, 0x8(%rax)
movq -0x8(%rbp), %rdi
callq 0x15d230
movq %rax, %rcx
movq -0x18(%rbp), %rax
movq %rcx, 0x68(%rax)
movq -0x18(%rbp), %rax
movq 0x68(%rax), %rax
movl $0x1, 0x78(%rax)
movq -0x18(%rbp), %rax
movq 0x68(%rax), %rax
movsd 0x128689(%rip), %xmm0   # 0x1ae888
movsd %xmm0, 0x80(%rax)
movq -0x18(%rbp), %rax
movq 0x68(%rax), %rax
movsd 0x128669(%rip), %xmm0   # 0x1ae880
movsd %xmm0, 0x88(%rax)
movq -0x8(%rbp), %rdi
movq -0x18(%rbp), %rsi
callq 0x86700
cmpl $0x0, %eax
jne 0x86236
jmp 0x8644a
movq -0x18(%rbp), %rax
movq 0x40(%rax), %rax
movq %rax, -0x20(%rbp)
movq -0x18(%rbp), %rax
movzbl 0x4(%rax), %eax
cmpl $0x3, %eax
jne 0x86337
movq $0x0, -0x28(%rbp)
movq -0x28(%rbp), %rax
movq -0x18(%rbp), %rcx
cmpq 0x60(%rcx), %rax
jge 0x86332
movq -0x20(%rbp), %rax
movq -0x8(%rbp), %rcx
movq 0x18(%rcx), %rcx
cmpq 0x18(%rcx), %rax
jl 0x86284
jmp 0x8644a
movq -0x8(%rbp), %rdi
movq -0x28(%rbp), %rax
movl %eax, %edx
movq -0x20(%rbp), %rcx
leaq 0x128627(%rip), %rsi    # 0x1ae8c0
movb $0x0, %al
callq 0x15b0d0
movq -0x8(%rbp), %rdi
movl $0x1, %esi
callq 0x15b560
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
leaq -0x20(%rbp), %rsi
callq 0x1652c0
movq %rax, -0x40(%rbp)
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
leaq -0x20(%rbp), %rsi
callq 0x1652c0
movq %rax, -0x48(%rbp)
movq -0x8(%rbp), %rdi
movq -0x40(%rbp), %rsi
movq -0x48(%rbp), %rdx
callq 0x15bba0
movq -0x8(%rbp), %rdi
movq -0x18(%rbp), %rsi
movq -0x20(%rbp), %rdx
movq -0x40(%rbp), %rcx
movq -0x48(%rbp), %r8
callq 0x86c30
movq -0x40(%rbp), %rax
imulq -0x48(%rbp), %rax
addq -0x20(%rbp), %rax
movq %rax, -0x20(%rbp)
movq -0x8(%rbp), %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0x15b560
movq -0x28(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x28(%rbp)
jmp 0x8625b
jmp 0x863ef
movq $0x0, -0x28(%rbp)
movq -0x28(%rbp), %rax
movq -0x18(%rbp), %rcx
cmpq 0x28(%rcx), %rax
jge 0x863ed
movq -0x20(%rbp), %rax
movq -0x8(%rbp), %rcx
movq 0x18(%rcx), %rcx
cmpq 0x18(%rcx), %rax
jl 0x86368
jmp 0x8644a
movq -0x8(%rbp), %rdi
movq -0x28(%rbp), %rax
movl %eax, %edx
movq -0x20(%rbp), %rcx
leaq 0x128554(%rip), %rsi    # 0x1ae8d1
movb $0x0, %al
callq 0x15b0d0
movq -0x8(%rbp), %rdi
movl $0x1, %esi
callq 0x15b560
movq -0x20(%rbp), %rax
addq $0xfa00, %rax           # imm = 0xFA00
movq -0x8(%rbp), %rcx
movq 0x18(%rcx), %rcx
cmpq 0x18(%rcx), %rax
jle 0x863af
jmp 0x8644a
movq -0x8(%rbp), %rdi
movq -0x18(%rbp), %rsi
movq -0x20(%rbp), %rdx
callq 0x86ce0
movq -0x20(%rbp), %rax
addq $0xfa00, %rax           # imm = 0xFA00
movq %rax, -0x20(%rbp)
movq -0x8(%rbp), %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0x15b560
movq -0x28(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x28(%rbp)
jmp 0x8633f
jmp 0x863ef
movq -0x18(%rbp), %rax
movq 0x48(%rax), %rax
movq -0x18(%rbp), %rcx
imulq 0x50(%rcx), %rax
movq %rax, -0x30(%rbp)
movq -0x8(%rbp), %rdi
movq -0x20(%rbp), %rdx
movq -0x30(%rbp), %rcx
leaq 0x1284cc(%rip), %rsi    # 0x1ae8e3
movb $0x0, %al
callq 0x15b0d0
movq -0x30(%rbp), %rax
addq -0x20(%rbp), %rax
movq %rax, -0x20(%rbp)
movq -0x18(%rbp), %rax
movzbl 0x4(%rax), %eax
cmpl $0x3, %eax
jne 0x86448
movq -0x8(%rbp), %rdi
movq -0x18(%rbp), %rsi
movq -0x20(%rbp), %rdx
callq 0x86ed0
jmp 0x8644a
movq -0x8(%rbp), %rdi
movl -0x34(%rbp), %esi
callq 0x15b5a0
cmpq $0x0, -0x18(%rbp)
je 0x86495
movq -0x18(%rbp), %rax
movq 0x30(%rax), %rdi
callq 0x16af60
movq -0x18(%rbp), %rax
movq 0x38(%rax), %rdi
callq 0x16af60
movq -0x8(%rbp), %rdi
movq -0x18(%rbp), %rax
movq 0x68(%rax), %rsi
callq 0x15d260
movq -0x8(%rbp), %rdi
movq -0x18(%rbp), %rsi
callq 0x15b820
addq $0x50, %rsp
popq %rbp
retq
nopl (%rax,%rax)