// File: /workspace/github_c_makefile_star2_O2/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 0x44f0
xorl %r12d, %r12d
testq %rax, %rax
je 0x4aa5
movq %rax, %rbx
testl %r15d, %r15d
cmovgl %r15d, %r12d
addq $0x44, %r14
leaq 0x568a(%rip), %r15      # 0xa000
subq $0x1, %r12
jb 0x4aa7
callq 0x4640
testq %rax, %rax
je 0x4a9d
movq %rax, %r13
leaq -0x40(%r14), %rdx
movq %rax, %rdi
leaq 0x56db(%rip), %rsi      # 0xa07a
callq 0x4580
movl -0x44(%r14), %eax
leaq 0x5728(%rip), %rdx      # 0xa0d7
cmpq $0x8, %rax
ja 0x49c0
leaq 0x9324(%rip), %rcx      # 0xdce0
movq (%rcx,%rax,8), %rdx
movq %r13, %rdi
leaq 0x56bb(%rip), %rsi      # 0xa085
callq 0x4580
movl -0x44(%r14), %eax
cmpq $0x8, %rax
ja 0x4a39
movslq (%r15,%rax,4), %rax
addq %r15, %rax
jmpq *%rax
movq %r14, %rdi
callq 0x45f0
cvtsi2sd %eax, %xmm0
jmp 0x4a07
movq %r13, %rdi
leaq 0x5690(%rip), %rsi      # 0xa08a
movq %r14, %rdx
jmp 0x4a4a
movq %r14, %rdi
callq 0x4150
movq %r13, %rdi
leaq 0x5679(%rip), %rsi      # 0xa08a
callq 0x4240
jmp 0x4a4f
movq %r14, %rdi
callq 0x4280
testq %rax, %rax
je 0x4a66
movq %r13, %rdi
leaq 0x565b(%rip), %rsi      # 0xa08a
movq %rax, %rdx
callq 0x4690
jmp 0x4a4f
movq %r13, %rdi
leaq 0x5647(%rip), %rsi      # 0xa08a
leaq 0x568d(%rip), %rdx      # 0xa0d7
callq 0x4580
movq %rbx, %rdi
movq %r13, %rsi
callq 0x41b0
addq $0x844, %r14            # imm = 0x844
jmp 0x4976
leaq 0x5652(%rip), %rax      # 0xa0bf
movq %rax, (%rsp)
leaq 0x5618(%rip), %rsi      # 0xa090
leaq 0x5617(%rip), %rdx      # 0xa096
leaq 0x5615(%rip), %rcx      # 0xa09b
leaq 0x5619(%rip), %r8       # 0xa0a6
pushq $0x3
popq %rdi
movl $0x97, %r9d
xorl %eax, %eax
callq 0x4290
movq %rbx, %rdi
callq 0x41d0
xorl %ebx, %ebx
movq %rbx, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq