// File: /workspace/github_c_makefile_star2_O0/jsummers[P]deark/modules/exe.c
// Function: do_ne_ext_header
static void do_ne_ext_header(deark *c, lctx *d, i64 pos1)
{
	u8 target_os;
	const char *desc;
	u8 b1, b2;

	de_dbg(c, "NE extended header at %"I64_FMT, pos1);
	de_dbg_indent(c, 1);

	b1 = de_getbyte(pos1+2);
	b2 = de_getbyte(pos1+3);
	de_dbg(c, "linker version: %d.%d", (int)b1,(int)b2);

	// 4-5: Offset of entry table
	// 6-7: length of entry table
	// 8-11: file load CRC

	d->ne_header_flags = (UI)de_getu16le(pos1+12);
	do_ne_header_flags(c, d);

	d->ne_number_of_segments = de_getu16le(pos1+28);
	de_dbg(c, "number of segments: %d", (int)d->ne_number_of_segments);

	if(d->ne_number_of_segments) {
		d->ne_segment_tbl_offset = de_getu16le(pos1+34);
		d->ne_segment_tbl_offset += pos1;
		de_dbg(c, "offset of segment table: %"I64_FMT, d->ne_segment_tbl_offset);
	}

	d->ne_rsrc_tbl_offset = de_getu16le(pos1+36);
	d->ne_rsrc_tbl_offset += pos1;
	de_dbg(c, "offset of resource table: %"I64_FMT, d->ne_rsrc_tbl_offset);

	d->ne_filealign_shift = (UI)de_getu16le(pos1+50);
	if(d->ne_filealign_shift==0) d->ne_filealign_shift = 9;
	de_dbg(c, "align shift: %u", d->ne_filealign_shift);

	target_os = de_getbyte(pos1+54);
	switch(target_os) {
	case 1: desc="OS/2"; break;
	case 2: desc="Windows"; break;
	case 3: desc="European MS-DOS 4.x"; break;
	case 4: desc="Windows 386"; break;
	case 5: desc="Borland Operating System Services"; break;
	default: desc="?";
	}
	de_dbg(c, "target OS: %d (%s)", (int)target_os, desc);

	de_dbg_indent(c, -1);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq -0x8(%rbp), %rdi
movq -0x18(%rbp), %rdx
leaq 0x147cd5(%rip), %rsi    # 0x1a89f8
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 $0x2, %rsi
callq 0x165060
movb %al, -0x29(%rbp)
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
movq -0x18(%rbp), %rsi
addq $0x3, %rsi
callq 0x165060
movb %al, -0x2a(%rbp)
movq -0x8(%rbp), %rdi
movzbl -0x29(%rbp), %edx
movzbl -0x2a(%rbp), %ecx
leaq 0x147c97(%rip), %rsi    # 0x1a8a12
movb $0x0, %al
callq 0x15b0d0
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
movq -0x18(%rbp), %rsi
addq $0xc, %rsi
callq 0x165280
movl %eax, %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x60(%rax)
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
callq 0x61a20
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
movq -0x18(%rbp), %rsi
addq $0x1c, %rsi
callq 0x165280
movq %rax, %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x48(%rax)
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rax
movq 0x48(%rax), %rax
movl %eax, %edx
leaq 0x147c46(%rip), %rsi    # 0x1a8a28
movb $0x0, %al
callq 0x15b0d0
movq -0x10(%rbp), %rax
cmpq $0x0, 0x48(%rax)
je 0x60e3e
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
movq -0x18(%rbp), %rsi
addq $0x22, %rsi
callq 0x165280
movq %rax, %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x50(%rax)
movq -0x18(%rbp), %rcx
movq -0x10(%rbp), %rax
addq 0x50(%rax), %rcx
movq %rcx, 0x50(%rax)
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rax
movq 0x50(%rax), %rdx
leaq 0x147c08(%rip), %rsi    # 0x1a8a3f
movb $0x0, %al
callq 0x15b0d0
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
movq -0x18(%rbp), %rsi
addq $0x24, %rsi
callq 0x165280
movq %rax, %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x58(%rax)
movq -0x18(%rbp), %rcx
movq -0x10(%rbp), %rax
addq 0x58(%rax), %rcx
movq %rcx, 0x58(%rax)
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rax
movq 0x58(%rax), %rdx
leaq 0x147bdb(%rip), %rsi    # 0x1a8a5c
movb $0x0, %al
callq 0x15b0d0
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
movq -0x18(%rbp), %rsi
addq $0x32, %rsi
callq 0x165280
movl %eax, %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x64(%rax)
movq -0x10(%rbp), %rax
cmpl $0x0, 0x64(%rax)
jne 0x60ebb
movq -0x10(%rbp), %rax
movl $0x9, 0x64(%rax)
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rax
movl 0x64(%rax), %edx
leaq 0x147bad(%rip), %rsi    # 0x1a8a7a
xorl %eax, %eax
callq 0x15b0d0
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
movq -0x18(%rbp), %rsi
addq $0x36, %rsi
callq 0x165060
movb %al, -0x19(%rbp)
movzbl -0x19(%rbp), %eax
decl %eax
movl %eax, %ecx
movq %rcx, -0x38(%rbp)
subl $0x4, %eax
ja 0x60f52
movq -0x38(%rbp), %rax
leaq 0x147344(%rip), %rcx    # 0x1a824c
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
leaq 0x1432c0(%rip), %rax    # 0x1a41d8
movq %rax, -0x28(%rbp)
jmp 0x60f5d
leaq 0x176ba7(%rip), %rax    # 0x1d7acc
movq %rax, -0x28(%rbp)
jmp 0x60f5d
leaq 0x147b58(%rip), %rax    # 0x1a8a8a
movq %rax, -0x28(%rbp)
jmp 0x60f5d
leaq 0x147b5f(%rip), %rax    # 0x1a8a9e
movq %rax, -0x28(%rbp)
jmp 0x60f5d
leaq 0x147b5e(%rip), %rax    # 0x1a8aaa
movq %rax, -0x28(%rbp)
jmp 0x60f5d
leaq 0x156cd4(%rip), %rax    # 0x1b7c2d
movq %rax, -0x28(%rbp)
movq -0x8(%rbp), %rdi
movzbl -0x19(%rbp), %edx
movq -0x28(%rbp), %rcx
leaq 0x147b5c(%rip), %rsi    # 0x1a8acc
movb $0x0, %al
callq 0x15b0d0
movq -0x8(%rbp), %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0x15b560
addq $0x40, %rsp
popq %rbp
retq
nopl (%rax,%rax)