// File: /workspace/github_c_makefile_star2_O1/Mikejmoffitt[P]romtools/bsplit/bsplit.c
// Function: split
void split(const char *in_fname, const char *out_even_fname, const char *out_odd_fname, int bytes)
{
	int c;
	FILE *fin, *fout_odd, *fout_even;
	fin = fopen(in_fname, "rb");
	if (!fin)
	{
		fprintf(stderr, "Couldn't open %s.\n", in_fname);
		return;
	}
	fout_odd = fopen(out_odd_fname, "wb");
	if (!fout_odd)
	{
		fprintf(stderr, "Couldn't open %s.\n", out_odd_fname);
		fclose(fin);
		return;
	}
	fout_even = fopen(out_even_fname, "wb");
	if (!fout_even)
	{
		fprintf(stderr, "Couldn't open %s.\n", out_even_fname);
		fclose(fin);
		fclose(fout_odd);
		return;
	}

	do
	{
		for (int i = 0; i < bytes; i++)
		{
			c = fgetc(fin);
			if (feof(fin))
			{
				goto done;
			}
			fputc(c, fout_even);
		}
		for (int i = 0; i < bytes; i++)
		{
			c = fgetc(fin);
			if (feof(fin))
			{
				goto done;
			}
			fputc(c, fout_odd);
		}
	}
	while (c != EOF);
done:
	fclose(fin);
	fclose(fout_odd);
	fclose(fout_even);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movl %ecx, %r14d
movq %rdx, %r15
movq %rsi, %r12
movq %rdi, %r13
leaq 0xe27(%rip), %rsi       # 0x2004
callq 0x10a0
testq %rax, %rax
je 0x1322
movq %rax, %rbx
leaq 0xe25(%rip), %rsi       # 0x201a
movq %r15, %rdi
callq 0x10a0
testq %rax, %rax
je 0x134b
movq %rax, %rbp
leaq 0xe0a(%rip), %rsi       # 0x201a
movq %r12, %rdi
callq 0x10a0
testq %rax, %rax
je 0x136b
movq %rax, %r15
testl %r14d, %r14d
setg 0xf(%rsp)
movq %rbp, 0x10(%rsp)
movl $0x4, %r13d
testl %r14d, %r14d
jle 0x1272
movl %r14d, %ebp
movq %rbx, %rdi
callq 0x1060
movl %eax, %r12d
movq %rbx, %rdi
callq 0x1090
testl %eax, %eax
jne 0x1267
movl %r12d, %edi
movq %r15, %rsi
callq 0x1070
decl %ebp
jne 0x123f
jmp 0x126d
movl $0x7, %r13d
movq 0x10(%rsp), %rbp
cmpl $0x4, %r13d
jne 0x12e7
movb 0xf(%rsp), %al
testl %r14d, %r14d
jle 0x12d7
movq %rbx, %rdi
callq 0x1060
movl %eax, %r12d
movq %rbx, %rdi
callq 0x1090
testl %eax, %eax
je 0x129e
movb 0xf(%rsp), %al
jmp 0x12d7
movl $0x1, %ecx
movl %ecx, %r13d
movl %r12d, %edi
movq %rbp, %rsi
callq 0x1070
cmpl %r13d, %r14d
je 0x12d1
movq %rbx, %rdi
callq 0x1060
movl %eax, %r12d
movq %rbx, %rdi
callq 0x1090
leal 0x1(%r13), %ecx
testl %eax, %eax
je 0x12a3
cmpl %r14d, %r13d
setl %al
testb %al, %al
jne 0x12ed
cmpl $-0x1, %r12d
jne 0x1231
jmp 0x12ed
cmpl $0x7, %r13d
jne 0x1313
movq %rbx, %rdi
callq 0x1040
movq %rbp, %rdi
callq 0x1040
movq %r15, %rdi
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x1040
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x2ccf(%rip), %rax      # 0x3ff8
movq (%rax), %rdi
leaq 0xcd4(%rip), %rsi       # 0x2007
movq %r13, %rdx
xorl %eax, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x1080
movq 0x2ca6(%rip), %rax      # 0x3ff8
movq (%rax), %rdi
leaq 0xcab(%rip), %rsi       # 0x2007
movq %r15, %rdx
xorl %eax, %eax
callq 0x1080
movq %rbx, %rdi
jmp 0x1300
movq 0x2c86(%rip), %rax      # 0x3ff8
movq (%rax), %rdi
leaq 0xc8b(%rip), %rsi       # 0x2007
movq %r12, %rdx
xorl %eax, %eax
callq 0x1080
movq %rbx, %rdi
callq 0x1040
movq %rbp, %rdi
jmp 0x1300