// File: Agusyc[P]CTRPG/src/jsonparser.cpp
// Function: parseItem(int)
Item parseItem(int index) {
    Json::Value root; // The root element
    Json::Reader reader; // The reader... that reads

    ifstream ifs("./json/items.json");

    bool parsingSuccessful = reader.parse(ifs, root);
    if(!parsingSuccessful) {
        // Print error
        cout << "Failed to parse the attacks." << endl << "Error:" << endl << reader.getFormattedErrorMessages();
        exit(1);
    }

    Json::Value jItem = root[index];

    Item item;

    item.name = jItem["name"].asString();
    item.attackBoost = jItem["attackBoost"].asInt();
    item.defenseBoost = jItem["defenseBoost"].asInt();
    item.manaRecover = jItem["manaRecover"].asInt();
    item.staminaRecover = jItem["staminaRecover"].asInt();
    item.hpRecover = jItem["hpRecover"].asInt();
    item.minLevel = jItem["minLevel"].asInt();
    item.maxLevel = jItem["maxLevel"].asInt();
    item.id = index;

    return item;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x4a0, %rsp            # imm = 0x4A0
movq %rdi, -0x3e8(%rbp)
movq %rdi, %rax
movq %rax, -0x3e0(%rbp)
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
leaq -0x38(%rbp), %rdi
xorl %esi, %esi
callq 0x3120
leaq -0x148(%rbp), %rdi
callq 0x32c0
jmp 0xd21c
leaq 0x42bc(%rip), %rsi      # 0x114df
leaq -0x360(%rbp), %rdi
movl $0x8, %edx
callq 0x3550
jmp 0xd236
leaq -0x148(%rbp), %rdi
leaq -0x360(%rbp), %rsi
leaq -0x38(%rbp), %rdx
movl $0x1, %ecx
callq 0x3570
movb %al, -0x3e9(%rbp)
jmp 0xd25a
movb -0x3e9(%rbp), %al
andb $0x1, %al
movb %al, -0x361(%rbp)
testb $0x1, -0x361(%rbp)
jne 0xd38d
movq 0xad54(%rip), %rdi      # 0x17fd0
leaq 0x426e(%rip), %rsi      # 0x114f1
callq 0x3290
movq %rax, -0x3f8(%rbp)
jmp 0xd291
movq -0x3f8(%rbp), %rdi
movq 0xad21(%rip), %rsi      # 0x17fc0
callq 0x32b0
movq %rax, -0x400(%rbp)
jmp 0xd2ad
movq -0x400(%rbp), %rdi
leaq 0x41ec(%rip), %rsi      # 0x114a7
callq 0x3290
movq %rax, -0x408(%rbp)
jmp 0xd2c9
movq -0x408(%rbp), %rdi
movq 0xace9(%rip), %rsi      # 0x17fc0
callq 0x32b0
movq %rax, -0x410(%rbp)
jmp 0xd2e5
leaq -0x388(%rbp), %rdi
leaq -0x148(%rbp), %rsi
callq 0x3480
jmp 0xd2fa
movq -0x410(%rbp), %rdi
leaq -0x388(%rbp), %rsi
callq 0x3230
jmp 0xd30f
leaq -0x388(%rbp), %rdi
callq 0x31b0
movl $0x1, %edi
callq 0x3350
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x150(%rbp)
movl %eax, -0x154(%rbp)
jmp 0xd686
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x150(%rbp)
movl %eax, -0x154(%rbp)
jmp 0xd67a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x150(%rbp)
movl %eax, -0x154(%rbp)
jmp 0xd66e
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x150(%rbp)
movl %eax, -0x154(%rbp)
leaq -0x388(%rbp), %rdi
callq 0x31b0
jmp 0xd66e
movl -0xc(%rbp), %esi
leaq -0x38(%rbp), %rdi
callq 0x32f0
movq %rax, -0x418(%rbp)
jmp 0xd3a2
movq -0x418(%rbp), %rsi
leaq -0x3b0(%rbp), %rdi
callq 0x34b0
jmp 0xd3b7
movq -0x3e8(%rbp), %rdi
movb $0x0, -0x3b1(%rbp)
callq 0x8580
leaq 0x413d(%rip), %rsi      # 0x1150e
leaq -0x3b0(%rbp), %rdi
callq 0x3100
movq %rax, -0x420(%rbp)
jmp 0xd3e6
movq -0x420(%rbp), %rsi
leaq -0x3d8(%rbp), %rdi
callq 0x3560
jmp 0xd3fb
movq -0x3e8(%rbp), %rdi
leaq -0x3d8(%rbp), %rsi
movq %rsi, -0x430(%rbp)
callq 0x3360
movq -0x430(%rbp), %rdi
callq 0x31b0
leaq 0x40eb(%rip), %rsi      # 0x11513
leaq -0x3b0(%rbp), %rdi
callq 0x3100
movq %rax, -0x428(%rbp)
jmp 0xd43d
movq -0x428(%rbp), %rdi
callq 0x3450
movl %eax, -0x434(%rbp)
jmp 0xd451
movq -0x3e8(%rbp), %rax
movl -0x434(%rbp), %ecx
movl %ecx, 0x20(%rax)
leaq 0x40b7(%rip), %rsi      # 0x1151f
leaq -0x3b0(%rbp), %rdi
callq 0x3100
movq %rax, -0x440(%rbp)
jmp 0xd47d
movq -0x440(%rbp), %rdi
callq 0x3450
movl %eax, -0x444(%rbp)
jmp 0xd491
movq -0x3e8(%rbp), %rax
movl -0x444(%rbp), %ecx
movl %ecx, 0x24(%rax)
leaq 0x4084(%rip), %rsi      # 0x1152c
leaq -0x3b0(%rbp), %rdi
callq 0x3100
movq %rax, -0x450(%rbp)
jmp 0xd4bd
movq -0x450(%rbp), %rdi
callq 0x3450
movl %eax, -0x454(%rbp)
jmp 0xd4d1
movq -0x3e8(%rbp), %rax
movl -0x454(%rbp), %ecx
movl %ecx, 0x28(%rax)
leaq 0x4050(%rip), %rsi      # 0x11538
leaq -0x3b0(%rbp), %rdi
callq 0x3100
movq %rax, -0x460(%rbp)
jmp 0xd4fd
movq -0x460(%rbp), %rdi
callq 0x3450
movl %eax, -0x464(%rbp)
jmp 0xd511
movq -0x3e8(%rbp), %rax
movl -0x464(%rbp), %ecx
movl %ecx, 0x2c(%rax)
leaq 0x401f(%rip), %rsi      # 0x11547
leaq -0x3b0(%rbp), %rdi
callq 0x3100
movq %rax, -0x470(%rbp)
jmp 0xd53d
movq -0x470(%rbp), %rdi
callq 0x3450
movl %eax, -0x474(%rbp)
jmp 0xd551
movq -0x3e8(%rbp), %rax
movl -0x474(%rbp), %ecx
movl %ecx, 0x30(%rax)
leaq 0x3fe9(%rip), %rsi      # 0x11551
leaq -0x3b0(%rbp), %rdi
callq 0x3100
movq %rax, -0x480(%rbp)
jmp 0xd57d
movq -0x480(%rbp), %rdi
callq 0x3450
movl %eax, -0x484(%rbp)
jmp 0xd591
movq -0x3e8(%rbp), %rax
movl -0x484(%rbp), %ecx
movl %ecx, 0x34(%rax)
leaq 0x3fb2(%rip), %rsi      # 0x1155a
leaq -0x3b0(%rbp), %rdi
callq 0x3100
movq %rax, -0x490(%rbp)
jmp 0xd5bd
movq -0x490(%rbp), %rdi
callq 0x3450
movl %eax, -0x494(%rbp)
jmp 0xd5d1
movq -0x3e8(%rbp), %rax
movl -0x494(%rbp), %ecx
movl %ecx, 0x38(%rax)
movl -0xc(%rbp), %ecx
movl %ecx, 0x3c(%rax)
movb $0x1, -0x3b1(%rbp)
testb $0x1, -0x3b1(%rbp)
jne 0xd631
jmp 0xd625
movq -0x3e8(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x150(%rbp)
movl %eax, -0x154(%rbp)
callq 0x85f0
leaq -0x3b0(%rbp), %rdi
callq 0x3150
jmp 0xd66e
movq -0x3e8(%rbp), %rdi
callq 0x85f0
leaq -0x3b0(%rbp), %rdi
callq 0x3150
leaq -0x360(%rbp), %rdi
callq 0x30b0
leaq -0x148(%rbp), %rdi
callq 0xf0a0
leaq -0x38(%rbp), %rdi
callq 0x3150
movq -0x3e0(%rbp), %rax
addq $0x4a0, %rsp            # imm = 0x4A0
popq %rbp
retq
leaq -0x360(%rbp), %rdi
callq 0x30b0
leaq -0x148(%rbp), %rdi
callq 0xf0a0
leaq -0x38(%rbp), %rdi
callq 0x3150
movq -0x150(%rbp), %rdi
callq 0x3530
nopl (%rax,%rax)