// File: /workspace/github_cpp_makefile_star2_O1/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
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x78, %rsp
movq %rsi, %rbx
movq %rdi, 0x68(%rsp)
leaq 0x38(%rsp), %r13
movq %r13, -0x10(%r13)
leaq 0x55ce(%rip), %rdx      # 0xf344
leaq 0x28(%rsp), %rdi
movq %rdx, %rsi
callq 0x6b90
leaq 0x18(%rsp), %rax
movq %rax, -0x10(%rax)
leaq 0x5f61(%rip), %rsi      # 0xfcf4
leaq 0x5f60(%rip), %rdx      # 0xfcfa
leaq 0x8(%rsp), %rdi
callq 0x6b90
leaq 0x28(%rsp), %rdi
leaq 0x8(%rsp), %rsi
movq %rbx, %rdx
callq 0x7732
movq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rax
cmpq %rax, %rdi
je 0x9dd2
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x21c0
movq 0x28(%rsp), %rdi
cmpq %r13, %rdi
je 0x9de9
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x21c0
movl $0xa, %edi
callq 0x2240
movq 0x68(%rsp), %rbx
movq %rbx, %rdi
callq 0xa360
movq %rbx, %rdi
callq 0xa502
movq 0x50(%rbx), %r14
movq 0x58(%rbx), %r12
cmpq %r12, %r14
je 0xa272
leaq 0x8(%rsp), %rbp
movq %r12, 0x70(%rsp)
cmpb $0x1, 0x2d(%r14)
jne 0xa265
testb $0x8, 0x21(%r14)
je 0xa265
cmpl $0x0, 0x24(%r14)
jne 0x9e4e
movq 0x30(%r14), %rax
cmpq 0x38(%r14), %rax
je 0xa265
movq %r14, %rsi
callq 0xa720
movzbl 0x20(%r14), %esi
movq 0x68(%rsp), %rbx
movq %rbx, %rdi
callq 0xaa60
movzbl 0x20(%r14), %esi
movq %rbx, %rdi
callq 0xac0e
movb $0x1, 0x2c(%r14)
cmpl $0x0, 0x28(%r14)
je 0x9f38
movq %r13, 0x28(%rsp)
leaq 0x28(%rsp), %rdi
leaq 0x54ae(%rip), %rdx      # 0xf344
movq %rdx, %rsi
callq 0x6b90
leaq 0x18(%rsp), %rax
movq %rax, 0x8(%rsp)
movq %rbp, %rdi
leaq 0x53f7(%rip), %rsi      # 0xf2a9
leaq 0x53f4(%rip), %rdx      # 0xf2ad
callq 0x6b90
movl 0x28(%r14), %esi
leaq 0x48(%rsp), %rbx
movq %rbx, %rdi
movl $0x4, %edx
movl $0x24, %ecx
callq 0x7538
leaq 0x28(%rsp), %rdi
movq %rbp, %rsi
movq %rbx, %rdx
callq 0x7732
movq 0x48(%rsp), %rdi
leaq 0x58(%rsp), %rax
cmpq %rax, %rdi
je 0x9f05
movq 0x58(%rsp), %rsi
incq %rsi
callq 0x21c0
movq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rax
cmpq %rax, %rdi
je 0x9f21
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x21c0
movq 0x28(%rsp), %rdi
cmpq %r13, %rdi
je 0x9f38
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x21c0
movq %rbp, %r15
movl 0x28(%r14), %r12d
movq 0x38(%r14), %rbp
cmpq %rbp, 0x30(%r14)
je 0xa0b5
cmpl %r12d, -0x4(%rbp)
jbe 0xa07c
movq %r13, 0x28(%rsp)
leaq 0x28(%rsp), %rdi
leaq 0x53dc(%rip), %rdx      # 0xf344
movq %rdx, %rsi
callq 0x6b90
movq %r13, %rbx
leaq 0x18(%rsp), %rax
movq %rax, 0x8(%rsp)
movq %r15, %rdi
leaq 0x5d76(%rip), %rsi      # 0xfcfd
leaq 0x5d71(%rip), %rdx      # 0xfcff
callq 0x6b90
movl -0x4(%rbp), %r13d
subl %r12d, %r13d
movl $0x1, %eax
cmpl $0xa, %r13d
leaq 0x48(%rsp), %r12
jb 0x9fef
movl $0x4, %eax
movl %r13d, %ecx
movl $0xd1b71759, %esi       # imm = 0xD1B71759
cmpl $0x63, %ecx
jbe 0x9fe8
cmpl $0x3e7, %ecx            # imm = 0x3E7
jbe 0x9fed
cmpl $0x2710, %ecx           # imm = 0x2710
jb 0x9fef
movl %ecx, %edx
imulq %rsi, %rdx
shrq $0x2d, %rdx
addl $0x4, %eax
cmpl $0x1869f, %ecx          # imm = 0x1869F
movl %edx, %ecx
ja 0x9fb7
addl $-0x3, %eax
jmp 0x9fef
addl $-0x2, %eax
jmp 0x9fef
decl %eax
movl %eax, %esi
leaq 0x58(%rsp), %rax
movq %rax, 0x48(%rsp)
movq %r12, %rdi
xorl %edx, %edx
callq 0x2200
movq 0x48(%rsp), %rdi
movl 0x50(%rsp), %esi
movl %r13d, %edx
callq 0x6a93
leaq 0x28(%rsp), %rdi
movq %r15, %rsi
movq %r12, %rdx
callq 0x7732
movq 0x48(%rsp), %rdi
leaq 0x58(%rsp), %rax
cmpq %rax, %rdi
movq %rbx, %r13
je 0xa045
movq 0x58(%rsp), %rsi
incq %rsi
callq 0x21c0
movq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rax
cmpq %rax, %rdi
je 0xa061
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x21c0
movq 0x28(%rsp), %rdi
cmpq %r13, %rdi
je 0xa078
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x21c0
movl -0x4(%rbp), %r12d
addq $-0x28, %rbp
movq %rbp, %rdi
callq 0x764c
movq 0x38(%r14), %rax
leaq -0x28(%rax), %rcx
movq %rcx, 0x38(%r14)
movq -0x28(%rax), %rdi
addq $-0x18, %rax
cmpq %rax, %rdi
je 0x9f3f
movq (%rax), %rsi
incq %rsi
callq 0x21c0
jmp 0x9f3f
cmpl 0x24(%r14), %r12d
movq %r15, %rbp
jae 0xa1dd
movq %r13, 0x28(%rsp)
leaq 0x28(%rsp), %rdi
leaq 0x5271(%rip), %rdx      # 0xf344
movq %rdx, %rsi
callq 0x6b90
leaq 0x18(%rsp), %rax
movq %rax, 0x8(%rsp)
movq %rbp, %rdi
leaq 0x5c0e(%rip), %rsi      # 0xfcfd
leaq 0x5c09(%rip), %rdx      # 0xfcff
callq 0x6b90
movl 0x24(%r14), %ebp
subl %r12d, %ebp
movl $0x1, %eax
cmpl $0xa, %ebp
leaq 0x48(%rsp), %rbx
jb 0xa155
movl $0x4, %eax
movl %ebp, %ecx
movl $0xd1b71759, %esi       # imm = 0xD1B71759
cmpl $0x63, %ecx
jbe 0xa14e
cmpl $0x3e7, %ecx            # imm = 0x3E7
jbe 0xa153
cmpl $0x2710, %ecx           # imm = 0x2710
jb 0xa155
movl %ecx, %edx
imulq %rsi, %rdx
shrq $0x2d, %rdx
addl $0x4, %eax
cmpl $0x1869f, %ecx          # imm = 0x1869F
movl %edx, %ecx
ja 0xa11d
addl $-0x3, %eax
jmp 0xa155
addl $-0x2, %eax
jmp 0xa155
decl %eax
movl %eax, %esi
leaq 0x58(%rsp), %rax
movq %rax, 0x48(%rsp)
movq %rbx, %rdi
xorl %edx, %edx
callq 0x2200
movq 0x48(%rsp), %rdi
movl 0x50(%rsp), %esi
movl %ebp, %edx
callq 0x6a93
leaq 0x28(%rsp), %rdi
movq %r15, %rbp
movq %r15, %rsi
movq %rbx, %rdx
callq 0x7732
movq 0x48(%rsp), %rdi
leaq 0x58(%rsp), %rax
cmpq %rax, %rdi
je 0xa1aa
movq 0x58(%rsp), %rsi
incq %rsi
callq 0x21c0
movq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rax
cmpq %rax, %rdi
je 0xa1c6
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x21c0
movq 0x28(%rsp), %rdi
cmpq %r13, %rdi
je 0xa1dd
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x21c0
movq %r13, 0x28(%rsp)
leaq 0x28(%rsp), %rdi
leaq 0x5156(%rip), %rdx      # 0xf344
movq %rdx, %rsi
callq 0x6b90
leaq 0x18(%rsp), %rax
movq %rax, 0x8(%rsp)
movq %rbp, %rdi
leaq 0x5af1(%rip), %rsi      # 0xfcfb
leaq 0x5aee(%rip), %rdx      # 0xfcff
callq 0x6b90
movq 0x70(%rsp), %r12
leaq 0x28(%rsp), %rdi
movq %rbp, %rsi
callq 0x766e
movq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rax
cmpq %rax, %rdi
je 0xa244
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x21c0
movq 0x28(%rsp), %rdi
cmpq %r13, %rdi
je 0xa25b
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x21c0
movl $0xa, %edi
callq 0x2240
addq $0x50, %r14
cmpq %r12, %r14
jne 0x9e23
movq 0x68(%rsp), %rdi
movl $0x1, %esi
callq 0xadc2
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0xa2c5
jmp 0xa2e6
jmp 0xa301
jmp 0xa29e
jmp 0xa2c5
jmp 0xa2e6
jmp 0xa301
movq %rax, %r14
movq 0x48(%rsp), %rdi
leaq 0x58(%rsp), %rax
cmpq %rax, %rdi
je 0xa2c8
movq 0x58(%rsp), %rsi
incq %rsi
callq 0x21c0
jmp 0xa2c8
jmp 0xa2c5
jmp 0xa2e6
jmp 0xa301
movq %rax, %r14
movq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rax
cmpq %rax, %rdi
je 0xa2e9
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x21c0
jmp 0xa2e9
movq %rax, %r14
movq 0x28(%rsp), %rdi
cmpq %r13, %rdi
jne 0xa34b
jmp 0xa358
jmp 0xa301
movq %rax, %r14
jmp 0xa325
movq %rax, %r14
jmp 0xa341
movq %rax, %r14
jmp 0xa358
movq %rax, %r14
movq 0x48(%rsp), %rdi
leaq 0x58(%rsp), %rax
cmpq %rax, %rdi
je 0xa325
movq 0x58(%rsp), %rsi
incq %rsi
callq 0x21c0
movq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rax
cmpq %rax, %rdi
je 0xa341
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x21c0
movq 0x28(%rsp), %rdi
cmpq %rbx, %rdi
je 0xa358
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x21c0
movq %r14, %rdi
callq 0x22c0