// File: /workspace/github_c_makefile_star2_O0/jsummers[P]deark/modules/exe.c
// Function: do_lx_or_le_ext_header
static void do_lx_or_le_ext_header(deark *c, lctx *d, i64 pos)
{
	i64 x1, x2;

	de_dbg(c, "%s header at %"I64_FMT, d->fmt==EXE_FMT_LE?"LE":"LX", pos);
	x1 = (u8)de_getbyte(pos+2);
	x2 = (u8)de_getbyte(pos+3);
	de_dbg(c, "byte order, word order: %d, %d", (int)x1, (int)x2);
	if(x1!=0 || x2!=0) {
		de_err(c, "Unsupported byte order.");
		return;
	}

	if(d->fmt==EXE_FMT_LE) {
		x1 = de_getu32le(pos+0x2c);
		de_dbg(c, "bytes on last page: %d", (int)x1);
	}
	else {
		d->lx_page_offset_shift = de_getu32le(pos+0x2c);
		de_dbg(c, "page offset shift: %d", (int)d->lx_page_offset_shift);
	}

	x1 = de_getu32le(pos+0x40);
	d->lx_object_tbl_offset = pos + x1;
	d->lx_object_tbl_entries = de_getu32le(pos+0x44);
	de_dbg(c, "object table offset=%"I64_FMT", entries=%d", d->lx_object_tbl_offset,
		(int)d->lx_object_tbl_entries);

	x1 = de_getu32le(pos+0x48);
	d->lx_object_page_tbl_offset = pos + x1;
	de_dbg(c, "object page table offset=%"I64_FMT, d->lx_object_page_tbl_offset);

	x1 = de_getu32le(pos+0x50);
	d->lx_rsrc_tbl_offset = pos + x1;
	d->lx_rsrc_tbl_entries = de_getu32le(pos+0x54);
	de_dbg(c, "resource table offset=%"I64_FMT" entries=%d", d->lx_rsrc_tbl_offset,
		(int)d->lx_rsrc_tbl_entries);

	d->lx_data_pages_offset = de_getu32le(pos+0x80);
	de_dbg(c, "data pages offset=%"I64_FMT, d->lx_data_pages_offset);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rax
movzbl (%rax), %ecx
leaq 0x1475c8(%rip), %rdx    # 0x1a857e
leaq 0x147769(%rip), %rax    # 0x1a8726
cmpl $0x6, %ecx
cmoveq %rax, %rdx
movq -0x18(%rbp), %rcx
leaq 0x147b50(%rip), %rsi    # 0x1a8b1f
movb $0x0, %al
callq 0x15b0d0
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
movq -0x18(%rbp), %rsi
addq $0x2, %rsi
callq 0x165060
movzbl %al, %eax
movq %rax, -0x20(%rbp)
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
movq -0x18(%rbp), %rsi
addq $0x3, %rsi
callq 0x165060
movzbl %al, %eax
movq %rax, -0x28(%rbp)
movq -0x8(%rbp), %rdi
movq -0x20(%rbp), %rax
movl %eax, %edx
movq -0x28(%rbp), %rax
movl %eax, %ecx
leaq 0x147b0b(%rip), %rsi    # 0x1a8b30
movb $0x0, %al
callq 0x15b0d0
cmpq $0x0, -0x20(%rbp)
jne 0x6103a
cmpq $0x0, -0x28(%rbp)
je 0x61051
movq -0x8(%rbp), %rdi
leaq 0x147b0a(%rip), %rsi    # 0x1a8b4f
movb $0x0, %al
callq 0x15bfb0
jmp 0x61250
movq -0x10(%rbp), %rax
movzbl (%rax), %eax
cmpl $0x6, %eax
jne 0x61090
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
movq -0x18(%rbp), %rsi
addq $0x2c, %rsi
callq 0x165540
movq %rax, -0x20(%rbp)
movq -0x8(%rbp), %rdi
movq -0x20(%rbp), %rax
movl %eax, %edx
leaq 0x147ae0(%rip), %rsi    # 0x1a8b67
movb $0x0, %al
callq 0x15b0d0
jmp 0x610d2
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
movq -0x18(%rbp), %rsi
addq $0x2c, %rsi
callq 0x165540
movq %rax, %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x98(%rax)
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rax
movq 0x98(%rax), %rax
movl %eax, %edx
leaq 0x147ab3(%rip), %rsi    # 0x1a8b7e
movb $0x0, %al
callq 0x15b0d0
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
movq -0x18(%rbp), %rsi
addq $0x40, %rsi
callq 0x165540
movq %rax, -0x20(%rbp)
movq -0x18(%rbp), %rcx
addq -0x20(%rbp), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0xa0(%rax)
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
movq -0x18(%rbp), %rsi
addq $0x44, %rsi
callq 0x165540
movq %rax, %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0xa8(%rax)
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rax
movq 0xa0(%rax), %rdx
movq -0x10(%rbp), %rax
movq 0xa8(%rax), %rax
movl %eax, %ecx
leaq 0x147a50(%rip), %rsi    # 0x1a8b94
movb $0x0, %al
callq 0x15b0d0
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
movq -0x18(%rbp), %rsi
addq $0x48, %rsi
callq 0x165540
movq %rax, -0x20(%rbp)
movq -0x18(%rbp), %rcx
addq -0x20(%rbp), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0xb0(%rax)
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rax
movq 0xb0(%rax), %rdx
leaq 0x147a2b(%rip), %rsi    # 0x1a8bb8
movb $0x0, %al
callq 0x15b0d0
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
movq -0x18(%rbp), %rsi
addq $0x50, %rsi
callq 0x165540
movq %rax, -0x20(%rbp)
movq -0x18(%rbp), %rcx
addq -0x20(%rbp), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0xb8(%rax)
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
movq -0x18(%rbp), %rsi
addq $0x54, %rsi
callq 0x165540
movq %rax, %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0xc0(%rax)
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rax
movq 0xb8(%rax), %rdx
movq -0x10(%rbp), %rax
movq 0xc0(%rax), %rax
movl %eax, %ecx
leaq 0x1479cf(%rip), %rsi    # 0x1a8bd5
movb $0x0, %al
callq 0x15b0d0
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
movq -0x18(%rbp), %rsi
addq $0x80, %rsi
callq 0x165540
movq %rax, %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0xc8(%rax)
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rax
movq 0xc8(%rax), %rdx
leaq 0x1479b1(%rip), %rsi    # 0x1a8bfa
movb $0x0, %al
callq 0x15b0d0
addq $0x30, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)