// File: /workspace/github_c_makefile_star2_O3/jiqingxiaoxi[P]RPA/RPA.c
// Function: read_parProbe
struct ExoProbe *read_parProbe(char *path,int common_flag,int specific_flag)
{
        char *in,line[100];
        int pos,len,gi,position,plus,minus,size,i,flag,total,*store,*temp,*data;
        float Tm,GContent;
        struct ExoProbe *new_probe,*p_probe,*head;
        struct Node *new_node,*p_node;
        FILE *fp;

///read the  probe file
        if(access(path,0)==-1)
        {
                printf("Error! Don't have the %s file!\n",path);
                exit(1);
        }
        fp=fopen(path,"r");
        if(fp==NULL)
        {
                printf("Error: can't open the %s file!\n",path);
                exit(1);
        }
        
        size=sizeof(struct ExoProbe);
        i=0;
        while(fscanf(fp,"pos:%d\tlength:%d\t+:%d\t-:%d\t%f\t%f\n",&pos,&len,&plus,&minus,&Tm,&GContent)!=EOF)
	{
                new_probe=(struct ExoProbe *)malloc(size);
                new_probe->pos=pos;
                new_probe->len=len;
                new_probe->total=1;
		if(plus==1)
	                new_probe->strand=0;
		else
			new_probe->strand=1;
                new_probe->Tm=Tm;
		new_probe->G_content=GContent;
                new_probe->next=NULL;
                new_probe->common=NULL;
		new_probe->specific=NULL;

                if(i==0)
                {
                        head=new_probe;
                        p_probe=new_probe;
                        i++;
                }
                else
                {
                        p_probe->next=new_probe;
                        p_probe=new_probe;
                }
        }
        fclose(fp);
        if(i==0)
        {
                printf("Sorry! Don't have any candidate probes in %s!\n",path);
                exit(1);
        }

	//parameter of common
        if(common_flag==1)
	{
		i=strlen(path);
		in=(char *)malloc(i+20);
		memset(in,'\0',i+20);
		strcpy(in,path);
		strcat(in,"-common.txt"); //suffix of parameter
		if(access(in,0)==-1)
		{
			printf("Error! Don't have the %s file!\n",in);
			exit(1);
		}

		fp=fopen(in,"r");
		if(fp==NULL)
		{
			printf("Error: can't open the %s file!\n",in);
			exit(1);
		}
                
		total=0;
		while(fgets(line,100,fp)!=NULL)
			total++;
		rewind(fp);
		store=(int *)malloc(total*sizeof(int));
		temp=(int *)malloc(total*sizeof(int));
		data=(int *)malloc(6*total*sizeof(int));
		total=0;
		while(fscanf(fp,"%d\t%d\t%d\t%d\t%d\t%d\n",&pos,&len,&gi,&position,&plus,&minus)!=EOF)
		{
			data[6*total]=pos;
			data[6*total+1]=len;
			data[6*total+2]=gi;
			data[6*total+3]=position;
			data[6*total+4]=plus;
			data[6*total+5]=minus;
			store[total]=total;
			total++;
		}
		fclose(fp);
		sort_merge(store,temp,data,0,(total-1));
		p_probe=head;
		size=sizeof(struct Node);
		flag=0;
		i=0;
		while(p_probe&&i<total)
		{
		//pos
			if(data[store[i]*6]<p_probe->pos)
			{
				i++;
				continue;
			}
			if(data[store[i]*6]>p_probe->pos)
			{
				p_probe=p_probe->next;
				flag=0;
				continue;
			}
			//len
			if(data[store[i]*6+1]<p_probe->len)
			{
				i++;
				continue;
			}
			if(data[store[i]*6+1]>p_probe->len)
			{
				p_probe=p_probe->next;
				flag=0;
				continue;
			}
			new_node=(struct Node *)malloc(size);
			new_node->gi=data[store[i]*6+2];
			new_node->pos=data[store[i]*6+3];
			new_node->plus=data[store[i]*6+4];
			new_node->minus=data[store[i]*6+5];
			new_node->next=NULL;
			if(flag==0)
			{
				flag++;
				p_probe->common=new_node;
				p_node=new_node;
			}
			else
			{
				p_node->next=new_node;
				p_node=new_node;
			}
			i++;
		}
		free(in);
		free(data);
		free(store);
		free(temp);
	}
	if(specific_flag==0)
		return head;
	i=strlen(path);
	in=(char *)malloc(i+20);
	memset(in,'\0',i+20);
	strcpy(in,path);
	strcat(in,"-specific.txt"); //suffix of parameter
	if(access(in,0)==-1)
	{
		printf("Error! Don't have the %s file!\n",in);
		exit(1);
	}

