// File: /workspace/github_c_makefile_star2_O2/loversmile[P]sugarcrm/sugar_function.c
// Function: setCall
int setCall(struct soap *soap, const char *soap_endpoint, char *session, char *call_id, SGCallItem *call_item, char **return_id)
{
    /* call_id if NULL, added new , if not NULL, update*/
    char soap_action[128] = {0};
    memset(soap_action, 0, sizeof(soap_action));
    snprintf(soap_action, sizeof(soap_action), "%s/set_entry", soap_endpoint);
    
    struct name_USCOREvalue_USCORElist *setEntry_name_value_list = NULL;
    struct ns1__set_USCOREentryResponse *_param_9 = NULL;
    setEntry_name_value_list = (struct name_USCOREvalue_USCORElist *)malloc(sizeof(struct name_USCOREvalue_USCORElist));
    _param_9 = (struct ns1__set_USCOREentryResponse *)malloc(sizeof(struct ns1__set_USCOREentryResponse));
    int item = 0;
    setEntry_name_value_list->__ptr = (struct ns1__name_USCOREvalue**)malloc(PTR_SIZE);
    setEntry_name_value_list->__ptr[item] = (struct ns1__name_USCOREvalue*)malloc(sizeof(struct ns1__name_USCOREvalue));
    setEntry_name_value_list->__ptr[item]->name = strdup("name");
    setEntry_name_value_list->__ptr[item++]->value = strdup(call_item->name ? call_item->name : "");
    setEntry_name_value_list->__ptr[item] = (struct ns1__name_USCOREvalue*)malloc(sizeof(struct ns1__name_USCOREvalue));
    setEntry_name_value_list->__ptr[item]->name = strdup("parent_type");
    setEntry_name_value_list->__ptr[item++]->value = strdup(call_item->parent_type ? call_item->parent_type : "");
    setEntry_name_value_list->__ptr[item] = (struct ns1__name_USCOREvalue*)malloc(sizeof(struct ns1__name_USCOREvalue));
    setEntry_name_value_list->__ptr[item]->name = strdup("parent_id");
    setEntry_name_value_list->__ptr[item++]->value = strdup(call_item->parent_id ? call_item->parent_id : "");
    setEntry_name_value_list->__ptr[item] = (struct ns1__name_USCOREvalue*)malloc(sizeof(struct ns1__name_USCOREvalue));
    setEntry_name_value_list->__ptr[item]->name = strdup("direction");
    setEntry_name_value_list->__ptr[item++]->value = strdup(call_item->direction ? call_item->direction : "");  
    setEntry_name_value_list->__ptr[item] = (struct ns1__name_USCOREvalue*)malloc(sizeof(struct ns1__name_USCOREvalue));
    setEntry_name_value_list->__ptr[item]->name = strdup("description");
    setEntry_name_value_list->__ptr[item++]->value = strdup(call_item->description ? call_item->description : "");
    setEntry_name_value_list->__ptr[item] = (struct ns1__name_USCOREvalue*)malloc(sizeof(struct ns1__name_USCOREvalue));
    setEntry_name_value_list->__ptr[item]->name = strdup("duration_minutes");
    setEntry_name_value_list->__ptr[item++]->value = strdup(call_item->duration_minutes ? call_item->duration_minutes : "");
    setEntry_name_value_list->__ptr[item] = (struct ns1__name_USCOREvalue*)malloc(sizeof(struct ns1__name_USCOREvalue));
    setEntry_name_value_list->__ptr[item]->name = strdup("duration_hours");
    setEntry_name_value_list->__ptr[item++]->value = strdup(call_item->duration_hours ? call_item->duration_hours : "");
    setEntry_name_value_list->__ptr[item] = (struct ns1__name_USCOREvalue*)malloc(sizeof(struct ns1__name_USCOREvalue));
    setEntry_name_value_list->__ptr[item]->name = strdup("date_start");
    setEntry_name_value_list->__ptr[item++]->value = strdup(call_item->date_start ? call_item->date_start : "");
    setEntry_name_value_list->__ptr[item] = (struct ns1__name_USCOREvalue*)malloc(sizeof(struct ns1__name_USCOREvalue));
    setEntry_name_value_list->__ptr[item]->name = strdup("assigned_user_id");
    setEntry_name_value_list->__ptr[item++]->value = strdup(call_item->assigned_user_id ? call_item->assigned_user_id : "");
    if (call_id != NULL && strlen(call_id) > 0) {
        setEntry_name_value_list->__ptr[item] = (struct ns1__name_USCOREvalue*)malloc(sizeof(struct ns1__name_USCOREvalue));
        setEntry_name_value_list->__ptr[item]->name = strdup("id");
        setEntry_name_value_list->__ptr[item++]->value = strdup(call_id);
    } 
    setEntry_name_value_list->__size = item;
    
    int ret = setEntry(soap, soap_endpoint, soap_action, session, "Calls", setEntry_name_value_list, _param_9);
        printf("8*****\n");
    if (ret == SOAP_OK) {
        printf("Success setEntry!\n");
        //snprintf(set_entry_res_id, sizeof(set_entry_res_id), "%s\0\n", _param_9->return_->id);
        *return_id = strdup(_param_9->return_->id);
    } else {
        printf("ret = %d\n", ret);
        soap_print_fault(soap, stderr);
        //goto end;
    }
    int j = 0;
	for(j = 0; j < item; j++)
	{
		SAFE_FREE(setEntry_name_value_list->__ptr[j]->name);
		SAFE_FREE(setEntry_name_value_list->__ptr[j]->value);
		SAFE_FREE(setEntry_name_value_list->__ptr[j]);
	}
	SAFE_FREE(setEntry_name_value_list->__ptr);
	SAFE_FREE(setEntry_name_value_list);
    SAFE_FREE(_param_9);
    return ret;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xc8, %rsp
movq %r9, 0x10(%rsp)
movq %r8, %r13
movq %rcx, 0x18(%rsp)
movq %rdx, 0x28(%rsp)
movq %rsi, %rcx
movq %rdi, 0x30(%rsp)
xorps %xmm0, %xmm0
leaq 0x40(%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 0x6c70(%rip), %rdx      # 0x4f0f7
movl $0x80, %esi
movq %rcx, 0x20(%rsp)
xorl %eax, %eax
callq 0x3150
pushq $0x10
popq %r14
movq %r14, %rdi
callq 0x3290
movq %rax, %rbx
pushq $0x8
popq %rdi
callq 0x3290
movq %rax, 0x38(%rsp)
pushq $0x40
popq %rdi
callq 0x3290
movq %rax, %r12
movq %rax, (%rbx)
movq %r14, %rdi
callq 0x3290
movq %rax, %rbp
movq %rax, (%r12)
leaq 0x412b(%rip), %rdi      # 0x4c603
callq 0x33a0
movq %rax, (%rbp)
movq (%r13), %rdi
testq %rdi, %rdi
leaq 0x5243(%rip), %r15      # 0x4d732
cmoveq %r15, %rdi
callq 0x33a0
movq %rax, 0x8(%rbp)
movq %r14, %rdi
callq 0x3290
movq %rax, %rbp
movq %rax, 0x8(%r12)
leaq 0x6bf1(%rip), %rdi      # 0x4f104
callq 0x33a0
movq %rax, (%rbp)
movq 0x8(%r13), %rdi
testq %rdi, %rdi
cmoveq %r15, %rdi
callq 0x33a0
movq %rax, 0x8(%rbp)
movq %r14, %rdi
callq 0x3290
movq %rax, %rbp
movq %rax, 0x10(%r12)
leaq 0x6bc9(%rip), %rdi      # 0x4f110
callq 0x33a0
movq %rax, (%rbp)
movq 0x10(%r13), %rdi
testq %rdi, %rdi
cmoveq %r15, %rdi
callq 0x33a0
movq %rax, 0x8(%rbp)
movq %r14, %rdi
callq 0x3290
movq %rax, %rbp
movq %rax, 0x18(%r12)
leaq 0x6b9f(%rip), %rdi      # 0x4f11a
callq 0x33a0
movq %rax, (%rbp)
movq 0x18(%r13), %rdi
testq %rdi, %rdi
cmoveq %r15, %rdi
callq 0x33a0
movq %rax, 0x8(%rbp)
movq %r14, %rdi
callq 0x3290
movq %rax, %rbp
movq %rax, 0x20(%r12)
leaq 0x4141(%rip), %rdi      # 0x4c6f0
callq 0x33a0
movq %rax, (%rbp)
movq 0x20(%r13), %rdi
testq %rdi, %rdi
cmoveq %r15, %rdi
callq 0x33a0
movq %rax, 0x8(%rbp)
movq %r14, %rdi
callq 0x3290
movq %rax, %rbp
movq %rax, 0x28(%r12)
leaq 0x6b41(%rip), %rdi      # 0x4f124
callq 0x33a0
movq %rax, (%rbp)
movq 0x28(%r13), %rdi
testq %rdi, %rdi
cmoveq %r15, %rdi
callq 0x33a0
movq %rax, 0x8(%rbp)
movq %r14, %rdi
callq 0x3290
movq %rax, %rbp
movq %rax, 0x30(%r12)
leaq 0x6b1e(%rip), %rdi      # 0x4f135
callq 0x33a0
movq %rax, (%rbp)
movq 0x30(%r13), %rdi
testq %rdi, %rdi
cmoveq %r15, %rdi
callq 0x33a0
movq %rax, 0x8(%rbp)
movq %r14, %rdi
callq 0x3290
movq %rax, %rbp
movq %rax, 0x38(%r12)
leaq 0x6a44(%rip), %rdi      # 0x4f08f
callq 0x33a0
movq %rax, (%rbp)
movq 0x38(%r13), %rdi
testq %rdi, %rdi
cmoveq %r15, %rdi
callq 0x33a0
movq %rax, 0x8(%rbp)
movq %r14, %rdi
callq 0x3290
movq %rax, %r14
movq %rax, 0x40(%r12)
leaq 0x3f24(%rip), %rdi      # 0x4c5a3
callq 0x33a0
movq %rax, (%r14)
movq 0x40(%r13), %rdi
testq %rdi, %rdi
cmoveq %r15, %rdi
movq 0x18(%rsp), %r15
callq 0x33a0
movq %rax, 0x8(%r14)
pushq $0x9
popq %r14
testq %r15, %r15
je 0x486de
cmpb $0x0, (%r15)
je 0x486de
pushq $0x10
popq %rdi
callq 0x3290
movq %rax, %r14
movq %rax, 0x48(%r12)
leaq 0x4184(%rip), %rdi      # 0x4c84a
callq 0x33a0
movq %rax, (%r14)
movq %r15, %rdi
callq 0x33a0
movq %rax, 0x8(%r14)
pushq $0xa
popq %r14
movl %r14d, 0x8(%rbx)
movq 0x38(%rsp), %r12
movq %r12, (%rsp)
leaq 0x6997(%rip), %r8       # 0x4f089
leaq 0x40(%rsp), %rdx
movq 0x30(%rsp), %r15
movq %r15, %rdi
movq 0x20(%rsp), %rsi
movq 0x28(%rsp), %rcx
movq %rbx, %r9
callq 0x31b6e
movl %eax, %ebp
leaq 0x6bf3(%rip), %rdi      # 0x4f30d
callq 0x30a0
testl %ebp, %ebp
je 0x48747
leaq 0x668e(%rip), %rdi      # 0x4edb8
movl %ebp, %esi
xorl %eax, %eax
callq 0x3140
movq 0x278be(%rip), %rax     # 0x6fff8
movq (%rax), %rsi
movq %r15, %rdi
callq 0x460f9
jmp 0x48767
leaq 0x6b58(%rip), %rdi      # 0x4f2a6
callq 0x30a0
movq (%r12), %rax
movq (%rax), %rdi
callq 0x33a0
movq 0x10(%rsp), %rcx
movq %rax, (%rcx)
movl %r14d, %r14d
xorl %r15d, %r15d
movq (%rbx), %rdi
cmpq %r15, %r14
je 0x487d0
movq (%rdi,%r15,8), %rdi
movq (%rdi), %rax
testq %rax, %rax
je 0x48798
movq %rax, %rdi
callq 0x3030
movq (%rbx), %rax
movq (%rax,%r15,8), %rcx
andq $0x0, (%rcx)
movq (%rax,%r15,8), %rdi
movq 0x8(%rdi), %rax
testq %rax, %rax
je 0x487be
movq %rax, %rdi
callq 0x3030
movq (%rbx), %rax
movq (%rax,%r15,8), %rcx
andq $0x0, 0x8(%rcx)
movq (%rax,%r15,8), %rdi
testq %rdi, %rdi
je 0x487cb
callq 0x3030
movq (%rbx), %rax
andq $0x0, (%rax,%r15,8)
incq %r15
jmp 0x4876d
callq 0x3030
movq %rbx, %rdi
callq 0x3030
movq %r12, %rdi
callq 0x3030
movl %ebp, %eax
addq $0xc8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq