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

    ifstream ifs("./json/attacks.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 jAttack = root[index];

    Attack attack;

    attack.name = jAttack["name"].asString();
    attack.damage = jAttack["damage"].asInt();
    attack.magicDamage = jAttack["magicDamage"].asInt();
    attack.mana = jAttack["mana"].asInt();
    attack.stamina = jAttack["stamina"].asInt();
    attack.minLevel = jAttack["minLevel"].asInt();
    attack.maxLevel = jAttack["maxLevel"].asInt();
    attack.cost = jAttack["cost"].asInt();
    attack.id = index;

    return attack;
}

// 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 0xd6dc
leaq 0x3d94(%rip), %rsi      # 0x11477
leaq -0x360(%rbp), %rdi
movl $0x8, %edx
callq 0x3550
jmp 0xd6f6
leaq -0x148(%rbp), %rdi
leaq -0x360(%rbp), %rsi
leaq -0x38(%rbp), %rdx
movl $0x1, %ecx
callq 0x3570
movb %al, -0x3e9(%rbp)
jmp 0xd71a
movb -0x3e9(%rbp), %al
andb $0x1, %al
movb %al, -0x361(%rbp)
testb $0x1, -0x361(%rbp)
jne 0xd84d
movq 0xa894(%rip), %rdi      # 0x17fd0
leaq 0x3dae(%rip), %rsi      # 0x114f1
callq 0x3290
movq %rax, -0x3f8(%rbp)
jmp 0xd751
movq -0x3f8(%rbp), %rdi
movq 0xa861(%rip), %rsi      # 0x17fc0
callq 0x32b0
movq %rax, -0x400(%rbp)
jmp 0xd76d
movq -0x400(%rbp), %rdi
leaq 0x3d2c(%rip), %rsi      # 0x114a7
callq 0x3290
movq %rax, -0x408(%rbp)
jmp 0xd789
movq -0x408(%rbp), %rdi
movq 0xa829(%rip), %rsi      # 0x17fc0
callq 0x32b0
movq %rax, -0x410(%rbp)
jmp 0xd7a5
leaq -0x388(%rbp), %rdi
leaq -0x148(%rbp), %rsi
callq 0x3480
jmp 0xd7ba
movq -0x410(%rbp), %rdi
leaq -0x388(%rbp), %rsi
callq 0x3230
jmp 0xd7cf
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 0xdb46
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x150(%rbp)
movl %eax, -0x154(%rbp)
jmp 0xdb3a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x150(%rbp)
movl %eax, -0x154(%rbp)
jmp 0xdb2e
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x150(%rbp)
movl %eax, -0x154(%rbp)
leaq -0x388(%rbp), %rdi
callq 0x31b0
jmp 0xdb2e
movl -0xc(%rbp), %esi
leaq -0x38(%rbp), %rdi
callq 0x32f0
movq %rax, -0x418(%rbp)
jmp 0xd862
movq -0x418(%rbp), %rsi
leaq -0x3b0(%rbp), %rdi
callq 0x34b0
jmp 0xd877
movq -0x3e8(%rbp), %rdi
movb $0x0, -0x3b1(%rbp)
callq 0x8490
leaq 0x3c7d(%rip), %rsi      # 0x1150e
leaq -0x3b0(%rbp), %rdi
callq 0x3100
movq %rax, -0x420(%rbp)
jmp 0xd8a6
movq -0x420(%rbp), %rsi
leaq -0x3d8(%rbp), %rdi
callq 0x3560
jmp 0xd8bb
movq -0x3e8(%rbp), %rdi
leaq -0x3d8(%rbp), %rsi
movq %rsi, -0x430(%rbp)
callq 0x3360
movq -0x430(%rbp), %rdi
callq 0x31b0
leaq 0x3c7b(%rip), %rsi      # 0x11563
leaq -0x3b0(%rbp), %rdi
callq 0x3100
movq %rax, -0x428(%rbp)
jmp 0xd8fd
movq -0x428(%rbp), %rdi
callq 0x3450
movl %eax, -0x434(%rbp)
jmp 0xd911
movq -0x3e8(%rbp), %rax
movl -0x434(%rbp), %ecx
movl %ecx, 0x20(%rax)
leaq 0x3c42(%rip), %rsi      # 0x1156a
leaq -0x3b0(%rbp), %rdi
callq 0x3100
movq %rax, -0x440(%rbp)
jmp 0xd93d
movq -0x440(%rbp), %rdi
callq 0x3450
movl %eax, -0x444(%rbp)
jmp 0xd951
movq -0x3e8(%rbp), %rax
movl -0x444(%rbp), %ecx
movl %ecx, 0x24(%rax)
leaq 0x3a5c(%rip), %rsi      # 0x113c4
leaq -0x3b0(%rbp), %rdi
callq 0x3100
movq %rax, -0x450(%rbp)
jmp 0xd97d
movq -0x450(%rbp), %rdi
callq 0x3450
movl %eax, -0x454(%rbp)
jmp 0xd991
movq -0x3e8(%rbp), %rax
movl -0x454(%rbp), %ecx
movl %ecx, 0x28(%rax)
leaq 0x3a21(%rip), %rsi      # 0x113c9
leaq -0x3b0(%rbp), %rdi
callq 0x3100
movq %rax, -0x460(%rbp)
jmp 0xd9bd
movq -0x460(%rbp), %rdi
callq 0x3450
movl %eax, -0x464(%rbp)
jmp 0xd9d1
movq -0x3e8(%rbp), %rax
movl -0x464(%rbp), %ecx
movl %ecx, 0x2c(%rax)
leaq 0x3b69(%rip), %rsi      # 0x11551
leaq -0x3b0(%rbp), %rdi
callq 0x3100
movq %rax, -0x470(%rbp)
jmp 0xd9fd
movq -0x470(%rbp), %rdi
callq 0x3450
movl %eax, -0x474(%rbp)
jmp 0xda11
movq -0x3e8(%rbp), %rax
movl -0x474(%rbp), %ecx
movl %ecx, 0x30(%rax)
leaq 0x3b32(%rip), %rsi      # 0x1155a
leaq -0x3b0(%rbp), %rdi
callq 0x3100
movq %rax, -0x480(%rbp)
jmp 0xda3d
movq -0x480(%rbp), %rdi
callq 0x3450
movl %eax, -0x484(%rbp)
jmp 0xda51
movq -0x3e8(%rbp), %rax
movl -0x484(%rbp), %ecx
movl %ecx, 0x34(%rax)
leaq 0x3b0e(%rip), %rsi      # 0x11576
leaq -0x3b0(%rbp), %rdi
callq 0x3100
movq %rax, -0x490(%rbp)
jmp 0xda7d
movq -0x490(%rbp), %rdi
callq 0x3450
movl %eax, -0x494(%rbp)
jmp 0xda91
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 0xdaf1
jmp 0xdae5
movq -0x3e8(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x150(%rbp)
movl %eax, -0x154(%rbp)
callq 0x8560
leaq -0x3b0(%rbp), %rdi
callq 0x3150
jmp 0xdb2e
movq -0x3e8(%rbp), %rdi
callq 0x8560
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)