// File: /workspace/github_cpp_makefile_star2_O1/TNanukem[P]chip8-emulator/emulator.cpp
// Function: emulator::loadGame(unsigned char, chip8*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>)
chip8 emulator::loadGame(uint8_t SaveStateSlot, chip8 *Chip8, std::string game){
	FILE* loadGame;

	std::string extension = std::string("_") + std::to_string(SaveStateSlot)
							+ std::string(".sav");
	game.append(extension);

	loadGame = fopen(game.c_str(),"rb");

	if(loadGame == NULL){
		return *Chip8;
	}

	chip8 aux;

	fread(&aux, sizeof(chip8), 1, loadGame);
	return aux;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xa8, %rsp
movq %r8, %r15
movq %rcx, -0xd0(%rbp)
movl %edx, %r12d
movq %rdi, %rbx
leaq -0x78(%rbp), %rax
movq %rax, -0x10(%rax)
leaq 0x1005(%rip), %rsi      # 0x422c
leaq 0xfff(%rip), %rdx       # 0x422d
leaq -0x88(%rbp), %rdi
callq 0x3eee
cmpb $0x64, %r12b
movl $0x3, %eax
sbbl $0x0, %eax
cmpb $0xa, %r12b
movl $0x1, %r13d
cmovael %eax, %r13d
leaq -0x98(%rbp), %r14
movq %r14, -0x10(%r14)
leaq -0xa8(%rbp), %rdi
movq %r13, %rsi
movl $0x2d, %edx
callq 0x2200
movzbl %r12b, %edx
movq -0xa8(%rbp), %rdi
movl %r13d, %esi
callq 0x3de1
movq -0x88(%rbp), %rcx
movq -0x80(%rbp), %r8
movq -0xa0(%rbp), %rdx
leaq (%rdx,%r8), %rax
movl $0xf, %esi
leaq -0x78(%rbp), %rdi
cmpq %rdi, %rcx
je 0x32ae
movq -0x78(%rbp), %rsi
cmpq %rsi, %rax
jbe 0x32cd
movl $0xf, %esi
cmpq %r14, -0xa8(%rbp)
je 0x32c8
movq -0x98(%rbp), %rsi
cmpq %rsi, %rax
jbe 0x32e2
movq -0xa8(%rbp), %rsi
leaq -0x88(%rbp), %rdi
callq 0x20d0
jmp 0x32f2
leaq -0xa8(%rbp), %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x21f0
leaq -0x38(%rbp), %rdx
movq %rdx, -0x10(%rdx)
movq (%rax), %rsi
leaq 0x10(%rax), %rcx
cmpq %rcx, %rsi
je 0x3313
movq %rsi, -0x48(%rbp)
movq (%rcx), %rdx
movq %rdx, -0x38(%rbp)
jmp 0x3319
movups (%rcx), %xmm0
movups %xmm0, (%rdx)
movq %rax, %rdx
addq $0x8, %rdx
movq 0x8(%rax), %rsi
movq %rsi, -0x40(%rbp)
movq %rcx, (%rax)
movq $0x0, (%rdx)
movb $0x0, (%rcx)
leaq -0xb8(%rbp), %r12
movq %r12, -0x10(%r12)
leaq 0xee6(%rip), %rsi       # 0x422e
leaq 0xee3(%rip), %rdx       # 0x4232
leaq -0xc8(%rbp), %rdi
callq 0x3eee
leaq -0x38(%rbp), %r13
movq -0x10(%r13), %rcx
movq -0x8(%r13), %r8
movq -0xc0(%rbp), %rdx
leaq (%rdx,%r8), %rax
movl $0xf, %esi
cmpq %r13, %rcx
je 0x3380
movq -0x38(%rbp), %rsi
cmpq %rsi, %rax
jbe 0x339f
movl $0xf, %esi
cmpq %r12, -0xc8(%rbp)
je 0x339a
movq -0xb8(%rbp), %rsi
cmpq %rsi, %rax
jbe 0x33b1
movq -0xc8(%rbp), %rsi
leaq -0x48(%rbp), %rdi
callq 0x20d0
jmp 0x33c1
leaq -0xc8(%rbp), %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x21f0
leaq -0x58(%rbp), %rdx
movq %rdx, -0x10(%rdx)
movq (%rax), %rsi
leaq 0x10(%rax), %rcx
cmpq %rcx, %rsi
je 0x33e2
movq %rsi, -0x68(%rbp)
movq (%rcx), %rdx
movq %rdx, -0x58(%rbp)
jmp 0x33e8
movups (%rcx), %xmm0
movups %xmm0, (%rdx)
movq %rax, %rdx
addq $0x8, %rdx
movq 0x8(%rax), %rsi
movq %rsi, -0x60(%rbp)
movq %rcx, (%rax)
movq $0x0, (%rdx)
movb $0x0, (%rcx)
movq -0xc8(%rbp), %rdi
cmpq %r12, %rdi
je 0x341f
movq -0xb8(%rbp), %rsi
incq %rsi
callq 0x21c0
movq -0x48(%rbp), %rdi
cmpq %r13, %rdi
je 0x3434
movq -0x38(%rbp), %rsi
incq %rsi
callq 0x21c0
movq -0xa8(%rbp), %rdi
cmpq %r14, %rdi
je 0x344f
movq -0x98(%rbp), %rsi
incq %rsi
callq 0x21c0
movq -0x88(%rbp), %rdi
leaq -0x78(%rbp), %rax
cmpq %rax, %rdi
je 0x346b
movq -0x78(%rbp), %rsi
incq %rsi
callq 0x21c0
movq -0x68(%rbp), %rsi
movq -0x60(%rbp), %rdx
movq %r15, %rdi
callq 0x20d0
movq (%r15), %rdi
leaq 0xbfb(%rip), %rsi       # 0x4080
callq 0x2210
testq %rax, %rax
je 0x34af
movw $0x0, 0x304c(%rbx)
movl $0x3050, %esi           # imm = 0x3050
movl $0x1, %edx
movq %rbx, %rdi
movq %rax, %rcx
callq 0x2280
jmp 0x34c3
movl $0x3050, %edx           # imm = 0x3050
movq %rbx, %rdi
movq -0xd0(%rbp), %rsi
callq 0x2180
leaq -0x58(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x34dc
movq -0x58(%rbp), %rsi
incq %rsi
callq 0x21c0
movq %rbx, %rax
addq $0xa8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
leaq -0x58(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x358d
movq -0x58(%rbp), %rsi
jmp 0x3580
movq %rax, %rbx
movq -0xc8(%rbp), %rdi
cmpq %r12, %rdi
je 0x352e
movq -0xb8(%rbp), %rsi
incq %rsi
callq 0x21c0
jmp 0x352e
movq %rax, %rbx
leaq -0x38(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x354c
movq -0x38(%rbp), %rsi
incq %rsi
callq 0x21c0
jmp 0x354c
movq %rax, %rbx
movq -0xa8(%rbp), %rdi
cmpq %r14, %rdi
je 0x356c
movq -0x98(%rbp), %rsi
incq %rsi
callq 0x21c0
jmp 0x356c
movq %rax, %rbx
movq -0x88(%rbp), %rdi
leaq -0x78(%rbp), %rax
cmpq %rax, %rdi
je 0x358d
movq -0x78(%rbp), %rsi
incq %rsi
callq 0x21c0
jmp 0x358d
movq %rax, %rbx
movq %rbx, %rdi
callq 0x22d0