// File: /workspace/github_c_makefile_star2_O0/loversmile[P]sugarcrm/sugar_function.c
// Function: sugarLogin
int sugarLogin(struct soap *soap, const char *soap_endpoint, char *login_name, char *login_pwd, struct ns1__loginResponse *_param_1)
{
    char soap_action[128] = {0};

    memset(soap_action, 0, sizeof(soap_action));
    snprintf(soap_action, sizeof(soap_action), "%s/login", soap_endpoint);
    struct ns1__user_USCOREauth *user_auth = NULL;
    struct name_USCOREvalue_USCORElist *name_value_list = NULL;
    user_auth = (struct ns1__user_USCOREauth*)malloc(sizeof(struct ns1__user_USCOREauth));
    
    char *username = (char*)malloc(256);
    char *password = (char*)malloc(512);
    
    snprintf(username, 256, "%s", login_name);
    char *md_res = MD_5(login_pwd);
    snprintf(password, 512, "%s", md_res);
    //printf("%s\n", password);
    if (md_res) {
        free(md_res);
        md_res = NULL;
    }

    user_auth->user_USCOREname = username;
    user_auth->password = password;
    char *application_name = "UCM6XXX";
    
    int ret = soap_call_ns1__login(soap, soap_endpoint, soap_action, user_auth, application_name, name_value_list, _param_1);

    //SAFE_FREE(username);
    //SAFE_FREE(password);
	if (user_auth)
	{
		SAFE_FREE(user_auth->user_USCOREname);
		SAFE_FREE(user_auth->password);
		free(user_auth);
	}
    return ret;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xf0, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movq %r8, -0x28(%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 0xaa8e(%rip), %rdx      # 0x7c33a
movb $0x0, %al
callq 0x3150
movq $0x0, -0xb8(%rbp)
movq $0x0, -0xc0(%rbp)
movl $0x10, %edi
callq 0x3290
movq %rax, -0xb8(%rbp)
movl $0x100, %edi            # imm = 0x100
callq 0x3290
movq %rax, -0xc8(%rbp)
movl $0x200, %edi            # imm = 0x200
callq 0x3290
movq %rax, -0xd0(%rbp)
movq -0xc8(%rbp), %rdi
movq -0x18(%rbp), %rcx
movl $0x100, %esi            # imm = 0x100
leaq 0x9bfc(%rip), %rdx      # 0x7b50f
movb $0x0, %al
callq 0x3150
movq -0x20(%rbp), %rdi
callq 0x6ff40
movq %rax, -0xd8(%rbp)
movq -0xd0(%rbp), %rdi
movq -0xd8(%rbp), %rcx
movl $0x200, %esi            # imm = 0x200
leaq 0x9bcb(%rip), %rdx      # 0x7b50f
movb $0x0, %al
callq 0x3150
cmpq $0x0, -0xd8(%rbp)
je 0x7196c
movq -0xd8(%rbp), %rdi
callq 0x3030
movq $0x0, -0xd8(%rbp)
movq -0xc8(%rbp), %rcx
movq -0xb8(%rbp), %rax
movq %rcx, (%rax)
movq -0xd0(%rbp), %rcx
movq -0xb8(%rbp), %rax
movq %rcx, 0x8(%rax)
leaq 0xa9ad(%rip), %rax      # 0x7c343
movq %rax, -0xe0(%rbp)
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
leaq -0xb0(%rbp), %rdx
movq -0xb8(%rbp), %rcx
movq -0xe0(%rbp), %r8
movq -0xc0(%rbp), %r9
movq -0x28(%rbp), %rax
movq %rax, (%rsp)
callq 0x49b90
movl %eax, -0xe4(%rbp)
cmpq $0x0, -0xb8(%rbp)
je 0x71a41
movq -0xb8(%rbp), %rax
cmpq $0x0, (%rax)
je 0x71a08
movq -0xb8(%rbp), %rax
movq (%rax), %rdi
callq 0x3030
movq -0xb8(%rbp), %rax
movq $0x0, (%rax)
movq -0xb8(%rbp), %rax
cmpq $0x0, 0x8(%rax)
je 0x71a35
movq -0xb8(%rbp), %rax
movq 0x8(%rax), %rdi
callq 0x3030
movq -0xb8(%rbp), %rax
movq $0x0, 0x8(%rax)
movq -0xb8(%rbp), %rdi
callq 0x3030
movl -0xe4(%rbp), %eax
addq $0xf0, %rsp
popq %rbp
retq