// File: ksherlock[P]wdc-utils/disassembler.cpp
// Function: disassembler::space(unsigned int)
void disassembler::space(unsigned size) {
	flush();

	std::string line;

	indent_to(line, kOpcodeTab);
	line += ds();
	indent_to(line, kOperandTab);


	while (size) {
		uint32_t chunk;
		if (_next_label == -1) chunk = size;
		else {
			chunk = _next_label - _pc;
			chunk = std::min(chunk, size);
		}

		line.resize(kOperandTab);
		line += std::to_string(chunk);
		indent_to(line, kCommentTab);
		line += "; ";

		line += to_x(_pc, 4);
		line.push_back(':');
		line.push_back('\n');
		fputs(line.c_str(), stdout);	


		_pc += chunk;
		size -= chunk;
		if (_next_label == _pc) _next_label = next_label(_pc);
	}


}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xd0, %rsp
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movq -0x8(%rbp), %rdi
movq %rdi, -0xb8(%rbp)
callq 0xd970
leaq -0x30(%rbp), %rdi
movq %rdi, -0xb0(%rbp)
callq 0x3380
movq -0xb0(%rbp), %rdi
movl $0x14, %esi
callq 0xcb10
jmp 0xda55
movq -0xb8(%rbp), %rsi
movq (%rsi), %rax
movq 0x30(%rax), %rax
leaq -0x60(%rbp), %rdi
callq *%rax
jmp 0xda6b
leaq -0x30(%rbp), %rdi
leaq -0x60(%rbp), %rsi
callq 0x3340
jmp 0xda7a
leaq -0x60(%rbp), %rdi
callq 0x3160
leaq -0x30(%rbp), %rdi
movl $0x1e, %esi
callq 0xcb10
jmp 0xda93
jmp 0xda95
cmpl $0x0, -0xc(%rbp)
je 0xdc77
movq -0xb8(%rbp), %rax
cmpl $-0x1, 0x30(%rax)
jne 0xdadf
movl -0xc(%rbp), %eax
movl %eax, -0x64(%rbp)
jmp 0xdb13
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
jmp 0xdc89
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
leaq -0x60(%rbp), %rdi
callq 0x3160
jmp 0xdc89
movq -0xb8(%rbp), %rax
movl 0x20(%rax), %ecx
movl 0x30(%rax), %eax
subl %ecx, %eax
movl %eax, -0x64(%rbp)
leaq -0x64(%rbp), %rdi
leaq -0xc(%rbp), %rsi
callq 0xf2a0
movq %rax, -0xc0(%rbp)
jmp 0xdb07
movq -0xc0(%rbp), %rax
movl (%rax), %eax
movl %eax, -0x64(%rbp)
leaq -0x30(%rbp), %rdi
movl $0x1e, %esi
callq 0x3370
jmp 0xdb23
movl -0x64(%rbp), %esi
leaq -0x88(%rbp), %rdi
callq 0x8980
jmp 0xdb34
leaq -0x30(%rbp), %rdi
leaq -0x88(%rbp), %rsi
callq 0x3340
jmp 0xdb46
leaq -0x88(%rbp), %rdi
callq 0x3160
leaq -0x30(%rbp), %rdi
movl $0x50, %esi
callq 0xcb10
jmp 0xdb62
leaq 0xe0c8(%rip), %rsi      # 0x1bc31
leaq -0x30(%rbp), %rdi
callq 0x3260
jmp 0xdb74
movq -0xb8(%rbp), %rax
movl 0x20(%rax), %esi
leaq -0xa8(%rbp), %rdi
movl $0x4, %edx
xorl %ecx, %ecx
callq 0xcb90
jmp 0xdb93
leaq -0x30(%rbp), %rdi
leaq -0xa8(%rbp), %rsi
callq 0x3340
jmp 0xdba5
leaq -0xa8(%rbp), %rdi
callq 0x3160
leaq -0x30(%rbp), %rdi
movl $0x3a, %esi
callq 0x3230
jmp 0xdbc1
leaq -0x30(%rbp), %rdi
movl $0xa, %esi
callq 0x3230
jmp 0xdbd1
leaq -0x30(%rbp), %rdi
callq 0x30f0
movq %rax, %rdi
movq 0x173dc(%rip), %rax     # 0x24fc0
movq (%rax), %rsi
callq 0x32e0
jmp 0xdbee
movq -0xb8(%rbp), %rcx
movl -0x64(%rbp), %eax
addl 0x20(%rcx), %eax
movl %eax, 0x20(%rcx)
movl -0x64(%rbp), %edx
movl -0xc(%rbp), %eax
subl %edx, %eax
movl %eax, -0xc(%rbp)
movl 0x30(%rcx), %eax
cmpl 0x20(%rcx), %eax
jne 0xdc72
movq -0xb8(%rbp), %rdi
movl 0x20(%rdi), %esi
movq (%rdi), %rax
movq 0x38(%rax), %rax
callq *%rax
movl %eax, -0xc4(%rbp)
jmp 0xdc2c
movq -0xb8(%rbp), %rax
movl -0xc4(%rbp), %ecx
movl %ecx, 0x30(%rax)
jmp 0xdc72
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
leaq -0x88(%rbp), %rdi
callq 0x3160
jmp 0xdc89
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
leaq -0xa8(%rbp), %rdi
callq 0x3160
jmp 0xdc89
jmp 0xda95
leaq -0x30(%rbp), %rdi
callq 0x3160
addq $0xd0, %rsp
popq %rbp
retq
leaq -0x30(%rbp), %rdi
callq 0x3160
movq -0x38(%rbp), %rdi
callq 0x3440
nopl (%rax,%rax)