// File: /workspace/github_c_makefile_star2_O0/shifengbin[P]bishe/Download/MatchURL.cpp
// Function: GetURLFromBody(ModePair*, char*, char*, int)
void GetURLFromBody( ModePair *pattern , char *host ,  char *body, int deep)
{
	regex_t reg,http;
	regmatch_t pmatch;
	char url[512] = { 0 };
	char *regexstr = NULL;
	char *temp;
	char chr;
	char *c;
	int len;
	if ( pattern == NULL || body == NULL )
	{
		puts("pattern or body is NULL");
		return ;
	}
	regexstr = pattern->getMode();
//	puts(body);
//	puts(regexstr);
	if (regcomp(&reg,regexstr,0)!=0)
	{
		puts("Regular Experssion Error");
		return ;
	}
	temp = body;	
	for(;;)
	{
		if (regexec(&reg,temp,1,&pmatch,0) == REG_NOMATCH)
		{
//			puts("NO Match");
			break;
		}
		else
		{
			temp = temp + pmatch.rm_so;
			len = pmatch.rm_eo - pmatch.rm_so;
			//write(STDOUT_FILENO,temp+6,len-7);
			c = temp +len -1;
			chr = *c;
			*c = '\0';
			if ( isAbsoluteURL( temp + 6 ) )	
			{
				sprintf(url,"%s",temp+6);
			}
			else
			{
				sprintf(url,"http://%s%s",host,temp+6);
			}
			///--------------store database
			if ( !Bloom::isExist(url) )
			{
				Bloom::addFilter(url);
//				puts(url);
				URL *u = new URL();
				u->setType(pattern->getType());
				u->setURLStr(url);
				u->setDeep(deep+1);
				u->save();
				delete u;
			}
			///--------------
			*c = chr;
			temp+=len;
		}
	}
	return;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x2f0, %rsp            # imm = 0x2F0
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movl %ecx, -0x1c(%rbp)
leaq -0x290(%rbp), %rdi
xorl %esi, %esi
movl $0x200, %edx            # imm = 0x200
callq 0x8160
movq $0x0, -0x298(%rbp)
cmpq $0x0, -0x8(%rbp)
je 0x9896
cmpq $0x0, -0x18(%rbp)
jne 0x98a7
leaq 0x9886c(%rip), %rdi     # 0xa2109
callq 0x8470
jmp 0x9af8
movq -0x8(%rbp), %rdi
callq 0xbbf0
movq %rax, -0x298(%rbp)
movq -0x298(%rbp), %rsi
leaq -0x50(%rbp), %rdi
xorl %edx, %edx
callq 0x8360
cmpl $0x0, %eax
je 0x98df
leaq 0x9884c(%rip), %rdi     # 0xa2121
callq 0x8470
jmp 0x9af8
movq -0x18(%rbp), %rax
movq %rax, -0x2a0(%rbp)
movq -0x2a0(%rbp), %rsi
leaq -0x50(%rbp), %rdi
movl $0x1, %edx
leaq -0x88(%rbp), %rcx
xorl %r8d, %r8d
callq 0x8210
cmpl $0x11, %eax
jne 0x9913
jmp 0x9af6
movq -0x2a0(%rbp), %rax
movslq -0x88(%rbp), %rcx
addq %rcx, %rax
movq %rax, -0x2a0(%rbp)
movl -0x84(%rbp), %eax
subl -0x88(%rbp), %eax
movl %eax, -0x2b4(%rbp)
movq -0x2a0(%rbp), %rax
movslq -0x2b4(%rbp), %rcx
addq %rcx, %rax
addq $-0x1, %rax
movq %rax, -0x2b0(%rbp)
movq -0x2b0(%rbp), %rax
movb (%rax), %al
movb %al, -0x2a1(%rbp)
movq -0x2b0(%rbp), %rax
movb $0x0, (%rax)
movq -0x2a0(%rbp), %rdi
addq $0x6, %rdi
callq 0x9820
cmpl $0x0, %eax
je 0x99a9
leaq -0x290(%rbp), %rdi
movq -0x2a0(%rbp), %rdx
addq $0x6, %rdx
leaq 0x9d45c(%rip), %rsi     # 0xa6dfc
movb $0x0, %al
callq 0x8080
jmp 0x99cd
leaq -0x290(%rbp), %rdi
movq -0x10(%rbp), %rdx
movq -0x2a0(%rbp), %rcx
addq $0x6, %rcx
leaq 0x98774(%rip), %rsi     # 0xa213a
movb $0x0, %al
callq 0x8080
leaq -0x290(%rbp), %rdi
callq 0x8980
cmpl $0x0, %eax
jne 0x9ac8
leaq -0x290(%rbp), %rdi
callq 0x8940
movl $0x20, %edi
callq 0x82d0
movq %rax, %rdi
movq %rdi, %rax
movq %rax, -0x2d8(%rbp)
callq 0x9b10
jmp 0x9a0c
movq -0x2d8(%rbp), %rax
movq %rax, -0x2c0(%rbp)
movq -0x2c0(%rbp), %rax
movq %rax, -0x2e8(%rbp)
movq -0x8(%rbp), %rdi
callq 0xbbd0
movq -0x2e8(%rbp), %rdi
movl %eax, %esi
callq 0x9b50
movq -0x2c0(%rbp), %rdi
leaq -0x290(%rbp), %rsi
callq 0x9b70
movq -0x2c0(%rbp), %rdi
movl -0x1c(%rbp), %esi
addl $0x1, %esi
callq 0x9bf0
movq -0x2c0(%rbp), %rdi
callq 0x9c10
movq -0x2c0(%rbp), %rax
movq %rax, -0x2e0(%rbp)
cmpq $0x0, %rax
je 0x9aa1
movq -0x2e0(%rbp), %rdi
callq 0x9c90
movq -0x2e0(%rbp), %rdi
movl $0x20, %esi
callq 0x82e0
jmp 0x9ac8
movq -0x2d8(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x2c8(%rbp)
movl %eax, -0x2cc(%rbp)
movl $0x20, %esi
callq 0x82e0
jmp 0x9b01
movb -0x2a1(%rbp), %cl
movq -0x2b0(%rbp), %rax
movb %cl, (%rax)
movl -0x2b4(%rbp), %ecx
movq -0x2a0(%rbp), %rax
movslq %ecx, %rcx
addq %rcx, %rax
movq %rax, -0x2a0(%rbp)
jmp 0x98ea
jmp 0x9af8
addq $0x2f0, %rsp            # imm = 0x2F0
popq %rbp
retq
movq -0x2c8(%rbp), %rdi
callq 0x84e0
nopl (%rax)