// File: ksherlock[P]wdc-utils/zrdz_disassembler.cpp
// Function: zrdz_disassembler::set_section(int)
void zrdz_disassembler::set_section(int section) {
	if (section == _section) return;
	if (section >= _sections.size()) {
		warnx("Invalid section %d", section);
		return;
	}
	auto &e = _sections[section];
	if (section >5 && !e.valid) {
		warnx("Invalid section %d", section);
		return;		
	}

	if (_section >= 0) {
		flush();
		_sections[_section].pc = pc();
		emit("", "ends");
		putchar('\n');
	}

	print_section(e);

	if (!e.processed) {
		print_globals(section);
		print_equs(section);
		e.processed = true;
	}

	_section = section;
	set_pc(e.pc);
	set_code((e.flags & SEC_DATA) == 0);
	recalc_next_label();
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xa0, %rsp
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movq -0x8(%rbp), %rcx
movq %rcx, -0x80(%rbp)
movl -0xc(%rbp), %eax
cmpl 0x68(%rcx), %eax
jne 0x13427
jmp 0x1363e
movq -0x80(%rbp), %rdi
movslq -0xc(%rbp), %rax
movq %rax, -0x88(%rbp)
addq $0x50, %rdi
callq 0x15af0
movq %rax, %rcx
movq -0x88(%rbp), %rax
cmpq %rcx, %rax
jb 0x13464
movl -0xc(%rbp), %esi
leaq 0x894c(%rip), %rdi      # 0x1bda4
movb $0x0, %al
callq 0x32a0
jmp 0x1363e
movq -0x80(%rbp), %rdi
addq $0x50, %rdi
movslq -0xc(%rbp), %rsi
callq 0x15bb0
movq %rax, -0x18(%rbp)
cmpl $0x5, -0xc(%rbp)
jle 0x1349f
movq -0x18(%rbp), %rax
testb $0x1, 0x2d(%rax)
jne 0x1349f
movl -0xc(%rbp), %esi
leaq 0x8911(%rip), %rdi      # 0x1bda4
movb $0x0, %al
callq 0x32a0
jmp 0x1363e
movq -0x80(%rbp), %rax
cmpl $0x0, 0x68(%rax)
jl 0x135c6
movq -0x80(%rbp), %rdi
callq 0xd970
movq -0x80(%rbp), %rdi
callq 0x160f0
movl %eax, %ecx
movq -0x80(%rbp), %rax
movl %ecx, -0x94(%rbp)
movq %rax, %rdi
addq $0x50, %rdi
movslq 0x68(%rax), %rsi
callq 0x15bb0
movl -0x94(%rbp), %ecx
movl %ecx, 0x48(%rax)
leaq -0x39(%rbp), %rdi
movq %rdi, -0x90(%rbp)
callq 0x3460
movq -0x90(%rbp), %rdx
leaq 0x7e72(%rip), %rsi      # 0x1b374
leaq -0x38(%rbp), %rdi
callq 0x8060
jmp 0x1350d
leaq -0x71(%rbp), %rdi
movq %rdi, -0xa0(%rbp)
callq 0x3460
movq -0xa0(%rbp), %rdx
leaq 0x879c(%rip), %rsi      # 0x1bcc7
leaq -0x70(%rbp), %rdi
callq 0x8060
jmp 0x13536
leaq -0x38(%rbp), %rdi
leaq -0x70(%rbp), %rsi
callq 0xcd80
jmp 0x13545
leaq -0x70(%rbp), %rdi
callq 0x3160
leaq -0x71(%rbp), %rdi
callq 0x32b0
leaq -0x38(%rbp), %rdi
callq 0x3160
leaq -0x39(%rbp), %rdi
callq 0x32b0
movl $0xa, %edi
callq 0x3390
jmp 0x135c6
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
jmp 0x135b8
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
jmp 0x135a6
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
leaq -0x70(%rbp), %rdi
callq 0x3160
leaq -0x71(%rbp), %rdi
callq 0x32b0
leaq -0x38(%rbp), %rdi
callq 0x3160
leaq -0x39(%rbp), %rdi
callq 0x32b0
jmp 0x13647
movq -0x80(%rbp), %rdi
movq -0x18(%rbp), %rsi
callq 0x12a60
movq -0x18(%rbp), %rax
testb $0x1, 0x2c(%rax)
jne 0x135fd
movq -0x80(%rbp), %rdi
movl -0xc(%rbp), %esi
callq 0x12ed0
movq -0x80(%rbp), %rdi
movl -0xc(%rbp), %esi
callq 0x13170
movq -0x18(%rbp), %rax
movb $0x1, 0x2c(%rax)
movq -0x80(%rbp), %rdi
movl -0xc(%rbp), %eax
movl %eax, 0x68(%rdi)
movq -0x18(%rbp), %rax
movl 0x48(%rax), %esi
callq 0x8bd0
movq -0x80(%rbp), %rdi
movq -0x18(%rbp), %rax
movzbl 0x21(%rax), %eax
andl $0x80, %eax
cmpl $0x0, %eax
sete %al
movzbl %al, %esi
andl $0x1, %esi
callq 0x16110
movq -0x80(%rbp), %rdi
callq 0x16160
addq $0xa0, %rsp
popq %rbp
retq
movq -0x48(%rbp), %rdi
callq 0x3440