// File: /workspace/github_c_makefile_star2_O2/annoroad[P]fqtools_plus/fqtools.c
// Function: process
local void process(void){
	prepare();
	if (g.Nthread > 1){
		parallel_filter_main();
	}else{
		single_filter_main();
	}

	//判断read1 和 read2是否都读完？------------------------------
	if (g.single_or_pair){
		if (g.read1Count != g.read2Count){
			fprintf(stderr, "read1 num not equal read2 num\n");
			exit(-1);
		}
	}


	//gzip--------------------------------------------------------
	char s1[strlen(g.outfq1)+100];
	char s2[strlen(g.outfq1)+100];
	char s3[strlen(g.rawcutfq1)+100];
	char s4[strlen(g.rawcutfq2)+100];
	sprintf(s1,"%s %s",g.speedy_gzip,g.outfq1);
	if(g.single_or_pair) sprintf(s2,"%s %s",g.speedy_gzip,g.outfq2);
	if (g.QUOTA > 0 && g.QUOTA < LONG_MAX){
		sprintf(s3,"%s %s",g.speedy_gzip,g.rawcutfq1);
		if(g.single_or_pair) sprintf(s4,"%s %s",g.speedy_gzip,g.rawcutfq2);
	}
	char* shell1[]={"sh","-c",s1,NULL};
	char* shell2[]={"sh","-c",s2,NULL};
	char* shell3[]={"sh","-c",s3,NULL};
	char* shell4[]={"sh","-c",s4,NULL};

	pid_t jobs[4]={0,0,0,0};

	int n=0;
	pid_t curjob;
	curjob = fork();
	if(curjob==0){
		execv("/bin/sh",shell1);
	}
	jobs[n] = curjob;
	n++;

	if (g.single_or_pair){
		curjob = fork();
		if(curjob==0){
			execv("/bin/sh",shell2);	
		}
		jobs[n] = curjob;
		n++;
	}

	if (g.QUOTA > 0 && g.QUOTA < LONG_MAX){
		curjob = fork();
		if(curjob==0){
			execv("/bin/sh",shell3);
		}
		jobs[n] = curjob;
		n++;
		if (g.single_or_pair){
			curjob = fork();
			if(curjob==0){
				execv("/bin/sh",shell4);
			}
			jobs[n] = curjob;
			n++;
		}
	}
		
	n--;

	while(n > -1){
		curjob = waitpid(jobs[n],NULL,0);
		if (curjob == jobs[n]){
			n--;
		}else{
			fprintf(stderr, "%d is wrong! return %d\n",jobs[0],curjob);
			exit(-1);
		}
	} 

}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x478, %rsp            # imm = 0x478
xorps %xmm0, %xmm0
movups %xmm0, 0x4f33(%rip)     # 0xa280
movq 0x4eec(%rip), %rdi      # 0xa240
leaq 0x28a0(%rip), %rsi      # 0x7bfb
callq 0x2210
movq %rax, 0x4f19(%rip)      # 0xa280
cmpb $0x0, 0x4e5a(%rip)      # 0xa1c8
je 0x538a
movq 0x4ed1(%rip), %rdi      # 0xa248
leaq 0x287d(%rip), %rsi      # 0x7bfb
callq 0x2210
movq %rax, 0x4efe(%rip)      # 0xa288
xorps %xmm0, %xmm0
movups %xmm0, 0x4efc(%rip)     # 0xa290
movq 0x4eb5(%rip), %rdi      # 0xa250
leaq 0x1e43(%rip), %rsi      # 0x71e5
callq 0x2260
movq %rax, 0x4ee2(%rip)      # 0xa290
testq %rax, %rax
je 0x5824
cmpb $0x0, 0x4e0a(%rip)      # 0xa1c8
je 0x53e3
movq 0x4e91(%rip), %rdi      # 0xa258
leaq 0x1e17(%rip), %rsi      # 0x71e5
callq 0x2260
movq %rax, 0x4ebe(%rip)      # 0xa298
testq %rax, %rax
je 0x5855
movq 0x4e96(%rip), %rdi      # 0xa280
leaq -0x4a0(%rbp), %rsi
movl $0x400, %edx            # imm = 0x400
callq 0x2080
testq %rax, %rax
je 0x5887
movq 0x4e75(%rip), %rdi      # 0xa280
leaq -0x4a0(%rbp), %rsi
movl $0x400, %edx            # imm = 0x400
callq 0x2080
testq %rax, %rax
je 0x5887
leaq -0x4a0(%rbp), %rdi
callq 0x20c0
movl 0x4d99(%rip), %edx      # 0xa1d0
movl %edx, %esi
notl %esi
addl %eax, %esi
movl 0x4d89(%rip), %ecx      # 0xa1cc
testl %ecx, %ecx
sete %dil
cmpl %ecx, %esi
setl %r8b
orb %dil, %r8b
cmpb $0x1, %r8b
jne 0x5460
movl %esi, 0x4d6e(%rip)      # 0xa1cc
movl %esi, %ecx
leal (%rcx,%rdx), %esi
movslq %esi, %rsi
cmpq %rsi, %rax
jb 0x5837
movabsq $0x7ffffffffffffffe, %rdx # imm = 0x7FFFFFFFFFFFFFFE
movq 0x4d58(%rip), %rax      # 0xa1d8
testq %rax, %rax
je 0x551c
movzbl 0x4d38(%rip), %edx      # 0xa1c8
testl %edx, %edx
je 0x549b
cmpl $0x1, %edx
jne 0x54aa
addl %ecx, %ecx
movslq %ecx, %rcx
cqto
idivq %rcx
movq %rax, 0x4d2e(%rip)      # 0xa1d8
movb $0x1, 0x4d53(%rip)      # 0xa204
xorps %xmm0, %xmm0
movups %xmm0, 0x4de5(%rip)     # 0xa2a0
movq 0x4d9e(%rip), %rdi      # 0xa260
leaq 0x1d1c(%rip), %rsi      # 0x71e5
callq 0x2260
movq %rax, 0x4dcb(%rip)      # 0xa2a0
testq %rax, %rax
je 0x5868
cmpb $0x0, 0x4ce3(%rip)      # 0xa1c8
je 0x5538
movq 0x4d7a(%rip), %rdi      # 0xa268
leaq 0x1cf0(%rip), %rsi      # 0x71e5
callq 0x2260
movq %rax, 0x4da7(%rip)      # 0xa2a8
testq %rax, %rax
jne 0x5538
movq 0x4aeb(%rip), %rax      # 0x9ff8
movq (%rax), %rdi
movq 0x4d51(%rip), %rdx      # 0xa268
jmp 0x5879
leaq 0x1(%rdx), %rax
movq %rax, 0x4cb1(%rip)      # 0xa1d8
movb $0x0, 0x4cd6(%rip)      # 0xa204
xorps %xmm0, %xmm0
movups %xmm0, 0x4d68(%rip)     # 0xa2a0
cvtsi2ssl 0x4c8c(%rip), %xmm0 # 0xa1cc
movups 0x4ca1(%rip), %xmm1     # 0xa1e8
shufps $0x0, %xmm0, %xmm0      # xmm0 = xmm0[0,0,0,0]
mulps %xmm1, %xmm0
movups %xmm0, 0x4c93(%rip)     # 0xa1e8
movq 0x4d24(%rip), %rdi      # 0xa280
xorl %esi, %esi
xorl %edx, %edx
callq 0x20d0
cmpl $0x2, 0x4c94(%rip)      # 0xa200
jl 0x5575
callq 0x27f9
jmp 0x557a
callq 0x3158
cmpb $0x0, 0x4c47(%rip)      # 0xa1c8
je 0x5597
movq 0x4c7e(%rip), %rax      # 0xa208
cmpq 0x4c7f(%rip), %rax      # 0xa210
jne 0x588e
movq 0x4cb2(%rip), %r13      # 0xa250
movq %r13, %rdi
callq 0x20c0
movq %rsp, %rbx
addq $0x73, %rax
andq $-0x10, %rax
subq %rax, %rbx
movq %rbx, %rsp
movq %rsp, %r14
subq %rax, %r14
movq %r14, %rsp
movq 0x4c99(%rip), %rdi      # 0xa260
callq 0x20c0
movq %rsp, %r15
addq $0x73, %rax
andq $-0x10, %rax
subq %rax, %r15
movq %r15, %rsp
movq 0x4c84(%rip), %rdi      # 0xa268
callq 0x20c0
movq %rsp, %r12
addq $0x73, %rax
andq $-0x10, %rax
subq %rax, %r12
movq %r12, %rsp
movq 0x4caf(%rip), %rdx      # 0xa2b0
leaq 0x25cd(%rip), %rsi      # 0x7bd5
movq %rbx, %rdi
movq %r13, %rcx
xorl %eax, %eax
callq 0x22a0
cmpb $0x0, 0x4bac(%rip)      # 0xa1c8
je 0x563d
movq 0x4c8b(%rip), %rdx      # 0xa2b0
movq 0x4c2c(%rip), %rcx      # 0xa258
leaq 0x25a2(%rip), %rsi      # 0x7bd5
movq %r14, %rdi
xorl %eax, %eax
callq 0x22a0
movq 0x4b94(%rip), %rax      # 0xa1d8
decq %rax
movabsq $0x7ffffffffffffffe, %r13 # imm = 0x7FFFFFFFFFFFFFFE
cmpq %r13, %rax
jae 0x569d
movq 0x4c53(%rip), %rdx      # 0xa2b0
movq 0x4bfc(%rip), %rcx      # 0xa260
leaq 0x256a(%rip), %rsi      # 0x7bd5
movq %r15, %rdi
xorl %eax, %eax
callq 0x22a0
cmpb $0x0, 0x4b4c(%rip)      # 0xa1c8
je 0x569d
movq 0x4c2b(%rip), %rdx      # 0xa2b0
movq 0x4bdc(%rip), %rcx      # 0xa268
leaq 0x2542(%rip), %rsi      # 0x7bd5
movq %r12, %rdi
xorl %eax, %eax
callq 0x22a0
leaq 0x253c(%rip), %rax      # 0x7be0
movq %rax, -0x4a0(%rbp)
leaq 0x19c9(%rip), %rcx      # 0x707b
movq %rcx, -0x498(%rbp)
movq %rbx, -0x490(%rbp)
andq $0x0, -0x488(%rbp)
movq %rax, -0xa0(%rbp)
movq %rcx, -0x98(%rbp)
movq %r14, -0x90(%rbp)
andq $0x0, -0x88(%rbp)
movq %rax, -0x80(%rbp)
movq %rcx, -0x78(%rbp)
movq %r15, -0x70(%rbp)
andq $0x0, -0x68(%rbp)
movq %rax, -0x60(%rbp)
movq %rcx, -0x58(%rbp)
movq %r12, -0x50(%rbp)
andq $0x0, -0x48(%rbp)
xorps %xmm0, %xmm0
movaps %xmm0, -0x40(%rbp)
callq 0x2330
movl %eax, %ebx
testl %eax, %eax
jne 0x572c
leaq 0x24bb(%rip), %rdi      # 0x7bdb
leaq -0x4a0(%rbp), %rsi
callq 0x2320
movl %ebx, -0x40(%rbp)
cmpb $0x0, 0x4a92(%rip)      # 0xa1c8
je 0x575f
callq 0x2330
movl %eax, %r14d
testl %eax, %eax
jne 0x5757
leaq 0x2490(%rip), %rdi      # 0x7bdb
leaq -0xa0(%rbp), %rsi
callq 0x2320
movl %r14d, -0x3c(%rbp)
pushq $0x2
jmp 0x5761
pushq $0x1
popq %r15
movq 0x4a6e(%rip), %rax      # 0xa1d8
decq %rax
cmpq %r13, %rax
jae 0x57d0
callq 0x2330
movl %eax, %r14d
testl %eax, %eax
jne 0x578e
leaq 0x2456(%rip), %rdi      # 0x7bdb
leaq -0x80(%rbp), %rsi
callq 0x2320
movl %r15d, %eax
movl %r14d, -0x40(%rbp,%rax,4)
leal 0x1(%r15), %r12d
cmpb $0x0, 0x4a27(%rip)      # 0xa1c8
je 0x57cd
callq 0x2330
movl %eax, %r14d
testl %eax, %eax
jne 0x57bf
leaq 0x2425(%rip), %rdi      # 0x7bdb
leaq -0x60(%rbp), %rsi
callq 0x2320
movl %r12d, %eax
movl %r14d, -0x40(%rbp,%rax,4)
addl $0x2, %r15d
jmp 0x57d0
movl %r12d, %r15d
movl %r15d, %r15d
testq %r15, %r15
jle 0x5815
movl -0x44(%rbp,%r15,4), %r14d
decq %r15
movl %r14d, %edi
xorl %esi, %esi
xorl %edx, %edx
callq 0x2230
cmpl %r14d, %eax
je 0x57d3
movq 0x4800(%rip), %rcx      # 0x9ff8
movq (%rcx), %rdi
leaq 0x23e1(%rip), %rsi      # 0x7be3
movl %ebx, %edx
movl %eax, %ecx
xorl %eax, %eax
callq 0x2160
pushq $-0x1
popq %rdi
callq 0x22b0
leaq -0x28(%rbp), %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x47cd(%rip), %rax      # 0x9ff8
movq (%rax), %rdi
movq 0x4a1b(%rip), %rdx      # 0xa250
jmp 0x5879
movq 0x47ba(%rip), %rsi      # 0x9ff8
movq (%rsi), %rdi
leal -0x1(%rax), %r8d
leaq 0x23c3(%rip), %rsi      # 0x7c0f
xorl %eax, %eax
callq 0x2160
jmp 0x5887
movq 0x479c(%rip), %rax      # 0x9ff8
movq (%rax), %rdi
movq 0x49f2(%rip), %rdx      # 0xa258
jmp 0x5879
movq 0x4789(%rip), %rax      # 0x9ff8
movq (%rax), %rdi
movq 0x49e7(%rip), %rdx      # 0xa260
leaq 0x237e(%rip), %rsi      # 0x7bfe
xorl %eax, %eax
callq 0x2160
xorl %edi, %edi
callq 0x22b0
movq 0x4763(%rip), %rax      # 0x9ff8
movq (%rax), %rcx
leaq 0x2317(%rip), %rdi      # 0x7bb6
pushq $0x1e
popq %rsi
pushq $0x1
popq %rdx
callq 0x22c0
jmp 0x580d