// File: /workspace/github_c_makefile_star2_O2/loversmile[P]sugarcrm/sugar_function.c
// Function: setContactRelation
int setContactRelation(struct soap *soap, const char *soap_endpoint, char *session, char *contact_id, char *link_name, char *link_id, SGLinkReturn *link_return)
{
    char soap_action[128] = {0};
    memset(soap_action, 0, sizeof(soap_action));
    snprintf(soap_action, sizeof(soap_action), "%s/set_relationship", soap_endpoint);
    
    struct ns1__set_USCORErelationshipResponse *_param_6 = NULL;
    _param_6 = (struct ns1__set_USCORErelationshipResponse *)malloc(sizeof(struct ns1__set_USCORErelationshipResponse));
    
    struct select_USCOREfields *related_USCOREids = NULL;
    related_USCOREids = (struct select_USCOREfields *)malloc(sizeof(struct select_USCOREfields));
    related_USCOREids->__ptr = (char**)malloc(PTR_SIZE);
    related_USCOREids->__ptr[0] = strdup(link_id);
    related_USCOREids->__size = 1;
    
    int delete_ = 0;
    struct name_USCOREvalue_USCORElist *rel_name_value_list = NULL;
    /*rel_name_value_list = (struct name_USCOREvalue_USCORElist *)soap_malloc(soap, sizeof(struct name_USCOREvalue_USCORElist));
    rel_name_value_list->__ptr = (struct ns1__name_USCOREvalue**)soap_malloc(soap, PTR_SIZE);
    rel_name_value_list->__ptr[0] = (struct ns1__name_USCOREvalue*)soap_malloc(soap, sizeof(struct ns1__name_USCOREvalue));
    rel_name_value_list->__ptr[0]->name = strdup("contact_role");
    rel_name_value_list->__ptr[0]->value = strdup("Other");
    rel_name_value_list->__size = 1; */

    int ret = setRelationship(soap, soap_endpoint, soap_action, session, "Contacts", contact_id, link_name, related_USCOREids, 
                rel_name_value_list, delete_, _param_6);
    if (ret == SOAP_OK) {
        printf("Success setContactRelation!\n");
        link_return->created = _param_6->return_->created;
        link_return->failed = _param_6->return_->failed;
        link_return->deleted = _param_6->return_->deleted;
        //printf("created = %d\nfailed = %d\ndeleted = %d\n", 
        //        _param_6->return_->created, _param_6->return_->failed, _param_6->return_->deleted);
    } else {
        printf("ret = %d\n", ret);
        soap_print_fault(soap, stderr);
        //goto end;
    }
	int j = 0;
	for (j = 0; j < related_USCOREids->__size; j++)
	{
		SAFE_FREE(related_USCOREids->__ptr[j]);
	}
	SAFE_FREE(related_USCOREids->__ptr);
	SAFE_FREE(related_USCOREids);
	SAFE_FREE(_param_6);
    return ret;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xa8, %rsp
movq %r9, (%rsp)
movq %r8, 0x18(%rsp)
movq %rcx, 0x10(%rsp)
movq %rdx, 0x8(%rsp)
movq %rsi, %r12
movq %rdi, %r13
xorps %xmm0, %xmm0
leaq 0x20(%rsp), %r15
movaps %xmm0, 0x70(%r15)
movaps %xmm0, 0x60(%r15)
movaps %xmm0, 0x50(%r15)
movaps %xmm0, 0x40(%r15)
movaps %xmm0, 0x30(%r15)
movaps %xmm0, 0x20(%r15)
movaps %xmm0, 0x10(%r15)
movaps %xmm0, (%r15)
leaq 0x61bf(%rip), %rdx      # 0x4f178
movl $0x80, %esi
movq %r15, %rdi
movq %r12, %rcx
xorl %eax, %eax
callq 0x3150
pushq $0x8
popq %rdi
callq 0x3290
movq %rax, %rbp
pushq $0x10
popq %rdi
callq 0x3290
movq %rax, %r14
pushq $0x40
popq %rdi
callq 0x3290
movq %rax, %rbx
movq %rax, (%r14)
movq (%rsp), %rdi
callq 0x33a0
movq %rax, (%rbx)
movl $0x1, 0x8(%r14)
subq $0x8, %rsp
leaq 0x6049(%rip), %r8       # 0x4f057
movq %r13, %rdi
movq %r12, %rsi
movq %r15, %rdx
movq %rbp, %r15
movq 0x10(%rsp), %rcx
movq 0x18(%rsp), %r9
pushq %rbp
pushq $0x0
pushq $0x0
pushq %r14
pushq 0x40(%rsp)
callq 0x47aec
addq $0x30, %rsp
movl %eax, %ebp
testl %eax, %eax
je 0x49062
leaq 0x5d73(%rip), %rdi      # 0x4edb8
movl %ebp, %esi
xorl %eax, %eax
callq 0x3140
movq 0x26fa3(%rip), %rax     # 0x6fff8
movq (%rax), %rsi
movq %r13, %rdi
callq 0x460f9
jmp 0x49085
movq 0xe0(%rsp), %rbx
leaq 0x6260(%rip), %rdi      # 0x4f2d1
callq 0x30a0
movq (%r15), %rax
movq (%rax), %rcx
movq %rcx, (%rbx)
movl 0x8(%rax), %eax
movl %eax, 0x8(%rbx)
xorl %ebx, %ebx
movslq 0x8(%r14), %rax
movq (%r14), %rdi
cmpq %rax, %rbx
jge 0x490ae
movq (%rdi,%rbx,8), %rdi
testq %rdi, %rdi
je 0x490a9
callq 0x3030
movq (%r14), %rax
andq $0x0, (%rax,%rbx,8)
incq %rbx
jmp 0x49087
callq 0x3030
movq %r14, %rdi
callq 0x3030
movq %r15, %rdi
callq 0x3030
movl %ebp, %eax
addq $0xa8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq