// File: /workspace/github_c_makefile_star2_O1/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
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movl %r9d, -0x2c(%rbp)
movq %r8, -0x38(%rbp)
movq %rcx, %r13
movl %edx, -0x30(%rbp)
movq %rsi, %rbx
movq %rdi, %r15
movslq 0x9af2(%rip), %rax      # 0xf4b8
imulq $0x844, %rax, %r12      # imm = 0x844
movq %r12, %rdi
callq 0x46b8
testq %rax, %rax
je 0x5a1c
movq %rax, %r14
movq %rax, %rdi
xorl %esi, %esi
movq %r12, %rdx
callq 0x42b0
movq 0x9ab7(%rip), %rax      # 0xf4a8
testq %rax, %rax
je 0x5a30
movq 0x9ab3(%rip), %rcx      # 0xf4b0
movq %rcx, (%rsp)
movq %r15, %rdi
movq %rbx, %rsi
movq %r13, %rdx
movq -0x38(%rbp), %rcx
movl -0x2c(%rbp), %r8d
movq %r14, %r9
callq *%rax
movl %eax, %r15d
jmp 0x5a6f
movl $0x186a2, %eax          # imm = 0x186A2
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x5919(%rip), %rax      # 0xb350
movq %rax, (%rsp)
leaq 0x564e(%rip), %rsi      # 0xb090
leaq 0x564d(%rip), %rdx      # 0xb096
leaq 0x564b(%rip), %rcx      # 0xb09b
leaq 0x58e3(%rip), %r8       # 0xb33a
movl $0x3, %edi
movl $0x27b, %r9d            # imm = 0x27B
xorl %eax, %eax
callq 0x4260
movl $0x186a0, %r15d         # imm = 0x186A0
xorl %r12d, %r12d
testl %r15d, %r15d
je 0x5a9e
xorl %r13d, %r13d
movq %r14, %rdi
callq 0x46b0
movl %r15d, %edi
movl -0x30(%rbp), %esi
movq %r13, %rdx
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x4370
movl 0x9a14(%rip), %eax      # 0xf4b8
testl %eax, %eax
jle 0x5ac9
movq %r14, %rcx
addq $0x4, %rcx
xorl %r12d, %r12d
cmpb $0x0, (%rcx)
je 0x5ac9
incq %r12
addq $0x844, %rcx            # imm = 0x844
cmpq %r12, %rax
jne 0x5ab2
movl %eax, %r12d
callq 0x45b0
testq %rax, %rax
je 0x5a77
movq %rax, %r13
movq %r14, %rdi
movl %r12d, %esi
callq 0x4570
testq %rax, %rax
je 0x5a7a
leaq 0x574a(%rip), %rsi      # 0xb237
movq %r13, %rdi
movq %rax, %rdx
callq 0x45f0
jmp 0x5a7a