// File: /workspace/github_c_makefile_star2_O0/back1127[P]linkedge-thing-access-websocket_client_sdk/sdk/leda.c
// Function: leda_rsp_call_service
int leda_rsp_call_service(char *pk, char *dn, int msg_id, const char *service_name, leda_device_data_t *input_params,
                          int params_cnt)
{
    int ret = LE_ERROR_UNKNOWN, i;
    leda_device_data_t *output_params = NULL;
    cJSON *payload = NULL, *params;

    output_params = malloc(sizeof(leda_device_data_t) * g_devs_cb.service_output_max_count);
    if (!output_params) {
        return LE_ERROR_ALLOCATING_MEM;
    }
    memset(output_params, 0, sizeof(leda_device_data_t) * g_devs_cb.service_output_max_count);
    if (g_devs_cb.call_service_cb) {
        ret = g_devs_cb.call_service_cb(pk, dn, service_name, input_params, params_cnt, output_params, g_devs_cb.usr_data_call_service);
    } else {
        log_e(LOG_TAG, "callback call_service_cb unregistered!\n");
    }

    if (ret != LE_SUCCESS) {
        goto end;
    }
    params_cnt = 0;
    for (i = 0; i < g_devs_cb.service_output_max_count; i++) {
        if (strlen(output_params[i].key) == 0) {
            break;
        }
        ++params_cnt;
    }
    payload = cJSON_CreateObject();
    if (!payload) {
        goto end;
    }
    params = struct_data_to_json_data(output_params, params_cnt);
    if (params) {
        cJSON_AddItemToObject(payload, "outputData", params);
    }

end:

    if (output_params) {
        free(output_params);
    }

    return leda_send_rsp(ret, msg_id, payload);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x60, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movl %edx, -0x1c(%rbp)
movq %rcx, -0x28(%rbp)
movq %r8, -0x30(%rbp)
movl %r9d, -0x34(%rbp)
movl $0x186a0, -0x38(%rbp)   # imm = 0x186A0
movq $0x0, -0x48(%rbp)
movq $0x0, -0x50(%rbp)
movslq 0xc583(%rip), %rax      # 0x125d0
imulq $0x844, %rax, %rdi      # imm = 0x844
callq 0x4798
movq %rax, -0x48(%rbp)
cmpq $0x0, -0x48(%rbp)
jne 0x6070
movl $0x186a2, -0x4(%rbp)    # imm = 0x186A2
jmp 0x61b9
movq -0x48(%rbp), %rdi
movslq 0xc555(%rip), %rax      # 0x125d0
imulq $0x844, %rax, %rdx      # imm = 0x844
xorl %esi, %esi
callq 0x4300
cmpq $0x0, 0xc51f(%rip)      # 0x125b0
je 0x60c4
movq 0xc516(%rip), %rax      # 0x125b0
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
movq -0x28(%rbp), %rdx
movq -0x30(%rbp), %rcx
movl -0x34(%rbp), %r8d
movq -0x48(%rbp), %r9
movq 0xc4ff(%rip), %r10      # 0x125b8
movq %r10, (%rsp)
callq *%rax
movl %eax, -0x38(%rbp)
jmp 0x60fd
movl $0x3, %edi
leaq 0x7fc0(%rip), %rsi      # 0xe090
leaq 0x7fbf(%rip), %rdx      # 0xe096
leaq 0x7fbd(%rip), %rcx      # 0xe09b
leaq 0x8255(%rip), %r8       # 0xe33a
movl $0x27b, %r9d            # imm = 0x27B
leaq 0x825e(%rip), %rax      # 0xe350
movq %rax, (%rsp)
movb $0x0, %al
callq 0x42b0
cmpl $0x0, -0x38(%rbp)
je 0x6108
jmp 0x6197
movl $0x0, -0x34(%rbp)
movl $0x0, -0x3c(%rbp)
movl -0x3c(%rbp), %eax
cmpl 0xc4b1(%rip), %eax      # 0x125d0
jge 0x6158
movq -0x48(%rbp), %rdi
movslq -0x3c(%rbp), %rax
imulq $0x844, %rax, %rax      # imm = 0x844
addq %rax, %rdi
addq $0x4, %rdi
callq 0x4250
cmpq $0x0, %rax
jne 0x6144
jmp 0x6158
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
movl -0x3c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x3c(%rbp)
jmp 0x6116
callq 0x4680
movq %rax, -0x50(%rbp)
cmpq $0x0, -0x50(%rbp)
jne 0x616a
jmp 0x6197
movq -0x48(%rbp), %rdi
movl -0x34(%rbp), %esi
callq 0x4640
movq %rax, -0x58(%rbp)
cmpq $0x0, -0x58(%rbp)
je 0x6195
movq -0x50(%rbp), %rdi
movq -0x58(%rbp), %rdx
leaq 0x80a7(%rip), %rsi      # 0xe237
callq 0x46e0
jmp 0x6197
cmpq $0x0, -0x48(%rbp)
je 0x61a7
movq -0x48(%rbp), %rdi
callq 0x4790
movl -0x38(%rbp), %edi
movl -0x1c(%rbp), %esi
movq -0x50(%rbp), %rdx
callq 0x43d0
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x60, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)