// File: 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:
subq $0x928, %rsp            # imm = 0x928
movl $0x0, 0x924(%rsp)
movl %edi, 0x920(%rsp)
movq %rsi, 0x918(%rsp)
cmpl $0x2, 0x920(%rsp)
jge 0x2a1d
movq 0x55ee(%rip), %rdi      # 0x7ff0
leaq 0x2a2a(%rip), %rsi      # 0x5433
callq 0x21b0
movq %rax, %rdi
movq 0x55a8(%rip), %rsi      # 0x7fc0
callq 0x21d0
movq 0x918(%rsp), %rax
movq 0x8(%rax), %rax
movq %rax, 0x138(%rsp)
leaq 0x8f7(%rsp), %rdi
movq %rdi, 0x140(%rsp)
callq 0x2310
movq 0x138(%rsp), %rsi
movq 0x140(%rsp), %rdx
leaq 0x8f8(%rsp), %rdi
callq 0x2260
jmp 0x2a65
leaq 0x8f7(%rsp), %rdi
callq 0x21f0
leaq 0x2a0d(%rip), %rsi      # 0x5486
leaq 0x8f8(%rsp), %rdi
callq 0x36d0
movb %al, 0x137(%rsp)
jmp 0x2a8f
movb 0x137(%rsp), %al
testb $0x1, %al
jne 0x2a9f
jmp 0x2b2c
movq 0x552a(%rip), %rdi      # 0x7fd0
leaq 0x29e3(%rip), %rsi      # 0x5490
callq 0x21b0
movq %rax, 0x128(%rsp)
jmp 0x2abc
movq 0x128(%rsp), %rdi
movq 0x54f5(%rip), %rsi      # 0x7fc0
callq 0x21d0
jmp 0x2ad2
movl $0x0, 0x924(%rsp)
movl $0x1, 0x8e0(%rsp)
jmp 0x355e
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x8e8(%rsp)
movl %eax, 0x8e4(%rsp)
leaq 0x8f7(%rsp), %rdi
callq 0x21f0
jmp 0x35bb
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x8e8(%rsp)
movl %eax, 0x8e4(%rsp)
jmp 0x35ae
movl $0x4, %edi
movl $0x2, %esi
callq 0x36b0
movl %eax, 0x124(%rsp)
jmp 0x2b44
movl 0x124(%rsp), %edx
leaq 0x6d8(%rsp), %rdi
leaq 0x8f8(%rsp), %rsi
callq 0x22c0
jmp 0x2b62
movq 0x6d8(%rsp), %rax
movq -0x18(%rax), %rax
leaq 0x6d8(%rsp,%rax), %rdi
callq 0x20a0
movb %al, 0x123(%rsp)
jmp 0x2b84
movb 0x123(%rsp), %al
testb $0x1, %al
jne 0x2b94
jmp 0x2c1a
movq 0x5455(%rip), %rdi      # 0x7ff0
leaq 0x2918(%rip), %rsi      # 0x54ba
callq 0x21b0
movq %rax, 0x118(%rsp)
jmp 0x2bb1
movq 0x118(%rsp), %rdi
leaq 0x8f8(%rsp), %rsi
callq 0x2190
movq %rax, 0x110(%rsp)
jmp 0x2bd0
movq 0x110(%rsp), %rdi
movq 0x53e1(%rip), %rsi      # 0x7fc0
callq 0x21d0
jmp 0x2be6
movl $0x0, 0x924(%rsp)
movl $0x1, 0x8e0(%rsp)
jmp 0x3551
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x8e8(%rsp)
movl %eax, 0x8e4(%rsp)
jmp 0x35a1
leaq 0x6d8(%rsp), %rdi
callq 0x22e0
movq %rdx, 0x100(%rsp)
movq %rax, 0x108(%rsp)
jmp 0x2c39
movq 0x100(%rsp), %rax
movq 0x108(%rsp), %rcx
movq %rcx, 0x6c0(%rsp)
movq %rax, 0x6c8(%rsp)
leaq 0x6c0(%rsp), %rdi
callq 0x3700
movq %rax, 0xf8(%rsp)
jmp 0x2c70
movq 0xf8(%rsp), %rax
movq %rax, 0x6d0(%rsp)
xorl %edx, %edx
movl %edx, %esi
leaq 0x6d8(%rsp), %rdi
callq 0x2250
jmp 0x2c93
movq 0x6d0(%rsp), %rax
movq %rax, 0xe0(%rsp)
leaq 0x6d8(%rsp), %rdi
callq 0x22e0
movq %rdx, 0xe8(%rsp)
movq %rax, 0xf0(%rsp)
jmp 0x2cc2
movq 0xe8(%rsp), %rax
movq 0xf0(%rsp), %rcx
movq %rcx, 0x6a8(%rsp)
movq %rax, 0x6b0(%rsp)
leaq 0x6a8(%rsp), %rdi
callq 0x3700
movq %rax, 0xd8(%rsp)
jmp 0x2cf9
movq 0xd8(%rsp), %rcx
movq 0xe0(%rsp), %rax
subq %rcx, %rax
movq %rax, 0x6b8(%rsp)
movq 0x6d0(%rsp), %rax
movq %rax, 0xc8(%rsp)
leaq 0x68f(%rsp), %rdi
movq %rdi, 0xd0(%rsp)
callq 0x3710
movq 0xc8(%rsp), %rsi
movq 0xd0(%rsp), %rdx
leaq 0x690(%rsp), %rdi
callq 0x3720
jmp 0x2d58
leaq 0x68f(%rsp), %rdi
callq 0x37a0
leaq 0x690(%rsp), %rdi
callq 0x37b0
movq %rax, %rsi
movq 0x6d0(%rsp), %rdx
leaq 0x6d8(%rsp), %rdi
callq 0x2230
jmp 0x2d8c
movl $0x0, 0x688(%rsp)
cmpl $0x55, 0x688(%rsp)
jge 0x2e2c
movslq 0x688(%rsp), %rcx
leaq 0x225c(%rip), %rax      # 0x5010
movsbl (%rax,%rcx), %eax
movl %eax, 0x684(%rsp)
movl 0x688(%rsp), %eax
movb %al, %dl
movslq 0x684(%rsp), %rcx
leaq 0x5419(%rip), %rax      # 0x81f0
movb %dl, (%rax,%rcx)
movl 0x688(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x688(%rsp)
jmp 0x2d97
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x8e8(%rsp)
movl %eax, 0x8e4(%rsp)
leaq 0x68f(%rsp), %rdi
callq 0x37a0
jmp 0x35a1
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x8e8(%rsp)
movl %eax, 0x8e4(%rsp)
jmp 0x3594
leaq 0x660(%rsp), %rdi
leaq 0x690(%rsp), %rsi
callq 0x2670
jmp 0x2e43
leaq 0x267f(%rip), %rdx      # 0x54c9
leaq 0x440(%rsp), %rdi
leaq 0x8f8(%rsp), %rsi
callq 0x37d0
jmp 0x2e61
leaq 0x460(%rsp), %rdi
leaq 0x440(%rsp), %rsi
movl $0x20, %edx
callq 0x2340
jmp 0x2e7d
leaq 0x440(%rsp), %rdi
callq 0x20f0
leaq 0x21df(%rip), %rsi      # 0x5070
leaq 0x460(%rsp), %rdi
callq 0x21b0
movq %rax, 0xc0(%rsp)
jmp 0x2ea8
movq 0xc0(%rsp), %rdi
leaq 0x660(%rsp), %rsi
callq 0x2190
movq %rax, 0xb8(%rsp)
jmp 0x2ec7
movq 0xb8(%rsp), %rdi
leaq 0x22ba(%rip), %rsi      # 0x5190
callq 0x21b0
movq %rax, 0xb0(%rsp)
jmp 0x2ee5
movq 0xb0(%rsp), %rdi
movq 0x50cc(%rip), %rsi      # 0x7fc0
callq 0x21d0
jmp 0x2efb
leaq 0x417(%rsp), %rdi
movq %rdi, 0xa8(%rsp)
callq 0x2310
movq 0xa8(%rsp), %rdx
leaq 0x2151(%rip), %rsi      # 0x5070
leaq 0x418(%rsp), %rdi
callq 0x2260
jmp 0x2f2e
leaq 0x418(%rsp), %rdi
callq 0x2120
movq 0x6b8(%rsp), %rcx
addq %rcx, %rax
movq %rax, 0x98(%rsp)
leaq 0x3ef(%rsp), %rdi
movq %rdi, 0xa0(%rsp)
callq 0x2310
movq 0xa0(%rsp), %rdx
leaq 0x221e(%rip), %rsi      # 0x5190
leaq 0x3f0(%rsp), %rdi
callq 0x2260
jmp 0x2f81
leaq 0x3f0(%rsp), %rdi
callq 0x2120
movq %rax, %rcx
movq 0x98(%rsp), %rax
addq %rcx, %rax
movq %rax, 0x90(%rsp)
leaq 0x3f0(%rsp), %rdi
callq 0x20f0
leaq 0x3ef(%rsp), %rdi
callq 0x21f0
leaq 0x418(%rsp), %rdi
callq 0x20f0
leaq 0x417(%rsp), %rdi
callq 0x21f0
movq 0x90(%rsp), %rax
movq %rax, 0x438(%rsp)
cmpq $0x186a0, 0x438(%rsp) # imm = 0x186A0
jbe 0x30e0
movq 0x4fef(%rip), %rdi      # 0x7ff0
leaq 0x24cd(%rip), %rsi      # 0x54d5
callq 0x21b0
movq %rax, 0x88(%rsp)
jmp 0x3017
movq 0x88(%rsp), %rdi
movq 0x4f9a(%rip), %rsi      # 0x7fc0
callq 0x21d0
jmp 0x302d
jmp 0x30e0
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x8e8(%rsp)
movl %eax, 0x8e4(%rsp)
jmp 0x3587
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x8e8(%rsp)
movl %eax, 0x8e4(%rsp)
leaq 0x440(%rsp), %rdi
callq 0x20f0
jmp 0x3587
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x8e8(%rsp)
movl %eax, 0x8e4(%rsp)
jmp 0x357a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x8e8(%rsp)
movl %eax, 0x8e4(%rsp)
jmp 0x30ce
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x8e8(%rsp)
movl %eax, 0x8e4(%rsp)
leaq 0x3ef(%rsp), %rdi
callq 0x21f0
leaq 0x418(%rsp), %rdi
callq 0x20f0
leaq 0x417(%rsp), %rdi
callq 0x21f0
jmp 0x357a
cmpl $0x3, 0x920(%rsp)
jl 0x351f
movq 0x918(%rsp), %rax
movq 0x10(%rax), %rax
movq %rax, 0x78(%rsp)
leaq 0x3c7(%rsp), %rdi
movq %rdi, 0x80(%rsp)
callq 0x2310
movq 0x78(%rsp), %rsi
movq 0x80(%rsp), %rdx
leaq 0x3c8(%rsp), %rdi
callq 0x2260
jmp 0x3130
leaq 0x3c7(%rsp), %rdi
callq 0x21f0
leaq 0x1b8(%rsp), %rdi
leaq 0x3c8(%rsp), %rsi
movl $0x2, %edx
callq 0x22c0
jmp 0x3159
leaq 0x1b8(%rsp), %rdi
callq 0x22e0
movq %rdx, 0x68(%rsp)
movq %rax, 0x70(%rsp)
jmp 0x3172
movq 0x68(%rsp), %rax
movq 0x70(%rsp), %rcx
movq %rcx, 0x1a0(%rsp)
movq %rax, 0x1a8(%rsp)
leaq 0x1a0(%rsp), %rdi
callq 0x3700
movq %rax, 0x60(%rsp)
jmp 0x31a0
movq 0x60(%rsp), %rax
movq %rax, 0x1b0(%rsp)
xorl %edx, %edx
movl %edx, %esi
leaq 0x1b8(%rsp), %rdi
callq 0x2250
jmp 0x31c0
movq 0x1b0(%rsp), %rax
movq %rax, 0x50(%rsp)
leaq 0x187(%rsp), %rdi
movq %rdi, 0x58(%rsp)
callq 0x2310
movq 0x50(%rsp), %rsi
movq 0x58(%rsp), %rdx
leaq 0x188(%rsp), %rdi
callq 0x3860
jmp 0x31f8
leaq 0x187(%rsp), %rdi
callq 0x21f0
leaq 0x188(%rsp), %rdi
callq 0x38e0
movq %rax, %rsi
movq 0x1b0(%rsp), %rdx
leaq 0x1b8(%rsp), %rdi
callq 0x2230
jmp 0x322c
leaq 0x188(%rsp), %rdi
movq %rdi, 0x40(%rsp)
callq 0x3900
movq 0x40(%rsp), %rdi
movq %rax, 0x158(%rsp)
callq 0x3930
movq %rax, 0x150(%rsp)
leaq 0x14f(%rsp), %rdi
movq %rdi, 0x48(%rsp)
callq 0x2310
movq 0x48(%rsp), %rcx
movq 0x158(%rsp), %rsi
movq 0x150(%rsp), %rdx
leaq 0x160(%rsp), %rdi
callq 0x3960
jmp 0x328e
leaq 0x14f(%rsp), %rdi
callq 0x21f0
movq 0x438(%rsp), %rax
movq %rax, 0x38(%rsp)
leaq 0x160(%rsp), %rdi
callq 0x2120
movq %rax, %rcx
movq 0x38(%rsp), %rax
addq %rcx, %rax
cmpq $0x186a0, %rax          # imm = 0x186A0
jbe 0x32da
cmpq $0x186a0, 0x438(%rsp) # imm = 0x186A0
jbe 0x3491
leaq 0x2238(%rip), %rsi      # 0x5519
leaq 0x460(%rsp), %rdi
callq 0x21b0
movq %rax, 0x30(%rsp)
jmp 0x32f5
movq 0x30(%rsp), %rdi
movq 0x4cbf(%rip), %rsi      # 0x7fc0
callq 0x21d0
jmp 0x3308
leaq 0x2210(%rip), %rsi      # 0x551f
leaq 0x460(%rsp), %rdi
callq 0x21b0
movq %rax, 0x28(%rsp)
jmp 0x3323
movq 0x28(%rsp), %rdi
leaq 0x3c8(%rsp), %rsi
callq 0x2190
movq %rax, 0x20(%rsp)
jmp 0x333c
movq 0x20(%rsp), %rdi
movq 0x4c78(%rip), %rsi      # 0x7fc0
callq 0x21d0
jmp 0x334f
leaq 0x460(%rsp), %rdi
leaq 0x160(%rsp), %rsi
callq 0x2190
movq %rax, 0x18(%rsp)
jmp 0x336b
movq 0x18(%rsp), %rdi
movq 0x4c49(%rip), %rsi      # 0x7fc0
callq 0x21d0
jmp 0x337e
leaq 0x21aa(%rip), %rsi      # 0x552f
leaq 0x460(%rsp), %rdi
callq 0x21b0
movq %rax, 0x10(%rsp)
jmp 0x3399
movq 0x10(%rsp), %rdi
movq 0x4c1b(%rip), %rsi      # 0x7fc0
callq 0x21d0
jmp 0x33ac
jmp 0x34c0
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x8e8(%rsp)
movl %eax, 0x8e4(%rsp)
leaq 0x3c7(%rsp), %rdi
callq 0x21f0
jmp 0x357a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x8e8(%rsp)
movl %eax, 0x8e4(%rsp)
jmp 0x3510
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x8e8(%rsp)
movl %eax, 0x8e4(%rsp)
jmp 0x3503
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x8e8(%rsp)
movl %eax, 0x8e4(%rsp)
leaq 0x187(%rsp), %rdi
callq 0x21f0
jmp 0x3503
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x8e8(%rsp)
movl %eax, 0x8e4(%rsp)
jmp 0x34f6
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x8e8(%rsp)
movl %eax, 0x8e4(%rsp)
leaq 0x14f(%rsp), %rdi
callq 0x21f0
jmp 0x34f6
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x8e8(%rsp)
movl %eax, 0x8e4(%rsp)
leaq 0x160(%rsp), %rdi
callq 0x20f0
jmp 0x34f6
movq 0x4b58(%rip), %rdi      # 0x7ff0
leaq 0x2097(%rip), %rsi      # 0x5536
callq 0x21b0
movq %rax, 0x8(%rsp)
jmp 0x34ab
movq 0x8(%rsp), %rdi
movq 0x4b09(%rip), %rsi      # 0x7fc0
callq 0x21d0
jmp 0x34be
jmp 0x34c0
leaq 0x160(%rsp), %rdi
callq 0x20f0
leaq 0x188(%rsp), %rdi
callq 0x39f0
leaq 0x1b8(%rsp), %rdi
callq 0x2040
leaq 0x3c8(%rsp), %rdi
callq 0x20f0
jmp 0x351f
leaq 0x188(%rsp), %rdi
callq 0x39f0
leaq 0x1b8(%rsp), %rdi
callq 0x2040
leaq 0x3c8(%rsp), %rdi
callq 0x20f0
jmp 0x357a
leaq 0x460(%rsp), %rdi
callq 0x22a0
leaq 0x660(%rsp), %rdi
callq 0x20f0
leaq 0x690(%rsp), %rdi
callq 0x3a50
movl $0x0, 0x8e0(%rsp)
leaq 0x6d8(%rsp), %rdi
callq 0x2040
leaq 0x8f8(%rsp), %rdi
callq 0x20f0
movl 0x924(%rsp), %eax
addq $0x928, %rsp            # imm = 0x928
retq
leaq 0x460(%rsp), %rdi
callq 0x22a0
leaq 0x660(%rsp), %rdi
callq 0x20f0
leaq 0x690(%rsp), %rdi
callq 0x3a50
leaq 0x6d8(%rsp), %rdi
callq 0x2040
leaq 0x8f8(%rsp), %rdi
callq 0x20f0
movq 0x8e8(%rsp), %rdi
callq 0x2300
nopl (%rax,%rax)