// File: /workspace/github_c_makefile_star2_O0/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
subq $0x60, %rsp
movq %rdi, -0x10(%rbp)
movl %esi, -0x14(%rbp)
callq 0x4520
movq %rax, -0x20(%rbp)
cmpq $0x0, -0x20(%rbp)
jne 0x4a3c
movq $0x0, -0x8(%rbp)
jmp 0x4c60
movl $0x0, -0x18(%rbp)
movl -0x18(%rbp), %eax
cmpl -0x14(%rbp), %eax
jge 0x4c58
callq 0x4680
movq %rax, -0x28(%rbp)
cmpq $0x0, -0x28(%rbp)
jne 0x4a75
movq -0x20(%rbp), %rdi
callq 0x41e0
movq $0x0, -0x8(%rbp)
jmp 0x4c60
movq -0x28(%rbp), %rdi
movq -0x10(%rbp), %rax
movslq -0x18(%rbp), %rcx
imulq $0x844, %rcx, %rcx      # imm = 0x844
leaq 0x4(%rax,%rcx), %rdx
leaq 0x95e6(%rip), %rsi      # 0xe07a
callq 0x45b0
movq -0x28(%rbp), %rax
movq %rax, -0x40(%rbp)
movq -0x10(%rbp), %rax
movslq -0x18(%rbp), %rcx
imulq $0x844, %rcx, %rcx      # imm = 0x844
movl (%rax,%rcx), %edi
callq 0x44d0
movq -0x40(%rbp), %rdi
movq %rax, %rdx
leaq 0x95bf(%rip), %rsi      # 0xe085
callq 0x45b0
movq -0x10(%rbp), %rax
movslq -0x18(%rbp), %rcx
imulq $0x844, %rcx, %rcx      # imm = 0x844
movl (%rax,%rcx), %eax
movq %rax, -0x38(%rbp)
subq $0x8, %rax
ja 0x4c26
movq -0x38(%rbp), %rax
leaq 0x950a(%rip), %rcx      # 0xe000
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq -0x28(%rbp), %rax
movq %rax, -0x48(%rbp)
movq -0x10(%rbp), %rdi
movslq -0x18(%rbp), %rax
imulq $0x844, %rax, %rax      # imm = 0x844
addq %rax, %rdi
addq $0x44, %rdi
callq 0x4630
movq -0x48(%rbp), %rdi
cvtsi2sd %eax, %xmm0
leaq 0x9559(%rip), %rsi      # 0xe08a
callq 0x4260
jmp 0x4c3d
movq -0x28(%rbp), %rax
movq %rax, -0x50(%rbp)
movq -0x10(%rbp), %rdi
movslq -0x18(%rbp), %rax
imulq $0x844, %rax, %rax      # imm = 0x844
addq %rax, %rdi
addq $0x44, %rdi
callq 0x4160
movq -0x50(%rbp), %rdi
leaq 0x9521(%rip), %rsi      # 0xe08a
callq 0x4260
jmp 0x4c3d
movq -0x28(%rbp), %rdi
movq -0x10(%rbp), %rdx
movslq -0x18(%rbp), %rax
imulq $0x844, %rax, %rax      # imm = 0x844
addq %rax, %rdx
addq $0x44, %rdx
leaq 0x94f6(%rip), %rsi      # 0xe08a
callq 0x45b0
jmp 0x4c3d
movq -0x10(%rbp), %rdi
movslq -0x18(%rbp), %rax
imulq $0x844, %rax, %rax      # imm = 0x844
addq %rax, %rdi
addq $0x44, %rdi
callq 0x42a0
movq %rax, -0x30(%rbp)
cmpq $0x0, -0x30(%rbp)
jne 0x4c10
movl $0x3, %edi
leaq 0x94c0(%rip), %rsi      # 0xe090
leaq 0x94bf(%rip), %rdx      # 0xe096
leaq 0x94bd(%rip), %rcx      # 0xe09b
leaq 0x94c1(%rip), %r8       # 0xe0a6
movl $0x97, %r9d
leaq 0x94cd(%rip), %rax      # 0xe0bf
movq %rax, (%rsp)
movb $0x0, %al
callq 0x42b0
movq -0x20(%rbp), %rdi
callq 0x41e0
movq $0x0, -0x8(%rbp)
jmp 0x4c60
movq -0x28(%rbp), %rdi
movq -0x30(%rbp), %rdx
leaq 0x946b(%rip), %rsi      # 0xe08a
callq 0x46e0
jmp 0x4c3d
movq -0x28(%rbp), %rdi
leaq 0x9459(%rip), %rsi      # 0xe08a
leaq 0x949f(%rip), %rdx      # 0xe0d7
callq 0x45b0
movq -0x20(%rbp), %rdi
movq -0x28(%rbp), %rsi
callq 0x41c0
movl -0x18(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x18(%rbp)
jmp 0x4a43
movq -0x20(%rbp), %rax
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x60, %rsp
popq %rbp
retq
nopw (%rax,%rax)