// File: /workspace/github_c_makefile_star2_O0/hkshenSmart[P]ONVIF-discovery_cs/discovery-nvc.c
// Function: main
int main(int argc, char *argv[])
{
    //struct soap discovery_soap; 
    struct soap *soap; 
    int result = 0; 
	struct d__ProbeType req;
	struct d__ProbeMatchesType resp;
	struct d__ScopesType sScope;
	struct SOAP_ENV__Header header;                             //soap header
	int count = 0;
//	struct SOAP_ENV__Header header;
	char guid_string[100];
    //uuid_t uuid;
    
    //soap_init(&discovery_soap); 
    //soap = &discovery_soap; 


    soap = soap_new();                                           //init soap
    if(soap==NULL)
        return -1;

    ////////////////////////////////////////////////////////////////////////////
    // discovery test
	//uuid_generate(uuid);
    //uuid_unparse(uuid, guid_string);

//    soap_omode(soap, SOAP_IO_FLUSH|SOAP_IO_STORE);
    soap_set_namespaces(soap, namespaces); 
	//����5����û�����ݾ��˳�
	soap->recv_timeout = 5;

	soap_default_SOAP_ENV__Header(soap, &header);                            //init soap header
	header.wsa__MessageID = guid_string;
	header.wsa__To = "urn:schemas-xmlsoap-org:ws:2005:04:discovery";
	header.wsa__Action = "http://schemas.xmllocal_soap.org/ws/2005/04/discovery/Probe";
	soap->header = &header;                                                  //bind the soap header for transport                                     

 	soap_default_d__ScopesType(soap, &sScope);
	sScope.__item = "";
	//sScope.__item = "onvif://www.onvif.org";

 	soap_default_d__ProbeType(soap, &req);
	req.Scopes = &sScope;
	req.Types = "";
	//req.Types = "dn:NetworkVideoTransmitter";

	do
	{
		soap_call___dndl__Probe(soap, "soap.udp://239.255.255.250:3702/datagram", NULL, &req, &resp); 

		if (soap->error) { 
			printf("soap error: %d, %s, %s\n", soap->error, *soap_faultcode(soap), *soap_faultstring(soap)); 
			result = soap->error; 
			break;
		} 
		else
		{
			printf("====================================================================\r\n");
				if(soap->header->wsa__MessageID)
					printf("MessageID   : %s\r\n", soap->header->wsa__MessageID);

				//if(soap->header->wsa__RelatesTo && soap->header->wsa__RelatesTo->__item)
					//printf("RelatesTo   : %s\r\n", soap->header->wsa__RelatesTo->__item);

				if(soap->header->wsa__To)
					printf("To          : %s\r\n", soap->header->wsa__To);

				if(soap->header->wsa__Action)
					printf("Action      : %s\r\n", soap->header->wsa__Action);
			printf("====================================================================\r\n");
				
			printf("soap_call___dndl__Probe __sizeProbeMatch=%d\r\n",resp.__sizeProbeMatch);
			printf("Target EP Address       : %s\r\n", resp.ProbeMatch[0].wsa__EndpointReference.Address);
			printf("Target Type             : %s\r\n", resp.ProbeMatch[0].Types);
			printf("Target Service Address  : %s\r\n", resp.ProbeMatch[0].XAddrs);
			printf("Target Metadata Version : %d\r\n", resp.ProbeMatch[0].MetadataVersion);
			printf("Target Scopes Address   : %s\r\n", resp.ProbeMatch[0].Scopes->__item);
			printf("====================================================================\r\n");
		}
	}while(0);

	soap_destroy(soap);                                                // remove deserialized class instances (C++ only)
	soap_end(soap);                                                    // clean up and remove deserialized data
    
    ////////////////////////////////////////////////////////////////////////////
//failed:
	soap_free(soap);                                                   //detach and free runtime context
	soap_done(soap);                                                   // detach context (last use and no longer in scope)

    return result; 
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x140, %rsp            # imm = 0x140
movl $0x0, -0x4(%rbp)
movl %edi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl $0x0, -0x1c(%rbp)
movl $0x0, -0xc4(%rbp)
callq 0x230a0
movq %rax, -0x18(%rbp)
cmpq $0x0, -0x18(%rbp)
jne 0x34c6
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x3758
movq -0x18(%rbp), %rdi
leaq 0x40cff(%rip), %rsi     # 0x441d0
callq 0x27220
movq -0x18(%rbp), %rax
movl $0x5, 0x50(%rax)
movq -0x18(%rbp), %rdi
leaq -0xc0(%rbp), %rsi
callq 0x4020
leaq -0x130(%rbp), %rax
movq %rax, -0xc0(%rbp)
leaq 0x34afe(%rip), %rax     # 0x38004
movq %rax, -0x98(%rbp)
leaq 0x34b1d(%rip), %rax     # 0x38031
movq %rax, -0x90(%rbp)
movq -0x18(%rbp), %rax
leaq -0xc0(%rbp), %rcx
movq %rcx, 0xbf30(%rax)
movq -0x18(%rbp), %rdi
leaq -0x88(%rbp), %rsi
callq 0x13b00
leaq 0x364df(%rip), %rax     # 0x39a23
movq %rax, -0x88(%rbp)
movq -0x18(%rbp), %rdi
leaq -0x48(%rbp), %rsi
callq 0x13800
leaq -0x88(%rbp), %rax
movq %rax, -0x40(%rbp)
leaq 0x364b9(%rip), %rax     # 0x39a23
movq %rax, -0x48(%rbp)
movq -0x18(%rbp), %rdi
leaq 0x34af4(%rip), %rsi     # 0x3806d
xorl %eax, %eax
movl %eax, %edx
leaq -0x48(%rbp), %rcx
leaq -0x70(%rbp), %r8
callq 0x163b0
movq -0x18(%rbp), %rax
cmpl $0x0, 0x1f274(%rax)
je 0x35f3
movq -0x18(%rbp), %rax
movl 0x1f274(%rax), %eax
movl %eax, -0x13c(%rbp)
movq -0x18(%rbp), %rdi
callq 0x4550
movq (%rax), %rax
movq %rax, -0x138(%rbp)
movq -0x18(%rbp), %rdi
callq 0x4650
movl -0x13c(%rbp), %esi
movq -0x138(%rbp), %rdx
movq (%rax), %rcx
leaq 0x34abc(%rip), %rdi     # 0x38096
movb $0x0, %al
callq 0x3140
movq -0x18(%rbp), %rax
movl 0x1f274(%rax), %eax
movl %eax, -0x1c(%rbp)
jmp 0x372a
leaq 0x34ab4(%rip), %rdi     # 0x380ae
movb $0x0, %al
callq 0x3140
movq -0x18(%rbp), %rax
movq 0xbf30(%rax), %rax
cmpq $0x0, (%rax)
je 0x362e
movq -0x18(%rbp), %rax
movq 0xbf30(%rax), %rax
movq (%rax), %rsi
leaq 0x34ace(%rip), %rdi     # 0x380f5
movb $0x0, %al
callq 0x3140
movq -0x18(%rbp), %rax
movq 0xbf30(%rax), %rax
cmpq $0x0, 0x28(%rax)
je 0x365d
movq -0x18(%rbp), %rax
movq 0xbf30(%rax), %rax
movq 0x28(%rax), %rsi
leaq 0x34ab2(%rip), %rdi     # 0x38108
movb $0x0, %al
callq 0x3140
movq -0x18(%rbp), %rax
movq 0xbf30(%rax), %rax
cmpq $0x0, 0x30(%rax)
je 0x368c
movq -0x18(%rbp), %rax
movq 0xbf30(%rax), %rax
movq 0x30(%rax), %rsi
leaq 0x34a96(%rip), %rdi     # 0x3811b
movb $0x0, %al
callq 0x3140
leaq 0x34a1b(%rip), %rdi     # 0x380ae
movb $0x0, %al
callq 0x3140
movl -0x70(%rbp), %esi
leaq 0x34a8a(%rip), %rdi     # 0x3812e
movb $0x0, %al
callq 0x3140
movq -0x68(%rbp), %rax
movq (%rax), %rsi
leaq 0x34aa3(%rip), %rdi     # 0x3815c
movb $0x0, %al
callq 0x3140
movq -0x68(%rbp), %rax
movq 0x40(%rax), %rsi
leaq 0x34aac(%rip), %rdi     # 0x3817b
movb $0x0, %al
callq 0x3140
movq -0x68(%rbp), %rax
movq 0x50(%rax), %rsi
leaq 0x34ab5(%rip), %rdi     # 0x3819a
movb $0x0, %al
callq 0x3140
movq -0x68(%rbp), %rax
movl 0x58(%rax), %esi
leaq 0x34abf(%rip), %rdi     # 0x381b9
movb $0x0, %al
callq 0x3140
movq -0x68(%rbp), %rax
movq 0x48(%rax), %rax
movq (%rax), %rsi
leaq 0x34ac5(%rip), %rdi     # 0x381d8
movb $0x0, %al
callq 0x3140
leaq 0x3498d(%rip), %rdi     # 0x380ae
movb $0x0, %al
callq 0x3140
jmp 0x372a
movq -0x18(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x24be0
movq -0x18(%rbp), %rdi
callq 0x284d0
movq -0x18(%rbp), %rdi
callq 0x23100
movq -0x18(%rbp), %rdi
callq 0x1ed80
movl -0x1c(%rbp), %eax
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x140, %rsp            # imm = 0x140
popq %rbp
retq
nopw %cs:(%rax,%rax)
nop