// File: /workspace/github_c_makefile_star2_O3/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 0x4490
testq %rax, %rax
je 0x4a3c
movq %rax, %rbx
testl %r15d, %r15d
jle 0x4a3e
movl %r15d, %r15d
addq $0x44, %r14
leaq 0x56f4(%rip), %r12      # 0xa000
callq 0x45e0
testq %rax, %rax
je 0x4a34
movq %rax, %r13
leaq -0x40(%r14), %rdx
movq %rax, %rdi
leaq 0x574f(%rip), %rsi      # 0xa07a
callq 0x4520
movl -0x44(%r14), %eax
leaq 0x579c(%rip), %rdx      # 0xa0d7
cmpq $0x8, %rax
ja 0x494c
leaq 0x9398(%rip), %rcx      # 0xdce0
movq (%rcx,%rax,8), %rdx
movq %r13, %rdi
leaq 0x572f(%rip), %rsi      # 0xa085
callq 0x4520
movl -0x44(%r14), %eax
cmpq $0x8, %rax
ja 0x49c8
movslq (%r12,%rax,4), %rax
addq %r12, %rax
jmpq *%rax
movq %r14, %rdi
callq 0x4590
xorps %xmm0, %xmm0
cvtsi2sd %eax, %xmm0
jmp 0x4996
movq %r13, %rdi
leaq 0x5701(%rip), %rsi      # 0xa08a
movq %r14, %rdx
jmp 0x49d9
movq %r14, %rdi
callq 0x4120
movq %r13, %rdi
leaq 0x56ea(%rip), %rsi      # 0xa08a
callq 0x4210
jmp 0x49de
movq %r14, %rdi
callq 0x4250
testq %rax, %rax
je 0x49fb
movq %r13, %rdi
leaq 0x56cc(%rip), %rsi      # 0xa08a
movq %rax, %rdx
callq 0x4610
jmp 0x49de
movq %r13, %rdi
leaq 0x56b8(%rip), %rsi      # 0xa08a
leaq 0x56fe(%rip), %rdx      # 0xa0d7
callq 0x4520
movq %rbx, %rdi
movq %r13, %rsi
callq 0x4180
addq $0x844, %r14            # imm = 0x844
decq %r15
jne 0x490c
jmp 0x4a3e
leaq 0x56bd(%rip), %rax      # 0xa0bf
movq %rax, (%rsp)
leaq 0x5683(%rip), %rsi      # 0xa090
leaq 0x5682(%rip), %rdx      # 0xa096
leaq 0x5680(%rip), %rcx      # 0xa09b
leaq 0x5684(%rip), %r8       # 0xa0a6
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