// File: nyorain[P]bintoheader/bintoheader.cpp
// Function: loadFile(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&)
std::vector<std::uint8_t> loadFile(const std::string& file)
{
	auto openmode = std::ios::ate | std::ios::binary;

	std::ifstream ifs(file, openmode);
	if(!ifs.is_open()) {
		std::cerr << "loadFile: couldnt open input file " << file << "\n";
		std::cerr << "error: " << std::strerror(errno) << "\n";
		exit(EXIT_FAILURE);
	}

	auto size = ifs.tellg();
	ifs.seekg(0, std::ios::beg);

	std::vector<std::uint8_t> buffer(size);
	auto data = reinterpret_cast<char*>(buffer.data());
	if(!ifs.read(data, size)) {
		std::cerr << "loadFile: failed to read input file " << file << "\n";
		std::cerr << "error: " << std::strerror(errno) << "\n";
		exit(EXIT_FAILURE);
	}

	return buffer;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x2f0, %rsp            # imm = 0x2F0
movq %rdi, -0x270(%rbp)
movq %rdi, %rax
movq %rax, -0x268(%rbp)
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl $0x2, %edi
movl $0x4, %esi
callq 0x5500
movl %eax, -0x14(%rbp)
movq -0x10(%rbp), %rsi
movl -0x14(%rbp), %edx
leaq -0x220(%rbp), %rdi
movq %rdi, -0x260(%rbp)
callq 0x3410
movq -0x260(%rbp), %rdi
callq 0x3400
movb %al, -0x251(%rbp)
jmp 0x3974
movb -0x251(%rbp), %al
testb $0x1, %al
jne 0x3a44
jmp 0x3984
movq 0xd665(%rip), %rdi      # 0x10ff0
leaq 0x7689(%rip), %rsi      # 0xb01b
callq 0x3270
movq %rax, -0x278(%rbp)
jmp 0x39a0
movq -0x278(%rbp), %rdi
movq -0x10(%rbp), %rsi
callq 0x3250
movq %rax, -0x280(%rbp)
jmp 0x39b9
movq -0x280(%rbp), %rdi
leaq 0x78dd(%rip), %rsi      # 0xb2a4
callq 0x3270
jmp 0x39ce
movq 0xd61b(%rip), %rdi      # 0x10ff0
leaq 0x7662(%rip), %rsi      # 0xb03e
callq 0x3270
movq %rax, -0x288(%rbp)
jmp 0x39ea
callq 0x3030
movl (%rax), %edi
callq 0x30c0
movq -0x288(%rbp), %rdi
movq %rax, %rsi
callq 0x3270
movq %rax, -0x290(%rbp)
jmp 0x3a0e
movq -0x290(%rbp), %rdi
leaq 0x7888(%rip), %rsi      # 0xb2a4
callq 0x3270
jmp 0x3a23
movl $0x1, %edi
callq 0x3300
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x228(%rbp)
movl %eax, -0x22c(%rbp)
jmp 0x3c8c
leaq -0x220(%rbp), %rdi
callq 0x3460
movq %rdx, -0x2a0(%rbp)
movq %rax, -0x298(%rbp)
jmp 0x3a60
movq -0x2a0(%rbp), %rax
movq -0x298(%rbp), %rcx
movq %rcx, -0x240(%rbp)
movq %rax, -0x238(%rbp)
xorl %edx, %edx
movl %edx, %esi
leaq -0x220(%rbp), %rdi
callq 0x3370
jmp 0x3a8e
movb $0x0, -0x241(%rbp)
leaq -0x240(%rbp), %rdi
callq 0x5520
movq %rax, -0x2a8(%rbp)
jmp 0x3aaa
leaq -0x242(%rbp), %rdi
movq %rdi, -0x2b0(%rbp)
callq 0x5540
movq -0x270(%rbp), %rdi
movq -0x2a8(%rbp), %rsi
movq -0x2b0(%rbp), %rdx
callq 0x5560
jmp 0x3ad9
leaq -0x242(%rbp), %rdi
callq 0x55d0
movq -0x270(%rbp), %rdi
callq 0x55f0
movq %rax, -0x250(%rbp)
movq -0x250(%rbp), %rax
movq %rax, -0x2c0(%rbp)
leaq -0x240(%rbp), %rdi
callq 0x5520
movq %rax, -0x2b8(%rbp)
jmp 0x3b1b
movq -0x2b8(%rbp), %rdx
movq -0x2c0(%rbp), %rsi
leaq -0x220(%rbp), %rdi
callq 0x3340
movq %rax, -0x2c8(%rbp)
jmp 0x3b3e
movq -0x2c8(%rbp), %rdi
movq (%rdi), %rax
movq -0x18(%rax), %rax
addq %rax, %rdi
callq 0x3150
movb %al, -0x2c9(%rbp)
jmp 0x3b5c
movb -0x2c9(%rbp), %al
testb $0x1, %al
jne 0x3b6b
jmp 0x3c54
movq 0xd47e(%rip), %rdi      # 0x10ff0
leaq 0x74cd(%rip), %rsi      # 0xb046
callq 0x3270
movq %rax, -0x2d8(%rbp)
jmp 0x3b87
movq -0x2d8(%rbp), %rdi
movq -0x10(%rbp), %rsi
callq 0x3250
movq %rax, -0x2e0(%rbp)
jmp 0x3ba0
movq -0x2e0(%rbp), %rdi
leaq 0x76f6(%rip), %rsi      # 0xb2a4
callq 0x3270
jmp 0x3bb5
movq 0xd434(%rip), %rdi      # 0x10ff0
leaq 0x747b(%rip), %rsi      # 0xb03e
callq 0x3270
movq %rax, -0x2e8(%rbp)
jmp 0x3bd1
callq 0x3030
movl (%rax), %edi
callq 0x30c0
movq -0x2e8(%rbp), %rdi
movq %rax, %rsi
callq 0x3270
movq %rax, -0x2f0(%rbp)
jmp 0x3bf5
movq -0x2f0(%rbp), %rdi
leaq 0x76a1(%rip), %rsi      # 0xb2a4
callq 0x3270
jmp 0x3c0a
movl $0x1, %edi
callq 0x3300
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x228(%rbp)
movl %eax, -0x22c(%rbp)
leaq -0x242(%rbp), %rdi
callq 0x55d0
jmp 0x3c8c
movq -0x270(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x228(%rbp)
movl %eax, -0x22c(%rbp)
callq 0x5610
jmp 0x3c8c
movb $0x1, -0x241(%rbp)
testb $0x1, -0x241(%rbp)
jne 0x3c70
movq -0x270(%rbp), %rdi
callq 0x5610
leaq -0x220(%rbp), %rdi
callq 0x30a0
movq -0x268(%rbp), %rax
addq $0x2f0, %rsp            # imm = 0x2F0
popq %rbp
retq
leaq -0x220(%rbp), %rdi
callq 0x30a0
movq -0x228(%rbp), %rdi
callq 0x3470
nopw %cs:(%rax,%rax)