// File: /workspace/github_c_makefile_star2_O1/loversmile[P]sugarcrm/sugar_function.c
// Function: setContactRelations
int setContactRelations(struct soap * soap,const char * soap_endpoint,char * session, SGContactsID *contacts_id, 
								char *link_name, SGLinksID *links_id, int num, SGLinkReturn *link_return)
{
	char soap_action[128] = {0};
    memset(soap_action, 0, sizeof(soap_action));
    snprintf(soap_action, sizeof(soap_action), "%s/set_relationships", soap_endpoint);
	struct select_USCOREfields *module_USCOREnames = NULL;
	struct select_USCOREfields *module_USCOREids = NULL;
	struct select_USCOREfields *link_USCOREfield_USCOREnames = NULL;
	struct new_USCOREset_USCORErelationhip_USCOREids *related_USCOREids = NULL;
	struct deleted_USCOREarray *delete_USCOREarray = NULL;
	SGContactsID *tmp_contacts_id = contacts_id;
	SGLinksID *tmp_links_id = links_id;
	module_USCOREnames = (struct select_USCOREfields *)malloc(sizeof(struct select_USCOREfields));
	module_USCOREids = (struct select_USCOREfields *)malloc(sizeof(struct select_USCOREfields));
	link_USCOREfield_USCOREnames = (struct select_USCOREfields *)malloc(sizeof(struct select_USCOREfields));
	related_USCOREids = (struct new_USCOREset_USCORErelationhip_USCOREids *)malloc(sizeof(struct new_USCOREset_USCORErelationhip_USCOREids));
	module_USCOREnames->__ptr =  (char **)malloc(PTR_SIZE * PTR_SIZE);
	module_USCOREids->__ptr = (char **)malloc(PTR_SIZE * PTR_SIZE);
	link_USCOREfield_USCOREnames->__ptr = (char **)malloc(PTR_SIZE * PTR_SIZE);
	related_USCOREids->__ptr = (struct select_USCOREfields **)malloc(sizeof(struct select_USCOREfields*));

	//related_USCOREids->__size = 1;
	
	int i = 0;

	for (i = 0; i < num; i++)
	{
		if (tmp_contacts_id && tmp_contacts_id->id &&
			tmp_links_id && tmp_links_id->id)
		{
			module_USCOREnames->__ptr[i] = strdup("Contacts");

			link_USCOREfield_USCOREnames->__ptr[i] = strdup(link_name);

			module_USCOREids->__ptr[i] = strdup(tmp_contacts_id->id);

			related_USCOREids->__ptr[i] = (struct select_USCOREfields *)malloc(sizeof(struct select_USCOREfields));
			related_USCOREids->__ptr[i]->__ptr = (char **)malloc(PTR_SIZE * PTR_SIZE);
			related_USCOREids->__ptr[i]->__ptr[0] = strdup(tmp_links_id->id);

			module_USCOREnames->__size = i + 1;
			link_USCOREfield_USCOREnames->__size = i + 1;
			module_USCOREids->__size = i + 1;
			related_USCOREids->__size = i + 1;
			related_USCOREids->__ptr[i]->__size = 1;
			tmp_contacts_id = tmp_contacts_id->next;
			tmp_links_id = tmp_links_id->next;
		}
	}

	struct ns1__set_USCORErelationshipsResponse *_param_7 = NULL;
	_param_7 = (struct ns1__set_USCORErelationshipsResponse *)malloc(sizeof(struct ns1__set_USCORErelationshipsResponse));
	int ret = setRelationships(soap, soap_endpoint, soap_action, session, module_USCOREnames,
				module_USCOREids, link_USCOREfield_USCOREnames, related_USCOREids,  NULL, 
				delete_USCOREarray, _param_7);
	if (ret == SOAP_OK)
	{
        printf("setContactRelations Success!!!!\n");
	}
	int j = 0;
	for (j = 0; j < num; j++)
	{
		SAFE_FREE(module_USCOREnames->__ptr[j]);
		SAFE_FREE(link_USCOREfield_USCOREnames->__ptr[j]);
		SAFE_FREE(module_USCOREids->__ptr[j]);
		SAFE_FREE(related_USCOREids->__ptr[j]->__ptr[0]);
		SAFE_FREE(related_USCOREids->__ptr[j]->__ptr);
		SAFE_FREE(related_USCOREids->__ptr[j]);
	}
	SAFE_FREE(related_USCOREids->__ptr);
	SAFE_FREE(related_USCOREids);
	SAFE_FREE(link_USCOREfield_USCOREnames->__ptr);
	SAFE_FREE(link_USCOREfield_USCOREnames);
	SAFE_FREE(module_USCOREids->__ptr);
	SAFE_FREE(module_USCOREids);
	SAFE_FREE(module_USCOREnames->__ptr);
	SAFE_FREE(module_USCOREnames);
	SAFE_FREE(_param_7);
	return ret;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xe8, %rsp
movq %r9, %r13
movq %r8, 0x58(%rsp)
movq %rcx, %rbp
movq %rdx, 0x50(%rsp)
movq %rsi, %rcx
movq %rdi, 0x40(%rsp)
xorps %xmm0, %xmm0
leaq 0x60(%rsp), %rdi
movaps %xmm0, 0x70(%rdi)
movaps %xmm0, 0x60(%rdi)
movaps %xmm0, 0x50(%rdi)
movaps %xmm0, 0x40(%rdi)
movaps %xmm0, 0x30(%rdi)
movaps %xmm0, 0x20(%rdi)
movaps %xmm0, 0x10(%rdi)
movaps %xmm0, (%rdi)
leaq 0x5b3a(%rip), %rdx      # 0x5418c
movl $0x80, %esi
movq %rcx, 0x48(%rsp)
xorl %eax, %eax
callq 0x3150
movl $0x10, %edi
callq 0x3280
movq %rax, %r15
movl $0x10, %edi
callq 0x3280
movq %rax, %rbx
movl $0x10, %edi
callq 0x3280
movq %rax, %r14
movl $0x10, %edi
callq 0x3280
movq %rax, %r12
movl $0x1000, %edi           # imm = 0x1000
callq 0x3280
movq %rax, (%r15)
movl $0x1000, %edi           # imm = 0x1000
callq 0x3280
movq %rbx, 0x28(%rsp)
movq %rax, (%rbx)
movq %r14, %rbx
movl $0x1000, %edi           # imm = 0x1000
callq 0x3280
movq %rax, (%r14)
movl $0x8, %edi
callq 0x3280
movq %rax, (%r12)
movl 0x120(%rsp), %ecx
movl %ecx, %eax
movq %rax, 0x38(%rsp)
testl %ecx, %ecx
movq %r14, 0x30(%rsp)
jle 0x4e7e8
xorl %r14d, %r14d
testq %rbp, %rbp
je 0x4e7d8
cmpq $0x0, (%rbp)
setne %al
testq %r13, %r13
setne %cl
andb %al, %cl
cmpb $0x1, %cl
jne 0x4e7da
movq %r13, %rdx
cmpq $0x0, (%r13)
je 0x4e7da
leaq 0x592e(%rip), %rdi      # 0x54057
movq %rdx, %r13
callq 0x3380
movq (%r15), %rcx
movq %rax, (%rcx,%r14,8)
movq 0x58(%rsp), %rdi
callq 0x3380
movq (%rbx), %rcx
movq %rax, (%rcx,%r14,8)
movq (%rbp), %rdi
callq 0x3380
movq 0x28(%rsp), %rcx
movq (%rcx), %rcx
movq %rax, (%rcx,%r14,8)
movl $0x10, %edi
callq 0x3280
movq (%r12), %rcx
movq %rax, (%rcx,%r14,8)
movl $0x1000, %edi           # imm = 0x1000
callq 0x3280
movq %r15, %rbx
movq (%r12), %r15
movq (%r15,%r14,8), %rcx
movq %rax, (%rcx)
movq (%r13), %rdi
callq 0x3380
movq (%r15,%r14,8), %rcx
movq %rbx, %r15
movq (%rcx), %rcx
movq %rax, (%rcx)
leal 0x1(%r14), %eax
movl %eax, 0x8(%rbx)
movq 0x30(%rsp), %rcx
movl %eax, 0x8(%rcx)
movq 0x28(%rsp), %rcx
movl %eax, 0x8(%rcx)
movq 0x30(%rsp), %rbx
movl %eax, 0x8(%r12)
movq (%r12), %rax
movq (%rax,%r14,8), %rax
movl $0x1, 0x8(%rax)
movq 0x8(%rbp), %rbp
movq 0x8(%r13), %r13
jmp 0x4e7da
xorl %ebp, %ebp
incq %r14
cmpq %r14, 0x38(%rsp)
jne 0x4e6f2
movl $0x8, %edi
callq 0x3280
movq %rax, %r13
movq %rax, 0x20(%rsp)
xorps %xmm0, %xmm0
movups %xmm0, 0x10(%rsp)
movq %r12, 0x8(%rsp)
movq %rbx, (%rsp)
leaq 0x60(%rsp), %rdx
movq 0x40(%rsp), %rdi
movq 0x48(%rsp), %rsi
movq 0x50(%rsp), %rcx
movq %r15, %r8
movq 0x28(%rsp), %r9
callq 0x34557
movl %eax, %ebp
testl %eax, %eax
jne 0x4e83e
leaq 0x5ab4(%rip), %rdi      # 0x542ed
callq 0x30a0
cmpl $0x0, 0x120(%rsp)
jle 0x4e927
xorl %r14d, %r14d
movq (%r15), %rax
movq (%rax,%r14,8), %rdi
testq %rdi, %rdi
je 0x4e86b
callq 0x3030
movq (%r15), %rax
movq $0x0, (%rax,%r14,8)
movq (%rbx), %rax
movq (%rax,%r14,8), %rdi
testq %rdi, %rdi
je 0x4e887
callq 0x3030
movq (%rbx), %rax
movq $0x0, (%rax,%r14,8)
movq 0x28(%rsp), %rbx
movq (%rbx), %rax
movq (%rax,%r14,8), %rdi
testq %rdi, %rdi
je 0x4e8a8
callq 0x3030
movq (%rbx), %rax
movq $0x0, (%rax,%r14,8)
movq (%r12), %rax
movq (%rax,%r14,8), %rax
movq (%rax), %rax
movq (%rax), %rdi
testq %rdi, %rdi
je 0x4e8d2
callq 0x3030
movq (%r12), %rax
movq (%rax,%r14,8), %rax
movq (%rax), %rax
movq $0x0, (%rax)
movq (%r12), %rax
movq (%rax,%r14,8), %rax
movq (%rax), %rdi
testq %rdi, %rdi
movq 0x30(%rsp), %rbx
je 0x4e8fb
callq 0x3030
movq (%r12), %rax
movq (%rax,%r14,8), %rax
movq $0x0, (%rax)
movq (%r12), %rax
movq (%rax,%r14,8), %rdi
testq %rdi, %rdi
je 0x4e919
callq 0x3030
movq (%r12), %rax
movq $0x0, (%rax,%r14,8)
incq %r14
cmpq %r14, 0x38(%rsp)
jne 0x4e84f
movq (%r12), %rdi
testq %rdi, %rdi
je 0x4e93d
callq 0x3030
movq $0x0, (%r12)
movq %r12, %rdi
callq 0x3030
movq (%rbx), %rdi
testq %rdi, %rdi
movq %rbx, %r14
movq 0x28(%rsp), %rbx
je 0x4e961
callq 0x3030
movq $0x0, (%r14)
movq %r14, %rdi
callq 0x3030
movq (%rbx), %rdi
testq %rdi, %rdi
je 0x4e97d
callq 0x3030
movq $0x0, (%rbx)
movq %rbx, %rdi
callq 0x3030
movq (%r15), %rdi
testq %rdi, %rdi
je 0x4e999
callq 0x3030
movq $0x0, (%r15)
movq %r15, %rdi
callq 0x3030
testq %r13, %r13
je 0x4e9ae
movq %r13, %rdi
callq 0x3030
movl %ebp, %eax
addq $0xe8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq