// File: /workspace/github_c_makefile_star2_O1/lh3[P]fermi2/seq.c
// Function: main_interleave
int main_interleave(int argc, char *argv[])
{
	gzFile fp1, fp2;
	kseq_t *seq[2];
	kstring_t str;

	if (argc < 3) {
		fprintf(stderr, "Usage: fermi interleave <in1.fq> <in2.fq>\n");
		return 1;
	}
	str.l = str.m = 0; str.s = 0;
	fp1 = strcmp(argv[1], "-")? gzopen(argv[1], "r") : gzdopen(fileno(stdin), "r");
	fp2 = strcmp(argv[2], "-")? gzopen(argv[2], "r") : gzdopen(fileno(stdin), "r");
	seq[0] = kseq_init(fp1);
	seq[1] = kseq_init(fp2);
	while (kseq_read(seq[0]) >= 0) {
		if (kseq_read(seq[1]) < 0) break; // one file ends
		str.l = 0;
		if (seq[0]->name.l > 2 && seq[0]->name.s[seq[0]->name.l-2] == '/' && isdigit(seq[0]->name.s[seq[0]->name.l-1]))
			seq[0]->name.s[(seq[0]->name.l -= 2)] = 0; // trim tailing "/[0-9]$"
		seq[1]->name.l = 0;
		kputsn(seq[0]->name.s, seq[0]->name.l, &seq[1]->name); // make sure two ends having the same name
		write_seq(seq[0], &str);
		write_seq(seq[1], &str);
		fputs(str.s, stdout);
	}
	kseq_destroy(seq[0]); gzclose(fp1);
	kseq_destroy(seq[1]); gzclose(fp2);
	free(str.s);
	return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
cmpl $0x2, %edi
jle 0xdfcf
movq %rsi, %rbx
xorps %xmm0, %xmm0
movaps %xmm0, (%rsp)
movq 0x8(%rsi), %r14
leaq 0xedae(%rip), %rsi      # 0x1cb8d
movq %r14, %rdi
callq 0x21a0
testl %eax, %eax
je 0xddfc
leaq 0xe592(%rip), %rsi      # 0x1c384
movq %r14, %rdi
callq 0x22b0
jmp 0xde19
movq 0x161c5(%rip), %rax     # 0x23fc8
movq (%rax), %rdi
callq 0x2200
leaq 0xe572(%rip), %rsi      # 0x1c384
movl %eax, %edi
callq 0x20c0
movq %rax, %r14
movq 0x10(%rbx), %rbx
leaq 0xed66(%rip), %rsi      # 0x1cb8d
movq %rbx, %rdi
callq 0x21a0
testl %eax, %eax
je 0xde44
leaq 0xe54a(%rip), %rsi      # 0x1c384
movq %rbx, %rdi
callq 0x22b0
jmp 0xde61
movq 0x1617d(%rip), %rax     # 0x23fc8
movq (%rax), %rdi
callq 0x2200
leaq 0xe52a(%rip), %rsi      # 0x1c384
movl %eax, %edi
callq 0x20c0
movq %rax, %rbx
movq %r14, 0x20(%rsp)
movq %r14, %rdi
callq 0xd8f7
movq %rax, %r12
movq %rbx, 0x18(%rsp)
movq %rbx, %rdi
callq 0xd8f7
movq %rax, %r15
movq %r12, %rdi
callq 0xd991
testl %eax, %eax
js 0xdf90
movq %rsp, %r13
movq %r15, %rdi
callq 0xd991
testl %eax, %eax
js 0xdf90
movl $0x0, (%rsp)
movl (%r12), %ebp
cmpl $0x3, %ebp
jb 0xdee6
movq 0x8(%r12), %rbx
leal -0x2(%rbp), %r14d
cmpb $0x2f, (%rbx,%r14)
jne 0xdee6
callq 0x2360
movq (%rax), %rax
decl %ebp
movsbq (%rbx,%rbp), %rcx
testb $0x8, 0x1(%rax,%rcx,2)
je 0xdee6
movl %r14d, (%r12)
movb $0x0, (%rbx,%r14)
movl $0x0, (%r15)
movq 0x8(%r12), %rbx
movslq (%r12), %rbp
leal 0x1(%rbp), %eax
cmpl 0x4(%r15), %eax
jb 0xdf34
movl %eax, %ecx
shrl %ecx
orl %eax, %ecx
movl %ecx, %eax
shrl $0x2, %eax
orl %ecx, %eax
movl %eax, %ecx
shrl $0x4, %ecx
orl %eax, %ecx
movl %ecx, %eax
shrl $0x8, %eax
orl %ecx, %eax
movl %eax, %esi
shrl $0x10, %esi
orl %eax, %esi
incl %esi
movl %esi, 0x4(%r15)
movq 0x8(%r15), %rdi
callq 0x2260
movq %rax, 0x8(%r15)
movl (%r15), %edi
addq 0x8(%r15), %rdi
movq %rbx, %rsi
movq %rbp, %rdx
callq 0x21f0
movl (%r15), %eax
addl %ebp, %eax
movl %eax, (%r15)
movq 0x8(%r15), %rcx
movb $0x0, (%rcx,%rax)
movq %r12, %rdi
movq %r13, %rsi
callq 0xdfdb
movq %r15, %rdi
movq %r13, %rsi
callq 0xdfdb
movq 0x8(%rsp), %rdi
movq 0x16048(%rip), %rax     # 0x23fc0
movq (%rax), %rsi
callq 0x2130
movq %r12, %rdi
callq 0xd991
testl %eax, %eax
jns 0xde97
movq %r12, %rdi
callq 0xd951
movq 0x20(%rsp), %rdi
callq 0x2030
movq %r15, %rdi
callq 0xd951
movq 0x18(%rsp), %rdi
callq 0x2030
movq 0x8(%rsp), %rdi
callq 0x2040
xorl %eax, %eax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x2ced
movl $0x1, %eax
jmp 0xdfc0