// File: /workspace/github_c_makefile_star2_O1/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, %r13
movq %rsi, %rbp
movq %rdi, %r12
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 0x6376(%rip), %rdx      # 0x54144
movl $0x80, %esi
movq %rbp, %rcx
xorl %eax, %eax
callq 0x3150
movl $0x10, %edi
callq 0x3280
movq %rax, %rbx
movl $0x8, %edi
callq 0x3280
movq %rax, %r15
movl $0x1000, %edi           # imm = 0x1000
callq 0x3280
movq %rax, (%rbx)
testq %r14, %r14
je 0x4e1bd
xorl %r12d, %r12d
leaq 0x491b(%rip), %r13      # 0x52732
leaq 0x3785(%rip), %r15      # 0x515a3
movq 0x10(%r14), %r14
movl $0x40, %edi
callq 0x3280
movq (%rbx), %rbp
movq (%rbp,%r12), %rcx
movq %rax, (%rcx)
movl $0x10, %edi
callq 0x3280
movq (%rbp,%r12), %rcx
movq (%rcx), %rcx
movq %rax, (%rcx)
leaq 0x37b0(%rip), %rdi      # 0x51603
callq 0x3380
movq (%rbx), %rbp
movq (%rbp,%r12), %rcx
movq (%rcx), %rcx
movq (%rcx), %rcx
movq %rax, (%rcx)
movq 0x8(%r14), %rax
movq (%rax), %rdi
testq %rdi, %rdi
cmoveq %r13, %rdi
callq 0x3380
movq (%rbp,%r12), %rcx
movq (%rcx), %rcx
movq (%rcx), %rcx
movq %rax, 0x8(%rcx)
movl $0x10, %edi
callq 0x3280
movq (%rbp,%r12), %rcx
movq (%rcx), %rcx
movq %rax, 0x8(%rcx)
leaq 0x625c(%rip), %rdi      # 0x54104
callq 0x3380
movq (%rbx), %rbp
movq (%rbp,%r12), %rcx
movq (%rcx), %rcx
movq 0x8(%rcx), %rcx
movq %rax, (%rcx)
movq 0x8(%r14), %rax
movq 0x8(%rax), %rdi
testq %rdi, %rdi
cmoveq %r13, %rdi
callq 0x3380
movq (%rbp,%r12), %rcx
movq (%rcx), %rcx
movq 0x8(%rcx), %rcx
movq %rax, 0x8(%rcx)
movl $0x10, %edi
callq 0x3280
movq (%rbp,%r12), %rcx
movq (%rcx), %rcx
movq %rax, 0x10(%rcx)
leaq 0x6210(%rip), %rdi      # 0x54110
callq 0x3380
movq (%rbx), %rbp
movq (%rbp,%r12), %rcx
movq (%rcx), %rcx
movq 0x10(%rcx), %rcx
movq %rax, (%rcx)
movq 0x8(%r14), %rax
movq 0x10(%rax), %rdi
testq %rdi, %rdi
cmoveq %r13, %rdi
callq 0x3380
movq (%rbp,%r12), %rcx
movq (%rcx), %rcx
movq 0x10(%rcx), %rcx
movq %rax, 0x8(%rcx)
movl $0x10, %edi
callq 0x3280
movq (%rbp,%r12), %rcx
movq (%rcx), %rcx
movq %rax, 0x18(%rcx)
leaq 0x61c2(%rip), %rdi      # 0x5411a
callq 0x3380
movq (%rbx), %rbp
movq (%rbp,%r12), %rcx
movq (%rcx), %rcx
movq 0x18(%rcx), %rcx
movq %rax, (%rcx)
movq 0x8(%r14), %rax
movq 0x18(%rax), %rdi
testq %rdi, %rdi
cmoveq %r13, %rdi
callq 0x3380
movq (%rbp,%r12), %rcx
movq (%rcx), %rcx
movq 0x18(%rcx), %rcx
movq %rax, 0x8(%rcx)
movl $0x10, %edi
callq 0x3280
movq (%rbp,%r12), %rcx
movq (%rcx), %rcx
movq %rax, 0x20(%rcx)
leaq 0x3740(%rip), %rdi      # 0x516f0
callq 0x3380
movq (%rbx), %rbp
movq (%rbp,%r12), %rcx
movq (%rcx), %rcx
movq 0x20(%rcx), %rcx
movq %rax, (%rcx)
movq 0x8(%r14), %rax
movq 0x20(%rax), %rdi
testq %rdi, %rdi
cmoveq %r13, %rdi
callq 0x3380
movq (%rbp,%r12), %rcx
movq (%rcx), %rcx
movq 0x20(%rcx), %rcx
movq %rax, 0x8(%rcx)
movl $0x10, %edi
callq 0x3280
movq (%rbp,%r12), %rcx
movq (%rcx), %rcx
movq %rax, 0x28(%rcx)
leaq 0x611c(%rip), %rdi      # 0x54124
callq 0x3380
movq (%rbx), %rbp
movq (%rbp,%r12), %rcx
movq (%rcx), %rcx
movq 0x28(%rcx), %rcx
movq %rax, (%rcx)
movq 0x8(%r14), %rax
movq 0x28(%rax), %rdi
testq %rdi, %rdi
cmoveq %r13, %rdi
callq 0x3380
movq (%rbp,%r12), %rcx
movq (%rcx), %rcx
movq 0x28(%rcx), %rcx
movq %rax, 0x8(%rcx)
movl $0x10, %edi
callq 0x3280
movq (%rbp,%r12), %rcx
movq (%rcx), %rcx
movq %rax, 0x30(%rcx)
leaq 0x60d5(%rip), %rdi      # 0x54135
callq 0x3380
movq (%rbx), %rbp
movq (%rbp,%r12), %rcx
movq (%rcx), %rcx
movq 0x30(%rcx), %rcx
movq %rax, (%rcx)
movq 0x8(%r14), %rax
movq 0x30(%rax), %rdi
testq %rdi, %rdi
cmoveq %r13, %rdi
callq 0x3380
movq (%rbp,%r12), %rcx
movq (%rcx), %rcx
movq 0x30(%rcx), %rcx
movq %rax, 0x8(%rcx)
movl $0x10, %edi
callq 0x3280
movq (%rbp,%r12), %rcx
movq (%rcx), %rcx
movq %rax, 0x38(%rcx)
leaq 0x5fd7(%rip), %rdi      # 0x5408f
callq 0x3380
movq (%rbx), %rbp
movq (%rbp,%r12), %rcx
movq (%rcx), %rcx
movq 0x38(%rcx), %rcx
movq %rax, (%rcx)
movq 0x8(%r14), %rax
movq 0x38(%rax), %rdi
testq %rdi, %rdi
cmoveq %r13, %rdi
callq 0x3380
movq (%rbp,%r12), %rcx
movq (%rcx), %rcx
movq 0x38(%rcx), %rcx
movq %rax, 0x8(%rcx)
movl $0x10, %edi
callq 0x3280
movq (%rbp,%r12), %rcx
movq (%rcx), %rcx
movq %rax, 0x40(%rcx)
movq %r15, %rdi
callq 0x3380
movq (%rbx), %rbp
movq (%rbp,%r12), %rcx
movq (%rcx), %rcx
movq 0x40(%rcx), %rcx
movq %rax, (%rcx)
movq 0x8(%r14), %rax
movq 0x40(%rax), %rdi
testq %rdi, %rdi
cmoveq %r13, %rdi
callq 0x3380
movq (%rbp,%r12), %rcx
movq (%rcx), %rcx
movq 0x40(%rcx), %rcx
movq %rax, 0x8(%rcx)
movq (%r14), %rcx
movl $0x9, %eax
testq %rcx, %rcx
je 0x4e1aa
cmpb $0x0, (%rcx)
je 0x4e1aa
movl $0x10, %edi
callq 0x3280
movq (%rbp,%r12), %rcx
movq (%rcx), %rcx
movq %rax, 0x48(%rcx)
leaq 0x36d4(%rip), %rdi      # 0x5184a
callq 0x3380
movq (%rbx), %rbp
movq (%rbp,%r12), %rcx
movq (%rcx), %rcx
movq 0x48(%rcx), %rcx
movq %rax, (%rcx)
movq (%r14), %rdi
callq 0x3380
movq (%rbp,%r12), %rcx
movq (%rcx), %rcx
movq 0x48(%rcx), %rcx
movq %rax, 0x8(%rcx)
movl $0xa, %eax
movq (%rbx), %rcx
movq (%rcx,%r12), %rcx
movl %eax, 0x8(%rcx)
addq $0x8, %r12
jmp 0x4de1e
movq %r15, (%rsp)
leaq 0x5ec1(%rip), %r8       # 0x54089
leaq 0x10(%rsp), %rdx
movq %r12, %rdi
movq %rbp, %rsi
movq %r13, %rcx
movq %rbx, %r9
callq 0x34cb2
movl %eax, %ebp
testl %eax, %eax
je 0x4e208
leaq 0x5bcd(%rip), %rdi      # 0x53db8
movl %ebp, %esi
xorl %eax, %eax
callq 0x3140
movq 0x23dfd(%rip), %rax     # 0x71ff8
movq (%rax), %rsi
movq %r12, %rdi
callq 0x4b1d6
jmp 0x4e24d
leaq 0x6097(%rip), %rdi      # 0x542a6
callq 0x30a0
movq (%r15), %rax
movq (%rax), %rax
cmpl $0x0, 0x8(%rax)
jle 0x4e24d
leaq 0x5f2c(%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 0x4e22a
movq (%rbx), %rdi
testq %rdi, %rdi
je 0x4e261
callq 0x3030
movq $0x0, (%rbx)
movq %rbx, %rdi
callq 0x3030
testq %r15, %r15
je 0x4e276
movq %r15, %rdi
callq 0x3030
movl %ebp, %eax
addq $0x98, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq