// File: /workspace/github_cpp_makefile_star2_O3/nyorain[P]bintoheader/bintoheader.cpp
// Function: outputData(std::vector<unsigned char, std::allocator<unsigned char>> const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&, int)
void outputData(const std::vector<std::uint8_t>& data, const std::string& file,
	const std::string& name, int size)
{
	auto fname = file;
	std::ofstream ofs(fname);
	if(!ofs.is_open()) {
		std::cerr << "outputData: couldnt open output file " << file << "\n";
		std::cerr << "error: " << std::strerror(errno) << "\n";
		exit(EXIT_FAILURE);
	}

	auto byteSize = size / 8;
	if(data.size() % byteSize) {
		std::cerr << "outputData: file size is not a multiple of specified integer size\n";
		std::cerr << "\tfile size: " << data.size() << " bytes\n";
		std::cerr << "\tspecified size: " << size / 8 << " bytes\n";
		exit(EXIT_FAILURE);
	}

	std::string dataString;
	dataString.reserve(data.size() * 5); //approx.

	auto currColSize = 4u;
	for(auto i = 0u; i < data.size() / byteSize; ++i) {
		std::uint64_t value = 0;
		auto ptr = &data[i * byteSize];

		if(size == 8) value = *reinterpret_cast<const std::uint8_t*>(ptr);
		else if(size == 16) value = *reinterpret_cast<const std::uint16_t*>(ptr);
		else if(size == 32) value = *reinterpret_cast<const std::uint32_t*>(ptr);
		else if(size == 64) value = *reinterpret_cast<const std::uint64_t*>(ptr);

		auto str = std::to_string(value);
		if(currColSize + str.size() + 2 >= lineLength)
		{
			dataString.append(",\n    ");
			currColSize = 4u;
		}
		else if(i != 0)
		{
			dataString.append(", ");
			currColSize += 2;
		}

		currColSize += str.size();
		dataString.append(str);
	}

	std::string outputTypeName = "uint" + std::to_string(size) + "_t";
	std::string includeGuard = name;
	for(auto& ch : includeGuard) ch = std::toupper(ch);

	std::string txt = fileTemplate;
	replace(txt, "%t", outputTypeName);
	replace(txt, "%d", dataString);
	replace(txt, "%n", name);
	replace(txt, "%i", includeGuard);

	ofs << txt;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x2f8, %rsp            # imm = 0x2F8
movl %ecx, %r15d
movq %rdx, -0xc8(%rbp)
movq %rsi, %rbx
movq %rdi, %r12
leaq -0x108(%rbp), %rax
movq %rax, -0x10(%rax)
movq (%rsi), %rsi
movq 0x8(%rbx), %rdx
addq %rsi, %rdx
leaq -0x118(%rbp), %r14
movq %r14, %rdi
callq 0x4482
leaq -0x318(%rbp), %rdi
movq %r14, %rsi
movl $0x10, %edx
callq 0x2360
leaq -0x2a8(%rbp), %rdi
callq 0x2060
testb %al, %al
je 0x2f72
leal 0x7(%r15), %eax
testl %r15d, %r15d
cmovnsl %r15d, %eax
sarl $0x3, %eax
movq 0x8(%r12), %rcx
subq (%r12), %rcx
movl %eax, -0x6c(%rbp)
movslq %eax, %rsi
movq %rcx, %rax
xorl %edx, %edx
movq %rsi, -0xd0(%rbp)
divq %rsi
testq %rdx, %rdx
jne 0x2ff8
movq %r15, -0xc0(%rbp)
leaq -0xe0(%rbp), %rax
movq %rax, -0x10(%rax)
movq $0x0, -0x8(%rax)
movb $0x0, (%rax)
leaq (%rcx,%rcx,4), %rsi
leaq -0xf0(%rbp), %rdi
callq 0x22a0
movq (%r12), %rcx
movq 0x8(%r12), %rax
subq %rcx, %rax
cmpq -0xd0(%rbp), %rax
jb 0x2b73
movq -0xc0(%rbp), %rax
addl $-0x8, %eax
roll $0x1d, %eax
xorl %r15d, %r15d
movl $0x4, %r13d
movl %eax, -0xb4(%rbp)
movl %eax, %eax
movq %rax, -0xf8(%rbp)
movabsq $0x346dc5d63886594b, %rbx # imm = 0x346DC5D63886594B
cmpl $0x7, -0xb4(%rbp)
ja 0x2a9f
movl %r15d, %eax
imull -0x6c(%rbp), %eax
movq -0xf8(%rbp), %rdx
leaq 0x25cf(%rip), %rsi      # 0x5004
movslq (%rsi,%rdx,4), %rdx
addq %rsi, %rdx
jmpq *%rdx
movzbl (%rcx,%rax), %r14d
jmp 0x2a56
movl (%rcx,%rax), %r14d
jmp 0x2a56
movzwl (%rcx,%rax), %r14d
jmp 0x2a56
movq (%rcx,%rax), %r14
movl $0x1, %esi
cmpq $0xa, %r14
jb 0x2ab0
movl $0x4, %esi
movq %r14, %rcx
cmpq $0x63, %rcx
jbe 0x2aa9
cmpq $0x3e7, %rcx            # imm = 0x3E7
jbe 0x2aae
cmpq $0x2710, %rcx           # imm = 0x2710
jb 0x2ab0
movq %rcx, %rax
mulq %rbx
shrq $0xb, %rdx
addl $0x4, %esi
cmpq $0x1869f, %rcx          # imm = 0x1869F
movq %rdx, %rcx
ja 0x2a69
addl $-0x3, %esi
jmp 0x2ab0
movl $0x1, %esi
xorl %r14d, %r14d
jmp 0x2ab0
addl $-0x2, %esi
jmp 0x2ab0
decl %esi
movl %esi, %esi
leaq -0x58(%rbp), %rax
movq %rax, -0x68(%rbp)
leaq -0x68(%rbp), %rdi
xorl %edx, %edx
callq 0x21e0
movq -0x68(%rbp), %rdi
movl -0x60(%rbp), %esi
movq %r14, %rdx
callq 0x3c80
movl %r13d, %eax
movq -0x60(%rbp), %rcx
addq %rcx, %rax
addq $-0x4e, %rax
cmpq $-0x51, %rax
ja 0x2b03
movl $0x4, %r13d
leaq -0xf0(%rbp), %rdi
leaq 0x260a(%rip), %rsi      # 0x5106
callq 0x2350
jmp 0x2b1f
testl %r15d, %r15d
je 0x2b1f
leaq -0xf0(%rbp), %rdi
leaq 0x25f7(%rip), %rsi      # 0x510d
callq 0x2350
addl $0x2, %r13d
movq -0x68(%rbp), %rsi
movq -0x60(%rbp), %r14
leaq -0xf0(%rbp), %rdi
movq %r14, %rdx
callq 0x2090
movq -0x68(%rbp), %rdi
leaq -0x58(%rbp), %rax
cmpq %rax, %rdi
je 0x2b4f
movq -0x58(%rbp), %rsi
incq %rsi
callq 0x2190
addl %r14d, %r13d
incl %r15d
movq (%r12), %rcx
movq 0x8(%r12), %rax
subq %rcx, %rax
xorl %edx, %edx
divq -0xd0(%rbp)
cmpq %r15, %rax
ja 0x2a17
movq -0xc0(%rbp), %r15
movl %r15d, %ebx
negl %ebx
cmovsl %r15d, %ebx
movl $0x1, %r14d
cmpl $0xa, %ebx
jb 0x2bd7
movl $0x4, %r14d
movl $0xd1b71759, %eax       # imm = 0xD1B71759
movl %ebx, %ecx
cmpl $0x63, %ecx
jbe 0x2bce
cmpl $0x3e7, %ecx            # imm = 0x3E7
jbe 0x2bd4
cmpl $0x2710, %ecx           # imm = 0x2710
jb 0x2bd7
movl %ecx, %edx
imulq %rax, %rdx
shrq $0x2d, %rdx
addl $0x4, %r14d
cmpl $0x1869f, %ecx          # imm = 0x1869F
movl %edx, %ecx
ja 0x2b9b
addl $-0x3, %r14d
jmp 0x2bd7
addl $-0x2, %r14d
jmp 0x2bd7
decl %r14d
shrl $0x1f, %r15d
leal (%r14,%r15), %esi
leaq -0x80(%rbp), %r12
movq %r12, -0x10(%r12)
leaq -0x90(%rbp), %rdi
movl $0x2d, %edx
callq 0x21e0
movl %r15d, %edi
leaq -0x90(%rbp), %r15
addq (%r15), %rdi
movl %r14d, %esi
movl %ebx, %edx
callq 0x3d00
leaq 0x24f9(%rip), %rcx      # 0x5110
movl $0x4, %r8d
movq %r15, %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x21c0
leaq -0xa0(%rbp), %r14
movq %r14, -0x10(%r14)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
je 0x2c56
movq %rdx, -0xb0(%rbp)
movq (%rcx), %rdx
movq %rdx, -0xa0(%rbp)
jmp 0x2c5d
movups (%rcx), %xmm0
movups %xmm0, (%r14)
movq 0x8(%rax), %rdx
leaq -0xb0(%rbp), %rdi
movq %rdx, 0x8(%rdi)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
leaq 0x2493(%rip), %rsi      # 0x5115
callq 0x2350
leaq -0x58(%rbp), %rsi
movq %rsi, -0x10(%rsi)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
je 0x2cab
movq %rdx, -0x68(%rbp)
movq (%rcx), %rdx
movq %rdx, -0x58(%rbp)
jmp 0x2cb1
movups (%rcx), %xmm0
movups %xmm0, (%rsi)
movq 0x8(%rax), %rdx
movq %rdx, -0x60(%rbp)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
movq -0xb0(%rbp), %rdi
cmpq %r14, %rdi
je 0x2ce3
movq -0xa0(%rbp), %rsi
incq %rsi
callq 0x2190
movq -0x90(%rbp), %rdi
cmpq %r12, %rdi
je 0x2cfb
movq -0x80(%rbp), %rsi
incq %rsi
callq 0x2190
leaq -0xb0(%rbp), %rdi
movq %r14, (%rdi)
movq -0xc8(%rbp), %rax
movq (%rax), %rsi
movq 0x8(%rax), %rdx
addq %rsi, %rdx
callq 0x4482
movq -0xa8(%rbp), %rbx
testq %rbx, %rbx
je 0x2d49
movq -0xb0(%rbp), %r13
xorl %r15d, %r15d
movsbl (%r13,%r15), %edi
callq 0x2340
movb %al, (%r13,%r15)
incq %r15
cmpq %r15, %rbx
jne 0x2d31
leaq -0x90(%rbp), %rdi
movq %r12, (%rdi)
leaq 0x23bf(%rip), %rsi      # 0x5119
leaq 0x247b(%rip), %rdx      # 0x51dc
callq 0x4520
leaq -0x38(%rbp), %r13
movq %r13, -0x10(%r13)
leaq 0x2468(%rip), %rsi      # 0x51dd
leaq 0x2463(%rip), %rdx      # 0x51df
leaq -0x48(%rbp), %rdi
callq 0x4520
leaq -0x90(%rbp), %rdi
leaq -0x48(%rbp), %rsi
leaq -0x68(%rbp), %rdx
callq 0x2660
movq -0x48(%rbp), %rdi
cmpq %r13, %rdi
je 0x2dae
movq -0x38(%rbp), %rsi
incq %rsi
callq 0x2190
leaq -0x48(%rbp), %rdi
movq %r13, (%rdi)
leaq 0x2424(%rip), %rsi      # 0x51e0
leaq 0x241f(%rip), %rdx      # 0x51e2
callq 0x4520
leaq -0x90(%rbp), %rdi
leaq -0x48(%rbp), %rsi
leaq -0xf0(%rbp), %rdx
callq 0x2660
movq -0x48(%rbp), %rdi
cmpq %r13, %rdi
je 0x2df4
movq -0x38(%rbp), %rsi
incq %rsi
callq 0x2190
leaq -0x48(%rbp), %rdi
movq %r13, (%rdi)
leaq 0x23e1(%rip), %rsi      # 0x51e3
leaq 0x23dc(%rip), %rdx      # 0x51e5
callq 0x4520
leaq -0x90(%rbp), %rdi
leaq -0x48(%rbp), %rsi
movq -0xc8(%rbp), %rdx
callq 0x2660
movq -0x48(%rbp), %rdi
cmpq %r13, %rdi
je 0x2e3a
movq -0x38(%rbp), %rsi
incq %rsi
callq 0x2190
leaq -0x48(%rbp), %rdi
movq %r13, (%rdi)
leaq 0x239e(%rip), %rsi      # 0x51e6
leaq 0x2399(%rip), %rdx      # 0x51e8
callq 0x4520
leaq -0x90(%rbp), %rdi
leaq -0x48(%rbp), %rsi
leaq -0xb0(%rbp), %rdx
callq 0x2660
movq -0x48(%rbp), %rdi
cmpq %r13, %rdi
je 0x2e80
movq -0x38(%rbp), %rsi
incq %rsi
callq 0x2190
movq -0x90(%rbp), %rsi
movq -0x88(%rbp), %rdx
leaq -0x318(%rbp), %rdi
callq 0x21d0
movq -0x90(%rbp), %rdi
cmpq %r12, %rdi
je 0x2eb2
movq -0x80(%rbp), %rsi
incq %rsi
callq 0x2190
movq -0xb0(%rbp), %rdi
cmpq %r14, %rdi
je 0x2ecd
movq -0xa0(%rbp), %rsi
incq %rsi
callq 0x2190
movq -0x68(%rbp), %rdi
leaq -0x58(%rbp), %rax
cmpq %rax, %rdi
leaq -0xe0(%rbp), %rbx
je 0x2eed
movq -0x58(%rbp), %rsi
incq %rsi
callq 0x2190
movq -0xf0(%rbp), %rdi
cmpq %rbx, %rdi
je 0x2f08
movq -0xe0(%rbp), %rsi
incq %rsi
callq 0x2190
movq 0x50b1(%rip), %rax      # 0x7fc0
movq (%rax), %rcx
movq 0x18(%rax), %rax
leaq -0x310(%rbp), %rdi
movq %rcx, -0x8(%rdi)
movq -0x18(%rcx), %rcx
movq %rax, -0x318(%rbp,%rcx)
callq 0x2150
leaq -0x220(%rbp), %rdi
callq 0x20a0
movq -0x118(%rbp), %rdi
leaq -0x108(%rbp), %rax
cmpq %rax, %rdi
je 0x2f60
movq -0x108(%rbp), %rsi
incq %rsi
callq 0x2190
addq $0x2f8, %rsp            # imm = 0x2F8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x5077(%rip), %rdi      # 0x7ff0
leaq 0x20f6(%rip), %rsi      # 0x5076
movl $0x25, %edx
callq 0x21d0
movq (%rbx), %rsi
movq 0x8(%rbx), %rdx
movq 0x5058(%rip), %rdi      # 0x7ff0
callq 0x21d0
leaq 0x230b(%rip), %rsi      # 0x52af
movl $0x1, %edx
movq %rax, %rdi
callq 0x21d0
movq 0x5038(%rip), %rdi      # 0x7ff0
leaq 0x208a(%rip), %rsi      # 0x5049
movl $0x7, %edx
callq 0x21d0
callq 0x2030
movl (%rax), %edi
callq 0x20b0
movq 0x5014(%rip), %rdi      # 0x7ff0
movq %rax, %rsi
callq 0x2170
leaq 0x22c4(%rip), %rsi      # 0x52af
movq %rax, %rdi
callq 0x2170
jmp 0x3087
movq 0x4ff1(%rip), %rdi      # 0x7ff0
leaq 0x2096(%rip), %rsi      # 0x509c
movl $0x42, %edx
callq 0x21d0
movq 0x4fd9(%rip), %rdi      # 0x7ff0
leaq 0x20c1(%rip), %rsi      # 0x50df
movl $0xc, %edx
callq 0x21d0
movq 0x8(%r12), %rsi
subq (%r12), %rsi
movq 0x4fb8(%rip), %rdi      # 0x7ff0
callq 0x2110
leaq 0x20a8(%rip), %rsi      # 0x50ec
movl $0x7, %edx
movq %rax, %rdi
callq 0x21d0
movq 0x4f98(%rip), %rdi      # 0x7ff0
leaq 0x2095(%rip), %rsi      # 0x50f4
movl $0x11, %edx
callq 0x21d0
movq 0x4f80(%rip), %rdi      # 0x7ff0
movl -0x6c(%rbp), %esi
callq 0x22e0
leaq 0x206d(%rip), %rsi      # 0x50ec
movq %rax, %rdi
callq 0x2170
movl $0x1, %edi
callq 0x21f0
jmp 0x3093
movq %rax, %rbx
jmp 0x3183
jmp 0x30c3
jmp 0x30a9
jmp 0x30c3
jmp 0x30a9
jmp 0x30c3
jmp 0x30a9
jmp 0x30c3
movq %rax, %rbx
movq -0x48(%rbp), %rdi
cmpq %r13, %rdi
je 0x30c6
movq -0x38(%rbp), %rsi
incq %rsi
callq 0x2190
jmp 0x30c6
movq %rax, %rbx
movq -0x90(%rbp), %rdi
cmpq %r12, %rdi
je 0x30de
movq -0x80(%rbp), %rsi
incq %rsi
callq 0x2190
movq -0xb0(%rbp), %rdi
cmpq %r14, %rdi
je 0x3148
movq -0xa0(%rbp), %rsi
incq %rsi
callq 0x2190
jmp 0x3148
movq %rax, %rbx
jmp 0x30de
jmp 0x3145
movq %rax, %rbx
movq -0xb0(%rbp), %rdi
cmpq %r14, %rdi
je 0x3125
movq -0xa0(%rbp), %rsi
incq %rsi
callq 0x2190
jmp 0x3125
movq %rax, %rbx
movq -0x90(%rbp), %rdi
cmpq %r12, %rdi
je 0x3161
movq -0x80(%rbp), %rsi
jmp 0x3159
jmp 0x3140
jmp 0x3140
movq %rax, %rbx
jmp 0x318f
movq %rax, %rbx
jmp 0x3161
movq %rax, %rbx
movq -0x68(%rbp), %rdi
leaq -0x58(%rbp), %rax
cmpq %rax, %rdi
je 0x3161
movq -0x58(%rbp), %rsi
incq %rsi
callq 0x2190
movq -0xf0(%rbp), %rdi
leaq -0xe0(%rbp), %rax
cmpq %rax, %rdi
je 0x3183
movq -0xe0(%rbp), %rsi
incq %rsi
callq 0x2190
leaq -0x318(%rbp), %rdi
callq 0x2260
movq -0x118(%rbp), %rdi
leaq -0x108(%rbp), %rax
cmpq %rax, %rdi
je 0x31b1
movq -0x108(%rbp), %rsi
incq %rsi
callq 0x2190
movq %rbx, %rdi
callq 0x2320