// File: /workspace/github_cpp_makefile_star2_O1/fgheng[P]keysound/src/Audio.cc
// Function: Audio::from_json(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&)
void Audio::from_json(const std::string &str) {
    // json
    std::map<std::string, uint16_t> a_map;
    bool has_file = false;

    std::ifstream f(str);
    std::stringstream json_buf;
    json_buf << f.rdbuf();
    f.close();

    cJSON *root = cJSON_Parse(json_buf.str().c_str());

    if (!root) {
        std::cout << "parse json failed" << std::endl;
        exit(EXIT_FAILURE);
    }

    cJSON *item;
    item = cJSON_GetObjectItem(root, "dir");
    if (item) {
        std::string wav_dir = std::string(item->valuestring);

        for (int i = 0; i < 256; i++) {
            item = cJSON_GetObjectItem(root, KEYS[i].first.c_str());

            if (!item) {
                datas[KEYS[i].second] = 0;
                continue;
            }

            std::string wav_name = std::string(item->valuestring);

            // 已经读取过该音频了	The audio has already been read
            if (a_map.count(wav_name) > 0) {
                datas[KEYS[i].second] = a_map[wav_name];
                continue;
            }

            // if (wav_datas[i].data) continue;

            if (read_wav(wav_dir + "/" + wav_name, wav_datas[i])) {
                datas[KEYS[i].second] = i;
                a_map[wav_name] = i;
                has_file = true;
            } else {
                datas[KEYS[i].second] = 0;
            }
        }
    } else {
        std::cout << "you must add a dir item in json" << std::endl;
        cJSON_Delete(root);
        exit(EXIT_FAILURE);
    }
    cJSON_Delete(root);

    if (!has_file) {
        std::cout << "no wav file read success" << std::endl;
        exit(EXIT_FAILURE);
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x458, %rsp            # imm = 0x458
movq %rdi, 0x8(%rsp)
leaq 0xa0(%rsp), %r12
movl $0x0, (%r12)
xorl %eax, %eax
movq %rax, 0x8(%r12)
movq %r12, 0x10(%r12)
movq %r12, 0x18(%r12)
movq %rax, 0x20(%r12)
leaq 0x250(%rsp), %rdi
movl $0x8, %edx
callq 0x3550
leaq 0xc8(%rsp), %rdi
callq 0x3250
leaq 0xd8(%rsp), %rdi
leaq 0x260(%rsp), %rsi
callq 0x30b0
leaq 0x250(%rsp), %rdi
callq 0x30a0
leaq 0xe0(%rsp), %rsi
leaq 0x10(%rsp), %rdi
callq 0x3540
movq 0x10(%rsp), %rdi
callq 0xa02c
movq %rax, %rbp
leaq 0x20(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x74c3
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x3390
testq %rbp, %rbp
je 0x7778
leaq 0x6f22(%rip), %rsi      # 0xe3f5
movq %rbp, %rdi
callq 0xa1be
testq %rax, %rax
je 0x779e
movq 0x20(%rax), %rsi
leaq 0x10(%rsp), %rdi
leaq 0x78(%rsp), %rdx
callq 0x7cd8
leaq 0xbe82(%rip), %r13      # 0x13380
xorl %r14d, %r14d
leaq 0x78(%rsp), %r15
movq 0x8(%rsp), %rbx
movq $0x0, 0x50(%rsp)
movq -0x20(%r13), %rsi
movq %rbp, %rdi
callq 0xa1be
testq %rax, %rax
je 0x7575
movq 0x20(%rax), %rsi
movq %r15, %rdi
leaq 0x30(%rsp), %rdx
callq 0x7cd8
leaq 0x98(%rsp), %rdi
movq %r15, %rsi
callq 0x7f36
cmpq %r12, %rax
je 0x758e
leaq 0x98(%rsp), %rdi
movq %r15, %rsi
callq 0x7d16
movzwl (%rax), %eax
movzwl (%r13), %ecx
movq 0x8(%rsp), %rdx
movw %ax, 0x1000(%rdx,%rcx,2)
jmp 0x76c2
movzwl (%r13), %eax
movq 0x8(%rsp), %rcx
movw $0x0, 0x1000(%rcx,%rax,2)
jmp 0x76e4
leaq 0x68(%rsp), %rax
movq %rax, 0x58(%rsp)
movq 0x10(%rsp), %rsi
movq 0x18(%rsp), %rdx
addq %rsi, %rdx
leaq 0x58(%rsp), %r12
movq %r12, %rdi
callq 0x7ea6
movq %r12, %rdi
leaq 0x6e81(%rip), %rsi      # 0xe43d
callq 0x3630
movq 0x78(%rsp), %rsi
movq 0x80(%rsp), %rdx
movq %r12, %rdi
callq 0x3110
leaq 0x40(%rsp), %rsi
movq %rsi, 0x30(%rsp)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
je 0x75fe
movq %rdx, 0x30(%rsp)
movq (%rcx), %rdx
movq %rdx, 0x40(%rsp)
jmp 0x7604
movups (%rcx), %xmm0
movups %xmm0, (%rsi)
movq 0x8(%rax), %rdx
movq %rdx, 0x38(%rsp)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
movq 0x8(%rsp), %rdi
leaq 0x30(%rsp), %rsi
movq %rbx, %rdx
callq 0x7a28
movl %eax, %r12d
movq 0x30(%rsp), %rdi
leaq 0x40(%rsp), %rax
cmpq %rax, %rdi
je 0x764d
movq 0x40(%rsp), %rsi
incq %rsi
callq 0x3390
movq 0x58(%rsp), %rdi
leaq 0x68(%rsp), %rax
cmpq %rax, %rdi
je 0x7669
movq 0x68(%rsp), %rsi
incq %rsi
callq 0x3390
testb %r12b, %r12b
je 0x76a6
movzwl (%r13), %eax
movq 0x8(%rsp), %rcx
movw %r14w, 0x1000(%rcx,%rax,2)
leaq 0x98(%rsp), %rdi
movq %r15, %rsi
callq 0x7d16
leaq 0xa0(%rsp), %r12
movw %r14w, (%rax)
movb $0x1, %al
movq %rax, 0x50(%rsp)
jmp 0x76c2
movzwl (%r13), %eax
movq 0x8(%rsp), %rcx
movw $0x0, 0x1000(%rcx,%rax,2)
leaq 0xa0(%rsp), %r12
movq 0x78(%rsp), %rdi
leaq 0x88(%rsp), %rax
cmpq %rax, %rdi
je 0x76e4
movq 0x88(%rsp), %rsi
incq %rsi
callq 0x3390
incq %r14
addq $0x10, %rbx
addq $0x28, %r13
cmpq $0x100, %r14            # imm = 0x100
jne 0x7514
movq 0x10(%rsp), %rdi
leaq 0x20(%rsp), %rax
cmpq %rax, %rdi
je 0x7718
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x3390
movq %rbp, %rdi
callq 0x9c93
testb $0x1, 0x50(%rsp)
je 0x77cc
movq 0xb85e(%rip), %rsi      # 0x12f90
leaq 0xc8(%rsp), %rdi
callq 0x3280
leaq 0x148(%rsp), %rdi
callq 0x3130
leaq 0x250(%rsp), %rdi
callq 0x30e0
leaq 0x98(%rsp), %rdi
callq 0x7d9e
addq $0x458, %rsp            # imm = 0x458
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0xb841(%rip), %rdi      # 0x12fc0
leaq 0x6cd8(%rip), %rsi      # 0xe45e
movl $0x11, %edx
callq 0x33d0
movq 0xb829(%rip), %rdi      # 0x12fc0
callq 0x31a0
jmp 0x77f0
movq 0xb81b(%rip), %rdi      # 0x12fc0
leaq 0x6cc4(%rip), %rsi      # 0xe470
movl $0x1f, %edx
callq 0x33d0
movq 0xb803(%rip), %rdi      # 0x12fc0
callq 0x31a0
movq %rbp, %rdi
callq 0x9c93
jmp 0x77f0
movq 0xb7ed(%rip), %rdi      # 0x12fc0
leaq 0x6cb6(%rip), %rsi      # 0xe490
movl $0x18, %edx
callq 0x33d0
movq 0xb7d5(%rip), %rdi      # 0x12fc0
callq 0x31a0
movl $0x1, %edi
callq 0x3410
jmp 0x7823
jmp 0x7823
movq %rax, %rbx
leaq 0x20(%rsp), %rax
movq -0x10(%rax), %rdi
jmp 0x78a7
jmp 0x7823
movq %rax, %rbx
jmp 0x78da
movq %rax, %rbx
jmp 0x78e7
jmp 0x7823
movq %rax, %rbx
jmp 0x78b9
movq %rax, %rbx
movq 0x30(%rsp), %rdi
leaq 0x40(%rsp), %rax
cmpq %rax, %rdi
je 0x7851
movq 0x40(%rsp), %rsi
incq %rsi
callq 0x3390
jmp 0x7851
jmp 0x784e
movq %rax, %rbx
movq 0x58(%rsp), %rdi
leaq 0x68(%rsp), %rax
cmpq %rax, %rdi
je 0x787b
movq 0x68(%rsp), %rsi
incq %rsi
callq 0x3390
jmp 0x787b
jmp 0x7878
jmp 0x7873
movq %rax, %rbx
jmp 0x789d
movq %rax, %rbx
movq 0x78(%rsp), %rdi
leaq 0x88(%rsp), %rax
cmpq %rax, %rdi
je 0x789d
movq 0x88(%rsp), %rsi
incq %rsi
callq 0x3390
movq 0x10(%rsp), %rdi
leaq 0x20(%rsp), %rax
cmpq %rax, %rdi
je 0x78b9
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x3390
movq 0xb6d0(%rip), %rsi      # 0x12f90
leaq 0xc8(%rsp), %rdi
callq 0x3280
leaq 0x148(%rsp), %rdi
callq 0x3130
leaq 0x250(%rsp), %rdi
callq 0x30e0
leaq 0x98(%rsp), %rdi
callq 0x7d9e
movq %rbx, %rdi
callq 0x35e0