// File: /workspace/github_c_makefile_star2_O0/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 %rbp
movq %rsp, %rbp
subq $0x80, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq $0x0, -0x40(%rbp)
movl $0x0, -0x5c(%rbp)
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
movq -0x18(%rbp), %rsi
movq -0x10(%rbp), %rax
movl 0x4(%rax), %edx
callq 0xf3330
movq %rax, -0x28(%rbp)
movq -0x8(%rbp), %rdi
movq -0x28(%rbp), %rax
movl %eax, %edx
leaq 0xc5a3d(%rip), %rsi     # 0x1c0210
movb $0x0, %al
callq 0x15b0d0
cmpq $0x1, -0x28(%rbp)
je 0xfa7e6
jmp 0xfa975
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
movq -0x18(%rbp), %rsi
movq -0x10(%rbp), %rax
movl 0x4(%rax), %edx
callq 0xf3330
movq %rax, -0x20(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x80(%rbp)
movq -0x20(%rbp), %rax
movl %eax, -0x74(%rbp)
movq -0x20(%rbp), %rdi
callq 0xfa990
movq -0x80(%rbp), %rdi
movl -0x74(%rbp), %edx
movq %rax, %rcx
leaq 0xc55b9(%rip), %rsi     # 0x1bfde4
movb $0x0, %al
callq 0x15b0d0
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
movq -0x18(%rbp), %rsi
movq -0x10(%rbp), %rax
movl 0x4(%rax), %edx
callq 0xf3de0
movq %rax, -0x38(%rbp)
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
movq -0x18(%rbp), %rsi
movq -0x10(%rbp), %rax
movl 0x4(%rax), %edx
callq 0xf3de0
movq %rax, -0x30(%rbp)
movq -0x8(%rbp), %rdi
movq -0x30(%rbp), %rsi
movq -0x38(%rbp), %rdx
callq 0x15bba0
movq -0x8(%rbp), %rdi
callq 0x1711d0
movq %rax, -0x40(%rbp)
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x40(%rbp), %rdx
movq -0x18(%rbp), %rcx
callq 0xf54d0
movq -0x8(%rbp), %rax
movq %rax, -0x70(%rbp)
movq -0x40(%rbp), %rdi
callq 0x172650
movq -0x70(%rbp), %rdi
movq %rax, %rdx
leaq 0xb3914(%rip), %rsi     # 0x1ae1d0
movb $0x0, %al
callq 0x15b0d0
movq -0x40(%rbp), %rdi
callq 0x171210
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x40(%rbp), %rdx
movq -0x18(%rbp), %rcx
callq 0xf3e30
movq -0x8(%rbp), %rax
movq %rax, -0x68(%rbp)
movq -0x40(%rbp), %rdi
callq 0x172650
movq -0x68(%rbp), %rdi
movq %rax, %rdx
leaq 0xbee4f(%rip), %rsi     # 0x1b974f
movb $0x0, %al
callq 0x15b0d0
cmpq $0x2, -0x20(%rbp)
jne 0xfa93a
movq -0x8(%rbp), %rdi
movq -0x18(%rbp), %rax
movq (%rax), %rax
movl %eax, %edx
leaq 0xc162e(%rip), %rsi     # 0x1bbf50
movb $0x0, %al
callq 0x15b0d0
movq -0x18(%rbp), %rax
movq (%rax), %rcx
addq $0x300, %rcx            # imm = 0x300
movq %rcx, (%rax)
movq -0x18(%rbp), %rsi
leaq -0x58(%rbp), %rdi
callq 0xf3580
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
leaq -0x58(%rbp), %rdx
callq 0xfaa40
leaq -0x58(%rbp), %rdi
callq 0xf3820
movq %rax, %rcx
movq -0x18(%rbp), %rax
addq (%rax), %rcx
movq %rcx, (%rax)
movl $0x1, -0x5c(%rbp)
movq -0x40(%rbp), %rdi
callq 0x171750
movl -0x5c(%rbp), %eax
addq $0x80, %rsp
popq %rbp
retq
nopw (%rax,%rax)