// File: ksherlock[P]wdc-utils/zrdz_disassembler.cpp
// Function: zrdz_disassembler::front_matter(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&)
void zrdz_disassembler::front_matter(const std::string &module) {
	emit("", "module", module);
	putchar('\n');
	print_externs();
	print_variables();

	// reference-only sections.
	for (auto &e : _sections) {
		if (!e.valid) continue;

		if ((e.flags & SEC_REF_ONLY) == 0) continue;
		if (e.size == 0 && e.symbols.empty()) continue;

		print_section(e);
		print_globals(e.number);
		print_equs(e.number);
		e.processed = true;

		if (e.org) emit("", ".org", to_x(e.org, 4, '$'));
		uint32_t pc = e.org;


		for (; !e.symbols.empty(); e.symbols.pop_back()) {
			auto &s = e.symbols.back();

			if (s.offset > pc) {
				emit("","ds", std::to_string(s.offset - pc));
				pc = s.offset;
			}
			emit(s.name);
		}

		if (pc < e.size)
			emit("","ds",std::to_string(e.size - pc));

		emit("", "ends");
		putchar('\n');
	}

	set_section(1);
	/*
	emit("","code");
	print_globals(1);
	print_equs(1);
	_sections[1].processed = true;
	*/

}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x2a0, %rsp            # imm = 0x2A0
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x250(%rbp)
leaq -0x31(%rbp), %rdi
movq %rdi, -0x248(%rbp)
callq 0x3460
movq -0x248(%rbp), %rdx
leaq 0x96e8(%rip), %rsi      # 0x1b374
leaq -0x30(%rbp), %rdi
callq 0x8060
jmp 0x11c97
leaq -0x69(%rbp), %rdi
movq %rdi, -0x258(%rbp)
callq 0x3460
movq -0x258(%rbp), %rdx
leaq 0xa00b(%rip), %rsi      # 0x1bcc0
leaq -0x68(%rbp), %rdi
callq 0x8060
jmp 0x11cc0
movq -0x10(%rbp), %rdx
leaq -0x30(%rbp), %rdi
leaq -0x68(%rbp), %rsi
callq 0xce40
jmp 0x11cd3
leaq -0x68(%rbp), %rdi
callq 0x3160
leaq -0x69(%rbp), %rdi
callq 0x32b0
leaq -0x30(%rbp), %rdi
callq 0x3160
leaq -0x31(%rbp), %rdi
callq 0x32b0
movl $0xa, %edi
callq 0x3390
movq -0x250(%rbp), %rdi
callq 0x12440
movq -0x250(%rbp), %rdi
callq 0x126d0
movq -0x250(%rbp), %rax
addq $0x50, %rax
movq %rax, -0x78(%rbp)
movq -0x78(%rbp), %rdi
callq 0x15d10
movq %rax, -0x80(%rbp)
movq -0x78(%rbp), %rdi
callq 0x15d40
movq %rax, -0x88(%rbp)
leaq -0x80(%rbp), %rdi
leaq -0x88(%rbp), %rsi
callq 0x15d70
testb $0x1, %al
jne 0x11d5e
jmp 0x12411
leaq -0x80(%rbp), %rdi
callq 0x15db0
movq %rax, -0x90(%rbp)
movq -0x90(%rbp), %rax
testb $0x1, 0x2d(%rax)
jne 0x11dd1
jmp 0x123a9
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
jmp 0x11dc3
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
jmp 0x11db1
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
leaq -0x68(%rbp), %rdi
callq 0x3160
leaq -0x69(%rbp), %rdi
callq 0x32b0
leaq -0x30(%rbp), %rdi
callq 0x3160
leaq -0x31(%rbp), %rdi
callq 0x32b0
jmp 0x1242b
movq -0x90(%rbp), %rax
movzbl 0x21(%rax), %eax
andl $0x8, %eax
cmpl $0x0, %eax
jne 0x11de9
jmp 0x123a9
movq -0x90(%rbp), %rax
cmpl $0x0, 0x24(%rax)
jne 0x11e11
movq -0x90(%rbp), %rdi
addq $0x30, %rdi
callq 0x15dd0
testb $0x1, %al
jne 0x11e0c
jmp 0x11e11
jmp 0x123a9
movq -0x250(%rbp), %rdi
movq -0x90(%rbp), %rsi
callq 0x12a60
movq -0x250(%rbp), %rdi
movq -0x90(%rbp), %rax
movzbl 0x20(%rax), %esi
callq 0x12ed0
movq -0x250(%rbp), %rdi
movq -0x90(%rbp), %rax
movzbl 0x20(%rax), %esi
callq 0x13170
movq -0x90(%rbp), %rax
movb $0x1, 0x2c(%rax)
movq -0x90(%rbp), %rax
cmpl $0x0, 0x28(%rax)
je 0x11fbf
leaq -0xb1(%rbp), %rdi
movq %rdi, -0x260(%rbp)
callq 0x3460
movq -0x260(%rbp), %rdx
leaq 0x94e5(%rip), %rsi      # 0x1b374
leaq -0xb0(%rbp), %rdi
callq 0x8060
jmp 0x11e9d
leaq -0xd9(%rbp), %rdi
movq %rdi, -0x268(%rbp)
callq 0x3460
movq -0x268(%rbp), %rdx
leaq 0x941b(%rip), %rsi      # 0x1b2d9
leaq -0xd8(%rbp), %rdi
callq 0x8060
jmp 0x11ecc
movq -0x90(%rbp), %rax
movl 0x28(%rax), %esi
leaq -0x100(%rbp), %rdi
movl $0x4, %edx
movl $0x24, %ecx
callq 0xcb90
jmp 0x11eee
leaq -0xb0(%rbp), %rdi
leaq -0xd8(%rbp), %rsi
leaq -0x100(%rbp), %rdx
callq 0xce40
jmp 0x11f0a
leaq -0x100(%rbp), %rdi
callq 0x3160
leaq -0xd8(%rbp), %rdi
callq 0x3160
leaq -0xd9(%rbp), %rdi
callq 0x32b0
leaq -0xb0(%rbp), %rdi
callq 0x3160
leaq -0xb1(%rbp), %rdi
callq 0x32b0
jmp 0x11fbf
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
jmp 0x11fae
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
jmp 0x11f96
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
jmp 0x11f8a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
leaq -0x100(%rbp), %rdi
callq 0x3160
leaq -0xd8(%rbp), %rdi
callq 0x3160
leaq -0xd9(%rbp), %rdi
callq 0x32b0
leaq -0xb0(%rbp), %rdi
callq 0x3160
leaq -0xb1(%rbp), %rdi
callq 0x32b0
jmp 0x1242b
movq -0x90(%rbp), %rax
movl 0x28(%rax), %eax
movl %eax, -0x104(%rbp)
movq -0x90(%rbp), %rdi
addq $0x30, %rdi
callq 0x15dd0
xorb $-0x1, %al
testb $0x1, %al
jne 0x11fea
jmp 0x12197
movq -0x90(%rbp), %rdi
addq $0x30, %rdi
callq 0xa4c0
movq %rax, -0x110(%rbp)
movq -0x110(%rbp), %rax
movl 0x24(%rax), %eax
cmpl -0x104(%rbp), %eax
jbe 0x12176
leaq -0x131(%rbp), %rdi
movq %rdi, -0x270(%rbp)
callq 0x3460
movq -0x270(%rbp), %rdx
leaq 0x933c(%rip), %rsi      # 0x1b374
leaq -0x130(%rbp), %rdi
callq 0x8060
jmp 0x12046
leaq -0x159(%rbp), %rdi
movq %rdi, -0x278(%rbp)
callq 0x3460
movq -0x278(%rbp), %rdx
leaq 0x9c62(%rip), %rsi      # 0x1bcc9
leaq -0x158(%rbp), %rdi
callq 0x8060
jmp 0x12075
movq -0x110(%rbp), %rax
movl 0x24(%rax), %esi
movl -0x104(%rbp), %eax
subl %eax, %esi
leaq -0x180(%rbp), %rdi
callq 0x8980
jmp 0x12095
leaq -0x130(%rbp), %rdi
leaq -0x158(%rbp), %rsi
leaq -0x180(%rbp), %rdx
callq 0xce40
jmp 0x120b1
leaq -0x180(%rbp), %rdi
callq 0x3160
leaq -0x158(%rbp), %rdi
callq 0x3160
leaq -0x159(%rbp), %rdi
callq 0x32b0
leaq -0x130(%rbp), %rdi
callq 0x3160
leaq -0x131(%rbp), %rdi
callq 0x32b0
movq -0x110(%rbp), %rax
movl 0x24(%rax), %eax
movl %eax, -0x104(%rbp)
jmp 0x12176
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
jmp 0x12165
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
jmp 0x1214d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
jmp 0x12141
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
leaq -0x180(%rbp), %rdi
callq 0x3160
leaq -0x158(%rbp), %rdi
callq 0x3160
leaq -0x159(%rbp), %rdi
callq 0x32b0
leaq -0x130(%rbp), %rdi
callq 0x3160
leaq -0x131(%rbp), %rdi
callq 0x32b0
jmp 0x1242b
movq -0x110(%rbp), %rdi
callq 0xcd30
movq -0x90(%rbp), %rdi
addq $0x30, %rdi
callq 0x15e90
jmp 0x11fcf
movl -0x104(%rbp), %eax
movq -0x90(%rbp), %rcx
cmpl 0x24(%rcx), %eax
jae 0x122fc
leaq -0x1a1(%rbp), %rdi
movq %rdi, -0x280(%rbp)
callq 0x3460
movq -0x280(%rbp), %rdx
leaq 0x91a6(%rip), %rsi      # 0x1b374
leaq -0x1a0(%rbp), %rdi
callq 0x8060
jmp 0x121dc
leaq -0x1c9(%rbp), %rdi
movq %rdi, -0x288(%rbp)
callq 0x3460
movq -0x288(%rbp), %rdx
leaq 0x9acc(%rip), %rsi      # 0x1bcc9
leaq -0x1c8(%rbp), %rdi
callq 0x8060
jmp 0x1220b
movq -0x90(%rbp), %rax
movl 0x24(%rax), %esi
movl -0x104(%rbp), %eax
subl %eax, %esi
leaq -0x1f0(%rbp), %rdi
callq 0x8980
jmp 0x1222b
leaq -0x1a0(%rbp), %rdi
leaq -0x1c8(%rbp), %rsi
leaq -0x1f0(%rbp), %rdx
callq 0xce40
jmp 0x12247
leaq -0x1f0(%rbp), %rdi
callq 0x3160
leaq -0x1c8(%rbp), %rdi
callq 0x3160
leaq -0x1c9(%rbp), %rdi
callq 0x32b0
leaq -0x1a0(%rbp), %rdi
callq 0x3160
leaq -0x1a1(%rbp), %rdi
callq 0x32b0
jmp 0x122fc
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
jmp 0x122eb
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
jmp 0x122d3
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
jmp 0x122c7
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
leaq -0x1f0(%rbp), %rdi
callq 0x3160
leaq -0x1c8(%rbp), %rdi
callq 0x3160
leaq -0x1c9(%rbp), %rdi
callq 0x32b0
leaq -0x1a0(%rbp), %rdi
callq 0x3160
leaq -0x1a1(%rbp), %rdi
callq 0x32b0
jmp 0x1242b
leaq -0x211(%rbp), %rdi
movq %rdi, -0x290(%rbp)
callq 0x3460
movq -0x290(%rbp), %rdx
leaq 0x9057(%rip), %rsi      # 0x1b374
leaq -0x210(%rbp), %rdi
callq 0x8060
jmp 0x1232b
leaq -0x239(%rbp), %rdi
movq %rdi, -0x298(%rbp)
callq 0x3460
movq -0x298(%rbp), %rdx
leaq 0x997b(%rip), %rsi      # 0x1bcc7
leaq -0x238(%rbp), %rdi
callq 0x8060
jmp 0x1235a
leaq -0x210(%rbp), %rdi
leaq -0x238(%rbp), %rsi
callq 0xcd80
jmp 0x1236f
leaq -0x238(%rbp), %rdi
callq 0x3160
leaq -0x239(%rbp), %rdi
callq 0x32b0
leaq -0x210(%rbp), %rdi
callq 0x3160
leaq -0x211(%rbp), %rdi
callq 0x32b0
movl $0xa, %edi
callq 0x3390
leaq -0x80(%rbp), %rdi
callq 0x15e10
jmp 0x11d45
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
jmp 0x12403
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
jmp 0x123eb
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
leaq -0x238(%rbp), %rdi
callq 0x3160
leaq -0x239(%rbp), %rdi
callq 0x32b0
leaq -0x210(%rbp), %rdi
callq 0x3160
leaq -0x211(%rbp), %rdi
callq 0x32b0
jmp 0x1242b
movq -0x250(%rbp), %rdi
movl $0x1, %esi
callq 0x13400
addq $0x2a0, %rsp            # imm = 0x2A0
popq %rbp
retq
movq -0x40(%rbp), %rdi
callq 0x3440
nopw %cs:(%rax,%rax)