	fp=fopen(in,"r");
	if(fp==NULL)
	{
		printf("Error: can't open the %s file!\n",in);
		exit(1);
	}
	total=0;
	while(fgets(line,100,fp)!=NULL)
		total++;
	rewind(fp);
	store=(int *)malloc(total*sizeof(int));
	temp=(int *)malloc(total*sizeof(int));
	data=(int *)malloc(6*total*sizeof(int));
	total=0;
	while(fscanf(fp,"%d\t%d\t%d\t%d\t%d\t%d\n",&pos,&len,&gi,&position,&plus,&minus)!=EOF)
	{
		data[6*total]=pos;
		data[6*total+1]=len;
		data[6*total+2]=gi;
		data[6*total+3]=position;
		data[6*total+4]=plus;
		data[6*total+5]=minus;
		store[total]=total;
		total++;
	}
	fclose(fp);
	sort_merge(store,temp,data,0,(total-1));

	p_probe=head;
	size=sizeof(struct Node);
	flag=0;
	i=0;
	while(p_probe&&i<total)
	{
	//pos
		if(data[store[i]*6]<p_probe->pos)
		{
			i++;
			continue;
		}
		if(data[store[i]*6]>p_probe->pos)
		{
			p_probe=p_probe->next;
			flag=0;
			continue;
		}
	//len
		if(data[store[i]*6+1]<p_probe->len)
		{
			i++;
			continue;
		}
		if(data[store[i]*6+1]>p_probe->len)
		{
			p_probe=p_probe->next;
			flag=0;
			continue;
		}
		new_node=(struct Node *)malloc(size);
		new_node->gi=data[store[i]*6+2];
		new_node->pos=data[store[i]*6+3];
		new_node->plus=data[store[i]*6+4];
		new_node->minus=data[store[i]*6+5];
		new_node->next=NULL;
		if(flag==0)
		{
			flag++;
			p_probe->specific=new_node;
			p_node=new_node;
		}
		else
		{
			p_node->next=new_node;
			p_node=new_node;
		}
		i++;
	}
	free(in);
	free(data);
	free(store);
	free(temp);

