// File: /workspace/github_c_makefile_star2_O0/jsummers[P]deark/modules/psd.c
// Function: do_psd_header
static int do_psd_header(deark *c, lctx *d, i64 pos)
{
	int retval = 0;

	de_dbg(c, "header at %d", (int)pos);
	de_dbg_indent(c, 1);
	d->version = (int)psd_getu16(pos+4);
	de_dbg(c, "PSD version: %d", d->version);
	init_version_specific_info(c, d);

	if(d->version==1) {
		de_declare_fmt(c, "PSD");
	}
	else if(d->version==2) {
		de_declare_fmt(c, "PSB");
	}
	else {
		de_err(c, "Unsupported PSD version: %d", (int)d->version);
		goto done;
	}

	d->main_iinfo->num_channels = psd_getu16(pos+12);
	de_dbg(c, "number of channels: %d", (int)d->main_iinfo->num_channels);

	d->main_iinfo->height = psd_getu32(pos+14);
	d->main_iinfo->width = psd_getu32(pos+18);
	de_dbg_dimensions(c, d->main_iinfo->width, d->main_iinfo->height);

	d->main_iinfo->bits_per_channel = psd_getu16(pos+22);
	de_dbg(c, "bits/channel: %d", (int)d->main_iinfo->bits_per_channel);

	d->main_iinfo->color_mode = psd_getu16(pos+24);
	de_dbg(c, "color mode: %d (%s)", (int)d->main_iinfo->color_mode,
		get_colormode_name(d->main_iinfo->color_mode));

	retval = 1;

done:
	de_dbg_indent(c, -1);
	return retval;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movl $0x0, -0x1c(%rbp)
movq -0x8(%rbp), %rdi
movq -0x18(%rbp), %rax
movl %eax, %edx
leaq 0xd1eb2(%rip), %rsi     # 0x1c4f8e
movb $0x0, %al
callq 0x15b0d0
movq -0x8(%rbp), %rdi
movl $0x1, %esi
callq 0x15b560
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
movq -0x18(%rbp), %rsi
addq $0x4, %rsi
movq -0x10(%rbp), %rax
movl 0x4(%rax), %edx
callq 0x165820
movl %eax, %ecx
movq -0x10(%rbp), %rax
movl %ecx, (%rax)
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rax
movl (%rax), %edx
leaq 0xcd0e6(%rip), %rsi     # 0x1c020c
movb $0x0, %al
callq 0x15b0d0
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
callq 0xf2f40
movq -0x10(%rbp), %rax
cmpl $0x1, (%rax)
jne 0xf3155
movq -0x8(%rbp), %rdi
leaq 0xcb71f(%rip), %rsi     # 0x1be86d
callq 0x15e380
jmp 0xf318f
movq -0x10(%rbp), %rax
cmpl $0x2, (%rax)
jne 0xf3170
movq -0x8(%rbp), %rdi
leaq 0xcd093(%rip), %rsi     # 0x1c01fc
callq 0x15e380
jmp 0xf318d
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rax
movl (%rax), %edx
leaq 0xcd07f(%rip), %rsi     # 0x1c0200
movb $0x0, %al
callq 0x15bfb0
jmp 0xf330c
jmp 0xf318f
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
movq -0x18(%rbp), %rsi
addq $0xc, %rsi
movq -0x10(%rbp), %rax
movl 0x4(%rax), %edx
callq 0x165820
movq %rax, %rcx
movq -0x10(%rbp), %rax
movq 0x50(%rax), %rax
movq %rcx, 0x18(%rax)
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rax
movq 0x50(%rax), %rax
movq 0x18(%rax), %rax
movl %eax, %edx
leaq 0xb76a9(%rip), %rsi     # 0x1aa87c
movb $0x0, %al
callq 0x15b0d0
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
movq -0x18(%rbp), %rsi
addq $0xe, %rsi
movq -0x10(%rbp), %rax
movl 0x4(%rax), %edx
callq 0x1658c0
movq %rax, %rcx
movq -0x10(%rbp), %rax
movq 0x50(%rax), %rax
movq %rcx, 0x8(%rax)
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
movq -0x18(%rbp), %rsi
addq $0x12, %rsi
movq -0x10(%rbp), %rax
movl 0x4(%rax), %edx
callq 0x1658c0
movq %rax, %rcx
movq -0x10(%rbp), %rax
movq 0x50(%rax), %rax
movq %rcx, (%rax)
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rax
movq 0x50(%rax), %rax
movq (%rax), %rsi
movq -0x10(%rbp), %rax
movq 0x50(%rax), %rax
movq 0x8(%rax), %rdx
callq 0x15bba0
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
movq -0x18(%rbp), %rsi
addq $0x16, %rsi
movq -0x10(%rbp), %rax
movl 0x4(%rax), %edx
callq 0x165820
movq %rax, %rcx
movq -0x10(%rbp), %rax
movq 0x50(%rax), %rax
movq %rcx, 0x20(%rax)
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rax
movq 0x50(%rax), %rax
movq 0x20(%rax), %rax
movl %eax, %edx
leaq 0xcd137(%rip), %rsi     # 0x1c03ca
movb $0x0, %al
callq 0x15b0d0
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
movq -0x18(%rbp), %rsi
addq $0x18, %rsi
movq -0x10(%rbp), %rax
movl 0x4(%rax), %edx
callq 0x165820
movq %rax, %rcx
movq -0x10(%rbp), %rax
movq 0x50(%rax), %rax
movq %rcx, 0x10(%rax)
movq -0x8(%rbp), %rax
movq %rax, -0x28(%rbp)
movq -0x10(%rbp), %rax
movq 0x50(%rax), %rax
movq 0x10(%rax), %rax
movl %eax, -0x20(%rbp)
movq -0x10(%rbp), %rax
movq 0x50(%rax), %rax
movq 0x10(%rax), %rdi
callq 0xfa990
movq -0x28(%rbp), %rdi
movl -0x20(%rbp), %edx
movq %rax, %rcx
leaq 0xccae6(%rip), %rsi     # 0x1bfde4
movb $0x0, %al
callq 0x15b0d0
movl $0x1, -0x1c(%rbp)
movq -0x8(%rbp), %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0x15b560
movl -0x1c(%rbp), %eax
addq $0x30, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)