// File: /workspace/github_cpp_makefile_star2_O3/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 0x1ff1(%rip), %rsi      # 0x522c
leaq 0x1feb(%rip), %rdx      # 0x522d
leaq -0x88(%rbp), %rdi
callq 0x3f24
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 0x3e14
movq -0x88(%rbp), %rcx
movq -0x80(%rbp), %r8
movq -0xa0(%rbp), %rdx
leaq (%rdx,%r8), %rax
movl $0xf, %edi
leaq -0x78(%rbp), %rsi
cmpq %rsi, %rcx
je 0x32c2
movq -0x78(%rbp), %rdi
movq -0xa8(%rbp), %rsi
cmpq %rdi, %rax
jbe 0x32e4
movl $0xf, %edi
cmpq %r14, %rsi
je 0x32df
movq -0x98(%rbp), %rdi
cmpq %rdi, %rax
jbe 0x32f2
leaq -0x88(%rbp), %rdi
callq 0x20d0
jmp 0x3302
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 0x3323
movq %rsi, -0x48(%rbp)
movq (%rcx), %rdx
movq %rdx, -0x38(%rbp)
jmp 0x3329
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 0x1ed6(%rip), %rsi      # 0x522e
leaq 0x1ed3(%rip), %rdx      # 0x5232
leaq -0xc8(%rbp), %rdi
callq 0x3f24
leaq -0x38(%rbp), %r13
movq -0x10(%r13), %rcx
movq -0x8(%r13), %r8
movq -0xc0(%rbp), %rdx
leaq (%rdx,%r8), %rax
movl $0xf, %edi
cmpq %r13, %rcx
je 0x3390
movq -0x38(%rbp), %rdi
movq -0xc8(%rbp), %rsi
cmpq %rdi, %rax
jbe 0x33b2
movl $0xf, %edi
cmpq %r12, %rsi
je 0x33ad
movq -0xb8(%rbp), %rdi
cmpq %rdi, %rax
jbe 0x33bd
leaq -0x48(%rbp), %rdi
callq 0x20d0
jmp 0x33cd
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 0x33ee
movq %rsi, -0x68(%rbp)
movq (%rcx), %rdx
movq %rdx, -0x58(%rbp)
jmp 0x33f4
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 0x342b
movq -0xb8(%rbp), %rsi
incq %rsi
callq 0x21c0
movq -0x48(%rbp), %rdi
cmpq %r13, %rdi
je 0x3440
movq -0x38(%rbp), %rsi
incq %rsi
callq 0x21c0
movq -0xa8(%rbp), %rdi
cmpq %r14, %rdi
je 0x345b
movq -0x98(%rbp), %rsi
incq %rsi
callq 0x21c0
movq -0x88(%rbp), %rdi
leaq -0x78(%rbp), %rax
cmpq %rax, %rdi
je 0x3477
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 0x1bef(%rip), %rsi      # 0x5080
callq 0x2210
testq %rax, %rax
je 0x34bb
movw $0x0, 0x304c(%rbx)
movl $0x3050, %esi           # imm = 0x3050
movl $0x1, %edx
movq %rbx, %rdi
movq %rax, %rcx
callq 0x2280
jmp 0x34cf
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 0x34e8
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 0x3599
movq -0x58(%rbp), %rsi
jmp 0x358c
movq %rax, %rbx
movq -0xc8(%rbp), %rdi
cmpq %r12, %rdi
je 0x353a
movq -0xb8(%rbp), %rsi
incq %rsi
callq 0x21c0
jmp 0x353a
movq %rax, %rbx
leaq -0x38(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x3558
movq -0x38(%rbp), %rsi
incq %rsi
callq 0x21c0
jmp 0x3558
movq %rax, %rbx
movq -0xa8(%rbp), %rdi
cmpq %r14, %rdi
je 0x3578
movq -0x98(%rbp), %rsi
incq %rsi
callq 0x21c0
jmp 0x3578
movq %rax, %rbx
movq -0x88(%rbp), %rdi
leaq -0x78(%rbp), %rax
cmpq %rax, %rdi
je 0x3599
movq -0x78(%rbp), %rsi
incq %rsi
callq 0x21c0
jmp 0x3599
movq %rax, %rbx
movq %rbx, %rdi
callq 0x22d0