// File: /workspace/github_c_makefile_star2_O1/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, %r14d
movl %esi, %r15d
movq %rdi, %rbx
xorl %esi, %esi
callq 0x11b0
cmpl $-0x1, %eax
je 0xc76d
leaq 0x2205(%rip), %rsi      # 0xe20e
movq %rbx, %rdi
callq 0x11c0
testq %rax, %rax
je 0xc776
movq %rax, %r12
movl %r15d, -0x50(%rbp)
movl %r14d, -0x60(%rbp)
movq %rbx, -0x68(%rbp)
leaq -0x6c(%rbp), %r10
leaq -0x70(%rbp), %r11
leaq 0x250a(%rip), %rsi      # 0xe542
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
movl %eax, -0x40(%rbp)
cmpl $-0x1, %eax
je 0xc116
movb $0x1, %r13b
movl $0x30, %edi
callq 0x1190
movq %rax, %r15
movl -0x34(%rbp), %eax
movl %eax, (%r15)
movl -0x30(%rbp), %eax
movl %eax, 0x4(%r15)
movl $0x1, 0xc(%r15)
xorl %eax, %eax
cmpl $0x1, -0x2c(%rbp)
setne %al
movl %eax, 0x8(%r15)
movss -0x70(%rbp), %xmm0
movss %xmm0, 0x10(%r15)
movss -0x6c(%rbp), %xmm0
movss %xmm0, 0x14(%r15)
xorps %xmm0, %xmm0
movups %xmm0, 0x18(%r15)
movq $0x0, 0x28(%r15)
movq %r15, %rax
testb $0x1, %r13b
jne 0xc0ce
movq %r15, 0x18(%r14)
movq %rbx, %rax
xorl %r13d, %r13d
movq %rax, %rbx
movq %r12, %rdi
leaq 0x2464(%rip), %rsi      # 0xe542
leaq -0x34(%rbp), %rdx
leaq -0x30(%rbp), %rcx
leaq -0x2c(%rbp), %r8
leaq -0x38(%rbp), %r9
xorl %eax, %eax
leaq -0x6c(%rbp), %r10
pushq %r10
leaq -0x70(%rbp), %r10
pushq %r10
callq 0x1060
movq %rbx, %rcx
addq $0x10, %rsp
movq %r15, %r14
cmpl $-0x1, %eax
jne 0xc069
jmp 0xc116
movq %rcx, -0x80(%rbp)
movq %r12, %rdi
callq 0x10a0
cmpl $-0x1, -0x40(%rbp)
movq -0x68(%rbp), %r14
je 0xc782
movabsq $0x1400000000, %rbx     # imm = 0x1400000000
cmpl $0x1, -0x50(%rbp)
jne 0xc43f
movq %r14, %rdi
callq 0x10b0
shlq $0x20, %rax
addq %rax, %rbx
sarq $0x20, %rbx
movq %rbx, %rdi
callq 0x1190
movq %rax, %r15
movq %rax, %rdi
xorl %esi, %esi
movq %rbx, %rdx
callq 0x1100
movq %r15, %rdi
movq %r14, %rsi
callq 0x1050
movq %r15, %rdi
callq 0x10b0
movabsq $0x2e6e6f6d6d6f632d, %rcx # imm = 0x2E6E6F6D6D6F632D
movq %rcx, (%r15,%rax)
movl $0x747874, 0x8(%r15,%rax) # imm = 0x747874
movq %r15, %rdi
xorl %esi, %esi
callq 0x11b0
cmpl $-0x1, %eax
je 0xc758
leaq 0x205b(%rip), %rsi      # 0xe20e
movq %r15, %rdi
callq 0x11c0
testq %rax, %rax
je 0xc761
movq %rax, %r14
movq %r15, -0x90(%rbp)
movq $-0x4, %rbx
movl $0xfffffffa, %r12d      # imm = 0xFFFFFFFA
leaq -0x100(%rbp), %r15
movq %r15, %rdi
movl $0x64, %esi
movq %r14, %rdx
callq 0x1130
addq $0x4, %rbx
addl $0x6, %r12d
testq %rax, %rax
jne 0xc1e2
movq %r14, %rdi
callq 0x10e0
movq %rbx, %rdi
callq 0x1190
movq %rax, -0x40(%rbp)
movq %rbx, %rdi
callq 0x1190
movq %rax, -0x78(%rbp)
movl %r12d, %edi
shlq $0x2, %rdi
callq 0x1190
movq %rax, %r13
leaq 0x22e0(%rip), %rsi      # 0xe515
xorl %r15d, %r15d
leaq -0x34(%rbp), %rdx
leaq -0x30(%rbp), %rcx
leaq -0x48(%rbp), %r8
leaq -0x44(%rbp), %r9
movq %r14, %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 %r13, -0x50(%rbp)
je 0xc2e4
addq $0x14, %r13
xorl %r15d, %r15d
leaq -0x38(%rbp), %rbx
movq -0x40(%rbp), %r12
movl -0x34(%rbp), %eax
movl %eax, -0x14(%r13)
movl -0x30(%rbp), %eax
movl %eax, -0x10(%r13)
movl -0x48(%rbp), %eax
movl %eax, -0xc(%r13)
movl -0x44(%rbp), %eax
movl %eax, -0x8(%r13)
movl -0x2c(%rbp), %eax
movl %eax, -0x4(%r13)
movl -0x38(%rbp), %eax
movl %eax, (%r13)
movl %r15d, (%r12,%r15,4)
incq %r15
movq %r14, %rdi
leaq 0x2260(%rip), %rsi      # 0xe515
leaq -0x34(%rbp), %rdx
leaq -0x30(%rbp), %rcx
leaq -0x48(%rbp), %r8
leaq -0x44(%rbp), %r9
xorl %eax, %eax
pushq %rbx
leaq -0x2c(%rbp), %r10
pushq %r10
callq 0x1060
addq $0x10, %rsp
addq $0x18, %r13
cmpl $-0x1, %eax
jne 0xc27a
movq -0x50(%rbp), %r13
movq %r14, %rdi
callq 0x10a0
leal -0x1(%r15), %r8d
xorl %ebx, %ebx
movq -0x40(%rbp), %r14
movq %r14, %rdi
movq -0x78(%rbp), %rsi
movq %r13, %rdx
xorl %ecx, %ecx
callq 0xb6b3
testl %r15d, %r15d
setg %al
movq -0x80(%rbp), %r12
testq %r12, %r12
setne %cl
andb %al, %cl
cmpb $0x1, %cl
jne 0xc40b
movl %r15d, %r8d
xorl %r13d, %r13d
movslq %r13d, %r13
movq -0x50(%rbp), %rdi
movslq (%r14,%r13,4), %rcx
addq %rcx, %rcx
leaq (%rcx,%rcx,2), %r14
movl (%rdi,%r14,4), %ecx
leal 0x1(%r14), %edx
movslq %edx, %rdx
cmpl (%r12), %ecx
jl 0xc371
jg 0xc359
movl 0x4(%r12), %esi
cmpl %esi, (%rdi,%rdx,4)
jl 0xc371
jle 0xc385
movq 0x18(%r12), %r12
testq %r12, %r12
setne %sil
xorl %ebx, %ebx
testb %al, %sil
jne 0xc345
jmp 0xc403
incq %r13
cmpq %r8, %r13
setl %al
movq -0x40(%rbp), %r14
jl 0xc32f
jmp 0xc74f
movl $0x18, %edi
movq %r8, -0x88(%rbp)
movq %r9, -0x58(%rbp)
callq 0x1190
movq -0x88(%rbp), %r8
movq -0x50(%rbp), %rdx
movl 0x8(%rdx,%r14,4), %ecx
movl %ecx, 0x4(%rax)
movl 0xc(%rdx,%r14,4), %ecx
movl %ecx, (%rax)
movl 0x10(%rdx,%r14,4), %ecx
movl %ecx, 0x8(%rax)
movl 0x14(%rdx,%r14,4), %ecx
movl %ecx, 0xc(%rax)
movq $0x0, 0x10(%rax)
movq -0x58(%rbp), %rdx
addq $0x10, %rdx
leaq 0x20(%r12), %rcx
testl %ebx, %ebx
cmovneq %rdx, %rcx
movq %rax, (%rcx)
incl %r13d
movl $0x1, %ebx
movq %rax, -0x58(%rbp)
movq %rax, %r9
cmpl %r15d, %r13d
setl %al
movq -0x40(%rbp), %r14
jl 0xc328
jmp 0xc40b
movq %r9, -0x58(%rbp)
movq -0x40(%rbp), %r14
movq -0x90(%rbp), %rdi
callq 0x1030
movq -0x50(%rbp), %rdi
callq 0x1030
movq %r14, %rdi
callq 0x1030
movq -0x78(%rbp), %rdi
callq 0x1030
movq -0x68(%rbp), %r14
movabsq $0x1400000000, %rbx     # imm = 0x1400000000
cmpl $0x0, -0x60(%rbp)
je 0xc739
movq %r14, %rdi
callq 0x10b0
shlq $0x20, %rax
addq %rax, %rbx
sarq $0x20, %rbx
movq %rbx, %rdi
callq 0x1190
movq %rax, %r15
movq %rax, %rdi
xorl %esi, %esi
movq %rbx, %rdx
callq 0x1100
movq %r15, %rdi
movq %r14, %rsi
callq 0x1050
movq %r15, %rdi
callq 0x10b0
movabsq $0x696669636570732d, %rcx # imm = 0x696669636570732D
movq %rcx, (%r15,%rax)
movabsq $0x7478742e636966, %rcx # imm = 0x7478742E636966
movq %rcx, 0x6(%r15,%rax)
movq %r15, %rdi
xorl %esi, %esi
callq 0x11b0
cmpl $-0x1, %eax
je 0xc758
leaq 0x1d50(%rip), %rsi      # 0xe20e
movq %r15, %rdi
callq 0x11c0
testq %rax, %rax
je 0xc761
movq %rax, %r14
movq %r15, -0x50(%rbp)
movq $-0x4, %rbx
movl $0xfffffffa, %r12d      # imm = 0xFFFFFFFA
leaq -0x100(%rbp), %r15
movq %r15, %rdi
movl $0x64, %esi
movq %r14, %rdx
callq 0x1130
addq $0x4, %rbx
addl $0x6, %r12d
testq %rax, %rax
jne 0xc4ea
movq %r14, %rdi
callq 0x10e0
movq %rbx, %rdi
callq 0x1190
movq %rax, -0x40(%rbp)
movq %rbx, %rdi
callq 0x1190
movq %rax, -0x68(%rbp)
movl %r12d, %edi
shlq $0x2, %rdi
callq 0x1190
movq %rax, %r12
leaq 0x1fd8(%rip), %rsi      # 0xe515
xorl %r15d, %r15d
leaq -0x34(%rbp), %rdx
leaq -0x30(%rbp), %rcx
leaq -0x48(%rbp), %r8
leaq -0x44(%rbp), %r9
movq %r14, %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 0xc5fa
movq %r12, -0x60(%rbp)
addq $0x14, %r12
leaq -0x44(%rbp), %rbx
xorl %r15d, %r15d
movq -0x40(%rbp), %r13
movl -0x34(%rbp), %eax
movl %eax, -0x14(%r12)
movl -0x30(%rbp), %eax
movl %eax, -0x10(%r12)
movl -0x48(%rbp), %eax
movl %eax, -0xc(%r12)
movl -0x44(%rbp), %eax
movl %eax, -0x8(%r12)
movl -0x2c(%rbp), %eax
movl %eax, -0x4(%r12)
movl -0x38(%rbp), %eax
movl %eax, (%r12)
movl %r15d, (%r13,%r15,4)
incq %r15
movq %r14, %rdi
leaq 0x1f4e(%rip), %rsi      # 0xe515
leaq -0x34(%rbp), %rdx
leaq -0x30(%rbp), %rcx
leaq -0x48(%rbp), %r8
movq %rbx, %r9
xorl %eax, %eax
leaq -0x38(%rbp), %r10
pushq %r10
leaq -0x2c(%rbp), %r10
pushq %r10
callq 0x1060
addq $0x10, %rsp
addq $0x18, %r12
cmpl $-0x1, %eax
jne 0xc586
movq -0x60(%rbp), %r12
movq %r14, %rdi
callq 0x10a0
leal -0x1(%r15), %r8d
xorl %ebx, %ebx
movq -0x40(%rbp), %r14
movq %r14, %rdi
movq -0x68(%rbp), %rsi
movq %r12, %rdx
xorl %ecx, %ecx
callq 0xb6b3
movq %r14, %r8
testl %r15d, %r15d
setg %al
movq %r12, %r9
movq -0x80(%rbp), %r12
testq %r12, %r12
setne %cl
andb %al, %cl
cmpb $0x1, %cl
movq -0x58(%rbp), %rdi
jne 0xc711
movl %r15d, %r10d
xorl %r13d, %r13d
movslq %r13d, %r13
movslq (%r8,%r13,4), %rcx
addq %rcx, %rcx
leaq (%rcx,%rcx,2), %r14
movl (%r9,%r14,4), %ecx
leal 0x1(%r14), %edx
movslq %edx, %rdx
cmpl (%r12), %ecx
jl 0xc68e
jg 0xc676
movl 0x4(%r12), %esi
cmpl %esi, (%r9,%rdx,4)
jl 0xc68e
jle 0xc69b
movq 0x18(%r12), %r12
testq %r12, %r12
setne %sil
xorl %ebx, %ebx
testb %al, %sil
jne 0xc661
jmp 0xc711
incq %r13
cmpq %r10, %r13
setl %al
jl 0xc64b
jmp 0xc711
movq %rdi, -0x58(%rbp)
movl $0x18, %edi
movq %r9, -0x60(%rbp)
movq %r10, -0x78(%rbp)
callq 0x1190
movq -0x78(%rbp), %r10
movq -0x60(%rbp), %r9
movq -0x40(%rbp), %r8
movl 0x8(%r9,%r14,4), %ecx
movl %ecx, 0x4(%rax)
movl 0xc(%r9,%r14,4), %ecx
movl %ecx, (%rax)
movl 0x10(%r9,%r14,4), %ecx
movl %ecx, 0x8(%rax)
movl 0x14(%r9,%r14,4), %ecx
movl %ecx, 0xc(%rax)
movq $0x0, 0x10(%rax)
movq -0x58(%rbp), %rdx
addq $0x10, %rdx
leaq 0x28(%r12), %rcx
testl %ebx, %ebx
cmovneq %rdx, %rcx
movq %rax, (%rcx)
incl %r13d
movl $0x1, %ebx
movq %rax, %rdi
cmpl %r15d, %r13d
setl %al
jl 0xc648
movq -0x50(%rbp), %rdi
movq %r8, %rbx
movq %r9, %r14
callq 0x1030
movq %r14, %rdi
callq 0x1030
movq %rbx, %rdi
callq 0x1030
movq -0x68(%rbp), %rdi
callq 0x1030
movq -0x80(%rbp), %rax
addq $0xd8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %r9, -0x58(%rbp)
jmp 0xc40b
leaq 0x1ae3(%rip), %rdi      # 0xe242
jmp 0xc768
leaq 0x1d2b(%rip), %rdi      # 0xe493
movq %r15, %rsi
jmp 0xc78c
leaq 0x1ace(%rip), %rdi      # 0xe242
jmp 0xc77d
leaq 0x1d16(%rip), %rdi      # 0xe493
movq %rbx, %rsi
jmp 0xc78c
leaq 0x1ddb(%rip), %rdi      # 0xe564
movq %r14, %rsi
xorl %eax, %eax
callq 0x10c0
movl $0x1, %edi
callq 0x11f0