// File: /workspace/github_c_makefile_star2_O1/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, 0x5926(%rip)     # 0xb278
movq 0x58df(%rip), %rdi      # 0xb238
leaq 0x22f7(%rip), %rsi      # 0x7c57
callq 0x2200
movq %rax, 0x590c(%rip)      # 0xb278
cmpb $0x0, 0x584d(%rip)      # 0xb1c0
je 0x598f
movq 0x58c4(%rip), %rdi      # 0xb240
leaq 0x22d4(%rip), %rsi      # 0x7c57
callq 0x2200
movq %rax, 0x58f1(%rip)      # 0xb280
xorps %xmm0, %xmm0
movups %xmm0, 0x58ef(%rip)     # 0xb288
movq 0x58a8(%rip), %rdi      # 0xb248
leaq 0x189a(%rip), %rsi      # 0x7241
callq 0x2250
movq %rax, 0x58d5(%rip)      # 0xb288
testq %rax, %rax
je 0x5df9
cmpb $0x0, 0x57fd(%rip)      # 0xb1c0
je 0x59e8
movq 0x5884(%rip), %rdi      # 0xb250
leaq 0x186e(%rip), %rsi      # 0x7241
callq 0x2250
movq %rax, 0x58b1(%rip)      # 0xb290
testq %rax, %rax
je 0x5e21
movq 0x5889(%rip), %rdi      # 0xb278
leaq -0x4a0(%rbp), %rsi
movl $0x400, %edx            # imm = 0x400
callq 0x2080
testq %rax, %rax
je 0x5e1a
movq 0x5868(%rip), %rdi      # 0xb278
leaq -0x4a0(%rbp), %rsi
movl $0x400, %edx            # imm = 0x400
callq 0x2080
testq %rax, %rax
je 0x5e1a
leaq -0x4a0(%rbp), %rdi
callq 0x20c0
movl 0x578c(%rip), %edx      # 0xb1c8
movl %edx, %ecx
notl %ecx
addl %eax, %ecx
movl 0x577c(%rip), %esi      # 0xb1c4
testl %esi, %esi
sete %dil
cmpl %esi, %ecx
setl %sil
orb %dil, %sil
cmpb $0x1, %sil
jne 0x5a63
movl %ecx, 0x5761(%rip)      # 0xb1c4
movl 0x575b(%rip), %ecx      # 0xb1c4
leal (%rcx,%rdx), %esi
movslq %esi, %rsi
cmpq %rsi, %rax
jb 0x5dfe
movabsq $0x7ffffffffffffffe, %rax # imm = 0x7FFFFFFFFFFFFFFE
movq 0x5747(%rip), %rsi      # 0xb1d0
testq %rsi, %rsi
je 0x5ab1
movzbl 0x572b(%rip), %eax      # 0xb1c0
testl %eax, %eax
je 0x5aa2
movb $0x1, %dl
cmpl $0x1, %eax
jne 0x5abd
addl %ecx, %ecx
movslq %ecx, %rcx
movq %rsi, %rax
cqto
idivq %rcx
movb $0x1, %dl
jmp 0x5ab6
incq %rax
xorl %edx, %edx
movq %rax, 0x5713(%rip)      # 0xb1d0
movb %dl, 0x5739(%rip)       # 0xb1fc
xorps %xmm0, %xmm0
movups %xmm0, 0x57cb(%rip)     # 0xb298
testq %rsi, %rsi
je 0x5b21
movq 0x577f(%rip), %rdi      # 0xb258
leaq 0x1761(%rip), %rsi      # 0x7241
callq 0x2250
movq %rax, 0x57ac(%rip)      # 0xb298
testq %rax, %rax
je 0x5e26
cmpb $0x0, 0x56c4(%rip)      # 0xb1c0
je 0x5b21
movq 0x575b(%rip), %rdi      # 0xb260
leaq 0x1735(%rip), %rsi      # 0x7241
callq 0x2250
movq %rax, 0x5788(%rip)      # 0xb2a0
testq %rax, %rax
je 0x5e30
xorps %xmm0, %xmm0
cvtsi2ssl 0x5698(%rip), %xmm0 # 0xb1c4
movups 0x56ad(%rip), %xmm1     # 0xb1e0
shufps $0x0, %xmm0, %xmm0      # xmm0 = xmm0[0,0,0,0]
mulps %xmm1, %xmm0
movups %xmm0, 0x569f(%rip)     # 0xb1e0
movq 0x5730(%rip), %rdi      # 0xb278
xorl %esi, %esi
xorl %edx, %edx
callq 0x20d0
cmpl $0x2, 0x56a0(%rip)      # 0xb1f8
jl 0x5b61
callq 0x2c53
jmp 0x5b66
callq 0x363d
cmpb $0x0, 0x5653(%rip)      # 0xb1c0
je 0x5b83
movq 0x568a(%rip), %rax      # 0xb200
cmpq 0x568b(%rip), %rax      # 0xb208
jne 0x5e2b
movq 0x56be(%rip), %r13      # 0xb248
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 0x56a5(%rip), %rdi      # 0xb258
callq 0x20c0
movq %rsp, %r15
addq $0x73, %rax
andq $-0x10, %rax
subq %rax, %r15
movq %r15, %rsp
movq 0x5690(%rip), %rdi      # 0xb260
callq 0x20c0
movq %rsp, %r12
addq $0x73, %rax
andq $-0x10, %rax
subq %rax, %r12
movq %r12, %rsp
movq 0x56bb(%rip), %rdx      # 0xb2a8
leaq 0x203d(%rip), %rsi      # 0x7c31
movq %rbx, %rdi
movq %r13, %rcx
xorl %eax, %eax
callq 0x2290
cmpb $0x0, 0x55b8(%rip)      # 0xb1c0
je 0x5c29
movq 0x5697(%rip), %rdx      # 0xb2a8
movq 0x5638(%rip), %rcx      # 0xb250
leaq 0x2012(%rip), %rsi      # 0x7c31
movq %r14, %rdi
xorl %eax, %eax
callq 0x2290
movq 0x55a0(%rip), %rax      # 0xb1d0
decq %rax
movabsq $0x7ffffffffffffffe, %r13 # imm = 0x7FFFFFFFFFFFFFFE
cmpq %r13, %rax
jae 0x5c89
movq 0x565f(%rip), %rdx      # 0xb2a8
movq 0x5608(%rip), %rcx      # 0xb258
leaq 0x1fda(%rip), %rsi      # 0x7c31
movq %r15, %rdi
xorl %eax, %eax
callq 0x2290
cmpb $0x0, 0x5558(%rip)      # 0xb1c0
je 0x5c89
movq 0x5637(%rip), %rdx      # 0xb2a8
movq 0x55e8(%rip), %rcx      # 0xb260
leaq 0x1fb2(%rip), %rsi      # 0x7c31
movq %r12, %rdi
xorl %eax, %eax
callq 0x2290
leaq 0x1fac(%rip), %rax      # 0x7c3c
movq %rax, -0x4a0(%rbp)
leaq 0x1439(%rip), %rcx      # 0x70d7
movq %rcx, -0x498(%rbp)
movq %rbx, -0x490(%rbp)
xorl %edx, %edx
movq %rdx, -0x488(%rbp)
movq %rax, -0xa0(%rbp)
movq %rcx, -0x98(%rbp)
movq %r14, -0x90(%rbp)
movq %rdx, -0x88(%rbp)
movq %rax, -0x80(%rbp)
movq %rcx, -0x78(%rbp)
movq %r15, -0x70(%rbp)
movq %rdx, -0x68(%rbp)
movq %rax, -0x60(%rbp)
movq %rcx, -0x58(%rbp)
movq %r12, -0x50(%rbp)
movq %rdx, -0x48(%rbp)
xorps %xmm0, %xmm0
movaps %xmm0, -0x40(%rbp)
callq 0x2320
movl %eax, %ebx
testl %eax, %eax
jne 0x5d16
leaq 0x1f2d(%rip), %rdi      # 0x7c37
leaq -0x4a0(%rbp), %rsi
callq 0x2310
movl %ebx, -0x40(%rbp)
cmpb $0x0, 0x54a0(%rip)      # 0xb1c0
je 0x5d4d
callq 0x2320
movl %eax, %r14d
testl %eax, %eax
jne 0x5d41
leaq 0x1f02(%rip), %rdi      # 0x7c37
leaq -0xa0(%rbp), %rsi
callq 0x2310
movl %r14d, -0x3c(%rbp)
movl $0x2, %r15d
jmp 0x5d53
movl $0x1, %r15d
movq 0x5476(%rip), %rax      # 0xb1d0
decq %rax
cmpq %r13, %rax
jae 0x5dc0
callq 0x2320
movl %eax, %r14d
testl %eax, %eax
jne 0x5d7e
leaq 0x1ec2(%rip), %rdi      # 0x7c37
leaq -0x80(%rbp), %rsi
callq 0x2310
movl %r15d, %eax
movl %r14d, -0x40(%rbp,%rax,4)
leal 0x1(%r15), %r12d
cmpb $0x0, 0x542f(%rip)      # 0xb1c0
je 0x5dbd
callq 0x2320
movl %eax, %r14d
testl %eax, %eax
jne 0x5daf
leaq 0x1e91(%rip), %rdi      # 0x7c37
leaq -0x60(%rbp), %rsi
callq 0x2310
movl %r12d, %eax
movl %r14d, -0x40(%rbp,%rax,4)
addl $0x2, %r15d
jmp 0x5dc0
movl %r12d, %r15d
movl %r15d, %r15d
testq %r15, %r15
jle 0x5dea
movl -0x44(%rbp,%r15,4), %r14d
decq %r15
movl %r14d, %edi
xorl %esi, %esi
xorl %edx, %edx
callq 0x2220
cmpl %r14d, %eax
je 0x5dc3
movl %ebx, %edi
movl %eax, %esi
callq 0x2546
leaq -0x28(%rbp), %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x256b
movq 0x51f3(%rip), %rsi      # 0xaff8
movq (%rsi), %rdi
leal -0x1(%rax), %r8d
leaq 0x1e58(%rip), %rsi      # 0x7c6b
xorl %eax, %eax
callq 0x2150
xorl %edi, %edi
callq 0x22a0
callq 0x24ac
callq 0x24fa
callq 0x2521
callq 0x24d3