// File: /workspace/github_c_makefile_star2_O3/loversmile[P]sugarcrm/sugar_function.c
// Function: setCalls
int setCalls(struct soap *soap, const char *soap_endpoint, char *session, SGCallsItem *calls_item, SGReturnCallsID *return_calls_id)
{
    char soap_action[128] = {0};
    memset(soap_action, 0, sizeof(soap_action));
    snprintf(soap_action, sizeof(soap_action), "%s/set_entries", soap_endpoint);
    
    //struct name_USCOREvalue_USCORElist *setEntry_name_value_list = NULL;
    struct name_USCOREvalue_USCORElists *setEntries_name_value_lists = NULL;
    //struct ns1__set_USCOREentryResponse *_param_9 = NULL;
    struct ns1__set_USCOREentriesResponse *_param_10 = NULL;
    setEntries_name_value_lists = (struct name_USCOREvalue_USCORElists *)malloc(sizeof(struct name_USCOREvalue_USCORElists));
    //setEntry_name_value_list = (struct name_USCOREvalue_USCORElist *)soap_malloc(soap, sizeof(struct name_USCOREvalue_USCORElist));
    _param_10 = (struct ns1__set_USCOREentriesResponse *)malloc(sizeof(struct ns1__set_USCOREentriesResponse));
	setEntries_name_value_lists->__ptr = (struct name_USCOREvalue_USCORElist **)malloc(PTR_SIZE * PTR_SIZE);
    SGCallsItem *calls_tmp = calls_item;
    //struct call_item *tmp = NULL;
    //for (calls_tmp = NULL; tmp = calls_tmp->call_item; tmp = calls_tmp)
    int items = 0;
	int item = 0;
    while(calls_tmp) {
        calls_tmp = calls_tmp->next;
        item = 0;
        setEntries_name_value_lists->__ptr[items]->__ptr = (struct ns1__name_USCOREvalue**)malloc(PTR_SIZE);
        setEntries_name_value_lists->__ptr[items]->__ptr[item] = (struct ns1__name_USCOREvalue*)malloc(sizeof(struct ns1__name_USCOREvalue));
        setEntries_name_value_lists->__ptr[items]->__ptr[item]->name = strdup("name");
        setEntries_name_value_lists->__ptr[items]->__ptr[item++]->value = strdup(calls_tmp->call_item->name ? calls_tmp->call_item->name : "");
        setEntries_name_value_lists->__ptr[items]->__ptr[item] = (struct ns1__name_USCOREvalue*)malloc(sizeof(struct ns1__name_USCOREvalue));
        setEntries_name_value_lists->__ptr[items]->__ptr[item]->name = strdup("parent_type");
        setEntries_name_value_lists->__ptr[items]->__ptr[item++]->value = strdup(calls_tmp->call_item->parent_type ? calls_tmp->call_item->parent_type : "");
        setEntries_name_value_lists->__ptr[items]->__ptr[item] = (struct ns1__name_USCOREvalue*)malloc(sizeof(struct ns1__name_USCOREvalue));
        setEntries_name_value_lists->__ptr[items]->__ptr[item]->name = strdup("parent_id");
        setEntries_name_value_lists->__ptr[items]->__ptr[item++]->value = strdup(calls_tmp->call_item->parent_id ? calls_tmp->call_item->parent_id : "");
        setEntries_name_value_lists->__ptr[items]->__ptr[item] = (struct ns1__name_USCOREvalue*)malloc(sizeof(struct ns1__name_USCOREvalue));
        setEntries_name_value_lists->__ptr[items]->__ptr[item]->name = strdup("direction");
        setEntries_name_value_lists->__ptr[items]->__ptr[item++]->value = strdup(calls_tmp->call_item->direction ? calls_tmp->call_item->direction : "");  
        setEntries_name_value_lists->__ptr[items]->__ptr[item] = (struct ns1__name_USCOREvalue*)malloc(sizeof(struct ns1__name_USCOREvalue));
        setEntries_name_value_lists->__ptr[items]->__ptr[item]->name = strdup("description");
        setEntries_name_value_lists->__ptr[items]->__ptr[item++]->value = strdup(calls_tmp->call_item->description ? calls_tmp->call_item->description : "");
        setEntries_name_value_lists->__ptr[items]->__ptr[item] = (struct ns1__name_USCOREvalue*)malloc(sizeof(struct ns1__name_USCOREvalue));
        setEntries_name_value_lists->__ptr[items]->__ptr[item]->name = strdup("duration_minutes");
        setEntries_name_value_lists->__ptr[items]->__ptr[item++]->value = strdup(calls_tmp->call_item->duration_minutes ? calls_tmp->call_item->duration_minutes : "");
        setEntries_name_value_lists->__ptr[items]->__ptr[item] = (struct ns1__name_USCOREvalue*)malloc(sizeof(struct ns1__name_USCOREvalue));
        setEntries_name_value_lists->__ptr[items]->__ptr[item]->name = strdup("duration_hours");
        setEntries_name_value_lists->__ptr[items]->__ptr[item++]->value = strdup(calls_tmp->call_item->duration_hours ? calls_tmp->call_item->duration_hours : "");
        setEntries_name_value_lists->__ptr[items]->__ptr[item] = (struct ns1__name_USCOREvalue*)malloc(sizeof(struct ns1__name_USCOREvalue));
        setEntries_name_value_lists->__ptr[items]->__ptr[item]->name = strdup("date_start");
        setEntries_name_value_lists->__ptr[items]->__ptr[item++]->value = strdup(calls_tmp->call_item->date_start ? calls_tmp->call_item->date_start : "");
        setEntries_name_value_lists->__ptr[items]->__ptr[item] = (struct ns1__name_USCOREvalue*)malloc(sizeof(struct ns1__name_USCOREvalue));
        setEntries_name_value_lists->__ptr[items]->__ptr[item]->name = strdup("assigned_user_id");
        setEntries_name_value_lists->__ptr[items]->__ptr[item++]->value = strdup(calls_tmp->call_item->assigned_user_id ? calls_tmp->call_item->assigned_user_id : "");
        if (calls_tmp->call_id != NULL && strlen(calls_tmp->call_id) > 0) {
            setEntries_name_value_lists->__ptr[items]->__ptr[item] = (struct ns1__name_USCOREvalue*)malloc(sizeof(struct ns1__name_USCOREvalue));
            setEntries_name_value_lists->__ptr[items]->__ptr[item]->name = strdup("id");
            setEntries_name_value_lists->__ptr[items]->__ptr[item++]->value = strdup(calls_tmp->call_id);
        } 
        setEntries_name_value_lists->__ptr[items]->__size = item;
        items++;
    }
    
    
    int ret = setEntries(soap, soap_endpoint, soap_action, session, "Calls", setEntries_name_value_lists, _param_10);
    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_10->return_->ids->__ptr);
        SGReturnCallsID *tmp_return_calls_id = return_calls_id;
        for (int i = 0; i < _param_10->return_->ids->__size; i++) {
            printf("_param_10->return_->ids->__ptr = %s\n", _param_10->return_->ids->__ptr[i]);
			tmp_return_calls_id = initSGReturnCallsID(tmp_return_calls_id);
			tmp_return_calls_id->return_call_id = strdup(_param_10->return_->ids->__ptr[i]);
			tmp_return_calls_id = tmp_return_calls_id->next;
        }
    } else {
        printf("ret = %d\n", ret);
        soap_print_fault(soap, stderr);
        //goto end;
    }
    int j = 0, k = 0;
	for (j = 0; j < items; j++)
	{
		for(k = 0; k < item; k++)
		{
			SAFE_FREE(setEntries_name_value_lists->__ptr[j]->__ptr[k]->name);
			SAFE_FREE(setEntries_name_value_lists->__ptr[j]->__ptr[k]->value);
			SAFE_FREE(setEntries_name_value_lists->__ptr[j]->__ptr[k]);
		}
		SAFE_FREE(setEntries_name_value_lists->__ptr[j]->__ptr);
		SAFE_FREE(setEntries_name_value_lists->__ptr[j]);
	}
	SAFE_FREE(setEntries_name_value_lists->__ptr);
	SAFE_FREE(setEntries_name_value_lists);
	SAFE_FREE(_param_10);
    return ret;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x98, %rsp
