// File: /workspace/github_c_makefile_star2_O0/loversmile[P]sugarcrm/sugar_function.c
// Function: setLead
int setLead(struct soap *soap, const char *soap_endpoint, char *session, char *lead_id, SGLeadItem *lead_item, char **return_id)
{
	/* lead_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("title");
    setEntry_name_value_list->__ptr[item++]->value = strdup(lead_item->title ? lead_item->title : "");
    setEntry_name_value_list->__ptr[item] = (struct ns1__name_USCOREvalue*)malloc(sizeof(struct ns1__name_USCOREvalue));
    setEntry_name_value_list->__ptr[item]->name = strdup("first_name");
    setEntry_name_value_list->__ptr[item++]->value = strdup(lead_item->first_name ? lead_item->first_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("last_name");
    setEntry_name_value_list->__ptr[item++]->value = strdup(lead_item->last_name ? lead_item->last_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("phone_home");
    setEntry_name_value_list->__ptr[item++]->value = strdup(lead_item->phone_home ? lead_item->phone_home : "");  
    setEntry_name_value_list->__ptr[item] = (struct ns1__name_USCOREvalue*)malloc(sizeof(struct ns1__name_USCOREvalue));
    setEntry_name_value_list->__ptr[item]->name = strdup("phone_mobile");
    setEntry_name_value_list->__ptr[item++]->value = strdup(lead_item->phone_mobile ? lead_item->phone_mobile : "");
    setEntry_name_value_list->__ptr[item] = (struct ns1__name_USCOREvalue*)malloc(sizeof(struct ns1__name_USCOREvalue));
    setEntry_name_value_list->__ptr[item]->name = strdup("phone_work");
    setEntry_name_value_list->__ptr[item++]->value = strdup(lead_item->phone_work ? lead_item->phone_work : "");
    setEntry_name_value_list->__ptr[item] = (struct ns1__name_USCOREvalue*)malloc(sizeof(struct ns1__name_USCOREvalue));
    setEntry_name_value_list->__ptr[item]->name = strdup("phone_other");
    setEntry_name_value_list->__ptr[item++]->value = strdup(lead_item->phone_other ? lead_item->phone_other : "");
    setEntry_name_value_list->__ptr[item] = (struct ns1__name_USCOREvalue*)malloc(sizeof(struct ns1__name_USCOREvalue));
    setEntry_name_value_list->__ptr[item]->name = strdup("phone_fax");
    setEntry_name_value_list->__ptr[item++]->value = strdup(lead_item->phone_fax ? lead_item->phone_fax : "");
    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(lead_item->description ? lead_item->description : "");
    if (lead_id != NULL && strlen(lead_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(lead_id);
    } 
    setEntry_name_value_list->__size = item;
    
    int ret = setEntry(soap, soap_endpoint, soap_action, session, "Contacts", setEntry_name_value_list, _param_9);
        printf("8*****\n");
    if (ret == SOAP_OK) {
        printf("Success setContact!\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
movq %rsp, %rbp
subq $0x120, %rsp            # imm = 0x120
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movq %r8, -0x28(%rbp)
movq %r9, -0x30(%rbp)
leaq -0xb0(%rbp), %rdi
xorl %esi, %esi
movl $0x80, %edx
callq 0x3190
leaq -0xb0(%rbp), %rdi
xorl %esi, %esi
movl $0x80, %edx
callq 0x3190
leaq -0xb0(%rbp), %rdi
movq -0x10(%rbp), %rcx
movl $0x80, %esi
leaq 0x5dd0(%rip), %rdx      # 0x7c4c0
movb $0x0, %al
callq 0x3150
movq $0x0, -0xb8(%rbp)
movq $0x0, -0xc0(%rbp)
movl $0x10, %edi
callq 0x3290
movq %rax, -0xb8(%rbp)
movl $0x8, %edi
callq 0x3290
movq %rax, -0xc0(%rbp)
movl $0x0, -0xc4(%rbp)
movl $0x40, %edi
callq 0x3290
movq %rax, %rcx
movq -0xb8(%rbp), %rax
movq %rcx, (%rax)
movl $0x10, %edi
callq 0x3290
movq %rax, %rdx
movq -0xb8(%rbp), %rax
movq (%rax), %rax
movslq -0xc4(%rbp), %rcx
movq %rdx, (%rax,%rcx,8)
leaq 0x5e64(%rip), %rdi      # 0x7c5dd
callq 0x33a0
movq %rax, %rcx
movq -0xb8(%rbp), %rax
movq (%rax), %rax
movslq -0xc4(%rbp), %rdx
movq (%rax,%rdx,8), %rax
movq %rcx, (%rax)
movq -0x28(%rbp), %rax
cmpq $0x0, (%rax)
je 0x767b3
movq -0x28(%rbp), %rax
movq (%rax), %rax
movq %rax, -0xd8(%rbp)
jmp 0x767c3
leaq 0x431f(%rip), %rax      # 0x7aad9
movq %rax, -0xd8(%rbp)
jmp 0x767c3
movq -0xd8(%rbp), %rdi
callq 0x33a0
movq %rax, %rcx
movq -0xb8(%rbp), %rax
movq (%rax), %rax
movl -0xc4(%rbp), %edx
movl %edx, %esi
addl $0x1, %esi
movl %esi, -0xc4(%rbp)
movslq %edx, %rdx
movq (%rax,%rdx,8), %rax
movq %rcx, 0x8(%rax)
movl $0x10, %edi
callq 0x3290
movq %rax, %rdx
movq -0xb8(%rbp), %rax
movq (%rax), %rax
movslq -0xc4(%rbp), %rcx
movq %rdx, (%rax,%rcx,8)
leaq 0x5dc2(%rip), %rdi      # 0x7c5e3
callq 0x33a0
movq %rax, %rcx
movq -0xb8(%rbp), %rax
movq (%rax), %rax
movslq -0xc4(%rbp), %rdx
movq (%rax,%rdx,8), %rax
movq %rcx, (%rax)
movq -0x28(%rbp), %rax
cmpq $0x0, 0x8(%rax)
je 0x7685d
movq -0x28(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0xe0(%rbp)
jmp 0x7686d
leaq 0x4275(%rip), %rax      # 0x7aad9
movq %rax, -0xe0(%rbp)
jmp 0x7686d
movq -0xe0(%rbp), %rdi
callq 0x33a0
movq %rax, %rcx
movq -0xb8(%rbp), %rax
movq (%rax), %rax
movl -0xc4(%rbp), %edx
movl %edx, %esi
addl $0x1, %esi
movl %esi, -0xc4(%rbp)
movslq %edx, %rdx
movq (%rax,%rdx,8), %rax
movq %rcx, 0x8(%rax)
movl $0x10, %edi
callq 0x3290
movq %rax, %rdx
movq -0xb8(%rbp), %rax
movq (%rax), %rax
movslq -0xc4(%rbp), %rcx
movq %rdx, (%rax,%rcx,8)
leaq 0x5d23(%rip), %rdi      # 0x7c5ee
callq 0x33a0
movq %rax, %rcx
movq -0xb8(%rbp), %rax
movq (%rax), %rax
movslq -0xc4(%rbp), %rdx
movq (%rax,%rdx,8), %rax
movq %rcx, (%rax)
movq -0x28(%rbp), %rax
cmpq $0x0, 0x10(%rax)
je 0x76907
movq -0x28(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0xe8(%rbp)
jmp 0x76917
leaq 0x41cb(%rip), %rax      # 0x7aad9
movq %rax, -0xe8(%rbp)
jmp 0x76917
movq -0xe8(%rbp), %rdi
callq 0x33a0
movq %rax, %rcx
movq -0xb8(%rbp), %rax
movq (%rax), %rax
movl -0xc4(%rbp), %edx
movl %edx, %esi
addl $0x1, %esi
movl %esi, -0xc4(%rbp)
movslq %edx, %rdx
movq (%rax,%rdx,8), %rax
movq %rcx, 0x8(%rax)
movl $0x10, %edi
callq 0x3290
movq %rax, %rdx
movq -0xb8(%rbp), %rax
movq (%rax), %rax
movslq -0xc4(%rbp), %rcx
movq %rdx, (%rax,%rcx,8)
leaq 0x5a74(%rip), %rdi      # 0x7c3e9
callq 0x33a0
movq %rax, %rcx
movq -0xb8(%rbp), %rax
movq (%rax), %rax
movslq -0xc4(%rbp), %rdx
movq (%rax,%rdx,8), %rax
movq %rcx, (%rax)
movq -0x28(%rbp), %rax
cmpq $0x0, 0x18(%rax)
je 0x769b1
movq -0x28(%rbp), %rax
movq 0x18(%rax), %rax
movq %rax, -0xf0(%rbp)
jmp 0x769c1
leaq 0x4121(%rip), %rax      # 0x7aad9
movq %rax, -0xf0(%rbp)
jmp 0x769c1
movq -0xf0(%rbp), %rdi
callq 0x33a0
movq %rax, %rcx
movq -0xb8(%rbp), %rax
movq (%rax), %rax
movl -0xc4(%rbp), %edx
movl %edx, %esi
addl $0x1, %esi
movl %esi, -0xc4(%rbp)
movslq %edx, %rdx
movq (%rax,%rdx,8), %rax
movq %rcx, 0x8(%rax)
movl $0x10, %edi
callq 0x3290
movq %rax, %rdx
movq -0xb8(%rbp), %rax
movq (%rax), %rax
movslq -0xc4(%rbp), %rcx
movq %rdx, (%rax,%rcx,8)
leaq 0x59e0(%rip), %rdi      # 0x7c3ff
callq 0x33a0
movq %rax, %rcx
movq -0xb8(%rbp), %rax
movq (%rax), %rax
movslq -0xc4(%rbp), %rdx
movq (%rax,%rdx,8), %rax
movq %rcx, (%rax)
movq -0x28(%rbp), %rax
cmpq $0x0, 0x20(%rax)
je 0x76a5b
movq -0x28(%rbp), %rax
movq 0x20(%rax), %rax
movq %rax, -0xf8(%rbp)
jmp 0x76a6b
leaq 0x4077(%rip), %rax      # 0x7aad9
movq %rax, -0xf8(%rbp)
jmp 0x76a6b
movq -0xf8(%rbp), %rdi
callq 0x33a0
movq %rax, %rcx
movq -0xb8(%rbp), %rax
movq (%rax), %rax
movl -0xc4(%rbp), %edx
movl %edx, %esi
addl $0x1, %esi
movl %esi, -0xc4(%rbp)
movslq %edx, %rdx
movq (%rax,%rdx,8), %rax
movq %rcx, 0x8(%rax)
movl $0x10, %edi
callq 0x3290
movq %rax, %rdx
movq -0xb8(%rbp), %rax
movq (%rax), %rax
movslq -0xc4(%rbp), %rcx
movq %rdx, (%rax,%rcx,8)
leaq 0x592b(%rip), %rdi      # 0x7c3f4
callq 0x33a0
movq %rax, %rcx
movq -0xb8(%rbp), %rax
movq (%rax), %rax
movslq -0xc4(%rbp), %rdx
movq (%rax,%rdx,8), %rax
movq %rcx, (%rax)
movq -0x28(%rbp), %rax
cmpq $0x0, 0x28(%rax)
je 0x76b05
movq -0x28(%rbp), %rax
movq 0x28(%rax), %rax
movq %rax, -0x100(%rbp)
jmp 0x76b15
leaq 0x3fcd(%rip), %rax      # 0x7aad9
movq %rax, -0x100(%rbp)
jmp 0x76b15
movq -0x100(%rbp), %rdi
callq 0x33a0
movq %rax, %rcx
movq -0xb8(%rbp), %rax
movq (%rax), %rax
movl -0xc4(%rbp), %edx
movl %edx, %esi
addl $0x1, %esi
movl %esi, -0xc4(%rbp)
movslq %edx, %rdx
movq (%rax,%rdx,8), %rax
movq %rcx, 0x8(%rax)
movl $0x10, %edi
callq 0x3290
movq %rax, %rdx
movq -0xb8(%rbp), %rax
movq (%rax), %rax
movslq -0xc4(%rbp), %rcx
movq %rdx, (%rax,%rcx,8)
leaq 0x5a85(%rip), %rdi      # 0x7c5f8
callq 0x33a0
movq %rax, %rcx
movq -0xb8(%rbp), %rax
movq (%rax), %rax
movslq -0xc4(%rbp), %rdx
movq (%rax,%rdx,8), %rax
movq %rcx, (%rax)
movq -0x28(%rbp), %rax
cmpq $0x0, 0x30(%rax)
je 0x76baf
movq -0x28(%rbp), %rax
movq 0x30(%rax), %rax
movq %rax, -0x108(%rbp)
jmp 0x76bbf
leaq 0x3f23(%rip), %rax      # 0x7aad9
movq %rax, -0x108(%rbp)
jmp 0x76bbf
movq -0x108(%rbp), %rdi
callq 0x33a0
movq %rax, %rcx
movq -0xb8(%rbp), %rax
movq (%rax), %rax
movl -0xc4(%rbp), %edx
movl %edx, %esi
addl $0x1, %esi
movl %esi, -0xc4(%rbp)
movslq %edx, %rdx
movq (%rax,%rdx,8), %rax
movq %rcx, 0x8(%rax)
movl $0x10, %edi
callq 0x3290
movq %rax, %rdx
movq -0xb8(%rbp), %rax
movq (%rax), %rax
movslq -0xc4(%rbp), %rcx
movq %rdx, (%rax,%rcx,8)
leaq 0x59e7(%rip), %rdi      # 0x7c604
callq 0x33a0
movq %rax, %rcx
movq -0xb8(%rbp), %rax
movq (%rax), %rax
movslq -0xc4(%rbp), %rdx
movq (%rax,%rdx,8), %rax
movq %rcx, (%rax)
movq -0x28(%rbp), %rax
cmpq $0x0, 0x38(%rax)
je 0x76c59
movq -0x28(%rbp), %rax
movq 0x38(%rax), %rax
movq %rax, -0x110(%rbp)
jmp 0x76c69
leaq 0x3e79(%rip), %rax      # 0x7aad9
movq %rax, -0x110(%rbp)
jmp 0x76c69
movq -0x110(%rbp), %rdi
callq 0x33a0
movq %rax, %rcx
movq -0xb8(%rbp), %rax
movq (%rax), %rax
movl -0xc4(%rbp), %edx
movl %edx, %esi
addl $0x1, %esi
movl %esi, -0xc4(%rbp)
movslq %edx, %rdx
movq (%rax,%rdx,8), %rax
movq %rcx, 0x8(%rax)
movl $0x10, %edi
callq 0x3290
movq %rax, %rdx
movq -0xb8(%rbp), %rax
movq (%rax), %rax
movslq -0xc4(%rbp), %rcx
movq %rdx, (%rax,%rcx,8)
leaq 0x2a19(%rip), %rdi      # 0x796e0
callq 0x33a0
movq %rax, %rcx
movq -0xb8(%rbp), %rax
movq (%rax), %rax
movslq -0xc4(%rbp), %rdx
movq (%rax,%rdx,8), %rax
movq %rcx, (%rax)
movq -0x28(%rbp), %rax
cmpq $0x0, 0x40(%rax)
je 0x76d03
movq -0x28(%rbp), %rax
movq 0x40(%rax), %rax
movq %rax, -0x118(%rbp)
jmp 0x76d13
leaq 0x3dcf(%rip), %rax      # 0x7aad9
movq %rax, -0x118(%rbp)
jmp 0x76d13
movq -0x118(%rbp), %rdi
callq 0x33a0
movq %rax, %rcx
movq -0xb8(%rbp), %rax
movq (%rax), %rax
movl -0xc4(%rbp), %edx
movl %edx, %esi
addl $0x1, %esi
movl %esi, -0xc4(%rbp)
movslq %edx, %rdx
movq (%rax,%rdx,8), %rax
movq %rcx, 0x8(%rax)
cmpq $0x0, -0x20(%rbp)
je 0x76ddd
movq -0x20(%rbp), %rdi
callq 0x3100
cmpq $0x0, %rax
jbe 0x76ddd
movl $0x10, %edi
callq 0x3290
movq %rax, %rdx
movq -0xb8(%rbp), %rax
movq (%rax), %rax
movslq -0xc4(%rbp), %rcx
movq %rdx, (%rax,%rcx,8)
leaq 0x2aaf(%rip), %rdi      # 0x7983a
callq 0x33a0
movq %rax, %rcx
movq -0xb8(%rbp), %rax
movq (%rax), %rax
movslq -0xc4(%rbp), %rdx
movq (%rax,%rdx,8), %rax
movq %rcx, (%rax)
movq -0x20(%rbp), %rdi
callq 0x33a0
movq %rax, %rcx
movq -0xb8(%rbp), %rax
movq (%rax), %rax
movl -0xc4(%rbp), %edx
movl %edx, %esi
addl $0x1, %esi
movl %esi, -0xc4(%rbp)
movslq %edx, %rdx
movq (%rax,%rdx,8), %rax
movq %rcx, 0x8(%rax)
movl -0xc4(%rbp), %ecx
movq -0xb8(%rbp), %rax
movl %ecx, 0x8(%rax)
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
leaq -0xb0(%rbp), %rdx
movq -0x18(%rbp), %rcx
movq -0xb8(%rbp), %r9
movq -0xc0(%rbp), %rax
leaq 0x55cb(%rip), %r8       # 0x7c3e0
movq %rax, (%rsp)
callq 0x71d50
movl %eax, -0xc8(%rbp)
leaq 0x56e2(%rip), %rdi      # 0x7c50d
movb $0x0, %al
callq 0x3140
cmpl $0x0, -0xc8(%rbp)
jne 0x76e67
leaq 0x57cc(%rip), %rdi      # 0x7c60e
movb $0x0, %al
callq 0x3140
movq -0xc0(%rbp), %rax
movq (%rax), %rax
movq (%rax), %rdi
callq 0x33a0
movq %rax, %rcx
movq -0x30(%rbp), %rax
movq %rcx, (%rax)
jmp 0x76e8e
movl -0xc8(%rbp), %esi
leaq 0x5256(%rip), %rdi      # 0x7c0ca
movb $0x0, %al
callq 0x3140
movq -0x8(%rbp), %rdi
movq 0x18172(%rip), %rax     # 0x8eff8
movq (%rax), %rsi
callq 0x6e2c0
movl $0x0, -0xcc(%rbp)
movl $0x0, -0xcc(%rbp)
movl -0xcc(%rbp), %eax
cmpl -0xc4(%rbp), %eax
jge 0x76fc0
movq -0xb8(%rbp), %rax
movq (%rax), %rax
movslq -0xcc(%rbp), %rcx
movq (%rax,%rcx,8), %rax
cmpq $0x0, (%rax)
je 0x76f08
movq -0xb8(%rbp), %rax
movq (%rax), %rax
movslq -0xcc(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq (%rax), %rdi
callq 0x3030
movq -0xb8(%rbp), %rax
movq (%rax), %rax
movslq -0xcc(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq $0x0, (%rax)
movq -0xb8(%rbp), %rax
movq (%rax), %rax
movslq -0xcc(%rbp), %rcx
movq (%rax,%rcx,8), %rax
cmpq $0x0, 0x8(%rax)
je 0x76f5f
movq -0xb8(%rbp), %rax
movq (%rax), %rax
movslq -0xcc(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq 0x8(%rax), %rdi
callq 0x3030
movq -0xb8(%rbp), %rax
movq (%rax), %rax
movslq -0xcc(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq $0x0, 0x8(%rax)
movq -0xb8(%rbp), %rax
movq (%rax), %rax
movslq -0xcc(%rbp), %rcx
cmpq $0x0, (%rax,%rcx,8)
je 0x76faa
movq -0xb8(%rbp), %rax
movq (%rax), %rax
movslq -0xcc(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
callq 0x3030
movq -0xb8(%rbp), %rax
movq (%rax), %rax
movslq -0xcc(%rbp), %rcx
movq $0x0, (%rax,%rcx,8)
jmp 0x76fac
movl -0xcc(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xcc(%rbp)
jmp 0x76ea2
movq -0xb8(%rbp), %rax
cmpq $0x0, (%rax)
je 0x76fea
movq -0xb8(%rbp), %rax
movq (%rax), %rdi
callq 0x3030
movq -0xb8(%rbp), %rax
movq $0x0, (%rax)
cmpq $0x0, -0xb8(%rbp)
je 0x7700b
movq -0xb8(%rbp), %rdi
callq 0x3030
movq $0x0, -0xb8(%rbp)
cmpq $0x0, -0xc0(%rbp)
je 0x7702c
movq -0xc0(%rbp), %rdi
callq 0x3030
movq $0x0, -0xc0(%rbp)
movl -0xc8(%rbp), %eax
addq $0x120, %rsp            # imm = 0x120
popq %rbp
retq
nopl (%rax,%rax)