	return head;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xd8, %rsp
movl %edx, -0x80(%rbp)
movl %esi, %r14d
movq %rdi, %rbx
xorl %esi, %esi
callq 0x11c0
cmpl $-0x1, %eax
je 0xc5bc
leaq 0x2371(%rip), %rsi      # 0xe21b
movq %rbx, %rdi
callq 0x11d0
testq %rax, %rax
je 0xc5c5
movq %rax, %r13
movl %r14d, -0x40(%rbp)
movq %rbx, -0x60(%rbp)
leaq -0x64(%rbp), %r10
leaq -0x68(%rbp), %r11
leaq 0x267a(%rip), %rsi      # 0xe54f
leaq -0x34(%rbp), %rdx
leaq -0x30(%rbp), %rcx
leaq -0x2c(%rbp), %r8
leaq -0x38(%rbp), %r9
movq %rax, %rdi
xorl %eax, %eax
pushq %r10
pushq %r11
callq 0x1060
addq $0x10, %rsp
cmpl $-0x1, %eax
je 0xc5d1
movl %eax, -0x50(%rbp)
movb $0x1, %r12b
movl $0x30, %edi
callq 0x11a0
movq %rax, %rbx
movl -0x34(%rbp), %eax
movl %eax, (%rbx)
movl -0x30(%rbp), %eax
movl %eax, 0x4(%rbx)
movl $0x1, 0xc(%rbx)
xorl %eax, %eax
cmpl $0x1, -0x2c(%rbp)
setne %al
movl %eax, 0x8(%rbx)
movss -0x68(%rbp), %xmm0
movss %xmm0, 0x10(%rbx)
movss -0x64(%rbp), %xmm0
movss %xmm0, 0x14(%rbx)
xorps %xmm0, %xmm0
movups %xmm0, 0x18(%rbx)
movq $0x0, 0x28(%rbx)
movq %rbx, %rax
testb $0x1, %r12b
jne 0xbf64
movq %rbx, 0x18(%r15)
movq %r14, %rax
movq %rax, -0x78(%rbp)
xorl %r12d, %r12d
movq %r13, %rdi
leaq 0x25da(%rip), %rsi      # 0xe54f
leaq -0x34(%rbp), %rdx
leaq -0x30(%rbp), %rcx
leaq -0x2c(%rbp), %r8
leaq -0x38(%rbp), %r9
xorl %eax, %eax
leaq -0x64(%rbp), %r10
pushq %r10
leaq -0x68(%rbp), %r10
pushq %r10
callq 0x1060
addq $0x10, %rsp
movq -0x78(%rbp), %r14
movq %rbx, %r15
cmpl $-0x1, %eax
jne 0xbf06
movq %r13, %rdi
callq 0x10a0
cmpl $-0x1, -0x50(%rbp)
je 0xc5d9
movabsq $0x1400000000, %r14     # imm = 0x1400000000
cmpl $0x1, -0x40(%rbp)
movq -0x60(%rbp), %rbx
jne 0xc2bd
movq %rbx, %rdi
callq 0x10b0
shlq $0x20, %rax
leaq (%rax,%r14), %rsi
sarq $0x20, %rsi
movl $0x1, %edi
callq 0x1140
movq %rax, %r12
movq %rax, %rdi
movq %rbx, %rsi
callq 0x1050
movq %r12, %rdi
callq 0x10b0
movabsq $0x2e6e6f6d6d6f632d, %rcx # imm = 0x2E6E6F6D6D6F632D
movq %rcx, (%r12,%rax)
movl $0x747874, 0x8(%r12,%rax) # imm = 0x747874
movq %r12, %rdi
xorl %esi, %esi
callq 0x11c0
cmpl $-0x1, %eax
je 0xc5fb
leaq 0x21e0(%rip), %rsi      # 0xe21b
movq %r12, %rdi
callq 0x11d0
testq %rax, %rax
je 0xc604
movq %rax, %r13
movq $-0x4, %rbx
movl $0xfffffffa, %r15d      # imm = 0xFFFFFFFA
leaq -0x100(%rbp), %r14
movq %r14, %rdi
movl $0x64, %esi
movq %r13, %rdx
callq 0x1130
addq $0x4, %rbx
addl $0x6, %r15d
testq %rax, %rax
jne 0xc063
movq %r12, -0x90(%rbp)
movq %r13, %rdi
callq 0x10e0
movq %rbx, %rdi
callq 0x11a0
movq %rax, -0x40(%rbp)
movq %rbx, %rdi
callq 0x11a0
movq %rax, -0x70(%rbp)
movl %r15d, %edi
shlq $0x2, %rdi
callq 0x11a0
movq %rax, %r12
leaq 0x2465(%rip), %rsi      # 0xe522
xorl %ebx, %ebx
leaq -0x34(%rbp), %rdx
leaq -0x30(%rbp), %rcx
leaq -0x48(%rbp), %r8
leaq -0x44(%rbp), %r9
movq %r13, %rdi
xorl %eax, %eax
leaq -0x38(%rbp), %r10
pushq %r10
leaq -0x2c(%rbp), %r10
pushq %r10
callq 0x1060
addq $0x10, %rsp
cmpl $-0x1, %eax
movq %r12, -0x50(%rbp)
je 0xc16d
movq %r12, %r15
addq $0x14, %r15
xorl %ebx, %ebx
leaq -0x38(%rbp), %r14
movq -0x40(%rbp), %r12
movl -0x34(%rbp), %eax
movl %eax, -0x14(%r15)
movl -0x30(%rbp), %eax
movl %eax, -0x10(%r15)
movl -0x48(%rbp), %eax
movl %eax, -0xc(%r15)
movl -0x44(%rbp), %eax
movl %eax, -0x8(%r15)
movl -0x2c(%rbp), %eax
movl %eax, -0x4(%r15)
movl -0x38(%rbp), %eax
movl %eax, (%r15)
movl %ebx, (%r12,%rbx,4)
incq %rbx
movq %r13, %rdi
leaq 0x23e5(%rip), %rsi      # 0xe522
leaq -0x34(%rbp), %rdx
leaq -0x30(%rbp), %rcx
leaq -0x48(%rbp), %r8
leaq -0x44(%rbp), %r9
xorl %eax, %eax
pushq %r14
leaq -0x2c(%rbp), %r10
pushq %r10
callq 0x1060
addq $0x10, %rsp
addq $0x18, %r15
cmpl $-0x1, %eax
jne 0xc103
movq -0x50(%rbp), %r12
movq %r13, %rdi
callq 0x10a0
leal -0x1(%rbx), %r8d
xorl %r14d, %r14d
movq -0x40(%rbp), %r15
movq %r15, %rdi
movq -0x70(%rbp), %rsi
movq %r12, %rdx
xorl %ecx, %ecx
callq 0xb5b2
testl %ebx, %ebx
setg %al
movq -0x78(%rbp), %r12
testq %r12, %r12
setne %cl
andb %al, %cl
cmpb $0x1, %cl
jne 0xc289
movl %ebx, %edi
xorl %r13d, %r13d
movslq %r13d, %r13
movq -0x50(%rbp), %rsi
movslq (%r15,%r13,4), %rax
addq %rax, %rax
leaq (%rax,%rax,2), %r15
movl (%rsi,%r15,4), %eax
leal 0x1(%r15), %ecx
movslq %ecx, %rcx
cmpl (%r12), %eax
jl 0xc1f3
jg 0xc1e1
movl 0x4(%r12), %edx
cmpl %edx, (%rsi,%rcx,4)
jl 0xc1f3
jle 0xc204
movq 0x18(%r12), %r12
xorl %r14d, %r14d
testq %r12, %r12
jne 0xc1cd
jmp 0xc281
incq %r13
cmpq %rdi, %r13
movq -0x40(%rbp), %r15
jl 0xc1b7
jmp 0xc5b3
movq %rdi, -0x88(%rbp)
movl $0x18, %edi
movq %r8, -0x58(%rbp)
callq 0x11a0
movq -0x88(%rbp), %rdi
movq -0x50(%rbp), %rdx
movl 0x8(%rdx,%r15,4), %ecx
movl %ecx, 0x4(%rax)
movl 0xc(%rdx,%r15,4), %ecx
movl %ecx, (%rax)
movl 0x10(%rdx,%r15,4), %ecx
movl %ecx, 0x8(%rax)
movl 0x14(%rdx,%r15,4), %ecx
movl %ecx, 0xc(%rax)
movq $0x0, 0x10(%rax)
movq -0x58(%rbp), %rdx
addq $0x10, %rdx
leaq 0x20(%r12), %rcx
testl %r14d, %r14d
cmovneq %rdx, %rcx
movq %rax, (%rcx)
incl %r13d
movl $0x1, %r14d
movq %rax, -0x58(%rbp)
movq %rax, %r8
cmpl %ebx, %r13d
movq -0x40(%rbp), %r15
jl 0xc1b0
jmp 0xc289
movq %r8, -0x58(%rbp)
movq -0x40(%rbp), %r15
movq -0x90(%rbp), %rdi
callq 0x1030
movq -0x50(%rbp), %rdi
callq 0x1030
movq %r15, %rdi
callq 0x1030
movq -0x70(%rbp), %rdi
callq 0x1030
movq -0x60(%rbp), %rbx
movabsq $0x1400000000, %r14     # imm = 0x1400000000
cmpl $0x0, -0x80(%rbp)
je 0xc59d
movq %rbx, %rdi
callq 0x10b0
shlq $0x20, %rax
addq %rax, %r14
sarq $0x20, %r14
movl $0x1, %edi
movq %r14, %rsi
callq 0x1140
movq %rax, %r14
movq %rax, %rdi
movq %rbx, %rsi
callq 0x1050
movq %r14, %rdi
callq 0x10b0
movabsq $0x696669636570732d, %rcx # imm = 0x696669636570732D
movq %rcx, (%r14,%rax)
movabsq $0x7478742e636966, %rcx # imm = 0x7478742E636966
movq %rcx, 0x6(%r14,%rax)
movq %r14, %rdi
xorl %esi, %esi
callq 0x11c0
cmpl $-0x1, %eax
je 0xc5e6
leaq 0x1ee7(%rip), %rsi      # 0xe21b
movq %r14, %rdi
callq 0x11d0
testq %rax, %rax
je 0xc5ef
movq %rax, %r12
movq %r14, -0x80(%rbp)
movq $-0x4, %rbx
movl $0xfffffffa, %r15d      # imm = 0xFFFFFFFA
leaq -0x100(%rbp), %r14
movq %r14, %rdi
movl $0x64, %esi
movq %r12, %rdx
callq 0x1130
addq $0x4, %rbx
addl $0x6, %r15d
testq %rax, %rax
jne 0xc360
movq %r12, %rdi
callq 0x10e0
movq %rbx, %rdi
callq 0x11a0
movq %rax, -0x40(%rbp)
movq %rbx, %rdi
callq 0x11a0
movq %rax, -0x60(%rbp)
movl %r15d, %edi
shlq $0x2, %rdi
callq 0x11a0
movq %rax, %r15
leaq 0x216f(%rip), %rsi      # 0xe522
xorl %ebx, %ebx
leaq -0x34(%rbp), %rdx
leaq -0x30(%rbp), %rcx
leaq -0x48(%rbp), %r8
leaq -0x44(%rbp), %r9
movq %r12, %rdi
xorl %eax, %eax
leaq -0x38(%rbp), %r10
pushq %r10
leaq -0x2c(%rbp), %r10
pushq %r10
callq 0x1060
addq $0x10, %rsp
cmpl $-0x1, %eax
je 0xc468
movq %r15, -0x50(%rbp)
addq $0x14, %r15
leaq -0x44(%rbp), %r14
xorl %ebx, %ebx
movq -0x40(%rbp), %r13
movl -0x34(%rbp), %eax
movl %eax, -0x14(%r15)
movl -0x30(%rbp), %eax
movl %eax, -0x10(%r15)
movl -0x48(%rbp), %eax
movl %eax, -0xc(%r15)
movl -0x44(%rbp), %eax
movl %eax, -0x8(%r15)
movl -0x2c(%rbp), %eax
movl %eax, -0x4(%r15)
movl -0x38(%rbp), %eax
movl %eax, (%r15)
movl %ebx, (%r13,%rbx,4)
incq %rbx
movq %r12, %rdi
leaq 0x20ed(%rip), %rsi      # 0xe522
leaq -0x34(%rbp), %rdx
leaq -0x30(%rbp), %rcx
leaq -0x48(%rbp), %r8
movq %r14, %r9
xorl %eax, %eax
leaq -0x38(%rbp), %r10
pushq %r10
leaq -0x2c(%rbp), %r10
pushq %r10
callq 0x1060
addq $0x10, %rsp
addq $0x18, %r15
cmpl $-0x1, %eax
jne 0xc3fa
movq -0x50(%rbp), %r15
movq %r12, %rdi
callq 0x10a0
leal -0x1(%rbx), %r8d
xorl %r14d, %r14d
movq %r15, %r13
movq -0x40(%rbp), %r15
movq %r15, %rdi
movq -0x60(%rbp), %rsi
movq %r13, %rdx
xorl %ecx, %ecx
callq 0xb5b2
movq %r15, %rdi
testl %ebx, %ebx
setg %al
movq -0x78(%rbp), %r12
testq %r12, %r12
setne %cl
andb %al, %cl
cmpb $0x1, %cl
movq -0x58(%rbp), %rsi
movq %r13, %r8
jne 0xc575
movl %ebx, %r9d
xorl %r13d, %r13d
movslq %r13d, %r13
movslq (%rdi,%r13,4), %rax
addq %rax, %rax
leaq (%rax,%rax,2), %r15
movl (%r8,%r15,4), %eax
leal 0x1(%r15), %ecx
movslq %ecx, %rcx
cmpl (%r12), %eax
jl 0xc4f6
jg 0xc4e7
movl 0x4(%r12), %edx
cmpl %edx, (%r8,%rcx,4)
jl 0xc4f6
jle 0xc500
movq 0x18(%r12), %r12
xorl %r14d, %r14d
testq %r12, %r12
jne 0xc4d2
jmp 0xc575
incq %r13
cmpq %r9, %r13
jl 0xc4bc
jmp 0xc575
movl $0x18, %edi
movq %rsi, -0x58(%rbp)
movq %r8, -0x50(%rbp)
movq %r9, -0x70(%rbp)
callq 0x11a0
movq -0x70(%rbp), %r9
movq -0x50(%rbp), %r8
movq -0x40(%rbp), %rdi
movl 0x8(%r8,%r15,4), %ecx
movl %ecx, 0x4(%rax)
movl 0xc(%r8,%r15,4), %ecx
movl %ecx, (%rax)
movl 0x10(%r8,%r15,4), %ecx
movl %ecx, 0x8(%rax)
movl 0x14(%r8,%r15,4), %ecx
movl %ecx, 0xc(%rax)
movq $0x0, 0x10(%rax)
movq -0x58(%rbp), %rdx
addq $0x10, %rdx
leaq 0x28(%r12), %rcx
testl %r14d, %r14d
cmovneq %rdx, %rcx
movq %rax, (%rcx)
incl %r13d
movl $0x1, %r14d
movq %rax, %rsi
cmpl %ebx, %r13d
jl 0xc4b9
movq %rdi, %rbx
movq -0x80(%rbp), %rdi
movq %r8, %r14
callq 0x1030
movq %r14, %rdi
callq 0x1030
movq %rbx, %rdi
callq 0x1030
movq -0x60(%rbp), %rdi
callq 0x1030
movq -0x78(%rbp), %rax
addq $0xd8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %r8, -0x58(%rbp)
jmp 0xc289
leaq 0x1c8c(%rip), %rdi      # 0xe24f
jmp 0xc5cc
leaq 0x1ed4(%rip), %rdi      # 0xe4a0
movq %rbx, %rsi
jmp 0xc60e
movq %r13, %rdi
callq 0x10a0
leaq 0x1f91(%rip), %rdi      # 0xe571
movq -0x60(%rbp), %rsi
jmp 0xc60e
leaq 0x1c62(%rip), %rdi      # 0xe24f
jmp 0xc5f6
leaq 0x1eaa(%rip), %rdi      # 0xe4a0
movq %r14, %rsi
jmp 0xc60e
leaq 0x1c4d(%rip), %rdi      # 0xe24f
jmp 0xc60b
leaq 0x1e95(%rip), %rdi      # 0xe4a0
movq %r12, %rsi
xorl %eax, %eax
callq 0x10c0
movl $0x1, %edi
callq 0x1200