movq %rcx, %r14
movq %rdx, 0x8(%rsp)
movq %rsi, %r13
movq %rdi, %rbp
xorps %xmm0, %xmm0
leaq 0x10(%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 0x684c(%rip), %rdx      # 0x54144
movl $0x80, %esi
movq %r13, %rcx
xorl %eax, %eax
callq 0x3150
movl $0x10, %edi
callq 0x3290
movq %rax, %rbx
movl $0x8, %edi
callq 0x3290
movq %rax, %r15
movl $0x1000, %edi           # imm = 0x1000
callq 0x3290
movq %rax, (%rbx)
testq %r14, %r14
je 0x4dcaf
movq %rax, %r12
xorl %r13d, %r13d
leaq 0x4dee(%rip), %rbp      # 0x52732
movq 0x10(%r14), %r14
movl $0x40, %edi
callq 0x3290
movq (%r12,%r13), %rcx
movq %rax, (%rcx)
movl $0x10, %edi
callq 0x3290
movq (%r12,%r13), %rcx
movq (%rcx), %rcx
movq %rax, (%rcx)
leaq 0x3c8f(%rip), %rdi      # 0x51603
callq 0x3390
movq (%r12,%r13), %rcx
movq (%rcx), %rcx
movq (%rcx), %rcx
movq %rax, (%rcx)
movq 0x8(%r14), %rax
movq (%rax), %rdi
testq %rdi, %rdi
cmoveq %rbp, %rdi
callq 0x3390
movq (%r12,%r13), %rcx
movq (%rcx), %rcx
movq (%rcx), %rcx
movq %rax, 0x8(%rcx)
movl $0x10, %edi
callq 0x3290
movq (%r12,%r13), %rcx
movq (%rcx), %rcx
movq %rax, 0x8(%rcx)
leaq 0x6741(%rip), %rdi      # 0x54104
callq 0x3390
movq (%r12,%r13), %rcx
movq (%rcx), %rcx
movq 0x8(%rcx), %rcx
movq %rax, (%rcx)
movq 0x8(%r14), %rax
movq 0x8(%rax), %rdi
testq %rdi, %rdi
cmoveq %rbp, %rdi
callq 0x3390
movq (%r12,%r13), %rcx
movq (%rcx), %rcx
movq 0x8(%rcx), %rcx
movq %rax, 0x8(%rcx)
movl $0x10, %edi
callq 0x3290
movq (%r12,%r13), %rcx
movq (%rcx), %rcx
movq %rax, 0x10(%rcx)
leaq 0x66fb(%rip), %rdi      # 0x54110
callq 0x3390
movq (%r12,%r13), %rcx
movq (%rcx), %rcx
movq 0x10(%rcx), %rcx
movq %rax, (%rcx)
movq 0x8(%r14), %rax
movq 0x10(%rax), %rdi
testq %rdi, %rdi
cmoveq %rbp, %rdi
callq 0x3390
movq (%r12,%r13), %rcx
movq (%rcx), %rcx
movq 0x10(%rcx), %rcx
movq %rax, 0x8(%rcx)
movl $0x10, %edi
callq 0x3290
movq (%r12,%r13), %rcx
movq (%rcx), %rcx
movq %rax, 0x18(%rcx)
leaq 0x66b3(%rip), %rdi      # 0x5411a
callq 0x3390
movq (%r12,%r13), %rcx
movq (%rcx), %rcx
movq 0x18(%rcx), %rcx
movq %rax, (%rcx)
movq 0x8(%r14), %rax
movq 0x18(%rax), %rdi
testq %rdi, %rdi
cmoveq %rbp, %rdi
callq 0x3390
movq (%r12,%r13), %rcx
movq (%rcx), %rcx
movq 0x18(%rcx), %rcx
movq %rax, 0x8(%rcx)
movl $0x10, %edi
callq 0x3290
movq (%r12,%r13), %rcx
movq (%rcx), %rcx
movq %rax, 0x20(%rcx)
leaq 0x3c37(%rip), %rdi      # 0x516f0
callq 0x3390
movq (%rbx), %r15
movq (%r15,%r13), %rcx
movq (%rcx), %rcx
movq 0x20(%rcx), %rcx
movq %rax, (%rcx)
movq 0x8(%r14), %rax
movq 0x20(%rax), %rdi
testq %rdi, %rdi
cmoveq %rbp, %rdi
callq 0x3390
movq (%r15,%r13), %rcx
movq (%rcx), %rcx
movq 0x20(%rcx), %rcx
movq %rax, 0x8(%rcx)
movl $0x10, %edi
callq 0x3290
movq (%r15,%r13), %rcx
movq (%rcx), %rcx
movq %rax, 0x28(%rcx)
leaq 0x6616(%rip), %rdi      # 0x54124
callq 0x3390
movq (%r15,%r13), %rcx
movq (%rcx), %rcx
movq 0x28(%rcx), %rcx
movq %rax, (%rcx)
movq 0x8(%r14), %rax
movq 0x28(%rax), %rdi
testq %rdi, %rdi
cmoveq %rbp, %rdi
callq 0x3390
movq (%r15,%r13), %rcx
movq (%rcx), %rcx
movq 0x28(%rcx), %rcx
movq %rax, 0x8(%rcx)
movl $0x10, %edi
callq 0x3290
movq (%r15,%r13), %rcx
movq (%rcx), %rcx
movq %rax, 0x30(%rcx)
leaq 0x65d5(%rip), %rdi      # 0x54135
callq 0x3390
movq (%r15,%r13), %rcx
movq (%rcx), %rcx
movq 0x30(%rcx), %rcx
movq %rax, (%rcx)
movq 0x8(%r14), %rax
movq 0x30(%rax), %rdi
testq %rdi, %rdi
cmoveq %rbp, %rdi
callq 0x3390
movq (%r15,%r13), %rcx
movq (%rcx), %rcx
movq 0x30(%rcx), %rcx
movq %rax, 0x8(%rcx)
movl $0x10, %edi
callq 0x3290
movq (%r15,%r13), %rcx
movq (%rcx), %rcx
movq %rax, 0x38(%rcx)
leaq 0x64dd(%rip), %rdi      # 0x5408f
callq 0x3390
movq (%r15,%r13), %rcx
movq (%rcx), %rcx
movq 0x38(%rcx), %rcx
movq %rax, (%rcx)
movq 0x8(%r14), %rax
movq 0x38(%rax), %rdi
testq %rdi, %rdi
cmoveq %rbp, %rdi
callq 0x3390
movq (%r15,%r13), %rcx
movq (%rcx), %rcx
movq 0x38(%rcx), %rcx
movq %rax, 0x8(%rcx)
movl $0x10, %edi
callq 0x3290
movq (%r15,%r13), %rcx
movq (%rcx), %rcx
movq %rax, 0x40(%rcx)
leaq 0x399f(%rip), %rdi      # 0x515a3
callq 0x3390
movq (%r15,%r13), %rcx
movq (%rcx), %rcx
movq 0x40(%rcx), %rcx
movq %rax, (%rcx)
movq 0x8(%r14), %rax
movq 0x40(%rax), %rdi
testq %rdi, %rdi
cmoveq %rbp, %rdi
callq 0x3390
movq (%r15,%r13), %rcx
movq (%rcx), %rcx
movq 0x40(%rcx), %rcx
movq %rax, 0x8(%rcx)
movq (%r14), %rax
testq %rax, %rax
je 0x4dc97
cmpb $0x0, (%rax)
movq (%rbx), %r12
je 0x4dc9a
movl $0x10, %edi
callq 0x3290
movq (%r15,%r13), %rcx
movq (%rcx), %rcx
movq %rax, 0x48(%rcx)
leaq 0x3be4(%rip), %rdi      # 0x5184a
callq 0x3390
movq (%r12,%r13), %rcx
movq (%rcx), %rcx
movq 0x48(%rcx), %rcx
movq %rax, (%rcx)
movq (%r14), %rdi
callq 0x3390
movq (%r12,%r13), %rcx
movq (%rcx), %rcx
movq 0x48(%rcx), %rcx
movq %rax, 0x8(%rcx)
movl $0xa, %eax
jmp 0x4dc9f
movq (%rbx), %r12
movl $0x9, %eax
movq (%r12,%r13), %rcx
movl %eax, 0x8(%rcx)
addq $0x8, %r13
jmp 0x4d944
movq %r15, (%rsp)
leaq 0x63cf(%rip), %r8       # 0x54089
leaq 0x10(%rsp), %rdx
movq %rbp, %r14
movq %rbp, %rdi
movq %r13, %rsi
movq 0x8(%rsp), %rcx
movq %rbx, %r9
callq 0x34f92
movl %eax, %ebp
testl %eax, %eax
je 0x4dcff
leaq 0x60d6(%rip), %rdi      # 0x53db8
movl %ebp, %esi
xorl %eax, %eax
callq 0x3140
movq 0x24306(%rip), %rax     # 0x71ff8
movq (%rax), %rsi
movq %r14, %rdi
callq 0x4ab13
jmp 0x4dd44
leaq 0x65a0(%rip), %rdi      # 0x542a6
callq 0x30a0
movq (%r15), %rax
movq (%rax), %rax
cmpl $0x0, 0x8(%rax)
jle 0x4dd44
leaq 0x6435(%rip), %r14      # 0x54153
xorl %r12d, %r12d
movq (%rax), %rax
movq (%rax,%r12,8), %rsi
movq %r14, %rdi
xorl %eax, %eax
callq 0x3140
incq %r12
movq (%r15), %rax
movq (%rax), %rax
movslq 0x8(%rax), %rcx
cmpq %rcx, %r12
jl 0x4dd21
movq (%rbx), %rdi
testq %rdi, %rdi
je 0x4dd51
callq 0x3030
movq %rbx, %rdi
callq 0x3030
testq %r15, %r15
je 0x4dd66
movq %r15, %rdi
callq 0x3030
movl %ebp, %eax
addq $0x98, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq