// File: /workspace/github_cpp_makefile_star2_O3/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 0x5764(%rip), %rdx      # 0xf344
leaq 0x28(%rsp), %rdi
movq %rdx, %rsi
callq 0x6a64
leaq 0x18(%rsp), %rax
movq %rax, -0x10(%rax)
leaq 0x60f7(%rip), %rsi      # 0xfcf4
leaq 0x60f6(%rip), %rdx      # 0xfcfa
leaq 0x8(%rsp), %rdi
callq 0x6a64
leaq 0x28(%rsp), %rdi
leaq 0x8(%rsp), %rsi
movq %rbx, %rdx
callq 0x75f4
movq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rax
cmpq %rax, %rdi
je 0x9c3c
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x21c0
movq 0x28(%rsp), %rdi
cmpq %r13, %rdi
je 0x9c53
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x21c0
movl $0xa, %edi
callq 0x2240
movq 0x68(%rsp), %rbx
movq %rbx, %rdi
callq 0xa1d6
movq %rbx, %rdi
callq 0xa37c
movq 0x50(%rbx), %r14
movq 0x58(%rbx), %rbx
cmpq %rbx, %r14
je 0xa0e7
leaq 0x8(%rsp), %rbp
leaq 0x48(%rsp), %r12
movl $0xd1b71759, %r15d      # imm = 0xD1B71759
movq %rbx, 0x70(%rsp)
cmpb $0x1, 0x2d(%r14)
jne 0xa0da
testb $0x8, 0x21(%r14)
je 0xa0da
cmpl $0x0, 0x24(%r14)
jne 0x9cc3
movq 0x30(%r14), %rax
cmpq 0x38(%r14), %rax
je 0xa0da
movq %r14, %rsi
callq 0xa59e
movzbl 0x20(%r14), %esi
movq 0x68(%rsp), %rbx
movq %rbx, %rdi
callq 0xa8c4
movzbl 0x20(%r14), %esi
movq %rbx, %rdi
callq 0xaa76
movb $0x1, 0x2c(%r14)
cmpl $0x0, 0x28(%r14)
je 0x9dae
movq %r13, 0x28(%rsp)
leaq 0x28(%rsp), %rdi
leaq 0x5639(%rip), %rdx      # 0xf344
movq %rdx, %rsi
callq 0x6a64
leaq 0x18(%rsp), %rax
movq %rax, 0x8(%rsp)
movq %rbp, %rdi
leaq 0x5582(%rip), %rsi      # 0xf2a9
leaq 0x557f(%rip), %rdx      # 0xf2ad
callq 0x6a64
movl 0x28(%r14), %esi
movq %r12, %rdi
movl $0x4, %edx
movl $0x24, %ecx
callq 0x73f8
leaq 0x28(%rsp), %rdi
movq %rbp, %rsi
movq %r12, %rdx
callq 0x75f4
movq 0x48(%rsp), %rdi
leaq 0x58(%rsp), %rax
cmpq %rax, %rdi
je 0x9d75
movq 0x58(%rsp), %rsi
incq %rsi
callq 0x21c0
movq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rax
cmpq %rax, %rdi
je 0x9d91
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x21c0
movq 0x28(%rsp), %rdi
cmpq %r13, %rdi
je 0x9da8
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x21c0
movl 0x28(%r14), %r12d
jmp 0x9db1
xorl %r12d, %r12d
movq 0x38(%r14), %rbp
cmpq %rbp, 0x30(%r14)
je 0x9f26
cmpl %r12d, -0x4(%rbp)
jbe 0x9eed
movq %r13, 0x28(%rsp)
leaq 0x28(%rsp), %rdi
leaq 0x556a(%rip), %rdx      # 0xf344
movq %rdx, %rsi
callq 0x6a64
movq %r13, %rbx
leaq 0x18(%rsp), %rax
movq %rax, 0x8(%rsp)
leaq 0x8(%rsp), %rdi
leaq 0x5f02(%rip), %rsi      # 0xfcfd
leaq 0x5efd(%rip), %rdx      # 0xfcff
callq 0x6a64
movl -0x4(%rbp), %r13d
subl %r12d, %r13d
movl $0x1, %eax
cmpl $0xa, %r13d
leaq 0x48(%rsp), %r12
jb 0x9e5e
movl $0x4, %eax
movl %r13d, %ecx
cmpl $0x63, %ecx
jbe 0x9e57
cmpl $0x3e7, %ecx            # imm = 0x3E7
jbe 0x9e5c
cmpl $0x2710, %ecx           # imm = 0x2710
jb 0x9e5e
movl %ecx, %edx
imulq %r15, %rdx
shrq $0x2d, %rdx
addl $0x4, %eax
cmpl $0x1869f, %ecx          # imm = 0x1869F
movl %edx, %ecx
ja 0x9e26
addl $-0x3, %eax
jmp 0x9e5e
addl $-0x2, %eax
jmp 0x9e5e
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 0x6961
leaq 0x28(%rsp), %rdi
leaq 0x8(%rsp), %rsi
movq %r12, %rdx
callq 0x75f4
movq 0x48(%rsp), %rdi
leaq 0x58(%rsp), %rax
cmpq %rax, %rdi
movq %rbx, %r13
je 0x9eb6
movq 0x58(%rsp), %rsi
incq %rsi
callq 0x21c0
movq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rax
cmpq %rax, %rdi
je 0x9ed2
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x21c0
movq 0x28(%rsp), %rdi
cmpq %r13, %rdi
je 0x9ee9
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x21c0
movl -0x4(%rbp), %r12d
addq $-0x28, %rbp
movq %rbp, %rdi
callq 0x750c
movq 0x38(%r14), %rax
leaq -0x28(%rax), %rbp
movq %rbp, 0x38(%r14)
movq -0x28(%rax), %rdi
addq $-0x18, %rax
cmpq %rax, %rdi
je 0x9db5
movq (%rax), %rsi
incq %rsi
callq 0x21c0
jmp 0x9db1
cmpl 0x24(%r14), %r12d
leaq 0x8(%rsp), %rbp
jae 0xa04d
movq %r13, 0x28(%rsp)
leaq 0x28(%rsp), %rdi
leaq 0x53fe(%rip), %rdx      # 0xf344
movq %rdx, %rsi
callq 0x6a64
leaq 0x18(%rsp), %rax
movq %rax, 0x8(%rsp)
movq %rbp, %rdi
leaq 0x5d9b(%rip), %rsi      # 0xfcfd
leaq 0x5d96(%rip), %rdx      # 0xfcff
callq 0x6a64
movl 0x24(%r14), %ebp
subl %r12d, %ebp
movl $0x1, %eax
cmpl $0xa, %ebp
leaq 0x48(%rsp), %rbx
jb 0x9fc3
movl $0x4, %eax
movl %ebp, %ecx
cmpl $0x63, %ecx
jbe 0x9fbc
cmpl $0x3e7, %ecx            # imm = 0x3E7
jbe 0x9fc1
cmpl $0x2710, %ecx           # imm = 0x2710
jb 0x9fc3
movl %ecx, %edx
imulq %r15, %rdx
shrq $0x2d, %rdx
addl $0x4, %eax
cmpl $0x1869f, %ecx          # imm = 0x1869F
movl %edx, %ecx
ja 0x9f8b
addl $-0x3, %eax
jmp 0x9fc3
addl $-0x2, %eax
jmp 0x9fc3
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 0x6961
leaq 0x28(%rsp), %rdi
leaq 0x8(%rsp), %rbp
movq %rbp, %rsi
movq %rbx, %rdx
callq 0x75f4
movq 0x48(%rsp), %rdi
leaq 0x58(%rsp), %rax
cmpq %rax, %rdi
je 0xa01a
movq 0x58(%rsp), %rsi
incq %rsi
callq 0x21c0
movq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rax
cmpq %rax, %rdi
je 0xa036
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x21c0
movq 0x28(%rsp), %rdi
cmpq %r13, %rdi
je 0xa04d
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x21c0
movq %r13, 0x28(%rsp)
leaq 0x28(%rsp), %rdi
leaq 0x52e6(%rip), %rdx      # 0xf344
movq %rdx, %rsi
callq 0x6a64
leaq 0x18(%rsp), %rax
movq %rax, 0x8(%rsp)
movq %rbp, %rdi
leaq 0x5c81(%rip), %rsi      # 0xfcfb
leaq 0x5c7e(%rip), %rdx      # 0xfcff
callq 0x6a64
movq 0x70(%rsp), %rbx
leaq 0x28(%rsp), %rdi
movq %rbp, %rsi
callq 0x752e
leaq 0x48(%rsp), %r12
movq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rax
cmpq %rax, %rdi
je 0xa0b9
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x21c0
movq 0x28(%rsp), %rdi
cmpq %r13, %rdi
je 0xa0d0
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x21c0
movl $0xa, %edi
callq 0x2240
addq $0x50, %r14
cmpq %rbx, %r14
jne 0x9c98
movq 0x68(%rsp), %rdi
movl $0x1, %esi
callq 0xac2e
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0xa13a
jmp 0xa15b
jmp 0xa16c
jmp 0xa113
jmp 0xa13a
jmp 0xa15b
jmp 0xa16c
movq %rax, %r14
movq 0x48(%rsp), %rdi
leaq 0x58(%rsp), %rax
cmpq %rax, %rdi
je 0xa13d
movq 0x58(%rsp), %rsi
incq %rsi
callq 0x21c0
jmp 0xa13d
jmp 0xa13a
jmp 0xa15b
jmp 0xa16c
movq %rax, %r14
movq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rax
cmpq %rax, %rdi
je 0xa15e
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x21c0
jmp 0xa15e
movq %rax, %r14
movq 0x28(%rsp), %rdi
cmpq %r13, %rdi
jne 0xa1c0
jmp 0xa1cd
jmp 0xa16c
movq %rax, %r14
jmp 0xa1cd
movq %rax, %r14
movq 0x48(%rsp), %rdi
leaq 0x58(%rsp), %rax
cmpq %rax, %rdi
je 0xa195
movq 0x58(%rsp), %rsi
incq %rsi
callq 0x21c0
jmp 0xa195
movq %rax, %r14
movq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rax
cmpq %rax, %rdi
je 0xa1b6
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x21c0
jmp 0xa1b6
movq %rax, %r14
movq 0x28(%rsp), %rdi
cmpq %rbx, %rdi
je 0xa1cd
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x21c0
movq %r14, %rdi
callq 0x22c0
nop