// File: /workspace/github_cpp_makefile_star2_O3/Agade09[P]CG-Send-Binary/Binary_To_Base85.cpp
// Function: main
int main(int argc,char** argv){
	if(argc<2){
		cerr << "Program takes at least one argument, the name of the program to convert to base 85" << endl;
	}
	const string Program_Name{argv[1]};
	if(Program_Name=="--version"){
		cout << "CG-Send-Binary V1.0\nBy github.com/Agade09" << endl;
		return 0;
	}
	ifstream Program_File(Program_Name,ios::binary | ios::ate);
	if(!Program_File){
		cerr << "Couldn't open " << Program_Name << endl;
		return 0;
	}
	const streamsize binary_size{Program_File.tellg()};
	Program_File.seekg(0,ios::beg);
	const long binary_bytes{binary_size-Program_File.tellg()};
	vector<unsigned char> Program_Binary(binary_size);
	Program_File.read(reinterpret_cast<char*>(Program_Binary.data()),binary_size);
	for(int i=0;i<85;i++){
		int ch{en85[i]};
		de85[ch]=i;
	}
	const string base85_Program_Binary=encode_85(Program_Binary);
	ofstream Program_Base85_File(Program_Name+"_Base85.cpp",ios::trunc);
	Program_Base85_File << half1 << base85_Program_Binary << half2 << endl;
	const size_t size_before_comments{string(half1).size()+binary_bytes+string(half2).size()};
	if(size_before_comments>Code_Size_Limit){
		cerr << "Warning: Base85 encoded binary is too large to be sent to Codingame" << endl;
	}
	if(argc>=3){//Append source code as comment
		const string Source_Filename{argv[2]};
		ifstream Source_File(Source_Filename,ios::ate);
		const streamsize source_size{Source_File.tellg()};
		Source_File.seekg(0,ios::beg);
		vector<char> Source(source_size);
		Source_File.read(reinterpret_cast<char*>(Source.data()),source_size);
		const string source_code(Source.begin(),Source.end());
		if(size_before_comments+source_code.size()<=Code_Size_Limit || size_before_comments>Code_Size_Limit){//If the file is going to be too big anyway, we might as well include the comments
			Program_Base85_File << "#if 0" << endl;
			Program_Base85_File << "//Source file: " << Source_Filename << endl;
			Program_Base85_File << source_code << endl;
			Program_Base85_File << "#endif" << endl;
		}
		else{
			cerr << "Warning: Could not include source code as a comment without exceeding Codingame code size limit" << endl;
		}
	}
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x6c8, %rsp            # imm = 0x6C8
movq %rsi, %r14
movl %edi, %ebp
cmpl $0x1, %edi
jg 0x2718
movq 0x3913(%rip), %rbx      # 0x5ff0
leaq 0x1982(%rip), %rsi      # 0x4066
movl $0x52, %edx
movq %rbx, %rdi
callq 0x2160
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x2140
movsbl %al, %esi
movq %rbx, %rdi
callq 0x2030
movq %rax, %rdi
callq 0x20c0
movq 0x8(%r14), %rsi
leaq 0x60(%rsp), %rbx
leaq 0x4c0(%rsp), %rdx
movq %rbx, %rdi
callq 0x2090
leaq 0x1981(%rip), %rsi      # 0x40b9
movq %rbx, %rdi
callq 0x2050
testl %eax, %eax
je 0x27d6
leaq 0x4c0(%rsp), %rdi
leaq 0x60(%rsp), %rsi
movl $0x6, %edx
callq 0x21b0
movq 0x4c0(%rsp), %rax
movq -0x18(%rax), %rax
testb $0x5, 0x4e0(%rsp,%rax)
je 0x2821
movq 0x3870(%rip), %rdi      # 0x5ff0
leaq 0x1966(%rip), %rsi      # 0x40ed
movl $0xe, %edx
callq 0x2160
movq 0x60(%rsp), %rsi
movq 0x68(%rsp), %rdx
movq 0x384e(%rip), %rdi      # 0x5ff0
callq 0x2160
movq %rax, %rbx
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x2140
movsbl %al, %esi
movq %rbx, %rdi
callq 0x2030
movq %rax, %rdi
callq 0x20c0
jmp 0x2d05
movq 0x37f3(%rip), %rbx      # 0x5fd0
leaq 0x18df(%rip), %rsi      # 0x40c3
movl $0x29, %edx
movq %rbx, %rdi
callq 0x2160
movq (%rbx), %rax
addq -0x18(%rax), %rbx
movq %rbx, %rdi
movl $0xa, %esi
callq 0x2140
movsbl %al, %esi
movq 0x37c1(%rip), %rdi      # 0x5fd0
callq 0x2030
movq %rax, %rdi
callq 0x20c0
jmp 0x2d12
leaq 0x4c0(%rsp), %rdi
callq 0x21c0
movq %rax, %rbx
leaq 0x4c0(%rsp), %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x2180
leaq 0x4c0(%rsp), %rdi
callq 0x21c0
movq %rax, %r15
leaq 0x80(%rsp), %rdi
leaq 0xb8(%rsp), %rdx
movq %rbx, %rsi
callq 0x2e56
movq 0x80(%rsp), %rsi
leaq 0x4c0(%rsp), %rdi
movq %rbx, %rdx
callq 0x2170
subq %r15, %rbx
xorl %eax, %eax
leaq 0x1782(%rip), %rcx      # 0x4010
leaq 0x38ab(%rip), %rdx      # 0x6140
movsbq (%rax,%rcx), %rsi
movb %al, (%rsi,%rdx)
incq %rax
cmpq $0x55, %rax
jne 0x2895
leaq 0x98(%rsp), %rdi
leaq 0x80(%rsp), %rsi
callq 0x2499
leaq 0xc8(%rsp), %r13
movq %r13, -0x10(%r13)
movq 0x60(%rsp), %rsi
movq 0x68(%rsp), %rdx
addq %rsi, %rdx
leaq 0xb8(%rsp), %rdi
callq 0x2f16
leaq 0x1814(%rip), %rsi      # 0x40fc
leaq 0xb8(%rsp), %rdi
callq 0x21f0
leaq 0x2c0(%rsp), %rdi
leaq 0xb8(%rsp), %rsi
movl $0x20, %edx
callq 0x2200
movq 0xb8(%rsp), %rdi
cmpq %r13, %rdi
je 0x2921
callq 0x2130
leaq 0x1908(%rip), %rsi      # 0x4230
leaq 0x2c0(%rsp), %rdi
movl $0x11c, %edx            # imm = 0x11C
callq 0x2160
movq 0x98(%rsp), %rsi
movq 0xa0(%rsp), %rdx
leaq 0x2c0(%rsp), %rdi
callq 0x2160
movq %rax, %r15
leaq 0x19ef(%rip), %rsi      # 0x4350
movl $0x2a2, %edx            # imm = 0x2A2
movq %rax, %rdi
callq 0x2160
movq (%r15), %rax
movq -0x18(%rax), %rdi
addq %r15, %rdi
movl $0xa, %esi
callq 0x2140
movsbl %al, %esi
movq %r15, %rdi
callq 0x2030
movq %rax, %rdi
callq 0x20c0
leaq 0xb8(%rsp), %rdi
movq %r13, (%rdi)
leaq 0x1889(%rip), %rsi      # 0x4230
leaq 0x199e(%rip), %rdx      # 0x434c
callq 0x2fac
movq 0xc0(%rsp), %r15
leaq 0x18(%rsp), %r12
movq %r12, -0x10(%r12)
leaq 0x1984(%rip), %rsi      # 0x4350
leaq 0x1c1f(%rip), %rdx      # 0x45f2
leaq 0x8(%rsp), %rdi
callq 0x2fac
addq %r15, %rbx
addq 0x10(%rsp), %rbx
movq 0x8(%rsp), %rdi
cmpq %r12, %rdi
je 0x29f4
callq 0x2130
movq 0xb8(%rsp), %rdi
cmpq %r13, %rdi
je 0x2a06
callq 0x2130
cmpq $0x186a1, %rbx          # imm = 0x186A1
jb 0x2a55
movq 0x35da(%rip), %r15      # 0x5ff0
leaq 0x16eb(%rip), %rsi      # 0x4108
movl $0x43, %edx
movq %r15, %rdi
callq 0x2160
movq (%r15), %rax
addq -0x18(%rax), %r15
movq %r15, %rdi
movl $0xa, %esi
callq 0x2140
movsbl %al, %esi
movq 0x35a8(%rip), %rdi      # 0x5ff0
callq 0x2030
movq %rax, %rdi
callq 0x20c0
cmpl $0x3, %ebp
jl 0x2ca5
movq 0x10(%r14), %rsi
leaq 0x8(%rsp), %rdi
leaq 0xb8(%rsp), %rdx
callq 0x2090
leaq 0xb8(%rsp), %rdi
leaq 0x8(%rsp), %rsi
movl $0x2, %edx
callq 0x21b0
leaq 0xb8(%rsp), %rdi
callq 0x21c0
movq %rax, %r14
leaq 0xb8(%rsp), %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x2180
leaq 0x48(%rsp), %rdi
leaq 0x28(%rsp), %rdx
movq %r14, %rsi
callq 0x2eb6
movq 0x48(%rsp), %rsi
leaq 0xb8(%rsp), %rdi
movq %r14, %rdx
callq 0x2170
movq 0x48(%rsp), %rsi
movq 0x50(%rsp), %rdx
leaq 0x38(%rsp), %r14
movq %r14, -0x10(%r14)
leaq 0x28(%rsp), %rdi
callq 0x30b2
cmpq $0x186a0, %rbx          # imm = 0x186A0
ja 0x2b3b
addq 0x30(%rsp), %rbx
cmpq $0x186a0, %rbx          # imm = 0x186A0
jbe 0x2b3b
movq 0x34e2(%rip), %rbx      # 0x5ff0
leaq 0x1654(%rip), %rsi      # 0x4169
movl $0x5f, %edx
movq %rbx, %rdi
callq 0x2160
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x2140
jmp 0x2c58
leaq 0x160a(%rip), %rsi      # 0x414c
leaq 0x2c0(%rsp), %rbx
movl $0x5, %edx
movq %rbx, %rdi
callq 0x2160
movq 0x2c0(%rsp), %rax
addq -0x18(%rax), %rbx
movq %rbx, %rdi
movl $0xa, %esi
callq 0x2140
movsbl %al, %esi
leaq 0x2c0(%rsp), %rdi
callq 0x2030
movq %rax, %rdi
callq 0x20c0
leaq 0x15c3(%rip), %rsi      # 0x4152
leaq 0x2c0(%rsp), %rdi
movl $0xf, %edx
callq 0x2160
movq 0x8(%rsp), %rsi
movq 0x10(%rsp), %rdx
leaq 0x2c0(%rsp), %rdi
callq 0x2160
movq %rax, %rbx
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x2140
movsbl %al, %esi
movq %rbx, %rdi
callq 0x2030
movq %rax, %rdi
callq 0x20c0
movq 0x28(%rsp), %rsi
movq 0x30(%rsp), %rdx
leaq 0x2c0(%rsp), %rdi
callq 0x2160
movq %rax, %rbx
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x2140
movsbl %al, %esi
movq %rbx, %rdi
callq 0x2030
movq %rax, %rdi
callq 0x20c0
leaq 0x1538(%rip), %rsi      # 0x4162
leaq 0x2c0(%rsp), %rbx
movl $0x6, %edx
movq %rbx, %rdi
callq 0x2160
movq 0x2c0(%rsp), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x2140
movsbl %al, %esi
movq %rbx, %rdi
callq 0x2030
movq %rax, %rdi
callq 0x20c0
movq 0x28(%rsp), %rdi
cmpq %r14, %rdi
je 0x2c7a
callq 0x2130
movq 0x48(%rsp), %rdi
testq %rdi, %rdi
je 0x2c89
callq 0x2130
leaq 0xb8(%rsp), %rdi
callq 0x2040
movq 0x8(%rsp), %rdi
cmpq %r12, %rdi
je 0x2ca5
callq 0x2130
movq 0x331c(%rip), %rax      # 0x5fc8
movq (%rax), %rcx
movq 0x18(%rax), %rax
leaq 0x2c8(%rsp), %rdi
movq %rcx, -0x8(%rdi)
movq -0x18(%rcx), %rcx
movq %rax, 0x2c0(%rsp,%rcx)
callq 0x20f0
leaq 0x3b8(%rsp), %rdi
callq 0x2070
leaq 0xa8(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x2cf3
callq 0x2130
movq 0x80(%rsp), %rdi
testq %rdi, %rdi
je 0x2d05
callq 0x2130
leaq 0x4c0(%rsp), %rdi
callq 0x2040
leaq 0x70(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x2d25
callq 0x2130
xorl %eax, %eax
addq $0x6c8, %rsp            # imm = 0x6C8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x2d3b
movq %rax, %rbx
jmp 0x2dbf
jmp 0x2d44
jmp 0x2d44
movq %rax, %rbx
jmp 0x2dce
movq %rax, %rbx
jmp 0x2ddb
jmp 0x2dec
movq %rax, %rbx
movq 0xb8(%rsp), %rdi
cmpq %r13, %rdi
jne 0x2de5
jmp 0x2def
jmp 0x2dec
jmp 0x2d72
movq %rax, %rbx
movq 0xb8(%rsp), %rdi
cmpq %r13, %rdi
je 0x2dfc
callq 0x2130
jmp 0x2dfc
movq %rax, %rbx
jmp 0x2dfc
jmp 0x2d90
movq %rax, %rbx
jmp 0x2e12
jmp 0x2e2b
jmp 0x2e2b
jmp 0x2e2b
jmp 0x2e2b
jmp 0x2dec
jmp 0x2e26
movq %rax, %rbx
movq 0x28(%rsp), %rdi
cmpq %r14, %rdi
je 0x2dbf
callq 0x2130
movq 0x48(%rsp), %rdi
testq %rdi, %rdi
je 0x2dce
callq 0x2130
leaq 0xb8(%rsp), %rdi
callq 0x2040
movq 0x8(%rsp), %rdi
cmpq %r12, %rdi
je 0x2def
callq 0x2130
jmp 0x2def
movq %rax, %rbx
leaq 0x2c0(%rsp), %rdi
callq 0x2190
leaq 0xa8(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x2e12
callq 0x2130
movq 0x80(%rsp), %rdi
testq %rdi, %rdi
je 0x2e2e
callq 0x2130
jmp 0x2e2e
movq %rax, %rbx
jmp 0x2e3b
movq %rax, %rbx
leaq 0x4c0(%rsp), %rdi
callq 0x2040
leaq 0x70(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x2e4e
callq 0x2130
movq %rbx, %rdi
callq 0x21d0