LLM4Binary/decompile-bench-makefile huggingface dataset:
// File: Thilotilo[P]DoaERando/General.cpp
// Function: DoaERando::General::DumpGeneral()
void General::DumpGeneral()
{
    printf("%s:\n", name);
    printf("\tid: 0x%02X\n", id);
    printf("\taddress: 0x%X\n", address);
    printf("\tcount: %d\n", count);
    printf("\tSTR: %d\n", strength);
    printf("\tINT: %d\n", intelligence);
    printf("\tAGI: %d\n", agility);
    printf("\tzone: %d\n", zone);
    printf("\tHP exp: %d, %d\n", enemySoldierExponent, allySoldierExponent);
    printf("\tDefense: %d\n", enemyDefenseId);
    printf("\tMax Tactic Level: %d\n", enemyMaxTacticLevel);
    printf("\tWeapon: 0x%02X\n", weaponId);
    printf("\tEncounterable? %d\n", encounterable);
    printf("\tRecruitable? %d\n", recruitable);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x10, %rsp
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rsi
movq %rsi, -0x10(%rbp)
addq $0xf, %rsi
leaq 0x186396(%rip), %rdi    # 0x59b6c5
movb $0x0, %al
callq 0x4f06e0
movq -0x10(%rbp), %rax
movzbl 0x4(%rax), %esi
leaq 0x186385(%rip), %rdi    # 0x59b6ca
movb $0x0, %al
callq 0x4f06e0
movq -0x10(%rbp), %rax
movl (%rax), %esi
leaq 0x18637e(%rip), %rdi    # 0x59b6d7
movb $0x0, %al
callq 0x4f06e0
movq -0x10(%rbp), %rax
movzbl 0x5(%rax), %esi
leaq 0x186378(%rip), %rdi    # 0x59b6e7
movb $0x0, %al
callq 0x4f06e0
movq -0x10(%rbp), %rax
movzbl 0x6(%rax), %esi
leaq 0x18636e(%rip), %rdi    # 0x59b6f3
movb $0x0, %al
callq 0x4f06e0
movq -0x10(%rbp), %rax
movzbl 0x7(%rax), %esi
leaq 0x186362(%rip), %rdi    # 0x59b6fd
movb $0x0, %al
callq 0x4f06e0
movq -0x10(%rbp), %rax
movzbl 0xe(%rax), %esi
leaq 0x186356(%rip), %rdi    # 0x59b707
movb $0x0, %al
callq 0x4f06e0
movq -0x10(%rbp), %rax
movzbl 0x8(%rax), %esi
leaq 0x18634a(%rip), %rdi    # 0x59b711
movb $0x0, %al
callq 0x4f06e0
movq -0x10(%rbp), %rax
movzbl 0xb(%rax), %esi
movzbl 0xc(%rax), %edx
leaq 0x18633b(%rip), %rdi    # 0x59b71c
movb $0x0, %al
callq 0x4f06e0
movq -0x10(%rbp), %rax
movzbl 0xa(%rax), %esi
leaq 0x186336(%rip), %rdi    # 0x59b72d
movb $0x0, %al
callq 0x4f06e0
movq -0x10(%rbp), %rax
movzbl 0xd(%rax), %esi
leaq 0x18632e(%rip), %rdi    # 0x59b73b
movb $0x0, %al
callq 0x4f06e0
movq -0x10(%rbp), %rax
movzbl 0x9(%rax), %esi
leaq 0x18632f(%rip), %rdi    # 0x59b752
movb $0x0, %al
callq 0x4f06e0
movq -0x10(%rbp), %rax
movb 0x23(%rax), %al
andb $0x1, %al
movzbl %al, %esi
leaq 0x186326(%rip), %rdi    # 0x59b763
movb $0x0, %al
callq 0x4f06e0
movq -0x10(%rbp), %rax
movb 0x24(%rax), %al
andb $0x1, %al
movzbl %al, %esi
leaq 0x186320(%rip), %rdi    # 0x59b777
movb $0x0, %al
callq 0x4f06e0
addq $0x10, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)
nop
// File: Thilotilo[P]DoaERando/Generals.cpp
// Function: DoaERando::Generals::ReadGenerals()
void Generals::ReadGenerals()
{
    for (BYTE i = 5; i < 0xD8; ++i)
    {
        if (i != UV10_ID)
        {
            AddGeneral(i);
            if (i == LIU_BEI_ID || i == CAO_PI_ID ||
                i == SIMA_YI_ID || i == SUN_QUAN_ID)
            {
                myRestrictedGeneralAddresses.push_back(GetGeneralAddress(i));
            }
        }
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x18(%rbp)
movb $0x5, -0x9(%rbp)
movzbl -0x9(%rbp), %eax
cmpl $0xd8, %eax
jge 0x4155dc
movzbl -0x9(%rbp), %eax
cmpl $0xb3, %eax
je 0x4155cd
movq -0x18(%rbp), %rdi
movzbl -0x9(%rbp), %esi
callq 0x4156d0
movzbl -0x9(%rbp), %eax
cmpl $0xa8, %eax
je 0x4155a3
movzbl -0x9(%rbp), %eax
cmpl $0x71, %eax
je 0x4155a3
movzbl -0x9(%rbp), %eax
cmpl $0x88, %eax
je 0x4155a3
movzbl -0x9(%rbp), %eax
cmpl $0x57, %eax
jne 0x4155cb
movq -0x18(%rbp), %rdi
movq %rdi, %rax
addq $0x18, %rax
movq %rax, -0x20(%rbp)
movzbl -0x9(%rbp), %esi
callq 0x4155f0
movq -0x20(%rbp), %rdi
movl %eax, -0x10(%rbp)
leaq -0x10(%rbp), %rsi
callq 0x416a50
jmp 0x4155cd
jmp 0x4155cf
movb -0x9(%rbp), %al
addb $0x1, %al
movb %al, -0x9(%rbp)
jmp 0x415558
addq $0x20, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)
// File: Thilotilo[P]DoaERando/Generals.cpp
// Function: DoaERando::Generals::GetGeneralBankAddress(unsigned char)
int Generals::GetGeneralBankAddress(BYTE id)
{
    const int GENERAL_ADDRESSES_LSB_START = 0x32610;
    const int GENERAL_ADDRESSES_MSB_START = 0x32710;
    int msb = myRom.ReadByte(GENERAL_ADDRESSES_MSB_START + id);
    int lsb = myRom.ReadByte(GENERAL_ADDRESSES_LSB_START + id);
    int address = (msb << 8) + lsb;
    return address;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movb %sil, %al
movq %rdi, -0x8(%rbp)
movb %al, -0x9(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x28(%rbp)
movl $0x32610, -0x10(%rbp)   # imm = 0x32610
movl $0x32710, -0x14(%rbp)   # imm = 0x32710
movq 0x48(%rax), %rdi
movzbl -0x9(%rbp), %esi
addl $0x32710, %esi          # imm = 0x32710
callq 0x404bb0
movb %al, %cl
movq -0x28(%rbp), %rax
movzbl %cl, %ecx
movl %ecx, -0x18(%rbp)
movq 0x48(%rax), %rdi
movzbl -0x9(%rbp), %esi
addl $0x32610, %esi          # imm = 0x32610
callq 0x404bb0
movzbl %al, %eax
movl %eax, -0x1c(%rbp)
movl -0x18(%rbp), %eax
shll $0x8, %eax
addl -0x1c(%rbp), %eax
movl %eax, -0x20(%rbp)
movl -0x20(%rbp), %eax
addq $0x30, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)
// File: Thilotilo[P]DoaERando/Generals.cpp
// Function: DoaERando::Generals::AddGeneral(unsigned char)
void Generals::AddGeneral(BYTE id)
{
    if (GeneralExists(id))
    {
        AddCopy(id);
    }
    else
    {
        auto address = GetGeneralAddress(id);
        General general(address, id, myRom);
        myGenerals.push_back(general);
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movb %sil, %al
movq %rdi, -0x8(%rbp)
movb %al, -0x9(%rbp)
movq -0x8(%rbp), %rdi
movq %rdi, -0x40(%rbp)
movzbl -0x9(%rbp), %esi
callq 0x415750
testb $0x1, %al
jne 0x4156f9
jmp 0x415708
movq -0x40(%rbp), %rdi
movzbl -0x9(%rbp), %esi
callq 0x4157e0
jmp 0x41573f
movq -0x40(%rbp), %rdi
movzbl -0x9(%rbp), %esi
callq 0x4155f0
movq -0x40(%rbp), %rcx
movl %eax, -0x10(%rbp)
movl -0x10(%rbp), %esi
movb -0x9(%rbp), %al
movq 0x48(%rcx), %rcx
leaq -0x38(%rbp), %rdi
movzbl %al, %edx
callq 0x414670
movq -0x40(%rbp), %rdi
leaq -0x38(%rbp), %rsi
callq 0x416a80
addq $0x40, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)
// File: Thilotilo[P]DoaERando/Generals.cpp
// Function: DoaERando::Generals::GeneralExists(unsigned char)
bool Generals::GeneralExists(BYTE id)
{
    for (int i = 0; i < myGenerals.size(); ++i)
    {
        if(myGenerals[i].address == GetGeneralAddress(id))
        {
            return true;
        }
    }

    return false;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movb %sil, %al
movq %rdi, -0x10(%rbp)
movb %al, -0x11(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x20(%rbp)
movl $0x0, -0x18(%rbp)
movq -0x20(%rbp), %rdi
movslq -0x18(%rbp), %rax
movq %rax, -0x28(%rbp)
callq 0x410a90
movq %rax, %rcx
movq -0x28(%rbp), %rax
cmpq %rcx, %rax
jae 0x4157c9
movq -0x20(%rbp), %rdi
movslq -0x18(%rbp), %rsi
callq 0x416bd0
movq -0x20(%rbp), %rdi
movl (%rax), %eax
movl %eax, -0x2c(%rbp)
movzbl -0x11(%rbp), %esi
callq 0x4155f0
movl %eax, %ecx
movl -0x2c(%rbp), %eax
cmpl %ecx, %eax
jne 0x4157bc
movb $0x1, -0x1(%rbp)
jmp 0x4157cd
jmp 0x4157be
movl -0x18(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x18(%rbp)
jmp 0x415771
movb $0x0, -0x1(%rbp)
movb -0x1(%rbp), %al
andb $0x1, %al
addq $0x30, %rsp
popq %rbp
retq
nopl (%rax,%rax)
// File: Thilotilo[P]DoaERando/Generals.cpp
// Function: DoaERando::Generals::AddCopy(unsigned char)
void Generals::AddCopy(BYTE id)
{
    auto address = GetGeneralAddress(id);
    for (auto& general: myGenerals)
    {
        if (general.address == address)
        {
            general.count++;
        }
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movb %sil, %al
movq %rdi, -0x8(%rbp)
movb %al, -0x9(%rbp)
movq -0x8(%rbp), %rdi
movq %rdi, -0x38(%rbp)
movzbl -0x9(%rbp), %esi
callq 0x4155f0
movl %eax, %ecx
movq -0x38(%rbp), %rax
movl %ecx, -0x10(%rbp)
movq %rax, -0x18(%rbp)
movq -0x18(%rbp), %rdi
callq 0x416af0
movq %rax, -0x20(%rbp)
movq -0x18(%rbp), %rdi
callq 0x416b20
movq %rax, -0x28(%rbp)
leaq -0x20(%rbp), %rdi
leaq -0x28(%rbp), %rsi
callq 0x416b50
testb $0x1, %al
jne 0x41583d
jmp 0x41586f
leaq -0x20(%rbp), %rdi
callq 0x416b90
movq %rax, -0x30(%rbp)
movq -0x30(%rbp), %rax
movl (%rax), %eax
cmpl -0x10(%rbp), %eax
jne 0x415862
movq -0x30(%rbp), %rax
movb 0x5(%rax), %cl
addb $0x1, %cl
movb %cl, 0x5(%rax)
jmp 0x415864
leaq -0x20(%rbp), %rdi
callq 0x416bb0
jmp 0x41582a
addq $0x40, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)
// File: Thilotilo[P]DoaERando/Generals.cpp
// Function: DoaERando::Generals::AdjustZone1Generals()
void Generals::AdjustZone1Generals()
{
    // These are generals that are not found in zone 1 but are marked as zone 1, making
    //  zone 1 over populated:

    // Zhou Chao is in Chang An - he belongs in chapter 3
    int zhouChaoIndex = GetGeneralIndexById(ZHOU_CHAO_ID);
    myGenerals[zhouChaoIndex].zone = 3;
    // Wang Gui is in Luo Yang - he belongs in chapter 2
    int wangGuiIndex = GetGeneralIndexById(WANG_GUI_ID);
    myGenerals[wangGuiIndex].zone = 2;
    // Sun Gan is not in the game - he belongs in chapter 0
    int sunGanIndex = GetGeneralIndexById(SUN_GAN_ID);
    myGenerals[sunGanIndex].zone = 0;
    // Huo Hu is in Lu Bu's fortress - he belongs in chapter 2
    int huoHuIndex = GetGeneralIndexById(HUO_HU_ID);
    myGenerals[huoHuIndex].zone = 2;
    // Yang Jin is in Hua Xiong's fortress - he belongs in chapter 2
    int yangJinIndex = GetGeneralIndexById(YANG_JIN_ID);
    myGenerals[yangJinIndex].zone = 2;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rdi
movq %rdi, -0x28(%rbp)
movl $0x8, %esi
callq 0x415940
movq -0x28(%rbp), %rdi
movl %eax, -0xc(%rbp)
movslq -0xc(%rbp), %rsi
callq 0x416bd0
movq -0x28(%rbp), %rdi
movb $0x3, 0x8(%rax)
movl $0x9, %esi
callq 0x415940
movq -0x28(%rbp), %rdi
movl %eax, -0x10(%rbp)
movslq -0x10(%rbp), %rsi
callq 0x416bd0
movq -0x28(%rbp), %rdi
movb $0x2, 0x8(%rax)
movl $0x9e, %esi
callq 0x415940
movq -0x28(%rbp), %rdi
movl %eax, -0x14(%rbp)
movslq -0x14(%rbp), %rsi
callq 0x416bd0
movq -0x28(%rbp), %rdi
movb $0x0, 0x8(%rax)
movl $0xb8, %esi
callq 0x415940
movq -0x28(%rbp), %rdi
movl %eax, -0x18(%rbp)
movslq -0x18(%rbp), %rsi
callq 0x416bd0
movq -0x28(%rbp), %rdi
movb $0x2, 0x8(%rax)
movl $0xb9, %esi
callq 0x415940
movq -0x28(%rbp), %rdi
movl %eax, -0x1c(%rbp)
movslq -0x1c(%rbp), %rsi
callq 0x416bd0
movb $0x2, 0x8(%rax)
addq $0x30, %rsp
popq %rbp
retq
// File: Thilotilo[P]DoaERando/Generals.cpp
// Function: DoaERando::Generals::GetGeneralIndexById(unsigned char)
int Generals::GetGeneralIndexById(BYTE id)
{
    int i = 0;
    for (i = 0; i < myGenerals.size(); ++i)
    {
        for (int j = myGenerals[i].id; j < myGenerals[i].id + myGenerals[i].count; ++j)
        {
            if (j == id)
            {
                return i;
            }
        }
    }
    return -1;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movb %sil, %al
movq %rdi, -0x10(%rbp)
movb %al, -0x11(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x28(%rbp)
movl $0x0, -0x18(%rbp)
movl $0x0, -0x18(%rbp)
movq -0x28(%rbp), %rdi
movslq -0x18(%rbp), %rax
movq %rax, -0x30(%rbp)
callq 0x410a90
movq %rax, %rcx
movq -0x30(%rbp), %rax
cmpq %rcx, %rax
jae 0x415a03
movq -0x28(%rbp), %rdi
movslq -0x18(%rbp), %rsi
callq 0x416bd0
movzbl 0x4(%rax), %eax
movl %eax, -0x1c(%rbp)
movq -0x28(%rbp), %rdi
movl -0x1c(%rbp), %eax
movl %eax, -0x34(%rbp)
movslq -0x18(%rbp), %rsi
callq 0x416bd0
movq -0x28(%rbp), %rdi
movzbl 0x4(%rax), %eax
movl %eax, -0x38(%rbp)
movslq -0x18(%rbp), %rsi
callq 0x416bd0
movl -0x38(%rbp), %ecx
movq %rax, %rdx
movl -0x34(%rbp), %eax
movzbl 0x5(%rdx), %edx
addl %edx, %ecx
cmpl %ecx, %eax
jge 0x4159f3
movl -0x1c(%rbp), %eax
movzbl -0x11(%rbp), %ecx
cmpl %ecx, %eax
jne 0x4159e6
movl -0x18(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x415a0a
jmp 0x4159e8
movl -0x1c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c(%rbp)
jmp 0x415999
jmp 0x4159f5
movl -0x18(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x18(%rbp)
jmp 0x415968
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
movl -0x4(%rbp), %eax
addq $0x40, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)
// File: Thilotilo[P]DoaERando/Generals.cpp
// Function: DoaERando::Generals::SwapIDs(int, int)
void Generals::SwapIDs(int slot1, int slot2)
{
    if (!isRestrictedGeneralAddress(myGenerals[slot1].address) &&
        !isRestrictedGeneralAddress(myGenerals[slot2].address))
    {
        auto tempId = myGenerals[slot1].id;
        auto tempCount = myGenerals[slot1].count;
        myGenerals[slot1].id = myGenerals[slot2].id;
        myGenerals[slot1].count = myGenerals[slot2].count;
        myGenerals[slot2].id = tempId;
        myGenerals[slot2].count = tempCount;
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movl %edx, -0x10(%rbp)
movq -0x8(%rbp), %rdi
movq %rdi, -0x20(%rbp)
movslq -0xc(%rbp), %rsi
callq 0x416bd0
movq -0x20(%rbp), %rdi
movl (%rax), %esi
callq 0x415b20
testb $0x1, %al
jne 0x415b1a
movq -0x20(%rbp), %rdi
movslq -0x10(%rbp), %rsi
callq 0x416bd0
movq -0x20(%rbp), %rdi
movl (%rax), %esi
callq 0x415b20
testb $0x1, %al
jne 0x415b1a
movq -0x20(%rbp), %rdi
movslq -0xc(%rbp), %rsi
callq 0x416bd0
movq -0x20(%rbp), %rdi
movb 0x4(%rax), %al
movb %al, -0x11(%rbp)
movslq -0xc(%rbp), %rsi
callq 0x416bd0
movq -0x20(%rbp), %rdi
movb 0x5(%rax), %al
movb %al, -0x12(%rbp)
movslq -0x10(%rbp), %rsi
callq 0x416bd0
movq -0x20(%rbp), %rdi
movb 0x4(%rax), %al
movb %al, -0x24(%rbp)
movslq -0xc(%rbp), %rsi
callq 0x416bd0
movb -0x24(%rbp), %cl
movq -0x20(%rbp), %rdi
movb %cl, 0x4(%rax)
movslq -0x10(%rbp), %rsi
callq 0x416bd0
movq -0x20(%rbp), %rdi
movb 0x5(%rax), %al
movb %al, -0x23(%rbp)
movslq -0xc(%rbp), %rsi
callq 0x416bd0
movb -0x23(%rbp), %cl
movq -0x20(%rbp), %rdi
movb %cl, 0x5(%rax)
movb -0x11(%rbp), %al
movb %al, -0x22(%rbp)
movslq -0x10(%rbp), %rsi
callq 0x416bd0
movb -0x22(%rbp), %cl
movq -0x20(%rbp), %rdi
movb %cl, 0x4(%rax)
movb -0x12(%rbp), %al
movb %al, -0x21(%rbp)
movslq -0x10(%rbp), %rsi
callq 0x416bd0
movb -0x21(%rbp), %cl
movb %cl, 0x5(%rax)
addq $0x30, %rsp
popq %rbp
retq
// File: Thilotilo[P]DoaERando/Generals.cpp
// Function: DoaERando::Generals::isRestrictedGeneralAddress(int)
bool Generals::isRestrictedGeneralAddress(int address)
{
    for (auto &i : myRestrictedGeneralAddresses)
    {
        if (i == address)
        {
            return true;
        }
    }
    return false;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x10(%rbp)
movl %esi, -0x14(%rbp)
movq -0x10(%rbp), %rax
addq $0x18, %rax
movq %rax, -0x20(%rbp)
movq -0x20(%rbp), %rdi
callq 0x416bf0
movq %rax, -0x28(%rbp)
movq -0x20(%rbp), %rdi
callq 0x416c20
movq %rax, -0x30(%rbp)
leaq -0x28(%rbp), %rdi
leaq -0x30(%rbp), %rsi
callq 0x416c50
testb $0x1, %al
jne 0x415b68
jmp 0x415b93
leaq -0x28(%rbp), %rdi
callq 0x416c90
movq %rax, -0x38(%rbp)
movq -0x38(%rbp), %rax
movl (%rax), %eax
cmpl -0x14(%rbp), %eax
jne 0x415b86
movb $0x1, -0x1(%rbp)
jmp 0x415b97
jmp 0x415b88
leaq -0x28(%rbp), %rdi
callq 0x416cb0
jmp 0x415b55
movb $0x0, -0x1(%rbp)
movb -0x1(%rbp), %al
andb $0x1, %al
addq $0x40, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)
// File: Thilotilo[P]DoaERando/Generals.cpp
// Function: DoaERando::Generals::SwapZones(int, int)
void Generals::SwapZones(int slot1, int slot2)
{
    if (!isRestrictedGeneralAddress(myGenerals[slot1].address) &&
        !isRestrictedGeneralAddress(myGenerals[slot2].address))
    {
        auto tempZone = myGenerals[slot1].zone;
        myGenerals[slot1].zone = myGenerals[slot2].zone;
        myGenerals[slot2].zone = tempZone;
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movl %edx, -0x10(%rbp)
movq -0x8(%rbp), %rdi
movq %rdi, -0x20(%rbp)
movslq -0xc(%rbp), %rsi
callq 0x416bd0
movq -0x20(%rbp), %rdi
movl (%rax), %esi
callq 0x415b20
testb $0x1, %al
jne 0x415c50
movq -0x20(%rbp), %rdi
movslq -0x10(%rbp), %rsi
callq 0x416bd0
movq -0x20(%rbp), %rdi
movl (%rax), %esi
callq 0x415b20
testb $0x1, %al
jne 0x415c50
movq -0x20(%rbp), %rdi
movslq -0xc(%rbp), %rsi
callq 0x416bd0
movq -0x20(%rbp), %rdi
movb 0x8(%rax), %al
movb %al, -0x11(%rbp)
movslq -0x10(%rbp), %rsi
callq 0x416bd0
movq -0x20(%rbp), %rdi
movb 0x8(%rax), %al
movb %al, -0x22(%rbp)
movslq -0xc(%rbp), %rsi
callq 0x416bd0
movb -0x22(%rbp), %cl
movq -0x20(%rbp), %rdi
movb %cl, 0x8(%rax)
movb -0x11(%rbp), %al
movb %al, -0x21(%rbp)
movslq -0x10(%rbp), %rsi
callq 0x416bd0
movb -0x21(%rbp), %cl
movb %cl, 0x8(%rax)
addq $0x30, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)
// File: Thilotilo[P]DoaERando/Generals.cpp
// Function: DoaERando::Generals::SetZonesForZone0(DoaERando::RandomNumberGenerator&)
void Generals::SetZonesForZone0(RNG& rng)
{
    for (auto& general : myGenerals)
    {
        if (general.zone == 0)
        {
            // Zone 1 already has too many generals, let's only allow zone 2 and above:
            general.zone = rng.GetRandomByte(2, 8);
        }
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x18(%rbp)
movq -0x18(%rbp), %rdi
callq 0x416af0
movq %rax, -0x20(%rbp)
movq -0x18(%rbp), %rdi
callq 0x416b20
movq %rax, -0x28(%rbp)
leaq -0x20(%rbp), %rdi
leaq -0x28(%rbp), %rsi
callq 0x416b50
testb $0x1, %al
jne 0x415ca5
jmp 0x415ce8
leaq -0x20(%rbp), %rdi
callq 0x416b90
movq %rax, -0x30(%rbp)
movq -0x30(%rbp), %rax
movzbl 0x8(%rax), %eax
cmpl $0x0, %eax
jne 0x415cdb
movq -0x10(%rbp), %rdi
movl $0x2, %esi
movl $0x8, %edx
callq 0x41db50
movb %al, %cl
movq -0x30(%rbp), %rax
movb %cl, 0x8(%rax)
jmp 0x415cdd
leaq -0x20(%rbp), %rdi
callq 0x416bb0
jmp 0x415c92
addq $0x30, %rsp
popq %rbp
retq
nop
// File: Thilotilo[P]DoaERando/Generals.cpp
// Function: DoaERando::Generals::isStartingGeneralAddress(int)
bool Generals::isStartingGeneralAddress(int address)
{
    for (auto &i : myStartingGeneralAddresses)
    {
        if (i == address)
        {
            return true;
        }
    }
    return false;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x10(%rbp)
movl %esi, -0x14(%rbp)
movq -0x10(%rbp), %rax
addq $0x30, %rax
movq %rax, -0x20(%rbp)
movq -0x20(%rbp), %rdi
callq 0x416bf0
movq %rax, -0x28(%rbp)
movq -0x20(%rbp), %rdi
callq 0x416c20
movq %rax, -0x30(%rbp)
leaq -0x28(%rbp), %rdi
leaq -0x30(%rbp), %rsi
callq 0x416c50
testb $0x1, %al
jne 0x415e18
jmp 0x415e43
leaq -0x28(%rbp), %rdi
callq 0x416c90
movq %rax, -0x38(%rbp)
movq -0x38(%rbp), %rax
movl (%rax), %eax
cmpl -0x14(%rbp), %eax
jne 0x415e36
movb $0x1, -0x1(%rbp)
jmp 0x415e47
jmp 0x415e38
leaq -0x28(%rbp), %rdi
callq 0x416cb0
jmp 0x415e05
movb $0x0, -0x1(%rbp)
movb -0x1(%rbp), %al
andb $0x1, %al
addq $0x40, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)
// File: Thilotilo[P]DoaERando/Generals.cpp
// Function: DoaERando::Generals::ScaleForZone(DoaERando::RandomNumberGenerator&)
void Generals::ScaleForZone(RNG& rng)
{
    for (auto& general : myGenerals)
    {
        if (general.id != CAO_PI_ID &&
            general.id != SIMA_YI_ID &&
            general.id != SUN_QUAN_ID)
        {
            general.ScaleWeaponForZone(rng);
            general.ScaleArmorForZone(rng);
            general.ScaleMaxTacticForZone(rng);
            general.ScaleSoldiersForZone(rng);
        }
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x18(%rbp)
movq -0x18(%rbp), %rdi
callq 0x416af0
movq %rax, -0x20(%rbp)
movq -0x18(%rbp), %rdi
callq 0x416b20
movq %rax, -0x28(%rbp)
leaq -0x20(%rbp), %rdi
leaq -0x28(%rbp), %rsi
callq 0x416b50
testb $0x1, %al
jne 0x415ea5
jmp 0x415f1f
leaq -0x20(%rbp), %rdi
callq 0x416b90
movq %rax, -0x30(%rbp)
movq -0x30(%rbp), %rax
movzbl 0x4(%rax), %eax
cmpl $0x71, %eax
je 0x415f0f
movq -0x30(%rbp), %rax
movzbl 0x4(%rax), %eax
cmpl $0x88, %eax
je 0x415f0f
movq -0x30(%rbp), %rax
movzbl 0x4(%rax), %eax
cmpl $0x57, %eax
je 0x415f0f
movq -0x30(%rbp), %rdi
movq -0x10(%rbp), %rsi
callq 0x4149c0
movq -0x30(%rbp), %rdi
movq -0x10(%rbp), %rsi
callq 0x414a30
movq -0x30(%rbp), %rdi
movq -0x10(%rbp), %rsi
callq 0x414aa0
movq -0x30(%rbp), %rdi
movq -0x10(%rbp), %rsi
callq 0x414af0
jmp 0x415f11
leaq -0x20(%rbp), %rdi
callq 0x416bb0
jmp 0x415e92
addq $0x30, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)
// File: Thilotilo[P]DoaERando/Generals.cpp
// Function: DoaERando::Generals::SetAndScaleGeneralForZone(unsigned char, unsigned char, DoaERando::RandomNumberGenerator&)
void Generals::SetAndScaleGeneralForZone(BYTE generalId, BYTE zone, RNG& rng)
{
    int generalIndex = GetGeneralIndexById(generalId);
    myGenerals[generalIndex].zone = zone;
    myGenerals[generalIndex].ScaleWeaponForZone(rng);
    myGenerals[generalIndex].ScaleArmorForZone(rng);
    myGenerals[generalIndex].ScaleMaxTacticForZone(rng);
    myGenerals[generalIndex].ScaleSoldiersForZone(rng);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movb %dl, %al
movb %sil, %dl
movq %rdi, -0x8(%rbp)
movb %dl, -0x9(%rbp)
movb %al, -0xa(%rbp)
movq %rcx, -0x18(%rbp)
movq -0x8(%rbp), %rdi
movq %rdi, -0x28(%rbp)
movzbl -0x9(%rbp), %esi
callq 0x415940
movq -0x28(%rbp), %rdi
movl %eax, -0x1c(%rbp)
movb -0xa(%rbp), %al
movb %al, -0x29(%rbp)
movslq -0x1c(%rbp), %rsi
callq 0x416bd0
movb -0x29(%rbp), %cl
movq -0x28(%rbp), %rdi
movb %cl, 0x8(%rax)
movslq -0x1c(%rbp), %rsi
callq 0x416bd0
movq %rax, %rdi
movq -0x18(%rbp), %rsi
callq 0x4149c0
movq -0x28(%rbp), %rdi
movslq -0x1c(%rbp), %rsi
callq 0x416bd0
movq %rax, %rdi
movq -0x18(%rbp), %rsi
callq 0x414a30
movq -0x28(%rbp), %rdi
movslq -0x1c(%rbp), %rsi
callq 0x416bd0
movq %rax, %rdi
movq -0x18(%rbp), %rsi
callq 0x414aa0
movq -0x28(%rbp), %rdi
movslq -0x1c(%rbp), %rsi
callq 0x416bd0
movq %rax, %rdi
movq -0x18(%rbp), %rsi
callq 0x414af0
addq $0x30, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)
// File: Thilotilo[P]DoaERando/Generals.cpp
// Function: DoaERando::Generals::UpdateGenerals()
void Generals::UpdateGenerals()
{
    const int GENERAL_ADDRESSES_LSB_START = 0x32610;
    const int GENERAL_ADDRESSES_MSB_START = 0x32710;
    for (auto& general : myGenerals)
    {
        general.UpdateGeneral(myRom);
        general.DumpGeneral();

        for (int i = 0; i < general.count; ++i)
        {
            int bankAddress = ConvertRomAddressToBankAddress(general.address);
            BYTE lsb = bankAddress & 0xFF;
            BYTE msb = (bankAddress >> 8) & 0xFF;
            myRom.WriteByte(GENERAL_ADDRESSES_MSB_START + general.id + i, msb);
            myRom.WriteByte(GENERAL_ADDRESSES_LSB_START + general.id + i, lsb);
        }
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x48(%rbp)
movl $0x32610, -0xc(%rbp)    # imm = 0x32610
movl $0x32710, -0x10(%rbp)   # imm = 0x32710
movq %rax, -0x18(%rbp)
movq -0x18(%rbp), %rdi
callq 0x416af0
movq %rax, -0x20(%rbp)
movq -0x18(%rbp), %rdi
callq 0x416b20
movq %rax, -0x28(%rbp)
leaq -0x20(%rbp), %rdi
leaq -0x28(%rbp), %rsi
callq 0x416b50
testb $0x1, %al
jne 0x4161e6
jmp 0x4162bb
leaq -0x20(%rbp), %rdi
callq 0x416b90
movq %rax, %rcx
movq -0x48(%rbp), %rax
movq %rcx, -0x30(%rbp)
movq -0x30(%rbp), %rdi
movq 0x48(%rax), %rsi
callq 0x415000
movq -0x30(%rbp), %rdi
callq 0x415310
movl $0x0, -0x34(%rbp)
movl -0x34(%rbp), %eax
movq -0x30(%rbp), %rcx
movzbl 0x5(%rcx), %ecx
cmpl %ecx, %eax
jge 0x4162ab
movq -0x48(%rbp), %rdi
movq -0x30(%rbp), %rax
movl (%rax), %esi
callq 0x4156b0
movl %eax, %ecx
movq -0x48(%rbp), %rax
movl %ecx, -0x38(%rbp)
movl -0x38(%rbp), %ecx
andl $0xff, %ecx
movb %cl, -0x39(%rbp)
movl -0x38(%rbp), %ecx
sarl $0x8, %ecx
andl $0xff, %ecx
movb %cl, -0x3a(%rbp)
movq 0x48(%rax), %rdi
movq -0x30(%rbp), %rax
movzbl 0x4(%rax), %esi
addl $0x32710, %esi          # imm = 0x32710
addl -0x34(%rbp), %esi
movzbl -0x3a(%rbp), %edx
callq 0x404c20
movq -0x48(%rbp), %rax
movq 0x48(%rax), %rdi
movq -0x30(%rbp), %rax
movzbl 0x4(%rax), %esi
addl $0x32610, %esi          # imm = 0x32610
addl -0x34(%rbp), %esi
movzbl -0x39(%rbp), %edx
callq 0x404c20
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
jmp 0x416217
jmp 0x4162ad
leaq -0x20(%rbp), %rdi
callq 0x416bb0
jmp 0x4161d0
addq $0x50, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)
// File: Thilotilo[P]DoaERando/Generals.cpp
// Function: DoaERando::Generals::GetGeneralIndexByAddress(int)
int Generals::GetGeneralIndexByAddress(int address)
{
    int i = 0;
    for (i = 0; i < myGenerals.size(); ++i)
    {
        if (myGenerals[i].address == address)
        {
            return i;
        }
    }
    return -1;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x10(%rbp)
movl %esi, -0x14(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x20(%rbp)
movl $0x0, -0x18(%rbp)
movl $0x0, -0x18(%rbp)
movq -0x20(%rbp), %rdi
movslq -0x18(%rbp), %rax
movq %rax, -0x28(%rbp)
callq 0x410a90
movq %rax, %rcx
movq -0x28(%rbp), %rax
cmpq %rcx, %rax
jae 0x41633b
movq -0x20(%rbp), %rdi
movslq -0x18(%rbp), %rsi
callq 0x416bd0
movl (%rax), %eax
cmpl -0x14(%rbp), %eax
jne 0x41632e
movl -0x18(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x416342
jmp 0x416330
movl -0x18(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x18(%rbp)
jmp 0x4162f5
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
movl -0x4(%rbp), %eax
addq $0x30, %rsp
popq %rbp
retq
nopl (%rax,%rax)
// File: Thilotilo[P]DoaERando/Generals.cpp
// Function: DoaERando::Generals::ScaleSpecialGenerals(DoaERando::RandomNumberGenerator&)
void Generals::ScaleSpecialGenerals(RNG& rng)
{
    int index = GetGeneralIndexById(CAO_PI_ID);
    myGenerals[index].enemyMaxTacticLevel = rng.GetRandomByte(35, 50);
    
    index = GetGeneralIndexById(SIMA_YI_ID);
    myGenerals[index].enemyMaxTacticLevel = rng.GetRandomByte(35, 50);

    index = GetGeneralIndexById(SUN_QUAN_ID);
    myGenerals[index].enemyMaxTacticLevel = rng.GetRandomByte(35, 50);

}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x8(%rbp), %rdi
movq %rdi, -0x20(%rbp)
movl $0x71, %esi
callq 0x415940
movl %eax, -0x14(%rbp)
movq -0x10(%rbp), %rdi
movl $0x23, %esi
movl $0x32, %edx
callq 0x41db50
movq -0x20(%rbp), %rdi
movb %al, -0x22(%rbp)
movslq -0x14(%rbp), %rsi
callq 0x416bd0
movb -0x22(%rbp), %cl
movq -0x20(%rbp), %rdi
movb %cl, 0xd(%rax)
movl $0x88, %esi
callq 0x415940
movl %eax, -0x14(%rbp)
movq -0x10(%rbp), %rdi
movl $0x23, %esi
movl $0x32, %edx
callq 0x41db50
movq -0x20(%rbp), %rdi
movb %al, -0x21(%rbp)
movslq -0x14(%rbp), %rsi
callq 0x416bd0
movb -0x21(%rbp), %cl
movq -0x20(%rbp), %rdi
movb %cl, 0xd(%rax)
movl $0x57, %esi
callq 0x415940
movl %eax, -0x14(%rbp)
movq -0x10(%rbp), %rdi
movl $0x23, %esi
movl $0x32, %edx
callq 0x41db50
movq -0x20(%rbp), %rdi
movb %al, -0x15(%rbp)
movslq -0x14(%rbp), %rsi
callq 0x416bd0
movb -0x15(%rbp), %cl
movb %cl, 0xd(%rax)
addq $0x30, %rsp
popq %rbp
retq
nopl (%rax,%rax)
// File: Thilotilo[P]DoaERando/Generals.cpp
// Function: DoaERando::Generals::RandomizeLiuShan(DoaERando::RandomNumberGenerator&)
void Generals::RandomizeLiuShan(RNG& rng)
{
    // Scale Liu Shan's STR/INT/AGI to an above average range (180-220)
    int LiuShanIndex = GetGeneralIndexById(LIU_CHAN_ID);
    myGenerals[LiuShanIndex].strength = rng.GetRandomByte(180, 220);
    myGenerals[LiuShanIndex].intelligence = rng.GetRandomByte(180, 220);
    myGenerals[LiuShanIndex].agility = rng.GetRandomByte(180, 220);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x8(%rbp), %rdi
movq %rdi, -0x20(%rbp)
movl $0xab, %esi
callq 0x415940
movl %eax, -0x14(%rbp)
movq -0x10(%rbp), %rdi
movl $0xb4, %esi
movl $0xdc, %edx
callq 0x41db50
movq -0x20(%rbp), %rdi
movb %al, -0x22(%rbp)
movslq -0x14(%rbp), %rsi
callq 0x416bd0
movb -0x22(%rbp), %cl
movb %cl, 0x6(%rax)
movq -0x10(%rbp), %rdi
movl $0xb4, %esi
movl $0xdc, %edx
callq 0x41db50
movq -0x20(%rbp), %rdi
movb %al, -0x21(%rbp)
movslq -0x14(%rbp), %rsi
callq 0x416bd0
movb -0x21(%rbp), %cl
movb %cl, 0x7(%rax)
movq -0x10(%rbp), %rdi
movl $0xb4, %esi
movl $0xdc, %edx
callq 0x41db50
movq -0x20(%rbp), %rdi
movb %al, -0x15(%rbp)
movslq -0x14(%rbp), %rsi
callq 0x416bd0
movb -0x15(%rbp), %cl
movb %cl, 0xe(%rax)
addq $0x30, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)
// File: Thilotilo[P]DoaERando/Generals.cpp
// Function: DoaERando::Generals::SetStartingGenerals(std::vector<unsigned char, std::allocator<unsigned char>>&)
void Generals::SetStartingGenerals(vector<BYTE>& startingGeneralIds)
{
    for (auto& generalId : startingGeneralIds)
    {
        int index = GetGeneralIndexById(generalId);
        myStartingGeneralAddresses.push_back(myGenerals[index].address);
        myGenerals[index].encounterable = false;
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x40(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x18(%rbp)
movq -0x18(%rbp), %rdi
callq 0x405780
movq %rax, -0x20(%rbp)
movq -0x18(%rbp), %rdi
callq 0x405610
movq %rax, -0x28(%rbp)
leaq -0x20(%rbp), %rdi
leaq -0x28(%rbp), %rsi
callq 0x40ffd0
testb $0x1, %al
jne 0x41679d
jmp 0x4167fd
leaq -0x20(%rbp), %rdi
callq 0x410010
movq -0x40(%rbp), %rdi
movq %rax, -0x30(%rbp)
movq -0x30(%rbp), %rax
movzbl (%rax), %esi
callq 0x415940
movq -0x40(%rbp), %rdi
movl %eax, -0x34(%rbp)
movq %rdi, %rax
addq $0x30, %rax
movq %rax, -0x48(%rbp)
movslq -0x34(%rbp), %rsi
callq 0x416bd0
movq -0x48(%rbp), %rdi
movq %rax, %rsi
callq 0x416cd0
movq -0x40(%rbp), %rdi
movslq -0x34(%rbp), %rsi
callq 0x416bd0
movb $0x0, 0x23(%rax)
leaq -0x20(%rbp), %rdi
callq 0x410030
jmp 0x41678a
addq $0x50, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)
// File: Thilotilo[P]DoaERando/Generals.cpp
// Function: DoaERando::Generals::GetGeneralIdsFromZone(unsigned char)
std::vector<BYTE> Generals::GetGeneralIdsFromZone(BYTE zone)
{
    std::vector<BYTE> generalIdsForZone;
    for (auto& general : myGenerals)
    {
        if (isStartingGeneralAddress(general.address) || isRestrictedGeneralAddress(general.address))
        {
            continue;
        }
        if (general.zone == zone)
        {
            // The game likes to use the last id if there are multiples
            generalIdsForZone.push_back(general.id + (general.count - 1));
        }
    }
    return generalIdsForZone;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x70, %rsp
movq %rdi, -0x68(%rbp)
movb %dl, %al
movq %rdi, %rcx
movq %rcx, -0x60(%rbp)
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movb %al, -0x11(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x58(%rbp)
movb $0x0, -0x12(%rbp)
callq 0x40fa90
movq -0x58(%rbp), %rax
movq %rax, -0x20(%rbp)
movq -0x20(%rbp), %rdi
callq 0x416af0
movq %rax, -0x28(%rbp)
movq -0x20(%rbp), %rdi
callq 0x416b20
movq %rax, -0x30(%rbp)
leaq -0x28(%rbp), %rdi
leaq -0x30(%rbp), %rsi
callq 0x416b50
testb $0x1, %al
jne 0x416879
jmp 0x41690a
leaq -0x28(%rbp), %rdi
callq 0x416b90
movq -0x58(%rbp), %rdi
movq %rax, -0x38(%rbp)
movq -0x38(%rbp), %rax
movl (%rax), %esi
callq 0x415dd0
testb $0x1, %al
jne 0x4168ae
movq -0x58(%rbp), %rdi
movq -0x38(%rbp), %rax
movl (%rax), %esi
callq 0x415b20
testb $0x1, %al
jne 0x4168ae
jmp 0x4168b0
jmp 0x4168fc
movq -0x38(%rbp), %rax
movzbl 0x8(%rax), %eax
movzbl -0x11(%rbp), %ecx
cmpl %ecx, %eax
jne 0x4168fa
movq -0x68(%rbp), %rdi
movq -0x38(%rbp), %rax
movl 0x4(%rax), %ecx
movzbl 0x5(%rax), %eax
addl %ecx, %eax
decb %al
movb %al, -0x39(%rbp)
leaq -0x39(%rbp), %rsi
callq 0x40fab0
jmp 0x4168e1
jmp 0x4168fa
movq -0x68(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
callq 0x404f50
jmp 0x416927
jmp 0x4168fc
leaq -0x28(%rbp), %rdi
callq 0x416bb0
jmp 0x416863
movb $0x1, -0x12(%rbp)
testb $0x1, -0x12(%rbp)
jne 0x41691d
movq -0x68(%rbp), %rdi
callq 0x404f50
movq -0x60(%rbp), %rax
addq $0x70, %rsp
popq %rbp
retq
movq -0x48(%rbp), %rdi
callq 0x4c9ba0
// File: Thilotilo[P]DoaERando/Generals.cpp
// Function: DoaERando::Generals::GetAllGeneralIds()
std::vector<BYTE> Generals::GetAllGeneralIds()
{
    std::vector<BYTE> generalIds;
    for (auto& general : myGenerals)
    {
        // The game likes to use the last id if there are multiples
        generalIds.push_back(general.id + (general.count - 1));
    }
    return generalIds;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x70, %rsp
movq %rdi, -0x68(%rbp)
movq %rdi, %rax
movq %rax, -0x60(%rbp)
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x58(%rbp)
movb $0x0, -0x11(%rbp)
callq 0x40fa90
movq -0x58(%rbp), %rax
movq %rax, -0x20(%rbp)
movq -0x20(%rbp), %rdi
callq 0x416af0
movq %rax, -0x28(%rbp)
movq -0x20(%rbp), %rdi
callq 0x416b20
movq %rax, -0x30(%rbp)
leaq -0x28(%rbp), %rdi
leaq -0x30(%rbp), %rsi
callq 0x416b50
testb $0x1, %al
jne 0x416991
jmp 0x4169e3
leaq -0x28(%rbp), %rdi
callq 0x416b90
movq -0x68(%rbp), %rdi
movq %rax, -0x38(%rbp)
movq -0x38(%rbp), %rax
movl 0x4(%rax), %ecx
movzbl 0x5(%rax), %eax
addl %ecx, %eax
decb %al
movb %al, -0x39(%rbp)
leaq -0x39(%rbp), %rsi
callq 0x40fab0
jmp 0x4169bf
jmp 0x4169c1
leaq -0x28(%rbp), %rdi
callq 0x416bb0
jmp 0x41697e
movq -0x68(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
callq 0x404f50
jmp 0x416a00
movb $0x1, -0x11(%rbp)
testb $0x1, -0x11(%rbp)
jne 0x4169f6
movq -0x68(%rbp), %rdi
callq 0x404f50
movq -0x60(%rbp), %rax
addq $0x70, %rsp
popq %rbp
retq
movq -0x48(%rbp), %rdi
callq 0x4c9ba0
nopl (%rax)
// File: Thilotilo[P]DoaERando/BattleRandomizer.cpp
// Function: DoaERando::Battle::Battle(int)
Battle::Battle(int id)
{
    vector<int> zoneForBattle = {1, 1, 1, 1, 1, 1,
                                 2, 2, 2, 2, 2, 2, 2, 2,
                                 3, 3, 3, 3, 3, 3,
                                 4, 4, 4, 4, 4, 4, 4,
                                 5, 5, 5, 5, 5,
                                 6, 6, 6, 6, 6, 6, 6, 6,
                                 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
                                 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
                                 4, 4,
                                 5, 5,
                                 7, 7, 8, 6};

    zone = zoneForBattle[id];
    battleId = id;
    for (int i = 0; i < 5; ++i)
    {
        generals[i] = 0x00;
    }
    slotsRemaining = 5;
    battleModified = false;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x1b0, %rsp            # imm = 0x1B0
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x1a8(%rbp)
leaq 0x1838f8(%rip), %rsi    # 0x59b78c
leaq -0x178(%rbp), %rdi
movq %rdi, -0x1a0(%rbp)
movl $0x140, %edx            # imm = 0x140
callq 0x401070
movq -0x1a0(%rbp), %rax
movq %rax, -0x38(%rbp)
movq $0x50, -0x30(%rbp)
leaq -0x179(%rbp), %rdi
movq %rdi, -0x198(%rbp)
callq 0x416e40
movq -0x198(%rbp), %rcx
movq -0x38(%rbp), %rsi
movq -0x30(%rbp), %rdx
leaq -0x28(%rbp), %rdi
callq 0x41be20
jmp 0x417eec
leaq -0x179(%rbp), %rdi
callq 0x4107c0
movslq -0xc(%rbp), %rsi
leaq -0x28(%rbp), %rdi
callq 0x41bea0
movq %rax, %rcx
movq -0x1a8(%rbp), %rax
movl (%rcx), %ecx
movl %ecx, (%rax)
movl -0xc(%rbp), %ecx
movl %ecx, 0x4(%rax)
movl $0x0, -0x190(%rbp)
cmpl $0x5, -0x190(%rbp)
jge 0x417f70
movq -0x1a8(%rbp), %rax
movslq -0x190(%rbp), %rcx
movb $0x0, 0x8(%rax,%rcx)
movl -0x190(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x190(%rbp)
jmp 0x417f23
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x188(%rbp)
movl %eax, -0x18c(%rbp)
leaq -0x179(%rbp), %rdi
callq 0x4107c0
jmp 0x417f94
movq -0x1a8(%rbp), %rax
movl $0x5, 0x10(%rax)
movb $0x0, 0x14(%rax)
leaq -0x28(%rbp), %rdi
callq 0x410580
addq $0x1b0, %rsp            # imm = 0x1B0
popq %rbp
retq
movq -0x188(%rbp), %rdi
callq 0x4c9ba0
// File: Thilotilo[P]DoaERando/BattleRandomizer.cpp
// Function: DoaERando::Battle::OrganizeBattle()
void Battle::OrganizeBattle()
{
    // Reorder battles so that Generals come first, then rebel forces, then empty slots
    std::vector<BYTE> generalList;
    int numRebels = 0;

    // First, let's just collect the generals and the number of rebel forces
    for (int i = 0; i < 5; ++i)
    {
        if (generals[i] > 0x04)
        {
            generalList.push_back(generals[i]);
        }
        if (generals[i] == 0x04)
        {
            numRebels++;
        }
    }

    int index = 0;

    // assign the generals
    for (auto& general : generalList)
    {
        generals[index++] = general;
    }
    // assign the rebel forces
    for (int i = 0; i < numRebels; ++i)
    {
        generals[index++] = 0x04;
    }
    // assign empty slots
    while (index < 0x05)
    {
        generals[index++] = 0x00;
    }

    battleModified = true;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x70, %rsp
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x68(%rbp)
leaq -0x20(%rbp), %rdi
callq 0x40fa90
movl $0x0, -0x24(%rbp)
movl $0x0, -0x28(%rbp)
cmpl $0x5, -0x28(%rbp)
jge 0x41803f
movq -0x68(%rbp), %rax
movslq -0x28(%rbp), %rcx
movzbl 0x8(%rax,%rcx), %eax
cmpl $0x4, %eax
jle 0x418017
movq -0x68(%rbp), %rax
movslq -0x28(%rbp), %rcx
leaq 0x8(%rax,%rcx), %rsi
leaq -0x20(%rbp), %rdi
callq 0x40fae0
jmp 0x417ffb
jmp 0x418017
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
leaq -0x20(%rbp), %rdi
callq 0x404f50
jmp 0x41811b
movq -0x68(%rbp), %rax
movslq -0x28(%rbp), %rcx
movzbl 0x8(%rax,%rcx), %eax
cmpl $0x4, %eax
jne 0x418032
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0x418034
movl -0x28(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x28(%rbp)
jmp 0x417fcb
movl $0x0, -0x38(%rbp)
leaq -0x20(%rbp), %rax
movq %rax, -0x40(%rbp)
movq -0x40(%rbp), %rdi
callq 0x405780
movq %rax, -0x48(%rbp)
movq -0x40(%rbp), %rdi
callq 0x405610
movq %rax, -0x50(%rbp)
leaq -0x48(%rbp), %rdi
leaq -0x50(%rbp), %rsi
callq 0x40ffd0
testb $0x1, %al
jne 0x41807b
jmp 0x4180b2
leaq -0x48(%rbp), %rdi
callq 0x410010
movq %rax, %rcx
movq -0x68(%rbp), %rax
movq %rcx, -0x58(%rbp)
movq -0x58(%rbp), %rcx
movb (%rcx), %dl
movl -0x38(%rbp), %ecx
movl %ecx, %esi
addl $0x1, %esi
movl %esi, -0x38(%rbp)
movslq %ecx, %rcx
movb %dl, 0x8(%rax,%rcx)
leaq -0x48(%rbp), %rdi
callq 0x410030
jmp 0x418068
movl $0x0, -0x5c(%rbp)
movl -0x5c(%rbp), %eax
cmpl -0x24(%rbp), %eax
jge 0x4180e3
movq -0x68(%rbp), %rax
movl -0x38(%rbp), %ecx
movl %ecx, %edx
addl $0x1, %edx
movl %edx, -0x38(%rbp)
movslq %ecx, %rcx
movb $0x4, 0x8(%rax,%rcx)
movl -0x5c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x5c(%rbp)
jmp 0x4180b9
jmp 0x4180e5
cmpl $0x5, -0x38(%rbp)
jge 0x418104
movq -0x68(%rbp), %rax
movl -0x38(%rbp), %ecx
movl %ecx, %edx
addl $0x1, %edx
movl %edx, -0x38(%rbp)
movslq %ecx, %rcx
movb $0x0, 0x8(%rax,%rcx)
jmp 0x4180e5
movq -0x68(%rbp), %rax
movb $0x1, 0x14(%rax)
leaq -0x20(%rbp), %rdi
callq 0x404f50
addq $0x70, %rsp
popq %rbp
retq
movq -0x30(%rbp), %rdi
callq 0x4c9ba0
nopw %cs:(%rax,%rax)
// File: Thilotilo[P]DoaERando/BattleRandomizer.cpp
// Function: DoaERando::BattleRandomizer::PlaceGeneralInBattle(unsigned char, int)
bool BattleRandomizer::PlaceGeneralInBattle(BYTE id, int battleId)
{
    if (myBattles[battleId].slotsRemaining == 0)
    {
        return false;
    }
    for (int i = 0; i < 5; ++i)
    {
        if (myBattles[battleId].generals[i] == id)
        {
            return false;
        }
        if (myBattles[battleId].generals[i] == 0x00)
        {
            myBattles[battleId].generals[i] = id;
            myBattles[battleId].slotsRemaining--;
            return true;
        }
    }
    return false;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movb %sil, %al
movq %rdi, -0x10(%rbp)
movb %al, -0x11(%rbp)
movl %edx, -0x18(%rbp)
movq -0x10(%rbp), %rdi
movq %rdi, -0x28(%rbp)
movslq -0x18(%rbp), %rsi
callq 0x41bf10
cmpl $0x0, 0x10(%rax)
jne 0x4181e5
movb $0x0, -0x1(%rbp)
jmp 0x418283
movl $0x0, -0x1c(%rbp)
cmpl $0x5, -0x1c(%rbp)
jge 0x41827f
movq -0x28(%rbp), %rdi
movslq -0x18(%rbp), %rsi
callq 0x41bf10
movslq -0x1c(%rbp), %rcx
movzbl 0x8(%rax,%rcx), %eax
movzbl -0x11(%rbp), %ecx
cmpl %ecx, %eax
jne 0x41821a
movb $0x0, -0x1(%rbp)
jmp 0x418283
movq -0x28(%rbp), %rdi
movslq -0x18(%rbp), %rsi
callq 0x41bf10
movslq -0x1c(%rbp), %rcx
movzbl 0x8(%rax,%rcx), %eax
cmpl $0x0, %eax
jne 0x41826f
movq -0x28(%rbp), %rdi
movb -0x11(%rbp), %al
movb %al, -0x29(%rbp)
movslq -0x18(%rbp), %rsi
callq 0x41bf10
movb -0x29(%rbp), %dl
movq -0x28(%rbp), %rdi
movslq -0x1c(%rbp), %rcx
movb %dl, 0x8(%rax,%rcx)
movslq -0x18(%rbp), %rsi
callq 0x41bf10
movl 0x10(%rax), %ecx
addl $-0x1, %ecx
movl %ecx, 0x10(%rax)
movb $0x1, -0x1(%rbp)
jmp 0x418283
jmp 0x418271
movl -0x1c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c(%rbp)
jmp 0x4181ec
movb $0x0, -0x1(%rbp)
movb -0x1(%rbp), %al
andb $0x1, %al
addq $0x30, %rsp
popq %rbp
retq
nop
// File: Thilotilo[P]DoaERando/BattleRandomizer.cpp
// Function: DoaERando::BattleRandomizer::FillBattleWithOnlyGenerals(std::vector<unsigned char, std::allocator<unsigned char>>, int, DoaERando::RandomNumberGenerator&)
void BattleRandomizer::FillBattleWithOnlyGenerals(vector<BYTE> generalIds, int battleId, RNG& rng)
{
    int startingIndex = 5 - myBattles[battleId].slotsRemaining;
    for (int i = startingIndex; i < 5; ++i)
    {
        bool success = false;
        while (!success)
        {
            BYTE generalToInsert = rng.GetRandomValueFromByteVector(generalIds);
            success = PlaceGeneralInBattle(generalToInsert, battleId);
        }
    }
    myBattles[battleId].OrganizeBattle();
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movq %rsi, -0x40(%rbp)
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl %edx, -0x14(%rbp)
movq %rcx, -0x20(%rbp)
movq -0x8(%rbp), %rdi
movq %rdi, -0x38(%rbp)
movslq -0x14(%rbp), %rsi
callq 0x41bf10
movq %rax, %rcx
movl $0x5, %eax
subl 0x10(%rcx), %eax
movl %eax, -0x24(%rbp)
movl -0x24(%rbp), %eax
movl %eax, -0x28(%rbp)
cmpl $0x5, -0x28(%rbp)
jge 0x4184eb
movb $0x0, -0x29(%rbp)
movb -0x29(%rbp), %al
xorb $-0x1, %al
testb $0x1, %al
jne 0x4184b5
jmp 0x4184de
movq -0x40(%rbp), %rsi
movq -0x20(%rbp), %rdi
callq 0x41dc20
movq -0x38(%rbp), %rdi
movb %al, -0x2a(%rbp)
movb -0x2a(%rbp), %al
movl -0x14(%rbp), %edx
movzbl %al, %esi
callq 0x4181b0
andb $0x1, %al
movb %al, -0x29(%rbp)
jmp 0x4184aa
jmp 0x4184e0
movl -0x28(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x28(%rbp)
jmp 0x4184a0
movq -0x38(%rbp), %rdi
movslq -0x14(%rbp), %rsi
callq 0x41bf10
movq %rax, %rdi
callq 0x417fa0
addq $0x40, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)
// File: Thilotilo[P]DoaERando/BattleRandomizer.cpp
// Function: DoaERando::BattleRandomizer::UpdateBattles(DoaERando::ROM&)
void BattleRandomizer::UpdateBattles(ROM& rom)
{
    const int BATTLE0_OFFSET = 0x30D70;

    for (auto& battle : myBattles)
    {
        if (battle.battleModified)
        {
            printf("Battle 0x%02X is now 0x%02X 0x%02X 0x%02X 0x%02X 0x%02X\n",
                   battle.battleId, battle.generals[0], battle.generals[1],
                   battle.generals[2], battle.generals[3], battle.generals[4]);
            int battleOffset = BATTLE0_OFFSET + (5 * battle.battleId);
            for (int i = 0; i < 5; ++i)
            {
                rom.WriteByte(battleOffset + i, battle.generals[i]);
            }
        }
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x8(%rbp), %rax
movl $0x30d70, -0x14(%rbp)   # imm = 0x30D70
movq %rax, -0x20(%rbp)
movq -0x20(%rbp), %rdi
callq 0x41c020
movq %rax, -0x28(%rbp)
movq -0x20(%rbp), %rdi
callq 0x41c050
movq %rax, -0x30(%rbp)
leaq -0x28(%rbp), %rdi
leaq -0x30(%rbp), %rsi
callq 0x41c080
testb $0x1, %al
jne 0x41bd5f
jmp 0x41be12
leaq -0x28(%rbp), %rdi
callq 0x41c0c0
movq %rax, -0x38(%rbp)
movq -0x38(%rbp), %rax
testb $0x1, 0x14(%rax)
je 0x41be02
movq -0x38(%rbp), %rax
movl 0x4(%rax), %esi
movq -0x38(%rbp), %rax
movzbl 0x8(%rax), %edx
movq -0x38(%rbp), %rax
movzbl 0x9(%rax), %ecx
movq -0x38(%rbp), %rax
movzbl 0xa(%rax), %r8d
movq -0x38(%rbp), %rax
movzbl 0xb(%rax), %r9d
movq -0x38(%rbp), %rax
movzbl 0xc(%rax), %eax
leaq 0x17fd28(%rip), %rdi    # 0x59bada
movl %eax, (%rsp)
movb $0x0, %al
callq 0x4f06e0
movq -0x38(%rbp), %rax
imull $0x5, 0x4(%rax), %eax
addl $0x30d70, %eax          # imm = 0x30D70
movl %eax, -0x3c(%rbp)
movl $0x0, -0x40(%rbp)
cmpl $0x5, -0x40(%rbp)
jge 0x41be00
movq -0x10(%rbp), %rdi
movl -0x3c(%rbp), %esi
addl -0x40(%rbp), %esi
movq -0x38(%rbp), %rax
movslq -0x40(%rbp), %rcx
movzbl 0x8(%rax,%rcx), %edx
callq 0x404c20
movl -0x40(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x40(%rbp)
jmp 0x41bdd3
jmp 0x41be02
jmp 0x41be04
leaq -0x28(%rbp), %rdi
callq 0x41c0e0
jmp 0x41bd49
addq $0x50, %rsp
popq %rbp
retq
nopl (%rax,%rax)
// File: Thilotilo[P]DoaERando/NPCManipulator.cpp
// Function: DoaERando::NPCManipulator::ReplaceSongYongAndSongRen(unsigned char, unsigned char)
void NPCManipulator::ReplaceSongYongAndSongRen(BYTE generalId1, BYTE generalId2)
{
    // This sets the NPC Data.
    myRom.WriteByte(0x31AC9, generalId1);
    myRom.WriteByte(0x31AD0, generalId2);
    // This sets the text strings.
    myRom.WriteByte(0x36207, generalId1);
    myRom.WriteByte(0x3620B, generalId2);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movb %dl, %al
movb %sil, %cl
movq %rdi, -0x8(%rbp)
movb %cl, -0x9(%rbp)
movb %al, -0xa(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x18(%rbp)
movq (%rax), %rdi
movl $0x31ac9, %esi          # imm = 0x31AC9
movzbl -0x9(%rbp), %edx
callq 0x404c20
movq -0x18(%rbp), %rax
movq (%rax), %rdi
movl $0x31ad0, %esi          # imm = 0x31AD0
movzbl -0xa(%rbp), %edx
callq 0x404c20
movq -0x18(%rbp), %rax
movq (%rax), %rdi
movl $0x36207, %esi          # imm = 0x36207
movzbl -0x9(%rbp), %edx
callq 0x404c20
movq -0x18(%rbp), %rax
movq (%rax), %rdi
movl $0x3620b, %esi          # imm = 0x3620B
movzbl -0xa(%rbp), %edx
callq 0x404c20
addq $0x20, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)
// File: Thilotilo[P]DoaERando/NPCManipulator.cpp
// Function: DoaERando::NPCManipulator::ReplaceChenDeng(unsigned char)
void NPCManipulator::ReplaceChenDeng(BYTE generalId)
{
    myRom.WriteByte(0x311C0, generalId);
    // This replaces the name given by Chen Deng's father
    myRom.WriteByte(0x2963D, generalId);
    // This is a temporary fix for extra long names before
    // we overhaul the text stuff.
    // It rewrites (so)n to s(on) so that it can create a
    // newline before the general name.
    myRom.WriteByte(0x29639, 0x2E);
    myRom.WriteByte(0x2963A, 0xE0);
    myRom.WriteByte(0x2963B, 0xEC);
    myRom.WriteByte(0x2963C, 0xD2);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movb %sil, %al
movq %rdi, -0x8(%rbp)
movb %al, -0x9(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x18(%rbp)
movq (%rax), %rdi
movl $0x311c0, %esi          # imm = 0x311C0
movzbl -0x9(%rbp), %edx
callq 0x404c20
movq -0x18(%rbp), %rax
movq (%rax), %rdi
movl $0x2963d, %esi          # imm = 0x2963D
movzbl -0x9(%rbp), %edx
callq 0x404c20
movq -0x18(%rbp), %rax
movq (%rax), %rdi
movl $0x29639, %esi          # imm = 0x29639
movl $0x2e, %edx
callq 0x404c20
movq -0x18(%rbp), %rax
movq (%rax), %rdi
movl $0x2963a, %esi          # imm = 0x2963A
movl $0xe0, %edx
callq 0x404c20
movq -0x18(%rbp), %rax
movq (%rax), %rdi
movl $0x2963b, %esi          # imm = 0x2963B
movl $0xec, %edx
callq 0x404c20
movq -0x18(%rbp), %rax
movq (%rax), %rdi
movl $0x2963c, %esi          # imm = 0x2963C
movl $0xd2, %edx
callq 0x404c20
addq $0x20, %rsp
popq %rbp
retq
nop
// File: Thilotilo[P]DoaERando/NPCManipulator.cpp
// Function: DoaERando::NPCManipulator::ReplaceHuangZhongAndWeiYan(unsigned char, unsigned char)
void NPCManipulator::ReplaceHuangZhongAndWeiYan(BYTE generalId1, BYTE generalId2)
{
    // This is the NPC data
    myRom.WriteByte(0x31772, generalId1);
    myRom.WriteByte(0x31779, generalId2);
    // This is for the post-battle flags change
    myRom.WriteByte(0x3B062, generalId1);
    myRom.WriteByte(0x3B065, generalId2);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movb %dl, %al
movb %sil, %cl
movq %rdi, -0x8(%rbp)
movb %cl, -0x9(%rbp)
movb %al, -0xa(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x18(%rbp)
movq (%rax), %rdi
movl $0x31772, %esi          # imm = 0x31772
movzbl -0x9(%rbp), %edx
callq 0x404c20
movq -0x18(%rbp), %rax
movq (%rax), %rdi
movl $0x31779, %esi          # imm = 0x31779
movzbl -0xa(%rbp), %edx
callq 0x404c20
movq -0x18(%rbp), %rax
movq (%rax), %rdi
movl $0x3b062, %esi          # imm = 0x3B062
movzbl -0x9(%rbp), %edx
callq 0x404c20
movq -0x18(%rbp), %rax
movq (%rax), %rdi
movl $0x3b065, %esi          # imm = 0x3B065
movzbl -0xa(%rbp), %edx
callq 0x404c20
addq $0x20, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)