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

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

	d->bodysize = de_getu32be_p(&pos);
	de_dbg(c, "body size: %"I64_FMT, d->bodysize);
	d->cardsize = de_getu32be_p(&pos);
	de_dbg(c, "card size: %"I64_FMT, d->cardsize);
	d->h = de_getu16be_p(&pos);
	d->w = de_getu16be_p(&pos);
	de_dbg_dimensions(c, d->w, d->h);
	d->camg_mode = (UI)de_getu32be_p(&pos);
	de_dbg(c, "CAMG mode: 0x%08x", d->camg_mode);
	if(d->camg_mode & 0x0800) d->ham_flag = 1;
	de_dbg_indent(c, 1);
	de_dbg(c, "HAM: %u", (UI)d->ham_flag);
	de_dbg_indent(c, -1);
	d->depth_pixel = (UI)de_getbyte_p(&pos);
	de_dbg(c, "depth: %u", d->depth_pixel);
	d->numcards = (i64)de_getbyte_p(&pos);
	de_dbg(c, "num cards: %"I64_FMT, d->numcards);
	d->hdrsize = pos;
	if(d->w==96 && d->depth_pixel==4) {
		; // Hack. Found a file that's really like this.
	}
	else if(d->w>88 && d->w<=96) {
		de_warn(c, "Unexpected width %d; assuming it should be 88", (int)d->w);
		d->w = 88;
		d->suppress_size_warnings = 1;
	}

	if(d->depth_pixel<1 || d->depth_pixel>8) {
		d->fatalerrflag = 1;
		d->need_errmsg = 1;
		goto done;
	}

	d->depth_color = d->depth_pixel;
	if(d->ham_flag) {
		if(d->depth_pixel!=6 && d->depth_pixel!=8) {
			d->fatalerrflag = 1;
			d->need_errmsg = 1;
			goto done;
		}
		d->depth_color -= 2;
	}

done:
	de_dbg_indent_restore(c, saved_indent_level);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq $0x0, -0x18(%rbp)
movq -0x8(%rbp), %rdi
leaq -0x1c(%rbp), %rsi
callq 0x15b580
movq -0x8(%rbp), %rdi
movq -0x18(%rbp), %rdx
leaq 0x5994f(%rip), %rsi     # 0x1aed63
movb $0x0, %al
callq 0x15b0d0
movq -0x8(%rbp), %rdi
movl $0x1, %esi
callq 0x15b560
movq -0x18(%rbp), %rax
addq $0x4, %rax
movq %rax, -0x18(%rbp)
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
leaq -0x18(%rbp), %rsi
callq 0x1654b0
movq %rax, %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x8(%rax)
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rdx
leaq 0x7c04e(%rip), %rsi     # 0x1d14b2
movb $0x0, %al
callq 0x15b0d0
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
leaq -0x18(%rbp), %rsi
callq 0x1654b0
movq %rax, %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x10(%rax)
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rdx
leaq 0x7c009(%rip), %rsi     # 0x1d14a3
movb $0x0, %al
callq 0x15b0d0
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
leaq -0x18(%rbp), %rsi
callq 0x165210
movq %rax, %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x20(%rax)
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
leaq -0x18(%rbp), %rsi
callq 0x165210
movq %rax, %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x18(%rax)
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rsi
movq -0x10(%rbp), %rax
movq 0x20(%rax), %rdx
callq 0x15bba0
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
leaq -0x18(%rbp), %rsi
callq 0x1654b0
movl %eax, %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x40(%rax)
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rax
movl 0x40(%rax), %edx
leaq 0x7bfb2(%rip), %rsi     # 0x1d14d0
movb $0x0, %al
callq 0x15b0d0
movq -0x10(%rbp), %rax
movl 0x40(%rax), %eax
andl $0x800, %eax            # imm = 0x800
cmpl $0x0, %eax
je 0x15553e
movq -0x10(%rbp), %rax
movb $0x1, 0x44(%rax)
movq -0x8(%rbp), %rdi
movl $0x1, %esi
callq 0x15b560
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rax
movzbl 0x44(%rax), %edx
leaq 0x479df(%rip), %rsi     # 0x19cf3e
movb $0x0, %al
callq 0x15b0d0
movq -0x8(%rbp), %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0x15b560
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
leaq -0x18(%rbp), %rsi
callq 0x165170
movzbl %al, %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x38(%rax)
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rax
movl 0x38(%rax), %edx
leaq 0x5a4e9(%rip), %rsi     # 0x1afa8a
movb $0x0, %al
callq 0x15b0d0
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
leaq -0x18(%rbp), %rsi
callq 0x165170
movzbl %al, %eax
movl %eax, %ecx
movq -0x10(%rbp), %rax
movq %rcx, 0x48(%rax)
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rax
movq 0x48(%rax), %rdx
leaq 0x7bee8(%rip), %rsi     # 0x1d14c1
movb $0x0, %al
callq 0x15b0d0
movq -0x18(%rbp), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x50(%rax)
movq -0x10(%rbp), %rax
cmpq $0x60, 0x18(%rax)
jne 0x155603
movq -0x10(%rbp), %rax
cmpl $0x4, 0x38(%rax)
jne 0x155603
jmp 0x15564b
movq -0x10(%rbp), %rax
cmpq $0x58, 0x18(%rax)
jle 0x155649
movq -0x10(%rbp), %rax
cmpq $0x60, 0x18(%rax)
jg 0x155649
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rax
movl %eax, %edx
leaq 0x7beb4(%rip), %rsi     # 0x1d14e2
movb $0x0, %al
callq 0x15bc10
movq -0x10(%rbp), %rax
movq $0x58, 0x18(%rax)
movq -0x10(%rbp), %rax
movb $0x1, 0x4(%rax)
jmp 0x15564b
movq -0x10(%rbp), %rax
cmpl $0x1, 0x38(%rax)
jb 0x15565f
movq -0x10(%rbp), %rax
cmpl $0x8, 0x38(%rax)
jbe 0x155671
movq -0x10(%rbp), %rax
movb $0x1, 0x2(%rax)
movq -0x10(%rbp), %rax
movb $0x1, 0x3(%rax)
jmp 0x1556be
movq -0x10(%rbp), %rax
movl 0x38(%rax), %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x3c(%rax)
movq -0x10(%rbp), %rax
cmpb $0x0, 0x44(%rax)
je 0x1556bc
movq -0x10(%rbp), %rax
cmpl $0x6, 0x38(%rax)
je 0x1556af
movq -0x10(%rbp), %rax
cmpl $0x8, 0x38(%rax)
je 0x1556af
movq -0x10(%rbp), %rax
movb $0x1, 0x2(%rax)
movq -0x10(%rbp), %rax
movb $0x1, 0x3(%rax)
jmp 0x1556be
movq -0x10(%rbp), %rax
movl 0x3c(%rax), %ecx
subl $0x2, %ecx
movl %ecx, 0x3c(%rax)
jmp 0x1556be
movq -0x8(%rbp), %rdi
movl -0x1c(%rbp), %esi
callq 0x15b5a0
addq $0x20, %rsp
popq %rbp
retq