// File: /workspace/github_cpp_makefile_star2_O2/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, 0x8(%rsp)
leaq 0x3d0b(%rip), %rsi      # 0xb3a0
leaq 0x38(%rsp), %rdi
leaq 0x58(%rsp), %rdx
callq 0x48d4
leaq 0x4699(%rip), %rsi      # 0xbd44
leaq 0x10(%rsp), %rdi
leaq 0x6(%rsp), %rdx
callq 0x48d4
leaq 0x38(%rsp), %rdi
leaq 0x10(%rsp), %rsi
movq %rbx, %rdx
callq 0x5864
leaq 0x10(%rsp), %r13
movq %r13, %rdi
callq 0x20d0
leaq 0x38(%rsp), %r15
movq %r15, %rdi
callq 0x20d0
pushq $0xa
popq %rdi
callq 0x2280
movq 0x8(%rsp), %rbx
movq %rbx, %rdi
callq 0x79bc
movq %rbx, %rdi
callq 0x7ad6
movq 0x50(%rbx), %r12
movq 0x58(%rbx), %rcx
leaq 0x58(%rsp), %rbx
movq %rcx, 0x30(%rsp)
cmpq %rcx, %r12
je 0x794c
cmpb $0x1, 0x2d(%r12)
jne 0x7943
testb $0x8, 0x21(%r12)
je 0x7943
cmpl $0x0, 0x24(%r12)
jne 0x774e
movq 0x30(%r12), %rax
cmpq 0x38(%r12), %rax
je 0x7943
movq %r12, %rsi
callq 0x7c4a
movzbl 0x20(%r12), %esi
movq 0x8(%rsp), %r14
movq %r14, %rdi
callq 0x7ed8
movzbl 0x20(%r12), %esi
movq %r14, %rdi
callq 0x7ffe
movb $0x1, 0x2c(%r12)
cmpl $0x0, 0x28(%r12)
je 0x77ed
movq %r15, %rdi
leaq 0x3c11(%rip), %rsi      # 0xb3a0
leaq 0x6(%rsp), %rdx
callq 0x48d4
movq %r13, %rdi
leaq 0x3b62(%rip), %rsi      # 0xb305
leaq 0x7(%rsp), %rdx
callq 0x48d4
movl 0x28(%r12), %esi
movq %rbx, %rdi
pushq $0x4
popq %rdx
pushq $0x24
popq %rcx
callq 0x56d0
movq %r15, %rdi
movq %r13, %rsi
movq %rbx, %rdx
callq 0x5864
movq %rbx, %rdi
callq 0x20d0
movq %r13, %rdi
callq 0x20d0
movq %r15, %rdi
callq 0x20d0
movl 0x28(%r12), %r14d
jmp 0x77f0
xorl %r14d, %r14d
leaq 0x30(%r12), %r13
movq 0x38(%r12), %rbp
cmpq %rbp, 0x30(%r12)
je 0x788b
cmpl %r14d, -0x4(%rbp)
jbe 0x7872
movq %r15, %rdi
leaq 0x3b8b(%rip), %rsi      # 0xb3a0
leaq 0x6(%rsp), %rdx
callq 0x48d4
leaq 0x10(%rsp), %rdi
leaq 0x4522(%rip), %rsi      # 0xbd4d
leaq 0x7(%rsp), %rdx
callq 0x48d4
movl -0x4(%rbp), %esi
subl %r14d, %esi
movq %rbx, %rdi
callq 0x4b15
movq %r15, %rdi
leaq 0x10(%rsp), %r14
movq %r14, %rsi
movq %rbx, %rdx
callq 0x5864
movq %rbx, %rdi
callq 0x20d0
movq %r14, %rdi
callq 0x20d0
movq %r15, %rdi
callq 0x20d0
movl -0x4(%rbp), %r14d
addq $-0x28, %rbp
movq %rbp, %rdi
callq 0x57c2
movq %r13, %rdi
callq 0x8f22
jmp 0x77f5
cmpl 0x24(%r12), %r14d
leaq 0x10(%rsp), %r13
jae 0x78f5
movq %r15, %rdi
leaq 0x3aff(%rip), %rsi      # 0xb3a0
leaq 0x6(%rsp), %rdx
callq 0x48d4
movq %r13, %rdi
leaq 0x4498(%rip), %rsi      # 0xbd4d
leaq 0x7(%rsp), %rdx
callq 0x48d4
movl 0x24(%r12), %esi
subl %r14d, %esi
movq %rbx, %rdi
callq 0x4b15
movq %r15, %rdi
movq %r13, %rsi
movq %rbx, %rdx
callq 0x5864
movq %rbx, %rdi
callq 0x20d0
movq %r13, %rdi
callq 0x20d0
movq %r15, %rdi
callq 0x20d0
movq %r15, %rdi
leaq 0x3aa1(%rip), %rsi      # 0xb3a0
movq %rbx, %rdx
callq 0x48d4
movq %r13, %rdi
leaq 0x443a(%rip), %rsi      # 0xbd4b
leaq 0x6(%rsp), %rdx
callq 0x48d4
movq %r15, %rdi
movq %r13, %rsi
callq 0x57e2
movq %r13, %rdi
callq 0x20d0
movq %r15, %rdi
callq 0x20d0
pushq $0xa
popq %rdi
callq 0x2280
movq 0x30(%rsp), %rcx
addq $0x50, %r12
jmp 0x7715
pushq $0x1
popq %rsi
movq 0x8(%rsp), %rdi
callq 0x8122
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x7989
jmp 0x79a7
jmp 0x7984
jmp 0x798e
jmp 0x7989
jmp 0x79a7
jmp 0x7984
jmp 0x798e
jmp 0x7989
jmp 0x79a7
jmp 0x7984
jmp 0x7989
jmp 0x79a7
jmp 0x7984
movq %rax, %rbx
jmp 0x79b4
movq %rax, %rbx
jmp 0x799b
movq %rax, %rbx
leaq 0x58(%rsp), %rdi
callq 0x20d0
leaq 0x10(%rsp), %rdi
callq 0x20d0
jmp 0x79aa
movq %rax, %rbx
leaq 0x38(%rsp), %rdi
callq 0x20d0
movq %rbx, %rdi
callq 0x2300