// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
pushq %r14
pushq %rbx
subq $0x130, %rsp            # imm = 0x130
movq 0x18(%rbp), %rax
movl 0x10(%rbp), %eax
movq %rdi, -0x18(%rbp)
movq %rsi, -0x20(%rbp)
movq %rdx, -0x28(%rbp)
movq %rcx, -0x30(%rbp)
movq %r8, -0x38(%rbp)
movq %r9, -0x40(%rbp)
leaq -0xc0(%rbp), %rdi
xorl %esi, %esi
movl $0x80, %edx
callq 0x3190
leaq -0xc0(%rbp), %rdi
xorl %esi, %esi
movl $0x80, %edx
callq 0x3190
leaq -0xc0(%rbp), %rdi
movq -0x20(%rbp), %rcx
movl $0x80, %esi
leaq 0x76bd(%rip), %rdx      # 0x7c5a7
movb $0x0, %al
callq 0x3150
movq $0x0, -0xc8(%rbp)
movq $0x0, -0xd0(%rbp)
movq $0x0, -0xd8(%rbp)
movq $0x0, -0xe0(%rbp)
movq $0x0, -0xe8(%rbp)
movq -0x30(%rbp), %rax
movq %rax, -0xf0(%rbp)
movq -0x40(%rbp), %rax
movq %rax, -0xf8(%rbp)
movl $0x10, %edi
callq 0x3290
movq %rax, -0xc8(%rbp)
movl $0x10, %edi
callq 0x3290
movq %rax, -0xd0(%rbp)
movl $0x10, %edi
callq 0x3290
movq %rax, -0xd8(%rbp)
movl $0x10, %edi
callq 0x3290
movq %rax, -0xe0(%rbp)
movl $0x1000, %edi           # imm = 0x1000
callq 0x3290
movq %rax, %rcx
movq -0xc8(%rbp), %rax
movq %rcx, (%rax)
movl $0x1000, %edi           # imm = 0x1000
callq 0x3290
movq %rax, %rcx
movq -0xd0(%rbp), %rax
movq %rcx, (%rax)
movl $0x1000, %edi           # imm = 0x1000
callq 0x3290
movq %rax, %rcx
movq -0xd8(%rbp), %rax
movq %rcx, (%rax)
movl $0x8, %edi
callq 0x3290
movq %rax, %rcx
movq -0xe0(%rbp), %rax
movq %rcx, (%rax)
movl $0x0, -0xfc(%rbp)
movl $0x0, -0xfc(%rbp)
movl -0xfc(%rbp), %eax
cmpl 0x10(%rbp), %eax
jge 0x751c1
cmpq $0x0, -0xf0(%rbp)
je 0x751ab
movq -0xf0(%rbp), %rax
cmpq $0x0, (%rax)
je 0x751ab
cmpq $0x0, -0xf8(%rbp)
je 0x751ab
movq -0xf8(%rbp), %rax
cmpq $0x0, (%rax)
je 0x751ab
leaq 0x739a(%rip), %rdi      # 0x7c3e0
callq 0x33a0
movq %rax, %rdx
movq -0xc8(%rbp), %rax
movq (%rax), %rax
movslq -0xfc(%rbp), %rcx
movq %rdx, (%rax,%rcx,8)
movq -0x38(%rbp), %rdi
callq 0x33a0
movq %rax, %rdx
movq -0xd8(%rbp), %rax
movq (%rax), %rax
movslq -0xfc(%rbp), %rcx
movq %rdx, (%rax,%rcx,8)
movq -0xf0(%rbp), %rax
movq (%rax), %rdi
callq 0x33a0
movq %rax, %rdx
movq -0xd0(%rbp), %rax
movq (%rax), %rax
movslq -0xfc(%rbp), %rcx
movq %rdx, (%rax,%rcx,8)
movl $0x10, %edi
callq 0x3290
movq %rax, %rdx
movq -0xe0(%rbp), %rax
movq (%rax), %rax
movslq -0xfc(%rbp), %rcx
movq %rdx, (%rax,%rcx,8)
movl $0x1000, %edi           # imm = 0x1000
callq 0x3290
movq %rax, %rcx
movq -0xe0(%rbp), %rax
movq (%rax), %rax
movslq -0xfc(%rbp), %rdx
movq (%rax,%rdx,8), %rax
movq %rcx, (%rax)
movq -0xf8(%rbp), %rax
movq (%rax), %rdi
callq 0x33a0
movq %rax, %rcx
movq -0xe0(%rbp), %rax
movq (%rax), %rax
movslq -0xfc(%rbp), %rdx
movq (%rax,%rdx,8), %rax
movq (%rax), %rax
movq %rcx, (%rax)
movl -0xfc(%rbp), %ecx
addl $0x1, %ecx
movq -0xc8(%rbp), %rax
movl %ecx, 0x8(%rax)
movl -0xfc(%rbp), %ecx
addl $0x1, %ecx
movq -0xd8(%rbp), %rax
movl %ecx, 0x8(%rax)
movl -0xfc(%rbp), %ecx
addl $0x1, %ecx
movq -0xd0(%rbp), %rax
movl %ecx, 0x8(%rax)
movl -0xfc(%rbp), %ecx
addl $0x1, %ecx
movq -0xe0(%rbp), %rax
movl %ecx, 0x8(%rax)
movq -0xe0(%rbp), %rax
movq (%rax), %rax
movslq -0xfc(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movl $0x1, 0x8(%rax)
movq -0xf0(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0xf0(%rbp)
movq -0xf8(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0xf8(%rbp)
jmp 0x751ad
movl -0xfc(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xfc(%rbp)
jmp 0x74ff2
movq $0x0, -0x108(%rbp)
movl $0x8, %edi
callq 0x3290
movq %rax, -0x108(%rbp)
movq -0x18(%rbp), %rdi
movq -0x20(%rbp), %rsi
leaq -0xc0(%rbp), %rdx
movq -0x28(%rbp), %rcx
movq -0xc8(%rbp), %r8
movq -0xd0(%rbp), %r9
movq -0xd8(%rbp), %rbx
movq -0xe0(%rbp), %r11
movq -0xe8(%rbp), %r10
movq -0x108(%rbp), %rax
xorl %r14d, %r14d
movq %rbx, (%rsp)
movq %r11, 0x8(%rsp)
movq $0x0, 0x10(%rsp)
movq %r10, 0x18(%rsp)
movq %rax, 0x20(%rsp)
callq 0x71e90
movl %eax, -0x10c(%rbp)
cmpl $0x0, -0x10c(%rbp)
jne 0x7525b
leaq 0x7368(%rip), %rdi      # 0x7c5bc
movb $0x0, %al
callq 0x3140
movl $0x0, -0x110(%rbp)
movl $0x0, -0x110(%rbp)
movl -0x110(%rbp), %eax
cmpl 0x10(%rbp), %eax
jge 0x75471
movq -0xc8(%rbp), %rax
movq (%rax), %rax
movslq -0x110(%rbp), %rcx
cmpq $0x0, (%rax,%rcx,8)
je 0x752c9
movq -0xc8(%rbp), %rax
movq (%rax), %rax
movslq -0x110(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
callq 0x3030
movq -0xc8(%rbp), %rax
movq (%rax), %rax
movslq -0x110(%rbp), %rcx
movq $0x0, (%rax,%rcx,8)
movq -0xd8(%rbp), %rax
movq (%rax), %rax
movslq -0x110(%rbp), %rcx
cmpq $0x0, (%rax,%rcx,8)
je 0x75314
movq -0xd8(%rbp), %rax
movq (%rax), %rax
movslq -0x110(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
callq 0x3030
movq -0xd8(%rbp), %rax
movq (%rax), %rax
movslq -0x110(%rbp), %rcx
movq $0x0, (%rax,%rcx,8)
movq -0xd0(%rbp), %rax
movq (%rax), %rax
movslq -0x110(%rbp), %rcx
cmpq $0x0, (%rax,%rcx,8)
je 0x7535f
movq -0xd0(%rbp), %rax
movq (%rax), %rax
movslq -0x110(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
callq 0x3030
movq -0xd0(%rbp), %rax
movq (%rax), %rax
movslq -0x110(%rbp), %rcx
movq $0x0, (%rax,%rcx,8)
movq -0xe0(%rbp), %rax
movq (%rax), %rax
movslq -0x110(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq (%rax), %rax
cmpq $0x0, (%rax)
je 0x753bc
movq -0xe0(%rbp), %rax
movq (%rax), %rax
movslq -0x110(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq (%rax), %rax
movq (%rax), %rdi
callq 0x3030
movq -0xe0(%rbp), %rax
movq (%rax), %rax
movslq -0x110(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq (%rax), %rax
movq $0x0, (%rax)
movq -0xe0(%rbp), %rax
movq (%rax), %rax
movslq -0x110(%rbp), %rcx
movq (%rax,%rcx,8), %rax
cmpq $0x0, (%rax)
je 0x75410
movq -0xe0(%rbp), %rax
movq (%rax), %rax
movslq -0x110(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq (%rax), %rdi
callq 0x3030
movq -0xe0(%rbp), %rax
movq (%rax), %rax
movslq -0x110(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq $0x0, (%rax)
movq -0xe0(%rbp), %rax
movq (%rax), %rax
movslq -0x110(%rbp), %rcx
cmpq $0x0, (%rax,%rcx,8)
je 0x7545b
movq -0xe0(%rbp), %rax
movq (%rax), %rax
movslq -0x110(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
callq 0x3030
movq -0xe0(%rbp), %rax
movq (%rax), %rax
movslq -0x110(%rbp), %rcx
movq $0x0, (%rax,%rcx,8)
jmp 0x7545d
movl -0x110(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x110(%rbp)
jmp 0x7526f
movq -0xe0(%rbp), %rax
cmpq $0x0, (%rax)
je 0x7549b
movq -0xe0(%rbp), %rax
movq (%rax), %rdi
callq 0x3030
movq -0xe0(%rbp), %rax
movq $0x0, (%rax)
cmpq $0x0, -0xe0(%rbp)
je 0x754bc
movq -0xe0(%rbp), %rdi
callq 0x3030
movq $0x0, -0xe0(%rbp)
movq -0xd8(%rbp), %rax
cmpq $0x0, (%rax)
je 0x754e6
movq -0xd8(%rbp), %rax
movq (%rax), %rdi
callq 0x3030
movq -0xd8(%rbp), %rax
movq $0x0, (%rax)
cmpq $0x0, -0xd8(%rbp)
je 0x75507
movq -0xd8(%rbp), %rdi
callq 0x3030
movq $0x0, -0xd8(%rbp)
movq -0xd0(%rbp), %rax
cmpq $0x0, (%rax)
je 0x75531
movq -0xd0(%rbp), %rax
movq (%rax), %rdi
callq 0x3030
movq -0xd0(%rbp), %rax
movq $0x0, (%rax)
cmpq $0x0, -0xd0(%rbp)
je 0x75552
movq -0xd0(%rbp), %rdi
callq 0x3030
movq $0x0, -0xd0(%rbp)
movq -0xc8(%rbp), %rax
cmpq $0x0, (%rax)
je 0x7557c
movq -0xc8(%rbp), %rax
movq (%rax), %rdi
callq 0x3030
movq -0xc8(%rbp), %rax
movq $0x0, (%rax)
cmpq $0x0, -0xc8(%rbp)
je 0x7559d
movq -0xc8(%rbp), %rdi
callq 0x3030
movq $0x0, -0xc8(%rbp)
cmpq $0x0, -0x108(%rbp)
je 0x755be
movq -0x108(%rbp), %rdi
callq 0x3030
movq $0x0, -0x108(%rbp)
movl -0x10c(%rbp), %eax
addq $0x130, %rsp            # imm = 0x130
popq %rbx
popq %r14
popq %rbp
retq