// File: /workspace/github_cpp_makefile_star2_O1/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 0x2a7f(%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 0x9d53
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 0x2a65(%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 0x9b22
callq 0x3260
leaq 0x284f(%rip), %rsi      # 0xc378
leaq -0x58(%rbp), %rdi
callq 0x30e0
movq %rax, %rdi
callq 0x33f0
movq -0x30(%rbp), %rcx
movl %eax, 0x20(%rcx)
leaq 0x2884(%rip), %rsi      # 0xc3cc
leaq -0x58(%rbp), %rdi
callq 0x30e0
movq %rax, %rdi
callq 0x33f0
movq -0x30(%rbp), %rcx
movl %eax, 0x24(%rcx)
leaq 0x2a4e(%rip), %rsi      # 0xc5b5
leaq -0x58(%rbp), %rdi
callq 0x30e0
movq %rax, %rdi
callq 0x33f0
movq -0x30(%rbp), %rcx
movl %eax, 0x28(%rcx)
leaq 0x284e(%rip), %rsi      # 0xc3d4
leaq -0x58(%rbp), %rdi
callq 0x30e0
movq %rax, %rdi
callq 0x33f0
movq -0x30(%rbp), %rcx
movl %eax, 0x2c(%rcx)
leaq 0x2834(%rip), %rsi      # 0xc3d9
leaq -0x58(%rbp), %rdi
callq 0x30e0
movq %rax, %rdi
callq 0x33f0
movq -0x30(%rbp), %rcx
movl %eax, 0x30(%rcx)
leaq 0x2805(%rip), %rsi      # 0xc3c9
leaq -0x58(%rbp), %rdi
callq 0x30e0
movq %rax, %rdi
callq 0x33f0
movq -0x30(%rbp), %rcx
movl %eax, 0x34(%rcx)
leaq 0x2803(%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 0x2985(%rip), %rsi      # 0xc58b
leaq -0x58(%rbp), %rdi
callq 0x30e0
movq %rax, %rdi
callq 0x33f0
movq -0x30(%rbp), %rcx
movl %eax, 0x40(%rcx)
leaq 0x296f(%rip), %rsi      # 0xc594
leaq -0x58(%rbp), %rdi
callq 0x30e0
movq %rax, %rdi
callq 0x33f0
movq -0x30(%rbp), %rcx
movl %eax, 0x44(%rcx)
leaq 0x277d(%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 0x9cda
movq %r15, %rdi
callq 0x3360
movq %rax, %rdi
callq 0x33f0
movq %r13, %rdi
movl %eax, %esi
callq 0x973e
movq %r14, %rdi
movq %r13, %rsi
callq 0xaa2c
movq -0x98(%rbp), %rdi
cmpq %rbx, %rdi
je 0x9cd0
callq 0x3260
movq %r15, %rdi
callq 0x3070
jmp 0x9c8b
leaq -0x58(%rbp), %rdi
callq 0x3140
leaq -0x3f8(%rbp), %rdi
callq 0x3080
leaq -0xf8(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x9d04
callq 0x3260
leaq -0x140(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x9d19
callq 0x3260
leaq -0x1a0(%rbp), %rdi
callq 0xa850
leaq -0x1f0(%rbp), %rdi
callq 0xa9de
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 0x5276(%rip), %rdi      # 0xefd0
leaq 0x279b(%rip), %rsi      # 0xc4fc
movl $0x1c, %edx
callq 0x32f0
movq 0x525e(%rip), %rdi      # 0xefd0
callq 0x3130
movq %rax, %rbx
leaq 0x2760(%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 0x9e37
callq 0x3260
jmp 0x9e37
jmp 0x9e01
jmp 0x9e22
jmp 0x9e22
jmp 0x9e22
movq %rax, %r14
jmp 0x9e43
movq %rax, %r14
jmp 0x9e4f
jmp 0x9e01
jmp 0x9e22
movq %rax, %r14
jmp 0x9e37
jmp 0x9e22
movq %rax, %r14
movq -0x98(%rbp), %rdi
cmpq %rbx, %rdi
je 0x9e25
callq 0x3260
jmp 0x9e25
jmp 0x9e22
jmp 0x9e22
movq %rax, %r14
movq -0x30(%rbp), %rdi
callq 0x7d9a
leaq -0x58(%rbp), %rdi
callq 0x3140
leaq -0x3f8(%rbp), %rdi
callq 0x3080
leaq -0x1f0(%rbp), %rdi
callq 0xa800
leaq -0xe0(%rbp), %rdi
callq 0x3140
movq %r14, %rdi
callq 0x34d0