// File: /workspace/github_c_makefile_star2_O0/back1127[P]linkedge-thing-access-websocket_client_sdk/sdk/leda.c
// Function: json_data_to_struct_data
int json_data_to_struct_data(cJSON *json_data, leda_device_data_t **struct_data, int *data_cnt)
{
    int size, i = 0;
    cJSON *item, *sub_item;
    char *buff;
    leda_device_data_t *data;
    

    size = cJSON_GetArraySize(json_data);
    if (size <= 0) {
        *data_cnt = 0;
        return LE_SUCCESS;
    }
    *data_cnt = size;
    data = malloc(sizeof(leda_device_data_t) * size);
    if (!data) {
        log_e(LOG_TAG, "no memory!");
        return LE_ERROR_ALLOCATING_MEM;
    }
    cJSON_ArrayForEach(item, json_data) {
        if (item->type == cJSON_String) {
            snprintf(data[i++].key, MAX_PARAM_NAME_LENGTH, "%s", item->valuestring);
            continue;
        }
        sub_item = cJSON_GetObjectItem(item, "identifier");
        if (!sub_item) {
            free(data);
            return LE_ERROR_INVAILD_PARAM;
        }
        snprintf(data[i].key, MAX_PARAM_NAME_LENGTH, "%s", sub_item->valuestring);
        sub_item = cJSON_GetObjectItem(item, "type");
        if (!sub_item | sub_item->type != cJSON_String) {
            free(data);
            return LE_ERROR_INVAILD_PARAM;
        }
        data[i].type = type_string_to_number(sub_item->valuestring);
        sub_item = cJSON_GetObjectItem(item, "value");
        if (!sub_item) {
            free(data);
            return LE_ERROR_INVAILD_PARAM;
        }
        switch (data[i].type) {
            case LEDA_TYPE_INT:
            case LEDA_TYPE_BOOL:
            case LEDA_TYPE_ENUM:
                snprintf(data[i].value, MAX_PARAM_VALUE_LENGTH, "%d", sub_item->valueint);
                break;
            case LEDA_TYPE_FLOAT:
            case LEDA_TYPE_DOUBLE:
                snprintf(data[i].value, MAX_PARAM_VALUE_LENGTH, "%lf", sub_item->valuedouble);
                break;
            case LEDA_TYPE_TEXT:
            case LEDA_TYPE_DATE:
                snprintf(data[i].value, MAX_PARAM_VALUE_LENGTH, "%s", sub_item->valuestring);
                break;
            case LEDA_TYPE_STRUCT:
            case LEDA_TYPE_ARRAY:
                buff = cJSON_Print(sub_item);
                if (!buff) {
                    log_e(LOG_TAG, "no memory!");
                    free(data);
                    return LE_ERROR_ALLOCATING_MEM;
                }
                snprintf(data[i].value, MAX_PARAM_VALUE_LENGTH, "%s", buff);
                free(buff);
                break;
            default:
                log_e(LOG_TAG, "invalid type for %s !\n", data[i].key);
                break;
        }
        ++i;
    }
    *struct_data = data;

    return LE_SUCCESS;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x70, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movl $0x0, -0x28(%rbp)
movq -0x10(%rbp), %rdi
callq 0x4330
movl %eax, -0x24(%rbp)
cmpl $0x0, -0x24(%rbp)
jg 0x4cb3
movq -0x20(%rbp), %rax
movl $0x0, (%rax)
movl $0x0, -0x4(%rbp)
jmp 0x5088
movl -0x24(%rbp), %ecx
movq -0x20(%rbp), %rax
movl %ecx, (%rax)
movslq -0x24(%rbp), %rax
imulq $0x844, %rax, %rdi      # imm = 0x844
callq 0x4798
movq %rax, -0x48(%rbp)
cmpq $0x0, -0x48(%rbp)
jne 0x4d1c
movl $0x3, %edi
leaq 0x93ad(%rip), %rsi      # 0xe090
leaq 0x93ac(%rip), %rdx      # 0xe096
leaq 0x93aa(%rip), %rcx      # 0xe09b
leaq 0x93e7(%rip), %r8       # 0xe0df
movl $0xb8, %r9d
leaq 0x93f3(%rip), %rax      # 0xe0f8
movq %rax, (%rsp)
movb $0x0, %al
callq 0x42b0
movl $0x186a2, -0x4(%rbp)    # imm = 0x186A2
jmp 0x5088
cmpq $0x0, -0x10(%rbp)
je 0x4d31
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0x50(%rbp)
jmp 0x4d39
xorl %eax, %eax
movq %rax, -0x50(%rbp)
jmp 0x4d39
movq -0x50(%rbp), %rax
movq %rax, -0x30(%rbp)
cmpq $0x0, -0x30(%rbp)
je 0x5076
movq -0x30(%rbp), %rax
cmpl $0x10, 0x18(%rax)
jne 0x4d95
movq -0x48(%rbp), %rdi
movl -0x28(%rbp), %eax
movl %eax, %ecx
addl $0x1, %ecx
movl %ecx, -0x28(%rbp)
cltq
imulq $0x844, %rax, %rax      # imm = 0x844
addq %rax, %rdi
addq $0x4, %rdi
movq -0x30(%rbp), %rax
movq 0x20(%rax), %rcx
movl $0x40, %esi
leaq 0x97c8(%rip), %rdx      # 0xe551
movb $0x0, %al
callq 0x42d0
jmp 0x5066
movq -0x30(%rbp), %rdi
leaq 0x92da(%rip), %rsi      # 0xe07a
callq 0x40d0
movq %rax, -0x38(%rbp)
cmpq $0x0, -0x38(%rbp)
jne 0x4dc5
movq -0x48(%rbp), %rdi
callq 0x4790
movl $0x186a1, -0x4(%rbp)    # imm = 0x186A1
jmp 0x5088
movq -0x48(%rbp), %rdi
movslq -0x28(%rbp), %rax
imulq $0x844, %rax, %rax      # imm = 0x844
addq %rax, %rdi
addq $0x4, %rdi
movq -0x38(%rbp), %rax
movq 0x20(%rax), %rcx
movl $0x40, %esi
leaq 0x9762(%rip), %rdx      # 0xe551
movb $0x0, %al
callq 0x42d0
movq -0x30(%rbp), %rdi
leaq 0x9284(%rip), %rsi      # 0xe085
callq 0x40d0
movq %rax, -0x38(%rbp)
cmpq $0x0, -0x38(%rbp)
setne %al
xorb $-0x1, %al
andb $0x1, %al
movzbl %al, %eax
movq -0x38(%rbp), %rcx
cmpl $0x10, 0x18(%rcx)
setne %cl
andb $0x1, %cl
movzbl %cl, %ecx
orl %ecx, %eax
cmpl $0x0, %eax
je 0x4e46
movq -0x48(%rbp), %rdi
callq 0x4790
movl $0x186a1, -0x4(%rbp)    # imm = 0x186A1
jmp 0x5088
movq -0x38(%rbp), %rax
movq 0x20(%rax), %rdi
callq 0x4320
movl %eax, %ecx
movq -0x48(%rbp), %rax
movslq -0x28(%rbp), %rdx
imulq $0x844, %rdx, %rdx      # imm = 0x844
addq %rdx, %rax
movl %ecx, (%rax)
movq -0x30(%rbp), %rdi
leaq 0x9216(%rip), %rsi      # 0xe08a
callq 0x40d0
movq %rax, -0x38(%rbp)
cmpq $0x0, -0x38(%rbp)
jne 0x4e99
movq -0x48(%rbp), %rdi
callq 0x4790
movl $0x186a1, -0x4(%rbp)    # imm = 0x186A1
jmp 0x5088
movq -0x48(%rbp), %rax
movslq -0x28(%rbp), %rcx
imulq $0x844, %rcx, %rcx      # imm = 0x844
movl (%rax,%rcx), %eax
movq %rax, -0x58(%rbp)
subq $0x8, %rax
ja 0x5009
movq -0x58(%rbp), %rax
leaq 0x9160(%rip), %rcx      # 0xe024
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq -0x48(%rbp), %rdi
movslq -0x28(%rbp), %rax
imulq $0x844, %rax, %rax      # imm = 0x844
addq %rax, %rdi
addq $0x44, %rdi
movq -0x38(%rbp), %rax
movl 0x28(%rax), %ecx
movl $0x800, %esi            # imm = 0x800
leaq 0x99cc(%rip), %rdx      # 0xe8c2
movb $0x0, %al
callq 0x42d0
jmp 0x505d
movq -0x48(%rbp), %rdi
movslq -0x28(%rbp), %rax
imulq $0x844, %rax, %rax      # imm = 0x844
addq %rax, %rdi
addq $0x44, %rdi
movq -0x38(%rbp), %rax
movsd 0x30(%rax), %xmm0
movl $0x800, %esi            # imm = 0x800
leaq 0x91d6(%rip), %rdx      # 0xe103
movb $0x1, %al
callq 0x42d0
jmp 0x505d
movq -0x48(%rbp), %rdi
movslq -0x28(%rbp), %rax
imulq $0x844, %rax, %rax      # imm = 0x844
addq %rax, %rdi
addq $0x44, %rdi
movq -0x38(%rbp), %rax
movq 0x20(%rax), %rcx
movl $0x800, %esi            # imm = 0x800
leaq 0x95ee(%rip), %rdx      # 0xe551
movb $0x0, %al
callq 0x42d0
jmp 0x505d
movq -0x38(%rbp), %rdi
callq 0x40f0
movq %rax, -0x40(%rbp)
cmpq $0x0, -0x40(%rbp)
jne 0x4fd1
movl $0x3, %edi
leaq 0x9101(%rip), %rsi      # 0xe090
leaq 0x9100(%rip), %rdx      # 0xe096
leaq 0x90fe(%rip), %rcx      # 0xe09b
leaq 0x913b(%rip), %r8       # 0xe0df
movl $0xe3, %r9d
leaq 0x9147(%rip), %rax      # 0xe0f8
movq %rax, (%rsp)
movb $0x0, %al
callq 0x42b0
movq -0x48(%rbp), %rdi
callq 0x4790
movl $0x186a2, -0x4(%rbp)    # imm = 0x186A2
jmp 0x5088
movq -0x48(%rbp), %rdi
movslq -0x28(%rbp), %rax
imulq $0x844, %rax, %rax      # imm = 0x844
addq %rax, %rdi
addq $0x44, %rdi
movq -0x40(%rbp), %rcx
movl $0x800, %esi            # imm = 0x800
leaq 0x955a(%rip), %rdx      # 0xe551
movb $0x0, %al
callq 0x42d0
movq -0x40(%rbp), %rdi
callq 0x4790
jmp 0x505d
movq -0x48(%rbp), %rax
movslq -0x28(%rbp), %rcx
imulq $0x844, %rcx, %rcx      # imm = 0x844
addq %rcx, %rax
addq $0x4, %rax
movl $0x3, %edi
leaq 0x9065(%rip), %rsi      # 0xe090
leaq 0x9064(%rip), %rdx      # 0xe096
leaq 0x9062(%rip), %rcx      # 0xe09b
leaq 0x909f(%rip), %r8       # 0xe0df
movl $0xeb, %r9d
leaq 0x90ba(%rip), %r10      # 0xe107
movq %r10, (%rsp)
movq %rax, 0x8(%rsp)
movb $0x0, %al
callq 0x42b0
movl -0x28(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x28(%rbp)
movq -0x30(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x30(%rbp)
jmp 0x4d41
movq -0x48(%rbp), %rcx
movq -0x18(%rbp), %rax
movq %rcx, (%rax)
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x70, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)