// File: /workspace/github_c_makefile_star2_O0/jsummers[P]deark/modules/xwd.c
// Function: do_header
static void do_header(deark *c, lctx *d)
{
	i64 pos;
	int saved_indent_level;
	UI k;

	de_dbg_indent_save(c, &saved_indent_level);
	pos = 0;
	de_dbg(c, "header at %"I64_FMT, pos);
	de_dbg_indent(c, 1);

	for(k=0; k<25; k++) {
		const char *name = NULL;

		d->hf[k] = (UI)de_getu32be_p(&pos);

		if(k==HF_PIXFMT) {
			name = get_pixfmt_name(d->hf[k]);
		}
		else if(k==HF_BYTE_ORDER) {
			if(d->hf[k]==0) name = "LE";
			else name = "BE";
		}
		else if(k==HF_BIT_ORDER) {
			if(d->hf[k]==0) name = "lsb first";
			else name = "msb first";
		}
		else if(k==HF_VCLASS) {
			d->vclass_adj = d->hf[k] & 0xfffffffeU;
			name = get_vclass_name(d->vclass_adj);
		}

		if(k>=HF_RMASK && k<=HF_BMASK) {
			de_dbg(c, "%s: 0x%08x", hnames[k], d->hf[k]);
		}
		else {
			if(name) {
				de_dbg(c, "%s: %u (%s)", hnames[k], d->hf[k], name);
			}
			else {
				de_dbg(c, "%s: %u", hnames[k], d->hf[k]);
			}
		}
	}

	if(d->hf[HF_HSIZE]<100) {
		d->errflag = 1;
		d->need_errmsg = 1;
		goto done;
	}

	if(d->hf[HF_VER]!=7) {
		d->errflag = 1;
		d->need_errmsg = 1;
		goto done;
	}

	if(d->hf[HF_WIDTH]>1000000 || d->hf[HF_HEIGHT]>1000000 ||
		d->hf[HF_BYTES_PER_LINE]>1000000)
	{
		d->errflag = 1;
		d->need_errmsg = 1;
		goto done;
	}

	interpret_header(c, d);
	if(d->errflag) goto done;
	find_cmap_and_image(c, d);

done:
	de_dbg_indent_restore(c, saved_indent_level);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x8(%rbp), %rdi
leaq -0x1c(%rbp), %rsi
callq 0x15b580
movq $0x0, -0x18(%rbp)
movq -0x8(%rbp), %rdi
movq -0x18(%rbp), %rdx
leaq 0x5583f(%rip), %rsi     # 0x1aed63
movb $0x0, %al
callq 0x15b0d0
movq -0x8(%rbp), %rdi
movl $0x1, %esi
callq 0x15b560
movl $0x0, -0x20(%rbp)
cmpl $0x19, -0x20(%rbp)
jae 0x1596d0
movq $0x0, -0x28(%rbp)
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
leaq -0x18(%rbp), %rsi
callq 0x1654b0
movl %eax, %edx
movq -0x10(%rbp), %rax
movl -0x20(%rbp), %ecx
movl %edx, 0x4(%rax,%rcx,4)
cmpl $0x2, -0x20(%rbp)
jne 0x15958f
movq -0x10(%rbp), %rax
movl -0x20(%rbp), %ecx
movl 0x4(%rax,%rcx,4), %edi
callq 0x159c00
movq %rax, -0x28(%rbp)
jmp 0x15961c
cmpl $0x7, -0x20(%rbp)
jne 0x1595bd
movq -0x10(%rbp), %rax
movl -0x20(%rbp), %ecx
cmpl $0x0, 0x4(%rax,%rcx,4)
jne 0x1595b0
leaq 0x4f17c(%rip), %rax     # 0x1a8726
movq %rax, -0x28(%rbp)
jmp 0x1595bb
leaq 0x56b02(%rip), %rax     # 0x1b00b9
movq %rax, -0x28(%rbp)
jmp 0x15961a
cmpl $0x9, -0x20(%rbp)
jne 0x1595eb
movq -0x10(%rbp), %rax
movl -0x20(%rbp), %ecx
cmpl $0x0, 0x4(%rax,%rcx,4)
jne 0x1595de
leaq 0x784ae(%rip), %rax     # 0x1d1a86
movq %rax, -0x28(%rbp)
jmp 0x1595e9
leaq 0x784ab(%rip), %rax     # 0x1d1a90
movq %rax, -0x28(%rbp)
jmp 0x159618
cmpl $0xd, -0x20(%rbp)
jne 0x159616
movq -0x10(%rbp), %rax
movl -0x20(%rbp), %ecx
movl 0x4(%rax,%rcx,4), %ecx
andl $-0x2, %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x68(%rax)
movq -0x10(%rbp), %rax
movl 0x68(%rax), %edi
callq 0x159c80
movq %rax, -0x28(%rbp)
jmp 0x159618
jmp 0x15961a
jmp 0x15961c
cmpl $0xe, -0x20(%rbp)
jb 0x159657
cmpl $0x10, -0x20(%rbp)
ja 0x159657
movq -0x8(%rbp), %rdi
movl -0x20(%rbp), %eax
movl %eax, %ecx
leaq 0xcc3e8(%rip), %rax     # 0x225a20
movq (%rax,%rcx,8), %rdx
movq -0x10(%rbp), %rax
movl -0x20(%rbp), %ecx
movl 0x4(%rax,%rcx,4), %ecx
leaq 0x7844c(%rip), %rsi     # 0x1d1a9a
movb $0x0, %al
callq 0x15b0d0
jmp 0x1596c0
cmpq $0x0, -0x28(%rbp)
je 0x159691
movq -0x8(%rbp), %rdi
movl -0x20(%rbp), %eax
movl %eax, %ecx
leaq 0xcc3b2(%rip), %rax     # 0x225a20
movq (%rax,%rcx,8), %rdx
movq -0x10(%rbp), %rax
movl -0x20(%rbp), %ecx
movl 0x4(%rax,%rcx,4), %ecx
movq -0x28(%rbp), %r8
leaq 0x7841d(%rip), %rsi     # 0x1d1aa5
movb $0x0, %al
callq 0x15b0d0
jmp 0x1596be
movq -0x8(%rbp), %rdi
movl -0x20(%rbp), %eax
movl %eax, %ecx
leaq 0xcc37f(%rip), %rax     # 0x225a20
movq (%rax,%rcx,8), %rdx
movq -0x10(%rbp), %rax
movl -0x20(%rbp), %ecx
movl 0x4(%rax,%rcx,4), %ecx
leaq 0x531cc(%rip), %rsi     # 0x1ac883
movb $0x0, %al
callq 0x15b0d0
jmp 0x1596c0
jmp 0x1596c2
movl -0x20(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x20(%rbp)
jmp 0x159540
movq -0x10(%rbp), %rax
cmpl $0x64, 0x4(%rax)
jae 0x1596eb
movq -0x10(%rbp), %rax
movb $0x1, (%rax)
movq -0x10(%rbp), %rax
movb $0x1, 0x1(%rax)
jmp 0x159763
movq -0x10(%rbp), %rax
cmpl $0x7, 0x8(%rax)
je 0x159706
movq -0x10(%rbp), %rax
movb $0x1, (%rax)
movq -0x10(%rbp), %rax
movb $0x1, 0x1(%rax)
jmp 0x159763
movq -0x10(%rbp), %rax
cmpl $0xf4240, 0x14(%rax)    # imm = 0xF4240
ja 0x15972d
movq -0x10(%rbp), %rax
cmpl $0xf4240, 0x18(%rax)    # imm = 0xF4240
ja 0x15972d
movq -0x10(%rbp), %rax
cmpl $0xf4240, 0x34(%rax)    # imm = 0xF4240
jbe 0x15973e
movq -0x10(%rbp), %rax
movb $0x1, (%rax)
movq -0x10(%rbp), %rax
movb $0x1, 0x1(%rax)
jmp 0x159763
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
callq 0x159d00
movq -0x10(%rbp), %rax
cmpb $0x0, (%rax)
je 0x159756
jmp 0x159763
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
callq 0x15a150
movq -0x8(%rbp), %rdi
movl -0x1c(%rbp), %esi
callq 0x15b5a0
addq $0x30, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)