// File: /workspace/github_c_makefile_star2_O0/loversmile[P]sugarcrm/sugar_function.c
// Function: setContact
int setContact(struct soap *soap, const char *soap_endpoint, char *session, char *contact_id, SGContactItem *contact_item, char **return_id)
{
	/* contact_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(contact_item->title ? contact_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(contact_item->first_name ? contact_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(contact_item->last_name ? contact_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(contact_item->phone_home ? contact_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(contact_item->phone_mobile ? contact_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(contact_item->phone_work ? contact_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(contact_item->phone_other ? contact_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(contact_item->phone_fax ? contact_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(contact_item->description ? contact_item->description : "");
    if (contact_id != NULL && strlen(contact_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(contact_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 0x6e90(%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 0x6f24(%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 0x756f3
movq -0x28(%rbp), %rax
movq (%rax), %rax
movq %rax, -0xd8(%rbp)
jmp 0x75703
leaq 0x53df(%rip), %rax      # 0x7aad9
movq %rax, -0xd8(%rbp)
jmp 0x75703
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 0x6e82(%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 0x7579d
movq -0x28(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0xe0(%rbp)
jmp 0x757ad
leaq 0x5335(%rip), %rax      # 0x7aad9
movq %rax, -0xe0(%rbp)
jmp 0x757ad
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 0x6de3(%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 0x75847
movq -0x28(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0xe8(%rbp)
jmp 0x75857
leaq 0x528b(%rip), %rax      # 0x7aad9
movq %rax, -0xe8(%rbp)
jmp 0x75857
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 0x6b34(%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 0x758f1
movq -0x28(%rbp), %rax
movq 0x18(%rax), %rax
movq %rax, -0xf0(%rbp)
jmp 0x75901
leaq 0x51e1(%rip), %rax      # 0x7aad9
movq %rax, -0xf0(%rbp)
jmp 0x75901
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 0x6aa0(%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 0x7599b
movq -0x28(%rbp), %rax
movq 0x20(%rax), %rax
movq %rax, -0xf8(%rbp)
jmp 0x759ab
leaq 0x5137(%rip), %rax      # 0x7aad9
movq %rax, -0xf8(%rbp)
jmp 0x759ab
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 0x69eb(%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 0x75a45
movq -0x28(%rbp), %rax
movq 0x28(%rax), %rax
movq %rax, -0x100(%rbp)
jmp 0x75a55
leaq 0x508d(%rip), %rax      # 0x7aad9
movq %rax, -0x100(%rbp)
jmp 0x75a55
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 0x6b45(%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 0x75aef
movq -0x28(%rbp), %rax
movq 0x30(%rax), %rax
movq %rax, -0x108(%rbp)
jmp 0x75aff
leaq 0x4fe3(%rip), %rax      # 0x7aad9
movq %rax, -0x108(%rbp)
jmp 0x75aff
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 0x6aa7(%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 0x75b99
movq -0x28(%rbp), %rax
movq 0x38(%rax), %rax
movq %rax, -0x110(%rbp)
jmp 0x75ba9
leaq 0x4f39(%rip), %rax      # 0x7aad9
movq %rax, -0x110(%rbp)
jmp 0x75ba9
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 0x3ad9(%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 0x75c43
movq -0x28(%rbp), %rax
movq 0x40(%rax), %rax
movq %rax, -0x118(%rbp)
jmp 0x75c53
leaq 0x4e8f(%rip), %rax      # 0x7aad9
movq %rax, -0x118(%rbp)
jmp 0x75c53
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 0x75d1d
movq -0x20(%rbp), %rdi
callq 0x3100
cmpq $0x0, %rax
jbe 0x75d1d
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 0x3b6f(%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 0x668b(%rip), %r8       # 0x7c3e0
movq %rax, (%rsp)
callq 0x71d50
movl %eax, -0xc8(%rbp)
leaq 0x67a2(%rip), %rdi      # 0x7c50d
movb $0x0, %al
callq 0x3140
cmpl $0x0, -0xc8(%rbp)
jne 0x75da7
leaq 0x688c(%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 0x75dce
movl -0xc8(%rbp), %esi
leaq 0x6316(%rip), %rdi      # 0x7c0ca
movb $0x0, %al
callq 0x3140
movq -0x8(%rbp), %rdi
movq 0x19232(%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 0x75f00
movq -0xb8(%rbp), %rax
movq (%rax), %rax
movslq -0xcc(%rbp), %rcx
movq (%rax,%rcx,8), %rax
cmpq $0x0, (%rax)
je 0x75e48
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 0x75e9f
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 0x75eea
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 0x75eec
movl -0xcc(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xcc(%rbp)
jmp 0x75de2
movq -0xb8(%rbp), %rax
cmpq $0x0, (%rax)
je 0x75f2a
movq -0xb8(%rbp), %rax
movq (%rax), %rdi
callq 0x3030
movq -0xb8(%rbp), %rax
movq $0x0, (%rax)
cmpq $0x0, -0xb8(%rbp)
je 0x75f4b
movq -0xb8(%rbp), %rdi
callq 0x3030
movq $0x0, -0xb8(%rbp)
cmpq $0x0, -0xc0(%rbp)
je 0x75f6c
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)