// File: /workspace/github_c_makefile_star2_O1/back1127[P]linkedge-thing-access-websocket_client_sdk/sdk/leda.c
// Function: struct_data_to_json_data
cJSON *struct_data_to_json_data(const leda_device_data_t *struct_data, int data_cnt)
{
    int i;
    cJSON *root, *item, *sub_item;
    
    root = cJSON_CreateArray();
    if (!root) {
        return NULL;
    }

    for (i = 0; i < data_cnt; i++) {
        item = cJSON_CreateObject();
        if (!item) {
            cJSON_Delete(root);
            return NULL;
        }
        cJSON_AddStringToObject(item, "identifier", struct_data[i].key);
        cJSON_AddStringToObject(item, "type",type_number_to_string(struct_data[i].type));
        switch (struct_data[i].type) {
            case LEDA_TYPE_INT:
            case LEDA_TYPE_BOOL:
            case LEDA_TYPE_ENUM:
                cJSON_AddNumberToObject(item, "value", atoi(struct_data[i].value));
                break;
            case LEDA_TYPE_DOUBLE:
            case LEDA_TYPE_FLOAT:
                cJSON_AddNumberToObject(item, "value", atof(struct_data[i].value));
                break;
            case LEDA_TYPE_DATE:
            case LEDA_TYPE_TEXT:
                cJSON_AddStringToObject(item, "value", struct_data[i].value);
                break;
            case LEDA_TYPE_ARRAY:
            case LEDA_TYPE_STRUCT:
                sub_item = cJSON_Parse(struct_data[i].value);
                if (!sub_item) {
                    log_e(LOG_TAG, "value format is error!\n");
                    cJSON_Delete(root);
                    return NULL;
                }
                cJSON_AddItemToObject(item, "value", sub_item);
                break;
            default:
                cJSON_AddStringToObject(item, "value", "invalid");
                break;
        }
        cJSON_AddItemToArray(root, item);
    }

    return root;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movl %esi, %r15d
movq %rdi, %r14
callq 0x4460
testq %rax, %rax
je 0x4a1c
movq %rax, %rbx
testl %r15d, %r15d
jle 0x4a1e
movl %r15d, %r15d
addq $0x44, %r14
leaq 0x6714(%rip), %r12      # 0xb000
callq 0x45b0
testq %rax, %rax
je 0x4a14
movq %rax, %r13
leaq -0x40(%r14), %rdx
movq %rax, %rdi
leaq 0x676f(%rip), %rsi      # 0xb07a
callq 0x44f0
movl -0x44(%r14), %eax
leaq 0x67bc(%rip), %rdx      # 0xb0d7
cmpq $0x8, %rax
ja 0x492c
leaq 0xa3b8(%rip), %rcx      # 0xece0
movq (%rcx,%rax,8), %rdx
movq %r13, %rdi
leaq 0x674f(%rip), %rsi      # 0xb085
callq 0x44f0
movl -0x44(%r14), %eax
cmpq $0x8, %rax
ja 0x49a8
movslq (%r12,%rax,4), %rax
addq %r12, %rax
jmpq *%rax
movq %r14, %rdi
callq 0x4560
xorps %xmm0, %xmm0
cvtsi2sd %eax, %xmm0
jmp 0x4976
movq %r13, %rdi
leaq 0x6721(%rip), %rsi      # 0xb08a
movq %r14, %rdx
jmp 0x49b9
movq %r14, %rdi
callq 0x4120
movq %r13, %rdi
leaq 0x670a(%rip), %rsi      # 0xb08a
callq 0x4210
jmp 0x49be
movq %r14, %rdi
callq 0x4250
testq %rax, %rax
je 0x49db
movq %r13, %rdi
leaq 0x66ec(%rip), %rsi      # 0xb08a
movq %rax, %rdx
callq 0x45f0
jmp 0x49be
movq %r13, %rdi
leaq 0x66d8(%rip), %rsi      # 0xb08a
leaq 0x671e(%rip), %rdx      # 0xb0d7
callq 0x44f0
movq %rbx, %rdi
movq %r13, %rsi
callq 0x4180
addq $0x844, %r14            # imm = 0x844
decq %r15
jne 0x48ec
jmp 0x4a1e
leaq 0x66dd(%rip), %rax      # 0xb0bf
movq %rax, (%rsp)
leaq 0x66a3(%rip), %rsi      # 0xb090
leaq 0x66a2(%rip), %rdx      # 0xb096
leaq 0x66a0(%rip), %rcx      # 0xb09b
leaq 0x66a4(%rip), %r8       # 0xb0a6
movl $0x3, %edi
movl $0x97, %r9d
xorl %eax, %eax
callq 0x4260
movq %rbx, %rdi
callq 0x41a0
xorl %ebx, %ebx
movq %rbx, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq