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

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

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

    Json::Value jEnemy = root[index];

    Enemy enemy;

    enemy.name = jEnemy["name"].asString();
    enemy.attack = jEnemy["attack"].asInt();
    enemy.defense = jEnemy["defense"].asInt();
    enemy.shieldDefense = jEnemy["shieldDefense"].asInt();
    enemy.mana = jEnemy["mana"].asInt();
    enemy.stamina = jEnemy["stamina"].asInt();
    enemy.hp = jEnemy["hp"].asInt();
    enemy.xp = jEnemy["xp"].asInt();
    enemy.id = index;
    enemy.minLevel = jEnemy["minLevel"].asInt();
    enemy.maxLevel = jEnemy["maxLevel"].asInt();

    // Iterates trough the array "attacks", which contains all the indexes of the attacks of the enemy
    for (const Json::Value& attack : jEnemy["attacks"]) {
        enemy.attacks.push_back(parseAttack(attack.asInt())); // Pushes the attack to the vector
    }

    return enemy;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x3d8, %rsp            # imm = 0x3D8
movl %esi, %r14d
movq %rdi, -0x30(%rbp)
leaq -0xe0(%rbp), %rdi
xorl %esi, %esi
callq 0x3100
leaq -0x1f0(%rbp), %rdi
callq 0x32a0
leaq 0x2acf(%rip), %rsi      # 0xc4e8
leaq -0x3f8(%rbp), %rdi
movl $0x8, %edx
callq 0x34f0
leaq -0x1f0(%rbp), %rdi
leaq -0x3f8(%rbp), %rsi
leaq -0xe0(%rbp), %rdx
movl $0x1, %ecx
callq 0x3510
testb %al, %al
je 0x9d03
leaq -0xe0(%rbp), %rdi
movl %r14d, %esi
callq 0x32c0
leaq -0x58(%rbp), %rdi
movq %rax, %rsi
callq 0x3450
movq -0x30(%rbp), %rcx
leaq 0x10(%rcx), %rax
movq %rax, (%rcx)
xorl %eax, %eax
movq %rax, 0x8(%rcx)
movb $0x0, 0x10(%rcx)
xorps %xmm0, %xmm0
movups %xmm0, 0x48(%rcx)
movq %rax, 0x58(%rcx)
leaq 0x2ab5(%rip), %rsi      # 0xc548
leaq -0x58(%rbp), %rdi
callq 0x30e0
leaq -0x98(%rbp), %rdi
movq %rax, %rsi
callq 0x3500
leaq -0x98(%rbp), %r15
movq -0x30(%rbp), %rdi
movq %r15, %rsi
callq 0x3330
movq (%r15), %rdi
leaq -0x88(%rbp), %rbx
cmpq %rbx, %rdi
je 0x9ad2
callq 0x3260
leaq 0x289f(%rip), %rsi      # 0xc378
leaq -0x58(%rbp), %rdi
callq 0x30e0
movq %rax, %rdi
callq 0x33f0
movq -0x30(%rbp), %rcx
movl %eax, 0x20(%rcx)
leaq 0x28d4(%rip), %rsi      # 0xc3cc
leaq -0x58(%rbp), %rdi
callq 0x30e0
movq %rax, %rdi
callq 0x33f0
movq -0x30(%rbp), %rcx
movl %eax, 0x24(%rcx)
leaq 0x2a9e(%rip), %rsi      # 0xc5b5
leaq -0x58(%rbp), %rdi
callq 0x30e0
movq %rax, %rdi
callq 0x33f0
movq -0x30(%rbp), %rcx
movl %eax, 0x28(%rcx)
leaq 0x289e(%rip), %rsi      # 0xc3d4
leaq -0x58(%rbp), %rdi
callq 0x30e0
movq %rax, %rdi
callq 0x33f0
movq -0x30(%rbp), %rcx
movl %eax, 0x2c(%rcx)
leaq 0x2884(%rip), %rsi      # 0xc3d9
leaq -0x58(%rbp), %rdi
callq 0x30e0
movq %rax, %rdi
callq 0x33f0
movq -0x30(%rbp), %rcx
movl %eax, 0x30(%rcx)
leaq 0x2855(%rip), %rsi      # 0xc3c9
leaq -0x58(%rbp), %rdi
callq 0x30e0
movq %rax, %rdi
callq 0x33f0
movq -0x30(%rbp), %rcx
movl %eax, 0x34(%rcx)
leaq 0x2853(%rip), %rsi      # 0xc3e6
leaq -0x58(%rbp), %rdi
callq 0x30e0
movq %rax, %rdi
callq 0x33f0
movq -0x30(%rbp), %rcx
movl %eax, 0x38(%rcx)
movl %r14d, 0x3c(%rcx)
leaq 0x29d5(%rip), %rsi      # 0xc58b
leaq -0x58(%rbp), %rdi
callq 0x30e0
movq %rax, %rdi
callq 0x33f0
movq -0x30(%rbp), %rcx
movl %eax, 0x40(%rcx)
leaq 0x29bf(%rip), %rsi      # 0xc594
leaq -0x58(%rbp), %rdi
callq 0x30e0
movq %rax, %rdi
callq 0x33f0
movq -0x30(%rbp), %rcx
movl %eax, 0x44(%rcx)
leaq 0x27cd(%rip), %rsi      # 0xc3c1
leaq -0x58(%rbp), %rdi
callq 0x30e0
movq %rax, %r14
leaq -0xb8(%rbp), %rdi
movq %rax, %rsi
callq 0x32d0
leaq -0xa8(%rbp), %rdi
movq %r14, %rsi
callq 0x33c0
movq -0x30(%rbp), %rax
leaq 0x48(%rax), %r14
leaq -0xb8(%rbp), %r15
leaq -0xa8(%rbp), %r12
leaq -0x98(%rbp), %r13
movq %r15, %rdi
movq %r12, %rsi
callq 0x3040
testb %al, %al
jne 0x9c8a
movq %r15, %rdi
callq 0x3360
movq %rax, %rdi
callq 0x33f0
movq %r13, %rdi
movl %eax, %esi
callq 0x96ee
movq %r14, %rdi
movq %r13, %rsi
callq 0xa9fa
movq -0x98(%rbp), %rdi
cmpq %rbx, %rdi
je 0x9c80
callq 0x3260
movq %r15, %rdi
callq 0x3070
jmp 0x9c3b
leaq -0x58(%rbp), %rdi
callq 0x3140
leaq -0x3f8(%rbp), %rdi
callq 0x3080
leaq -0xf8(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x9cb4
callq 0x3260
leaq -0x140(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x9cc9
callq 0x3260
leaq -0x1a0(%rbp), %rdi
callq 0xa800
leaq -0x1f0(%rbp), %rdi
callq 0xa9a0
leaq -0xe0(%rbp), %rdi
callq 0x3140
movq -0x30(%rbp), %rax
addq $0x3d8, %rsp            # imm = 0x3D8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x52c6(%rip), %rdi      # 0xefd0
leaq 0x27eb(%rip), %rsi      # 0xc4fc
movl $0x1c, %edx
callq 0x32f0
movq 0x52ae(%rip), %rdi      # 0xefd0
callq 0x3130
movq %rax, %rbx
leaq 0x27b0(%rip), %rsi      # 0xc4e1
movl $0x6, %edx
movq %rax, %rdi
callq 0x32f0
movq %rbx, %rdi
callq 0x3130
movq %rax, %rbx
leaq -0x98(%rbp), %rdi
leaq -0x1f0(%rbp), %rsi
callq 0x3420
leaq -0x98(%rbp), %rsi
movq %rbx, %rdi
callq 0x3230
leaq -0x98(%rbp), %rdi
callq 0x3120
movl $0x1, %edi
callq 0x3320
movq %rax, %r14
leaq -0x88(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x9de7
callq 0x3260
jmp 0x9de7
jmp 0x9db1
jmp 0x9dd2
jmp 0x9dd2
jmp 0x9dd2
movq %rax, %r14
jmp 0x9df3
movq %rax, %r14
jmp 0x9dff
jmp 0x9db1
jmp 0x9dd2
movq %rax, %r14
jmp 0x9de7
jmp 0x9dd2
movq %rax, %r14
movq -0x98(%rbp), %rdi
cmpq %rbx, %rdi
je 0x9dd5
callq 0x3260
jmp 0x9dd5
jmp 0x9dd2
jmp 0x9dd2
movq %rax, %r14
movq -0x30(%rbp), %rdi
callq 0x7d0e
leaq -0x58(%rbp), %rdi
callq 0x3140
leaq -0x3f8(%rbp), %rdi
callq 0x3080
leaq -0x1f0(%rbp), %rdi
callq 0xa7b0
leaq -0xe0(%rbp), %rdi
callq 0x3140
movq %r14, %rdi
callq 0x34d0