// File: /workspace/github_c_makefile_star2_O1/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, 0x8(%rsp)
movq %r8, 0x18(%rsp)
movq %rcx, %r13
movq %rdx, 0x10(%rsp)
movq %rsi, %r12
movq %rdi, (%rsp)
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 0x5cd5(%rip), %rdx      # 0x54178
movl $0x80, %esi
movq %r15, %rdi
movq %r12, %rcx
xorl %eax, %eax
callq 0x3150
movl $0x8, %edi
callq 0x3280
movq %rax, %rbp
movl $0x10, %edi
callq 0x3280
movq %rax, %r14
movl $0x40, %edi
callq 0x3280
movq %rax, %rbx
movq %rax, (%r14)
movq 0x8(%rsp), %rdi
callq 0x3380
movq %rax, (%rbx)
movq (%rsp), %rbx
movl $0x1, 0x8(%r14)
leaq 0x5acd(%rip), %rdi      # 0x53fcc
movq %r13, %rsi
xorl %eax, %eax
callq 0x3140
subq $0x8, %rsp
leaq 0x5b43(%rip), %r8       # 0x54057
movq %rbx, %rdi
movq %r12, %rsi
movq %r15, %rdx
movq %rbp, %r15
movq 0x18(%rsp), %rcx
movq %r13, %r9
pushq %rbp
pushq $0x0
pushq $0x0
pushq %r14
pushq 0x40(%rsp)
callq 0x342e7
addq $0x30, %rsp
movl %eax, %ebp
testl %eax, %eax
je 0x4e566
leaq 0x586f(%rip), %rdi      # 0x53db8
movl %ebp, %esi
xorl %eax, %eax
callq 0x3140
movq 0x23a9f(%rip), %rax     # 0x71ff8
movq (%rax), %rsi
movq %rbx, %rdi
callq 0x4b1d6
jmp 0x4e58d
movq 0xe0(%rsp), %rbx
leaq 0x5d5c(%rip), %rdi      # 0x542d1
callq 0x30a0
movq (%r15), %rax
movl (%rax), %ecx
movl %ecx, (%rbx)
movl 0x4(%rax), %ecx
movl %ecx, 0x4(%rbx)
movl 0x8(%rax), %eax
movl %eax, 0x8(%rbx)
cmpl $0x0, 0x8(%r14)
jle 0x4e5be
xorl %ebx, %ebx
movq (%r14), %rax
movq (%rax,%rbx,8), %rdi
testq %rdi, %rdi
je 0x4e5b2
callq 0x3030
movq (%r14), %rax
movq $0x0, (%rax,%rbx,8)
incq %rbx
movslq 0x8(%r14), %rax
cmpq %rax, %rbx
jl 0x4e596
movq (%r14), %rdi
testq %rdi, %rdi
je 0x4e5d2
callq 0x3030
movq $0x0, (%r14)
movq %r14, %rdi
callq 0x3030
testq %r15, %r15
je 0x4e5e7
movq %r15, %rdi
callq 0x3030
movl %ebp, %eax
addq $0xa8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq