// File: /workspace/github_c_makefile_star2_O2/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 $0xc8, %rsp
movl %edx, -0x60(%rbp)
movl %esi, %r14d
movq %rdi, %rbx
xorl %esi, %esi
callq 0x11b0
cmpl $-0x1, %eax
je 0xb3c7
movl %r14d, -0x40(%rbp)
leaq 0x2456(%rip), %rsi      # 0xd23b
movq %rbx, -0x48(%rbp)
movq %rbx, %rdi
callq 0x11c0
testq %rax, %rax
je 0xb3d3
movq %rax, %r12
movb $0x1, %r13b
leaq -0x30(%rbp), %r14
pushq $0x30
popq %r15
movq %rbx, -0x70(%rbp)
movq %r12, %rdi
leaq 0x2759(%rip), %rsi      # 0xd56f
leaq -0x34(%rbp), %rdx
movq %r14, %rcx
leaq -0x2c(%rbp), %r8
leaq -0x38(%rbp), %r9
xorl %eax, %eax
leaq -0x78(%rbp), %r10
pushq %r10
leaq -0x7c(%rbp), %r10
pushq %r10
callq 0x1060
popq %rcx
popq %rdx
cmpl $-0x1, %eax
je 0xaea5
movq %r15, %rdi
callq 0x1190
movl -0x34(%rbp), %ecx
movl %ecx, (%rax)
movl -0x30(%rbp), %ecx
movl %ecx, 0x4(%rax)
xorl %ecx, %ecx
cmpl $0x1, -0x2c(%rbp)
movl $0x1, 0xc(%rax)
setne %cl
movl %ecx, 0x8(%rax)
movss -0x7c(%rbp), %xmm0
movss %xmm0, 0x10(%rax)
movss -0x78(%rbp), %xmm0
movss %xmm0, 0x14(%rax)
xorps %xmm0, %xmm0
movups %xmm0, 0x18(%rax)
andq $0x0, 0x28(%rax)
testb $0x1, %r13b
jne 0xae9a
movq %rax, 0x18(%rbx)
xorl %r13d, %r13d
movq %rax, %rbx
jmp 0xae0c
xorl %r13d, %r13d
movq %rax, %rbx
jmp 0xae08
movq %r12, %rdi
callq 0x10a0
testb $0x1, %r13b
jne 0xb3dc
movabsq $0x1400000000, %r14     # imm = 0x1400000000
cmpl $0x1, -0x40(%rbp)
movq -0x48(%rbp), %rbx
jne 0xb138
movq %rbx, %rdi
callq 0x10b0
shlq $0x20, %rax
leaq (%rax,%r14), %rsi
sarq $0x20, %rsi
pushq $0x1
popq %rdi
callq 0x1140
movq %rax, %r14
movq %rax, %rdi
movq %rbx, %rsi
callq 0x1050
movq %r14, %rdi
callq 0x10b0
movabsq $0x2e6e6f6d6d6f632d, %rcx # imm = 0x2E6E6F6D6D6F632D
movq %rcx, (%r14,%rax)
movl $0x747874, 0x8(%r14,%rax) # imm = 0x747874
movq %r14, %rdi
xorl %esi, %esi
callq 0x11b0
cmpl $-0x1, %eax
je 0xb3bb
leaq 0x2309(%rip), %rsi      # 0xd23b
movq %r14, -0x88(%rbp)
movq %r14, %rdi
callq 0x11c0
testq %rax, %rax
je 0xb3f6
movq %rax, %rbx
pushq $-0x4
popq %r14
pushq $-0x6
popq %r13
leaq -0xf0(%rbp), %r15
pushq $0x64
popq %r12
movq %r15, %rdi
movl %r12d, %esi
movq %rbx, %rdx
callq 0x1130
addq $0x4, %r14
addl $0x6, %r13d
testq %rax, %rax
jne 0xaf60
movq %rbx, %rdi
callq 0x10e0
movq %r14, %rdi
callq 0x1190
movq %rax, %r12
movq %r14, %rdi
callq 0x1190
movq %rax, -0x40(%rbp)
movl %r13d, %edi
shlq $0x2, %rdi
callq 0x1190
movq %rax, -0x58(%rbp)
movq %rax, %r13
addq $0x14, %r13
xorl %r15d, %r15d
xorl %r14d, %r14d
movq %rbx, %rdi
leaq 0x2581(%rip), %rsi      # 0xd542
leaq -0x34(%rbp), %rdx
leaq -0x30(%rbp), %rcx
leaq -0x50(%rbp), %r8
leaq -0x4c(%rbp), %r9
xorl %eax, %eax
leaq -0x38(%rbp), %r10
pushq %r10
leaq -0x2c(%rbp), %r10
pushq %r10
callq 0x1060
popq %rcx
popq %rdx
cmpl $-0x1, %eax
je 0xb02f
movl -0x34(%rbp), %eax
movl %eax, -0x14(%r13)
movl -0x30(%rbp), %eax
movl %eax, -0x10(%r13)
movl -0x50(%rbp), %eax
movl %eax, -0xc(%r13)
movl -0x4c(%rbp), %eax
movl %eax, -0x8(%r13)
movl -0x2c(%rbp), %eax
movl %eax, -0x4(%r13)
movl -0x38(%rbp), %eax
movl %eax, (%r13)
movl %r14d, (%r12,%r14,4)
incq %r14
movabsq $0x100000000, %rax      # imm = 0x100000000
addq %rax, %r15
addq $0x18, %r13
jmp 0xafb7
movq %rbx, %rdi
callq 0x10a0
decl %r14d
xorl %ebx, %ebx
movq %r12, %rdi
movq -0x40(%rbp), %rsi
movq -0x58(%rbp), %r13
movq %r13, %rdx
xorl %ecx, %ecx
movl %r14d, %r8d
callq 0xa60e
movq %r13, %rsi
sarq $0x20, %r15
xorl %edx, %edx
movq -0x70(%rbp), %r14
movslq %ebx, %rbx
cmpq %r15, %rbx
jge 0xb102
testq %r14, %r14
je 0xb102
movslq (%r12,%rbx,4), %rax
imulq $0x6, %rax, %r13
movl (%r14), %eax
cmpl %eax, (%rsi,%r13,4)
jl 0xb0a4
jg 0xb09c
movl %r13d, %eax
orl $0x1, %eax
cltq
movl 0x4(%r14), %ecx
cmpl %ecx, (%rsi,%rax,4)
jl 0xb0a4
jle 0xb0a9
movq 0x18(%r14), %r14
xorl %edx, %edx
jmp 0xb06d
incq %rbx
jmp 0xb064
pushq $0x18
popq %rdi
movl %edx, -0x74(%rbp)
callq 0x1190
movq -0x58(%rbp), %rsi
movl 0x8(%rsi,%r13,4), %ecx
movl %ecx, 0x4(%rax)
movl 0xc(%rsi,%r13,4), %ecx
movl %ecx, (%rax)
movl 0x10(%rsi,%r13,4), %ecx
movl %ecx, 0x8(%rax)
movl 0x14(%rsi,%r13,4), %ecx
movl %ecx, 0xc(%rax)
andq $0x0, 0x10(%rax)
movq -0x68(%rbp), %rdx
addq $0x10, %rdx
leaq 0x20(%r14), %rcx
cmpl $0x0, -0x74(%rbp)
cmovneq %rdx, %rcx
pushq $0x1
popq %rdx
movq %rax, (%rcx)
incq %rbx
movq %rax, -0x68(%rbp)
jmp 0xb061
movq %rsi, %rbx
movq -0x88(%rbp), %rdi
callq 0x1030
movq %rbx, %rdi
callq 0x1030
movq %r12, %rdi
callq 0x1030
movq -0x40(%rbp), %rdi
callq 0x1030
movq -0x48(%rbp), %rbx
movabsq $0x1400000000, %r14     # imm = 0x1400000000
cmpl $0x0, -0x60(%rbp)
je 0xb3a5
movq %rbx, %rdi
callq 0x10b0
shlq $0x20, %rax
addq %rax, %r14
sarq $0x20, %r14
pushq $0x1
popq %rdi
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 0x11b0
cmpl $-0x1, %eax
je 0xb3bb
leaq 0x208e(%rip), %rsi      # 0xd23b
movq %r14, -0x40(%rbp)
movq %r14, %rdi
callq 0x11c0
testq %rax, %rax
je 0xb3e9
movq %rax, %r13
pushq $-0x4
popq %r14
pushq $-0x6
popq %r12
leaq -0xf0(%rbp), %rbx
pushq $0x64
popq %r15
movq %rbx, %rdi
movl %r15d, %esi
movq %r13, %rdx
callq 0x1130
addq $0x4, %r14
addl $0x6, %r12d
testq %rax, %rax
jne 0xb1d8
movq %r13, %rdi
callq 0x10e0
movq %r14, %rdi
callq 0x1190
movq %rax, %rbx
movq %r14, %rdi
callq 0x1190
movq %rax, -0x48(%rbp)
movl %r12d, %edi
shlq $0x2, %rdi
callq 0x1190
movq %rax, -0x60(%rbp)
movq %rax, %r12
addq $0x14, %r12
xorl %r15d, %r15d
xorl %r14d, %r14d
movq %r13, %rdi
leaq 0x2309(%rip), %rsi      # 0xd542
leaq -0x34(%rbp), %rdx
leaq -0x30(%rbp), %rcx
leaq -0x50(%rbp), %r8
leaq -0x4c(%rbp), %r9
xorl %eax, %eax
leaq -0x38(%rbp), %r10
pushq %r10
leaq -0x2c(%rbp), %r10
pushq %r10
callq 0x1060
popq %rcx
popq %rdx
cmpl $-0x1, %eax
je 0xb2ac
movl -0x34(%rbp), %eax
movl %eax, -0x14(%r12)
movl -0x30(%rbp), %eax
movl %eax, -0x10(%r12)
movl -0x50(%rbp), %eax
movl %eax, -0xc(%r12)
movl -0x4c(%rbp), %eax
movl %eax, -0x8(%r12)
movl -0x2c(%rbp), %eax
movl %eax, -0x4(%r12)
movl -0x38(%rbp), %eax
movl %eax, (%r12)
movl %r14d, (%rbx,%r14,4)
incq %r14
movabsq $0x100000000, %rax      # imm = 0x100000000
addq %rax, %r15
addq $0x18, %r12
jmp 0xb22f
movq %r13, %rdi
callq 0x10a0
decl %r14d
xorl %r13d, %r13d
movq %rbx, %rdi
movq -0x48(%rbp), %rsi
movq -0x60(%rbp), %r12
movq %r12, %rdx
xorl %ecx, %ecx
movl %r14d, %r8d
callq 0xa60e
movq %r12, %rsi
sarq $0x20, %r15
xorl %edx, %edx
movq -0x70(%rbp), %r14
movslq %r13d, %r13
cmpq %r15, %r13
jge 0xb380
testq %r14, %r14
je 0xb380
movslq (%rbx,%r13,4), %rax
imulq $0x6, %rax, %r12
movl (%r14), %eax
cmpl %eax, (%rsi,%r12,4)
jl 0xb322
jg 0xb31a
movl %r12d, %eax
orl $0x1, %eax
cltq
movl 0x4(%r14), %ecx
cmpl %ecx, (%rsi,%rax,4)
jl 0xb322
jle 0xb327
movq 0x18(%r14), %r14
xorl %edx, %edx
jmp 0xb2eb
incq %r13
jmp 0xb2e2
pushq $0x18
popq %rdi
movl %edx, -0x58(%rbp)
callq 0x1190
movq -0x60(%rbp), %rsi
movl 0x8(%rsi,%r12,4), %ecx
movl %ecx, 0x4(%rax)
movl 0xc(%rsi,%r12,4), %ecx
movl %ecx, (%rax)
movl 0x10(%rsi,%r12,4), %ecx
movl %ecx, 0x8(%rax)
movl 0x14(%rsi,%r12,4), %ecx
movl %ecx, 0xc(%rax)
andq $0x0, 0x10(%rax)
movq -0x68(%rbp), %rdx
addq $0x10, %rdx
leaq 0x28(%r14), %rcx
cmpl $0x0, -0x58(%rbp)
cmovneq %rdx, %rcx
movq %rax, (%rcx)
incq %r13
pushq $0x1
popq %rdx
movq %rax, -0x68(%rbp)
jmp 0xb2df
movq %rsi, %r14
movq -0x40(%rbp), %rdi
callq 0x1030
movq %r14, %rdi
callq 0x1030
movq %rbx, %rdi
callq 0x1030
movq -0x48(%rbp), %rdi
callq 0x1030
movq -0x70(%rbp), %rax
addq $0xc8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x1ead(%rip), %rdi      # 0xd26f
movq %r14, %rsi
jmp 0xb404
leaq 0x1ea1(%rip), %rdi      # 0xd26f
movq %rbx, %rsi
jmp 0xb404
leaq 0x20e6(%rip), %rdi      # 0xd4c0
jmp 0xb3e3
leaq 0x21ae(%rip), %rdi      # 0xd591
movq -0x48(%rbp), %rsi
jmp 0xb404
leaq 0x20d0(%rip), %rdi      # 0xd4c0
movq -0x40(%rbp), %rsi
jmp 0xb404
leaq 0x20c3(%rip), %rdi      # 0xd4c0
movq -0x88(%rbp), %rsi
xorl %eax, %eax
callq 0x10c0
pushq $0x1
popq %rdi
callq 0x11f0