// File: /workspace/github_c_makefile_star2_O1/jsummers[P]deark/modules/psd.c
// Function: do_pattern_internal
static int do_pattern_internal(deark *c, lctx *d, zztype *zz)
{
	i64 pat_color_mode;
	i64 ver;
	i64 w, h;
	de_ucstring *s = NULL;
	zztype vmalzz; // for virtual memory array list
	int retval = 0;

	ver = psd_getu32zz(zz);
	de_dbg(c, "version: %d", (int)ver);
	if(ver!=1) goto done;

	pat_color_mode = psd_getu32zz(zz);
	de_dbg(c, "color mode: %d (%s)", (int)pat_color_mode, get_colormode_name(pat_color_mode));

	h = psd_getu16zz(zz);
	w = psd_getu16zz(zz);
	de_dbg_dimensions(c, w, h);

	s = ucstring_create(c);
	read_unicode_string(c, d, s, zz);
	de_dbg(c, "name: \"%s\"", ucstring_getpsz_d(s));

	ucstring_empty(s);
	read_pascal_string_to_ucstring(c, d, s, zz);
	de_dbg(c, "id: \"%s\"", ucstring_getpsz_d(s));

	if(pat_color_mode==PSD_CM_PALETTE) {
		de_dbg(c, "palette at %d", (int)zz->pos);
		zz->pos += 3*256;
	}

	zz_init(&vmalzz, zz);
	do_vm_array_list(c, d, &vmalzz);
	zz->pos += zz_used(&vmalzz);
	retval = 1;
done:
	ucstring_destroy(s);
	return retval;
}

// Assembly:
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x20, %rsp
movq %rdx, %rbx
movq %rsi, %r14
movq %rdi, %r15
movq 0x18(%rdi), %rdi
movl 0x4(%rsi), %edx
movq (%rbx), %rsi
callq 0xef614
movq %rax, %r12
addq $0x4, (%rbx)
leaq 0x88621(%rip), %rsi     # 0x1343d1
xorl %r13d, %r13d
movq %r15, %rdi
movl %r12d, %edx
xorl %eax, %eax
callq 0xe9226
cmpq $0x1, %r12
jne 0xabdf0
movq 0x18(%r15), %rdi
movl 0x4(%r14), %edx
movq (%rbx), %rsi
callq 0xef614
movq %rax, %r13
addq $0x4, (%rbx)
cmpq $0x9, %rax
ja 0xabdf8
leaq 0xda026(%rip), %rax     # 0x185e10
movq (%rax,%r13,8), %rcx
jmp 0xabdff
xorl %r12d, %r12d
jmp 0xabf2f
leaq 0x8006a(%rip), %rcx     # 0x12be69
leaq 0x8819f(%rip), %rsi     # 0x133fa5
movq %r15, %rdi
movl %r13d, %edx
xorl %eax, %eax
callq 0xe9226
movq 0x18(%r15), %rdi
movl 0x4(%r14), %edx
movq (%rbx), %rsi
callq 0xef570
movq %rax, %r12
movq (%rbx), %rsi
addq $0x2, %rsi
movq %rsi, (%rbx)
movq 0x18(%r15), %rdi
movl 0x4(%r14), %edx
callq 0xef570
addq $0x2, (%rbx)
movq %r15, %rdi
movq %rax, %rsi
movq %r12, %rdx
callq 0xe9b05
movq %r15, %rdi
callq 0xf6870
movq %rax, %r12
movq %r15, %rdi
movq %r14, %rsi
movq %rax, %rdx
movq %rbx, %rcx
callq 0xa803f
movq %r12, %rdi
callq 0xf7557
leaq 0x766f9(%rip), %rsi     # 0x122573
movq %r15, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0xe9226
movq %r12, %rdi
callq 0xf6883
movq %r15, %rdi
movq %r14, %rsi
movq %r12, %rdx
movq %rbx, %rcx
callq 0xa696e
movq %r12, %rdi
callq 0xf7557
leaq 0x81a8a(%rip), %rsi     # 0x12d939
movq %r15, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0xe9226
cmpq $0x2, %r13
jne 0xabedc
movl (%rbx), %edx
leaq 0x842a5(%rip), %rsi     # 0x130170
movq %r15, %rdi
xorl %eax, %eax
callq 0xe9226
addq $0x300, (%rbx)          # imm = 0x300
movq (%rbx), %rax
movq 0x10(%rbx), %rcx
leaq 0x8(%rsp), %r13
movq %rax, 0x8(%r13)
movq %rax, (%r13)
movq %rcx, 0x10(%r13)
movq %r15, %rdi
movq %r14, %rsi
movq %r13, %rdx
callq 0xabf48
movq 0x8(%r13), %rcx
movq 0x10(%r13), %rsi
movq %rsi, %rax
subq %rcx, %rax
jle 0xabf24
movq 0x8(%rsp), %rdx
cmpq %rsi, %rdx
jg 0xabf26
subq %rcx, %rdx
movq %rdx, %rax
jmp 0xabf26
xorl %eax, %eax
addq %rax, (%rbx)
movl $0x1, %r13d
movq %r12, %rdi
callq 0xf6bb0
movl %r13d, %eax
addq $0x20, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq