LLM4Binary/decompile-bench-makefile huggingface dataset:
// File: Thilotilo[P]DoaERando/Randomizer.cpp
// Function: DoaERando::Randomizer::PrintName(unsigned char)
void Randomizer::PrintName(BYTE id)
{
    int nameOffset = GetGeneralLocation(id) + 20;
    while (myRom->ReadByte(nameOffset) != 0xFF)
    {
        char character = myRom->ReadByte(nameOffset) + 'A' - 0x10;
        switch(myRom->ReadByte(nameOffset))
        {
            case 0x2D:
                character = 'r';
                break;
            case 0x2F:
                character = 't';
                break;
            case 0x64:
                character = 'u';
                break;
            case 0x0A:
                character = ' ';
                break;
            default:
                break;
        }

        printf("%c", character);
        ++nameOffset;
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movb %sil, %al
movq %rdi, -0x8(%rbp)
movb %al, -0x9(%rbp)
movq -0x8(%rbp), %rdi
movq %rdi, -0x20(%rbp)
movzbl -0x9(%rbp), %esi
callq 0x406060
addl $0x14, %eax
movl %eax, -0x10(%rbp)
movq -0x20(%rbp), %rax
movq (%rax), %rdi
movl -0x10(%rbp), %esi
callq 0x404bb0
movzbl %al, %eax
cmpl $0xff, %eax
je 0x4061b0
movq -0x20(%rbp), %rax
movq (%rax), %rdi
movl -0x10(%rbp), %esi
callq 0x404bb0
movb %al, %cl
movq -0x20(%rbp), %rax
addb $0x31, %cl
movb %cl, -0x11(%rbp)
movq (%rax), %rdi
movl -0x10(%rbp), %esi
callq 0x404bb0
movzbl %al, %ecx
movl %ecx, -0x24(%rbp)
subb $0xa, %al
je 0x406188
jmp 0x406158
movl -0x24(%rbp), %eax
subl $0x2d, %eax
je 0x406176
jmp 0x406162
movl -0x24(%rbp), %eax
subl $0x2f, %eax
je 0x40617c
jmp 0x40616c
movl -0x24(%rbp), %eax
subl $0x64, %eax
je 0x406182
jmp 0x40618e
movb $0x72, -0x11(%rbp)
jmp 0x406190
movb $0x74, -0x11(%rbp)
jmp 0x406190
movb $0x75, -0x11(%rbp)
jmp 0x406190
movb $0x20, -0x11(%rbp)
jmp 0x406190
jmp 0x406190
movsbl -0x11(%rbp), %esi
leaq 0x194ec9(%rip), %rdi    # 0x59b064
movb $0x0, %al
callq 0x4f06e0
movl -0x10(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x10(%rbp)
jmp 0x406109
addq $0x30, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)
// File: Thilotilo[P]DoaERando/Randomizer.cpp
// Function: DoaERando::IsSingleExitCave(int)
static bool IsSingleExitCave(int offset)
{
    const int XU_ZHE_CAVE_OFFSET = 0x07;
    const int GOLD_KEY_CAVE_OFFSET = 0x46;
    const int NAN_YANG_CAVE_OFFSET = 0x63;
    const int SALTPETER_CAVE_OFFSET = 0x99;

    return (offset == XU_ZHE_CAVE_OFFSET ||
            offset == GOLD_KEY_CAVE_OFFSET ||
            offset == NAN_YANG_CAVE_OFFSET ||
            offset == SALTPETER_CAVE_OFFSET);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
movl %edi, -0x4(%rbp)
movl $0x7, -0x8(%rbp)
movl $0x46, -0xc(%rbp)
movl $0x63, -0x10(%rbp)
movl $0x99, -0x14(%rbp)
movb $0x1, %al
cmpl $0x7, -0x4(%rbp)
movb %al, -0x15(%rbp)
je 0x407b61
movb $0x1, %al
cmpl $0x46, -0x4(%rbp)
movb %al, -0x15(%rbp)
je 0x407b61
movb $0x1, %al
cmpl $0x63, -0x4(%rbp)
movb %al, -0x15(%rbp)
je 0x407b61
cmpl $0x99, -0x4(%rbp)
sete %al
movb %al, -0x15(%rbp)
movb -0x15(%rbp), %al
andb $0x1, %al
popq %rbp
retq
nopl (%rax,%rax)
// File: Thilotilo[P]DoaERando/Randomizer.cpp
// Function: DoaERando::AreExitsFromSameCave(int, int)
static bool AreExitsFromSameCave(int offset1, int offset2)
{
    const int MT_GANG_TAI_ENTRANCE_OFFSET = 0x0B;
    const int MT_GANG_TAI_EXIT_OFFSET = 0x1F;
    const int WU_CAVE_EXIT_OFFSET = 0x26;
    const int WU_CAVE_ENTRANCE_OFFSET = 0x39;
    const int CHANG_AN_ENTRANCE_OFFSET = 0x58;
    const int CHANG_AN_EXIT_OFFSET = 0x61;
    const int WEI_CAVE_2_ENTRANCE_OFFSET = 0x6C;
    const int WEI_CAVE_2_EXIT_OFFSET = 0x7B;
    const int WEI_CAVE_1_EXIT_OFFSET = 0x7E;
    const int WEI_CAVE_1_ENTRANCE_OFFSET = 0x93;

    return ((offset1 == MT_GANG_TAI_ENTRANCE_OFFSET && offset2 == MT_GANG_TAI_EXIT_OFFSET) ||
            (offset1 == MT_GANG_TAI_EXIT_OFFSET && offset2 == MT_GANG_TAI_ENTRANCE_OFFSET) ||
            (offset1 == WU_CAVE_ENTRANCE_OFFSET && offset2 == WU_CAVE_EXIT_OFFSET) ||
            (offset1 == WU_CAVE_EXIT_OFFSET && offset2 == WU_CAVE_ENTRANCE_OFFSET) ||
            (offset1 == CHANG_AN_ENTRANCE_OFFSET && offset2 == CHANG_AN_EXIT_OFFSET) ||
            (offset1 == CHANG_AN_EXIT_OFFSET && offset2 == CHANG_AN_ENTRANCE_OFFSET) ||
            (offset1 == WEI_CAVE_2_ENTRANCE_OFFSET && offset2 == WEI_CAVE_2_EXIT_OFFSET) ||
            (offset1 == WEI_CAVE_2_EXIT_OFFSET && offset2 == WEI_CAVE_2_ENTRANCE_OFFSET) ||
            (offset1 == WEI_CAVE_1_ENTRANCE_OFFSET && offset2 == WEI_CAVE_1_EXIT_OFFSET) ||
            (offset1 == WEI_CAVE_1_EXIT_OFFSET && offset2 == WEI_CAVE_1_ENTRANCE_OFFSET));
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
movl %edi, -0x4(%rbp)
movl %esi, -0x8(%rbp)
movl $0xb, -0xc(%rbp)
movl $0x1f, -0x10(%rbp)
movl $0x26, -0x14(%rbp)
movl $0x39, -0x18(%rbp)
movl $0x58, -0x1c(%rbp)
movl $0x61, -0x20(%rbp)
movl $0x6c, -0x24(%rbp)
movl $0x7b, -0x28(%rbp)
movl $0x7e, -0x2c(%rbp)
movl $0x93, -0x30(%rbp)
cmpl $0xb, -0x4(%rbp)
jne 0x407bd5
movb $0x1, %al
cmpl $0x1f, -0x8(%rbp)
movb %al, -0x31(%rbp)
je 0x407c86
cmpl $0x1f, -0x4(%rbp)
jne 0x407bea
movb $0x1, %al
cmpl $0xb, -0x8(%rbp)
movb %al, -0x31(%rbp)
je 0x407c86
cmpl $0x39, -0x4(%rbp)
jne 0x407bff
movb $0x1, %al
cmpl $0x26, -0x8(%rbp)
movb %al, -0x31(%rbp)
je 0x407c86
cmpl $0x26, -0x4(%rbp)
jne 0x407c10
movb $0x1, %al
cmpl $0x39, -0x8(%rbp)
movb %al, -0x31(%rbp)
je 0x407c86
cmpl $0x58, -0x4(%rbp)
jne 0x407c21
movb $0x1, %al
cmpl $0x61, -0x8(%rbp)
movb %al, -0x31(%rbp)
je 0x407c86
cmpl $0x61, -0x4(%rbp)
jne 0x407c32
movb $0x1, %al
cmpl $0x58, -0x8(%rbp)
movb %al, -0x31(%rbp)
je 0x407c86
cmpl $0x6c, -0x4(%rbp)
jne 0x407c43
movb $0x1, %al
cmpl $0x7b, -0x8(%rbp)
movb %al, -0x31(%rbp)
je 0x407c86
cmpl $0x7b, -0x4(%rbp)
jne 0x407c54
movb $0x1, %al
cmpl $0x6c, -0x8(%rbp)
movb %al, -0x31(%rbp)
je 0x407c86
cmpl $0x93, -0x4(%rbp)
jne 0x407c68
movb $0x1, %al
cmpl $0x7e, -0x8(%rbp)
movb %al, -0x31(%rbp)
je 0x407c86
xorl %eax, %eax
cmpl $0x7e, -0x4(%rbp)
movb %al, -0x32(%rbp)
jne 0x407c80
cmpl $0x93, -0x8(%rbp)
sete %al
movb %al, -0x32(%rbp)
movb -0x32(%rbp), %al
movb %al, -0x31(%rbp)
movb -0x31(%rbp), %al
andb $0x1, %al
popq %rbp
retq
nopl (%rax)
// File: Thilotilo[P]DoaERando/Randomizer.cpp
// Function: DoaERando::Randomizer::FixNMIGlitch()
void Randomizer::FixNMIGlitch()
{
    // This should hopefully stop all of the crashes
    std::vector<BYTE> loopingCode = {
        0x68,               // PLA
        0x85, 0xF3,         // STA $F3
        0x68,               // PLA
        0x85, 0xF4,         // STA $F4
        // Now we're just shifting this section up to follow immediately
        0xA0, 0x02,         // LDY #$02
        0xB1, 0xF3,         // LDA ($F3),Y
        0x48,               // PHA
        0x88,               // DEY
        0xB1, 0xF3,         // LDA ($F3),Y
        0x48,               // PHA
        0xA5, 0x45,         // LDA $45
        0x4C, 0x80, 0xC4,   // JMP $C480
        // Zero out remaining bytes from this logic
        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
    };
    for (int i = 0; i < loopingCode.size(); ++i)
    {
        myRom->WriteByte(0x3C50B + i, loopingCode[i]);
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x90, %rsp
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x78(%rbp)
movups 0x192d66(%rip), %xmm0   # 0x59b324
movups %xmm0, -0x41(%rbp)
movups 0x192d4c(%rip), %xmm0   # 0x59b315
movaps %xmm0, -0x50(%rbp)
leaq -0x50(%rbp), %rax
movq %rax, -0x30(%rbp)
movq $0x1f, -0x28(%rbp)
leaq -0x51(%rbp), %rdi
movq %rdi, -0x70(%rbp)
callq 0x404e70
movq -0x70(%rbp), %rcx
movq -0x30(%rbp), %rsi
movq -0x28(%rbp), %rdx
leaq -0x20(%rbp), %rdi
callq 0x40fb50
jmp 0x408601
leaq -0x51(%rbp), %rdi
callq 0x404fb0
movl $0x0, -0x68(%rbp)
movslq -0x68(%rbp), %rax
movq %rax, -0x80(%rbp)
leaq -0x20(%rbp), %rdi
callq 0x405010
movq %rax, %rcx
movq -0x80(%rbp), %rax
cmpq %rcx, %rax
jae 0x4086a8
movq -0x78(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x90(%rbp)
movslq -0x68(%rbp), %rsi
movl %esi, %eax
addl $0x3c50b, %eax          # imm = 0x3C50B
movl %eax, -0x84(%rbp)
leaq -0x20(%rbp), %rdi
callq 0x405030
movq -0x90(%rbp), %rdi
movl -0x84(%rbp), %esi
movzbl (%rax), %edx
callq 0x404c20
jmp 0x40866d
jmp 0x40866f
movl -0x68(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x68(%rbp)
jmp 0x408611
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
leaq -0x51(%rbp), %rdi
callq 0x404fb0
jmp 0x4086ba
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
leaq -0x20(%rbp), %rdi
callq 0x404f50
jmp 0x4086ba
leaq -0x20(%rbp), %rdi
callq 0x404f50
addq $0x90, %rsp
popq %rbp
retq
movq -0x60(%rbp), %rdi
callq 0x4c9ba0
nopw %cs:(%rax,%rax)
// File: Thilotilo[P]DoaERando/Randomizer.cpp
// Function: DoaERando::Randomizer::GivePartyMaxFoodFromNPC()
void Randomizer::GivePartyMaxFoodFromNPC()
{
    printf("Feeding the armies well...\n");
    // 0xF423F is 999999 in decimal.  These bytes determine the amount of food the NPC gives you.
    // Note that the text still says 1000.  I'll need to change that elsewhere.
    myRom->WriteByte(0x361D7, 0x0F);
    myRom->WriteByte(0x361DB, 0x42);
    myRom->WriteByte(0x361DF, 0x3F);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x10, %rsp
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x10(%rbp)
leaq 0x1929af(%rip), %rdi    # 0x59b15a
movb $0x0, %al
callq 0x4f06e0
movq -0x10(%rbp), %rax
movq (%rax), %rdi
movl $0x361d7, %esi          # imm = 0x361D7
movl $0xf, %edx
callq 0x404c20
movq -0x10(%rbp), %rax
movq (%rax), %rdi
movl $0x361db, %esi          # imm = 0x361DB
movl $0x42, %edx
callq 0x404c20
movq -0x10(%rbp), %rax
movq (%rax), %rdi
movl $0x361df, %esi          # imm = 0x361DF
movl $0x3f, %edx
callq 0x404c20
addq $0x10, %rsp
popq %rbp
retq
nopw (%rax,%rax)
// File: Thilotilo[P]DoaERando/Randomizer.cpp
// Function: DoaERando::Randomizer::ModifyEncounterRate()
void Randomizer::ModifyEncounterRate()
{
    printf("Keeping the enemies away(ish)...\n");
    // Don't encounter enemies on anything that's not mountains (and whatever id 0x05 is)
    myRom->WriteByte(0x3F4D6, 0x04);
    // Make Mountain encounter rate really high (50%)
    myRom->WriteByte(0x3F51C, 0x01);
    myRom->WriteByte(0x3F522, 0x00);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x10, %rsp
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x10(%rbp)
leaq 0x19295b(%rip), %rdi    # 0x59b176
movb $0x0, %al
callq 0x4f06e0
movq -0x10(%rbp), %rax
movq (%rax), %rdi
movl $0x3f4d6, %esi          # imm = 0x3F4D6
movl $0x4, %edx
callq 0x404c20
movq -0x10(%rbp), %rax
movq (%rax), %rdi
movl $0x3f51c, %esi          # imm = 0x3F51C
movl $0x1, %edx
callq 0x404c20
movq -0x10(%rbp), %rax
movq (%rax), %rdi
movl $0x3f522, %esi          # imm = 0x3F522
xorl %edx, %edx
callq 0x404c20
addq $0x10, %rsp
popq %rbp
retq
nopw (%rax,%rax)
// File: Thilotilo[P]DoaERando/Randomizer.cpp
// Function: DoaERando::Randomizer::DisableChapter1LockForSiShui()
void Randomizer::DisableChapter1LockForSiShui()
{
    printf("Opening Si Shui fortress to Liu Bei...\n");
    // Make only chapters below 1 (i.e., none) block entrance to Si Shui
    myRom->WriteByte(0x3642B, 0x01);
    // Don't disable Si Shui battle unless we enter in chapter 0 (i.e., never)
    myRom->WriteByte(0x3643B, 0x00);
    // Don't decrement the Y counter unless we are in a chapter below 1 (i.e., never)
    myRom->WriteByte(0x3BE8B, 0x01);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x10, %rsp
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x10(%rbp)
leaq 0x19290d(%rip), %rdi    # 0x59b198
movb $0x0, %al
callq 0x4f06e0
movq -0x10(%rbp), %rax
movq (%rax), %rdi
movl $0x3642b, %esi          # imm = 0x3642B
movl $0x1, %edx
callq 0x404c20
movq -0x10(%rbp), %rax
movq (%rax), %rdi
movl $0x3643b, %esi          # imm = 0x3643B
xorl %edx, %edx
callq 0x404c20
movq -0x10(%rbp), %rax
movq (%rax), %rdi
movl $0x3be8b, %esi          # imm = 0x3BE8B
movl $0x1, %edx
callq 0x404c20
addq $0x10, %rsp
popq %rbp
retq
nopw (%rax,%rax)
// File: Thilotilo[P]DoaERando/Randomizer.cpp
// Function: DoaERando::Randomizer::IncreaseTacticGains()
void Randomizer::IncreaseTacticGains()
{
    // Since we aren't gaining TP on every level now, let's up our TP gain
    // Here, we're going to randomize each 1/16 chance value to be between
    // 5-10, with the last slot being 15-20.
    const int TACTIC_GAINS_OFFSET = 0x3B666;
    for (int i = 0; i < 15; ++i)
    {
        BYTE tacticGain = myRNG.GetRandomByte(5, 10);
        myRom->WriteByte(TACTIC_GAINS_OFFSET + i, tacticGain);
        printf("Increasing tactic gain 0x%X to %d\n", i, tacticGain);
    }
    BYTE tacticGain = myRNG.GetRandomByte(15, 20);
    myRom->WriteByte(TACTIC_GAINS_OFFSET + 15, tacticGain);
    printf("Increasing tactic gain 0x%X to %d\n", 15, tacticGain);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x20(%rbp)
movl $0x3b666, -0xc(%rbp)    # imm = 0x3B666
movl $0x0, -0x10(%rbp)
cmpl $0xf, -0x10(%rbp)
jge 0x408a3d
movq -0x20(%rbp), %rdi
addq $0x8, %rdi
movl $0x5, %esi
movl $0xa, %edx
callq 0x41db50
movb %al, %cl
movq -0x20(%rbp), %rax
movb %cl, -0x11(%rbp)
movq (%rax), %rdi
movl -0x10(%rbp), %esi
addl $0x3b666, %esi          # imm = 0x3B666
movzbl -0x11(%rbp), %edx
callq 0x404c20
movl -0x10(%rbp), %esi
movzbl -0x11(%rbp), %edx
leaq 0x192795(%rip), %rdi    # 0x59b1c0
movb $0x0, %al
callq 0x4f06e0
movl -0x10(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x10(%rbp)
jmp 0x4089e2
movq -0x20(%rbp), %rdi
addq $0x8, %rdi
movl $0xf, %esi
movl $0x14, %edx
callq 0x41db50
movb %al, %cl
movq -0x20(%rbp), %rax
movb %cl, -0x12(%rbp)
movq (%rax), %rdi
movl $0x3b675, %esi          # imm = 0x3B675
movzbl -0x12(%rbp), %edx
callq 0x404c20
movzbl -0x12(%rbp), %edx
leaq 0x192747(%rip), %rdi    # 0x59b1c0
movl $0xf, %esi
movb $0x0, %al
callq 0x4f06e0
addq $0x20, %rsp
popq %rbp
retq
nopl (%rax,%rax)
// File: Thilotilo[P]DoaERando/Randomizer.cpp
// Function: DoaERando::Randomizer::DoubleXpGain()
void Randomizer::DoubleXpGain()
{
    const int XP_MULTIPLIER_OFFSET = 0x39a28;
    for (int i = 0; i < 8; ++i)
    {
        BYTE currentXpBoost = myRom->ReadByte(XP_MULTIPLIER_OFFSET + i);
        BYTE increasedXpBoost = currentXpBoost * 2;
        myRom->WriteByte(XP_MULTIPLIER_OFFSET + i, increasedXpBoost);
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x20(%rbp)
movl $0x39a28, -0xc(%rbp)    # imm = 0x39A28
movl $0x0, -0x10(%rbp)
cmpl $0x8, -0x10(%rbp)
jge 0x408aff
movq -0x20(%rbp), %rax
movq (%rax), %rdi
movl -0x10(%rbp), %esi
addl $0x39a28, %esi          # imm = 0x39A28
callq 0x404bb0
movb %al, %cl
movq -0x20(%rbp), %rax
movb %cl, -0x11(%rbp)
movzbl -0x11(%rbp), %ecx
shll %ecx
movb %cl, -0x12(%rbp)
movq (%rax), %rdi
movl -0x10(%rbp), %esi
addl $0x39a28, %esi          # imm = 0x39A28
movzbl -0x12(%rbp), %edx
callq 0x404c20
movl -0x10(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x10(%rbp)
jmp 0x408ab2
addq $0x20, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)
// File: Thilotilo[P]DoaERando/Randomizer.cpp
// Function: DoaERando::Randomizer::MakeAllGeneralsRecruitableAndEncounterable()
void Randomizer::MakeAllGeneralsRecruitableAndEncounterable()
{
    myGenerals.SetAllGeneralsEncounterable();
    myGenerals.SetAllGeneralsRecruitable();

    //Allow any General that appears in a town and isn't already on your party to show up.
    myRom->WriteByte(0x3E8F0, 0xC0); // Compare general config with 0xC0 rather than 0x80
    myRom->WriteByte(0x3E8F1, 0xD0); // Branch if != 0xC0 rather than branching if == 0x80 
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x10, %rsp
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rdi
movq %rdi, -0x10(%rbp)
addq $0x9d0, %rdi            # imm = 0x9D0
callq 0x415cf0
movq -0x10(%rbp), %rdi
addq $0x9d0, %rdi            # imm = 0x9D0
callq 0x415d60
movq -0x10(%rbp), %rax
movq (%rax), %rdi
movl $0x3e8f0, %esi          # imm = 0x3E8F0
movl $0xc0, %edx
callq 0x404c20
movq -0x10(%rbp), %rax
movq (%rax), %rdi
movl $0x3e8f1, %esi          # imm = 0x3E8F1
movl $0xd0, %edx
callq 0x404c20
addq $0x10, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)
// File: Thilotilo[P]DoaERando/Randomizer.cpp
// Function: DoaERando::Randomizer::RandomizeTacticLevels()
void Randomizer::RandomizeTacticLevels()
{
    const int TACTIC_LEVEL_OFFSET = 0x3b880;
    printf("Old Tactic Levels:\n");
    for(int i = 1; i < 50; ++i)
    {
        printf("  Level %d: Tactic id 0x%X\n", i + 1, myRom->ReadByte(TACTIC_LEVEL_OFFSET + i));
    }
    for (int i = 0; i < 10000; ++i)
    {
        int levelSlot1 = myRNG.GetRandomByte(1, 49);
        int levelSlot2 = myRNG.GetRandomByte(1, 49);

        myRom->SwapBytes(TACTIC_LEVEL_OFFSET + levelSlot1, TACTIC_LEVEL_OFFSET + levelSlot2);
    }

    printf("New Tactic Levels:\n");
    for(int i = 1; i < 50; ++i)
    {
        printf("  Level %d: Tactic id 0x%X\n", i + 1, myRom->ReadByte(TACTIC_LEVEL_OFFSET + i));
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x28(%rbp)
movl $0x3b880, -0xc(%rbp)    # imm = 0x3B880
leaq 0x192641(%rip), %rdi    # 0x59b1e3
movb $0x0, %al
callq 0x4f06e0
movl $0x1, -0x10(%rbp)
cmpl $0x32, -0x10(%rbp)
jge 0x408bf3
movq -0x28(%rbp), %rax
movl -0x10(%rbp), %ecx
addl $0x1, %ecx
movl %ecx, -0x2c(%rbp)
movq (%rax), %rdi
movl -0x10(%rbp), %esi
addl $0x3b880, %esi          # imm = 0x3B880
callq 0x404bb0
movl -0x2c(%rbp), %esi
movzbl %al, %edx
leaq 0x192616(%rip), %rdi    # 0x59b1f7
movb $0x0, %al
callq 0x4f06e0
movl -0x10(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x10(%rbp)
jmp 0x408bb0
movl $0x0, -0x14(%rbp)
cmpl $0x2710, -0x14(%rbp)    # imm = 0x2710
jge 0x408c68
movq -0x28(%rbp), %rdi
addq $0x8, %rdi
movl $0x1, %esi
movl $0x31, %edx
callq 0x41db50
movq -0x28(%rbp), %rdi
movzbl %al, %eax
movl %eax, -0x18(%rbp)
addq $0x8, %rdi
movl $0x1, %esi
movl $0x31, %edx
callq 0x41db50
movb %al, %cl
movq -0x28(%rbp), %rax
movzbl %cl, %ecx
movl %ecx, -0x1c(%rbp)
movq (%rax), %rdi
movl -0x18(%rbp), %esi
addl $0x3b880, %esi          # imm = 0x3B880
movl -0x1c(%rbp), %edx
addl $0x3b880, %edx          # imm = 0x3B880
callq 0x404cb0
movl -0x14(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x14(%rbp)
jmp 0x408bfa
leaq 0x1925a4(%rip), %rdi    # 0x59b213
movb $0x0, %al
callq 0x4f06e0
movl $0x1, -0x20(%rbp)
cmpl $0x32, -0x20(%rbp)
jge 0x408cc0
movq -0x28(%rbp), %rax
movl -0x20(%rbp), %ecx
addl $0x1, %ecx
movl %ecx, -0x30(%rbp)
movq (%rax), %rdi
movl -0x20(%rbp), %esi
addl $0x3b880, %esi          # imm = 0x3B880
callq 0x404bb0
movl -0x30(%rbp), %esi
movzbl %al, %edx
leaq 0x192549(%rip), %rdi    # 0x59b1f7
movb $0x0, %al
callq 0x4f06e0
movl -0x20(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x20(%rbp)
jmp 0x408c7d
addq $0x30, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)
// File: Thilotilo[P]DoaERando/Randomizer.cpp
// Function: DoaERando::Randomizer::RandomizeBattles()
void Randomizer::RandomizeBattles()
{
    myBattleRandomizer.RandomizeZone1(myGenerals, myRNG);
    myBattleRandomizer.RandomizeZone2(myGenerals, myRNG);
    myBattleRandomizer.RandomizeZone3(myGenerals, myRNG);
    myBattleRandomizer.RandomizeZone4(myGenerals, myRNG);
    myBattleRandomizer.RandomizeZone5(myGenerals, myRNG);
    myBattleRandomizer.RandomizeZone6(myGenerals, myRNG);
    myBattleRandomizer.RandomizeZone7(myGenerals, myRNG);
    myBattleRandomizer.RandomizeZone8(myGenerals, myRNG);
    myBattleRandomizer.UpdateBattles(*myRom);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x10, %rsp
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rdx
movq %rdx, -0x10(%rbp)
movq %rdx, %rdi
addq $0xa20, %rdi            # imm = 0xA20
movq %rdx, %rsi
addq $0x9d0, %rsi            # imm = 0x9D0
addq $0x8, %rdx
callq 0x418510
movq -0x10(%rbp), %rdx
movq %rdx, %rdi
addq $0xa20, %rdi            # imm = 0xA20
movq %rdx, %rsi
addq $0x9d0, %rsi            # imm = 0x9D0
addq $0x8, %rdx
callq 0x418a30
movq -0x10(%rbp), %rdx
movq %rdx, %rdi
addq $0xa20, %rdi            # imm = 0xA20
movq %rdx, %rsi
addq $0x9d0, %rsi            # imm = 0x9D0
addq $0x8, %rdx
callq 0x418d30
movq -0x10(%rbp), %rdx
movq %rdx, %rdi
addq $0xa20, %rdi            # imm = 0xA20
movq %rdx, %rsi
addq $0x9d0, %rsi            # imm = 0x9D0
addq $0x8, %rdx
callq 0x419000
movq -0x10(%rbp), %rdx
movq %rdx, %rdi
addq $0xa20, %rdi            # imm = 0xA20
movq %rdx, %rsi
addq $0x9d0, %rsi            # imm = 0x9D0
addq $0x8, %rdx
callq 0x419380
movq -0x10(%rbp), %rdx
movq %rdx, %rdi
addq $0xa20, %rdi            # imm = 0xA20
movq %rdx, %rsi
addq $0x9d0, %rsi            # imm = 0x9D0
addq $0x8, %rdx
callq 0x419660
movq -0x10(%rbp), %rdx
movq %rdx, %rdi
addq $0xa20, %rdi            # imm = 0xA20
movq %rdx, %rsi
addq $0x9d0, %rsi            # imm = 0x9D0
addq $0x8, %rdx
callq 0x419950
movq -0x10(%rbp), %rdx
movq %rdx, %rdi
addq $0xa20, %rdi            # imm = 0xA20
movq %rdx, %rsi
addq $0x9d0, %rsi            # imm = 0x9D0
addq $0x8, %rdx
callq 0x419d70
movq -0x10(%rbp), %rax
movq %rax, %rdi
addq $0xa20, %rdi            # imm = 0xA20
movq (%rax), %rsi
callq 0x41bd10
addq $0x10, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)
// File: Thilotilo[P]DoaERando/Randomizer.cpp
// Function: DoaERando::Randomizer::MoveGuiYangBattle()
void Randomizer::MoveGuiYangBattle()
{
    // First, set the flags to clear the throne room battle
    // We only want to set two bits, so let's read and then set those 2 bits only
    auto flags = myRom->ReadByte(0x34761);
    // bit 1 = Gui Yang battle started
    // bit 2 = Gui Yang battle won
    flags |= 0x06;
    myRom->WriteByte(0x34761, flags);

    // Next, we're going to move the Gui Yang battle to the castle entrance
    myRom->WriteByte(0x30C2B, 0x09); // Vertical offset in block
    myRom->WriteByte(0x30C83, 0x12); // Vertical block
    myRom->WriteByte(0x30CDB, 0x03); // Horizontal offset in block
    myRom->WriteByte(0x30D33, 0x0E); // Horizontal block
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x18(%rbp)
movq (%rax), %rdi
movl $0x34761, %esi          # imm = 0x34761
callq 0x404bb0
movb %al, %cl
movq -0x18(%rbp), %rax
movb %cl, -0x9(%rbp)
movzbl -0x9(%rbp), %ecx
orl $0x6, %ecx
movb %cl, -0x9(%rbp)
movq (%rax), %rdi
movl $0x34761, %esi          # imm = 0x34761
movzbl -0x9(%rbp), %edx
callq 0x404c20
movq -0x18(%rbp), %rax
movq (%rax), %rdi
movl $0x30c2b, %esi          # imm = 0x30C2B
movl $0x9, %edx
callq 0x404c20
movq -0x18(%rbp), %rax
movq (%rax), %rdi
movl $0x30c83, %esi          # imm = 0x30C83
movl $0x12, %edx
callq 0x404c20
movq -0x18(%rbp), %rax
movq (%rax), %rdi
movl $0x30cdb, %esi          # imm = 0x30CDB
movl $0x3, %edx
callq 0x404c20
movq -0x18(%rbp), %rax
movq (%rax), %rdi
movl $0x30d33, %esi          # imm = 0x30D33
movl $0xe, %edx
callq 0x404c20
addq $0x20, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)
// File: Thilotilo[P]DoaERando/Randomizer.cpp
// Function: DoaERando::Randomizer::SetGeneralForZone0AndRemove(unsigned char, std::vector<unsigned char, std::allocator<unsigned char>>&)
void Randomizer::SetGeneralForZone0AndRemove(BYTE generalId, std::vector<BYTE>& ids)
{
    myGenerals.SetAndScaleGeneralForZone(generalId, 0, myRNG);
    myGenerals.SetGeneralEncounterable(generalId, false);
    myGenerals.SetGeneralRecruitable(generalId, false);
    PullIdFromVector(generalId, ids);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movb %sil, %al
movq %rdi, -0x8(%rbp)
movb %al, -0x9(%rbp)
movq %rdx, -0x18(%rbp)
movq -0x8(%rbp), %rcx
movq %rcx, -0x20(%rbp)
movq %rcx, %rdi
addq $0x9d0, %rdi            # imm = 0x9D0
movb -0x9(%rbp), %al
addq $0x8, %rcx
xorl %edx, %edx
movzbl %al, %esi
callq 0x415f30
movq -0x20(%rbp), %rdi
addq $0x9d0, %rdi            # imm = 0x9D0
xorl %edx, %edx
movzbl -0x9(%rbp), %esi
callq 0x416050
movq -0x20(%rbp), %rdi
addq $0x9d0, %rdi            # imm = 0x9D0
xorl %edx, %edx
movzbl -0x9(%rbp), %esi
callq 0x4160a0
movb -0x9(%rbp), %al
movq -0x18(%rbp), %rsi
movzbl %al, %edi
callq 0x409810
addq $0x20, %rsp
popq %rbp
retq
nopw (%rax,%rax)
// File: Thilotilo[P]DoaERando/Randomizer.cpp
// Function: DoaERando::Randomizer::ReconfigureLiuKuiTentGeneral()
void Randomizer::ReconfigureLiuKuiTentGeneral()
{
    std::vector<BYTE> tentNPCData {
        // Configure NPC info ->actual NPC ID to be set by the manipulator,
        // So we just set it to 0 for now
        0x13, 0x04, 0x97, 0x1C, 0x19, 0x19, 0x00,
        // Since there's no longer any code to execute, we need to clear
        // those extra 2 bytes too (plus move the original FF)
        0xFF, 0x00, 0x00
    };

    for (int i = 0; i < tentNPCData.size(); ++i)
    {
        myRom->WriteByte(0x31420 + i, tentNPCData[i]);
    }

    // Remove now-unused code for loading the NPC so we can reclaim
    // it for other nefarious purposes.
    const size_t NUM_EVENT_BYTES_TO_CLEAR = 11;
    for (size_t i = 0; i < NUM_EVENT_BYTES_TO_CLEAR; ++i)
    {
        myRom->WriteByte(0x36EE0 + i, 0x00);
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x90, %rsp
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x70(%rbp)
movb $0x13, -0x3a(%rbp)
movb $0x4, -0x39(%rbp)
movb $-0x69, -0x38(%rbp)
movb $0x1c, -0x37(%rbp)
movb $0x19, -0x36(%rbp)
movb $0x19, -0x35(%rbp)
movb $0x0, -0x34(%rbp)
movb $-0x1, -0x33(%rbp)
movb $0x0, -0x32(%rbp)
movb $0x0, -0x31(%rbp)
leaq -0x3a(%rbp), %rax
movq %rax, -0x30(%rbp)
movq $0xa, -0x28(%rbp)
leaq -0x3b(%rbp), %rdi
movq %rdi, -0x68(%rbp)
callq 0x404e70
movq -0x68(%rbp), %rcx
movq -0x30(%rbp), %rsi
movq -0x28(%rbp), %rdx
leaq -0x20(%rbp), %rdi
callq 0x40fb50
jmp 0x409ae3
leaq -0x3b(%rbp), %rdi
callq 0x404fb0
movl $0x0, -0x50(%rbp)
movslq -0x50(%rbp), %rax
movq %rax, -0x78(%rbp)
leaq -0x20(%rbp), %rdi
callq 0x405010
movq %rax, %rcx
movq -0x78(%rbp), %rax
cmpq %rcx, %rax
jae 0x409b84
movq -0x70(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x88(%rbp)
movslq -0x50(%rbp), %rsi
movl %esi, %eax
addl $0x31420, %eax          # imm = 0x31420
movl %eax, -0x7c(%rbp)
leaq -0x20(%rbp), %rdi
callq 0x405030
movq -0x88(%rbp), %rdi
movl -0x7c(%rbp), %esi
movzbl (%rax), %edx
callq 0x404c20
jmp 0x409b49
jmp 0x409b4b
movl -0x50(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x50(%rbp)
jmp 0x409af3
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
leaq -0x3b(%rbp), %rdi
callq 0x404fb0
jmp 0x409bd6
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
leaq -0x20(%rbp), %rdi
callq 0x404f50
jmp 0x409bd6
movq $0xb, -0x58(%rbp)
movq $0x0, -0x60(%rbp)
cmpq $0xb, -0x60(%rbp)
jae 0x409bc4
movq -0x70(%rbp), %rax
movq (%rax), %rdi
movl -0x60(%rbp), %esi
addl $0x36ee0, %esi          # imm = 0x36EE0
xorl %edx, %edx
callq 0x404c20
jmp 0x409bb4
jmp 0x409bb6
movq -0x60(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x60(%rbp)
jmp 0x409b94
leaq -0x20(%rbp), %rdi
callq 0x404f50
addq $0x90, %rsp
popq %rbp
retq
movq -0x48(%rbp), %rdi
callq 0x4c9ba0
nop
// File: Thilotilo[P]DoaERando/Randomizer.cpp
// Function: DoaERando::Randomizer::MakeZone0GeneralsUnfirable()
void Randomizer::MakeZone0GeneralsUnfirable()
{
    std::vector<BYTE> newCode {
        // $60AF contains the general id
        0xAC, 0xAF, 0x60,   // LDY $60AF
        0xA9, 0x02,         // LDA #$02
        // E3C8 returns byte A of the general info of the general id in Y
        0x20, 0xC8, 0xE3,   // JSR $E3C8
        0xF0, 0x05,         // BEQ ($94E5) - the "can't fire" response
        0xD0, 0x09,         // BNE ($94EB) - the confirmation dialog
        // Now finish padding the rest of the overwritten code
        0x00, 0x00, 0x00
    };

    for (int i = 0; i < newCode.size(); ++i)
    {
        myRom->WriteByte(0x394E6 + i, newCode[i]);
    }

    // Remove the old unfirable generals list so we can reclaim
    // it for other nefarious purposes.
    const size_t NUM_EVENT_BYTES_TO_CLEAR = 17;
    for (size_t i = 0; i < NUM_EVENT_BYTES_TO_CLEAR; ++i)
    {
        myRom->WriteByte(0x39587 + i, 0x00);
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x90, %rsp
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x70(%rbp)
movb $-0x54, -0x3f(%rbp)
movb $-0x51, -0x3e(%rbp)
movb $0x60, -0x3d(%rbp)
movb $-0x57, -0x3c(%rbp)
movb $0x2, -0x3b(%rbp)
movb $0x20, -0x3a(%rbp)
movb $-0x38, -0x39(%rbp)
movb $-0x1d, -0x38(%rbp)
movb $-0x10, -0x37(%rbp)
movb $0x5, -0x36(%rbp)
movb $-0x30, -0x35(%rbp)
movb $0x9, -0x34(%rbp)
movb $0x0, -0x33(%rbp)
movb $0x0, -0x32(%rbp)
movb $0x0, -0x31(%rbp)
leaq -0x3f(%rbp), %rax
movq %rax, -0x30(%rbp)
movq $0xf, -0x28(%rbp)
leaq -0x40(%rbp), %rdi
movq %rdi, -0x68(%rbp)
callq 0x404e70
movq -0x68(%rbp), %rcx
movq -0x30(%rbp), %rsi
movq -0x28(%rbp), %rdx
leaq -0x20(%rbp), %rdi
callq 0x40fb50
jmp 0x409c67
leaq -0x40(%rbp), %rdi
callq 0x404fb0
movl $0x0, -0x50(%rbp)
movslq -0x50(%rbp), %rax
movq %rax, -0x78(%rbp)
leaq -0x20(%rbp), %rdi
callq 0x405010
movq %rax, %rcx
movq -0x78(%rbp), %rax
cmpq %rcx, %rax
jae 0x409d08
movq -0x70(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x88(%rbp)
movslq -0x50(%rbp), %rsi
movl %esi, %eax
addl $0x394e6, %eax          # imm = 0x394E6
movl %eax, -0x7c(%rbp)
leaq -0x20(%rbp), %rdi
callq 0x405030
movq -0x88(%rbp), %rdi
movl -0x7c(%rbp), %esi
movzbl (%rax), %edx
callq 0x404c20
jmp 0x409ccd
jmp 0x409ccf
movl -0x50(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x50(%rbp)
jmp 0x409c77
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
leaq -0x40(%rbp), %rdi
callq 0x404fb0
jmp 0x409d5a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
leaq -0x20(%rbp), %rdi
callq 0x404f50
jmp 0x409d5a
movq $0x11, -0x58(%rbp)
movq $0x0, -0x60(%rbp)
cmpq $0x11, -0x60(%rbp)
jae 0x409d48
movq -0x70(%rbp), %rax
movq (%rax), %rdi
movl -0x60(%rbp), %esi
addl $0x39587, %esi          # imm = 0x39587
xorl %edx, %edx
callq 0x404c20
jmp 0x409d38
jmp 0x409d3a
movq -0x60(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x60(%rbp)
jmp 0x409d18
leaq -0x20(%rbp), %rdi
callq 0x404f50
addq $0x90, %rsp
popq %rbp
retq
movq -0x48(%rbp), %rdi
callq 0x4c9ba0
nopw %cs:(%rax,%rax)
// File: Thilotilo[P]DoaERando/Randomizer.cpp
// Function: DoaERando::Randomizer::RemoveUneededEntranceTriggerCode()
void Randomizer::RemoveUneededEntranceTriggerCode()
{
    // Tie Men Xia - we don't want to remove NPCs, so the
    // code is unneeded
    // Remove the "code executed" bit
    BYTE execByte = myRom->ReadByte(0x31A2D);
    execByte &= 0xDF; // clear bit 5
    myRom->WriteByte(0x31A2D, execByte);
    // Blank out both the code-to-execute pointer (moving the
    // FF terminator as well) and the actual code
    myRom->WriteByte(0x31A31, 0xFF);
    myRom->WriteByte(0x31A32, 0x00);
    myRom->WriteByte(0x31A33, 0x00);

    const size_t NUM_EVENT_BYTES_TO_CLEAR = 15;
    for (size_t i = 0; i < NUM_EVENT_BYTES_TO_CLEAR; ++i)
    {
        myRom->WriteByte(0x3536E, 0x00);
    }

}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x28(%rbp)
movq (%rax), %rdi
movl $0x31a2d, %esi          # imm = 0x31A2D
callq 0x404bb0
movb %al, %cl
movq -0x28(%rbp), %rax
movb %cl, -0x9(%rbp)
movzbl -0x9(%rbp), %ecx
andl $0xdf, %ecx
movb %cl, -0x9(%rbp)
movq (%rax), %rdi
movl $0x31a2d, %esi          # imm = 0x31A2D
movzbl -0x9(%rbp), %edx
callq 0x404c20
movq -0x28(%rbp), %rax
movq (%rax), %rdi
movl $0x31a31, %esi          # imm = 0x31A31
movl $0xff, %edx
callq 0x404c20
movq -0x28(%rbp), %rax
movq (%rax), %rdi
movl $0x31a32, %esi          # imm = 0x31A32
xorl %edx, %edx
callq 0x404c20
movq -0x28(%rbp), %rax
movq (%rax), %rdi
movl $0x31a33, %esi          # imm = 0x31A33
xorl %edx, %edx
callq 0x404c20
movq $0xf, -0x18(%rbp)
movq $0x0, -0x20(%rbp)
cmpq $0xf, -0x20(%rbp)
jae 0x409e2c
movq -0x28(%rbp), %rax
movq (%rax), %rdi
movl $0x3536e, %esi          # imm = 0x3536E
xorl %edx, %edx
callq 0x404c20
movq -0x20(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x20(%rbp)
jmp 0x409e04
addq $0x30, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)
// File: Thilotilo[P]DoaERando/Randomizer.cpp
// Function: DoaERando::Randomizer::MoveGemswordToSimaHuisHut()
void Randomizer::MoveGemswordToSimaHuisHut()
{
    // Move the actual gemsword
    myRom->WriteByte(0x30A12, 0x01);
    myRom->WriteByte(0x30A52, 0x01);
    myRom->WriteByte(0x30A92, 0x0A);
    myRom->WriteByte(0x30AD2, 0x1E);

    // Remove the gemsword room in Luo Yang
    // (Easier and nicer than removing the discolored tile
    myRom->WriteByte(0x1F6F2, 0x15);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x10, %rsp
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x10(%rbp)
movq (%rax), %rdi
movl $0x30a12, %esi          # imm = 0x30A12
movl $0x1, %edx
callq 0x404c20
movq -0x10(%rbp), %rax
movq (%rax), %rdi
movl $0x30a52, %esi          # imm = 0x30A52
movl $0x1, %edx
callq 0x404c20
movq -0x10(%rbp), %rax
movq (%rax), %rdi
movl $0x30a92, %esi          # imm = 0x30A92
movl $0xa, %edx
callq 0x404c20
movq -0x10(%rbp), %rax
movq (%rax), %rdi
movl $0x30ad2, %esi          # imm = 0x30AD2
movl $0x1e, %edx
callq 0x404c20
movq -0x10(%rbp), %rax
movq (%rax), %rdi
movl $0x1f6f2, %esi          # imm = 0x1F6F2
movl $0x15, %edx
callq 0x404c20
addq $0x10, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)
// File: Thilotilo[P]DoaERando/Randomizer.cpp
// Function: DoaERando::Randomizer::RemoveFinalIntroScreen()
void Randomizer::RemoveFinalIntroScreen()
{
    // This is just a way of freeing bytes from bank 7 in order to
    // put code in.  We free a few hundred bytes this way. We free
    // up bytes in 2 places: the code that calls the screen and
    // the text in that screen.

    const int NUM_BYTES_TO_CLEAR_CODE = 0x1DC58 - 0x1DAF9;
    const int NUM_BYTES_TO_CLEAR_TEXT = 0x1D27A - 0x1D244;

    for (int i = 0; i < NUM_BYTES_TO_CLEAR_CODE; ++i)
    {
        myRom->WriteByte(0x1DAF9, 0x00);
    }

    for (int i = 0; i < NUM_BYTES_TO_CLEAR_TEXT; ++i)
    {
        myRom->WriteByte(0x1D27A, 0x00);
    }

    // Lastly, we have to tell the code to skip over the zeroed code
    // (JMP $926A)
    myRom->WriteByte(0x1D241, 0x4C);
    myRom->WriteByte(0x1D242, 0x6A);
    myRom->WriteByte(0x1D243, 0x92);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x20(%rbp)
movl $0x15f, -0xc(%rbp)      # imm = 0x15F
movl $0x36, -0x10(%rbp)
movl $0x0, -0x14(%rbp)
cmpl $0x15f, -0x14(%rbp)     # imm = 0x15F
jge 0x40b170
movq -0x20(%rbp), %rax
movq (%rax), %rdi
movl $0x1daf9, %esi          # imm = 0x1DAF9
xorl %edx, %edx
callq 0x404c20
movl -0x14(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x14(%rbp)
jmp 0x40b149
movl $0x0, -0x18(%rbp)
cmpl $0x36, -0x18(%rbp)
jge 0x40b19b
movq -0x20(%rbp), %rax
movq (%rax), %rdi
movl $0x1d27a, %esi          # imm = 0x1D27A
xorl %edx, %edx
callq 0x404c20
movl -0x18(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x18(%rbp)
jmp 0x40b177
movq -0x20(%rbp), %rax
movq (%rax), %rdi
movl $0x1d241, %esi          # imm = 0x1D241
movl $0x4c, %edx
callq 0x404c20
movq -0x20(%rbp), %rax
movq (%rax), %rdi
movl $0x1d242, %esi          # imm = 0x1D242
movl $0x6a, %edx
callq 0x404c20
movq -0x20(%rbp), %rax
movq (%rax), %rdi
movl $0x1d243, %esi          # imm = 0x1D243
movl $0x92, %edx
callq 0x404c20
addq $0x20, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)
// File: Thilotilo[P]DoaERando/Randomizer.cpp
// Function: DoaERando::Randomizer::ProtectChapter1Generals()
void Randomizer::ProtectChapter1Generals()
{
    // The Yellow Scarves battles do stuff to Cheng Yuanzhi and Zheng Mao.
    // We want it to not do that.

    // Don't change the flags for generals once all 3 Yellow Scarves locations
    // have been checked.
    myRom->WriteByte(0x3B03D, 0xF0);
    myRom->WriteByte(0x3B03E, 0x06);
    for (int i = 0; i < 6; ++i)
    {
        myRom->WriteByte(0x3B03F + i, 0x00);
    }

    // Don't modify flags for these generals after finishing chapter 1 either
    myRom->WriteByte(0x3632D, 0xFF);
    myRom->WriteByte(0x3632E, 0xFF);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x18(%rbp)
movq (%rax), %rdi
movl $0x3b03d, %esi          # imm = 0x3B03D
movl $0xf0, %edx
callq 0x404c20
movq -0x18(%rbp), %rax
movq (%rax), %rdi
movl $0x3b03e, %esi          # imm = 0x3B03E
movl $0x6, %edx
callq 0x404c20
movl $0x0, -0xc(%rbp)
cmpl $0x6, -0xc(%rbp)
jge 0x40b5eb
movq -0x18(%rbp), %rax
movq (%rax), %rdi
movl -0xc(%rbp), %esi
addl $0x3b03f, %esi          # imm = 0x3B03F
xorl %edx, %edx
callq 0x404c20
movl -0xc(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xc(%rbp)
jmp 0x40b5c3
movq -0x18(%rbp), %rax
movq (%rax), %rdi
movl $0x3632d, %esi          # imm = 0x3632D
movl $0xff, %edx
callq 0x404c20
movq -0x18(%rbp), %rax
movq (%rax), %rdi
movl $0x3632e, %esi          # imm = 0x3632E
movl $0xff, %edx
callq 0x404c20
addq $0x20, %rsp
popq %rbp
retq
nopl (%rax)
// File: Thilotilo[P]DoaERando/Randomizer.cpp
// Function: DoaERando::Randomizer::MakeWarlordsImmuneToAnSha()
void Randomizer::MakeWarlordsImmuneToAnSha()
{
    // Sun Quan, Cao Pi, and Sima Yi are already immune to An Sha
    myRom->WriteByte(0x3BC5F, 0xA8); // Add Liu Bei
    myRom->WriteByte(0x3BC60, 0x70); // Add Cao Cao
    myRom->WriteByte(0x3BC61, 0x56); // Add Sun Ce
    myRom->WriteByte(0x3BC62, 0xAB); // Add Liu Chan
    myRom->WriteByte(0x3BC63, 0xBC); // Add the Lu Bu that takes the gemsword
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x10, %rsp
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x10(%rbp)
movq (%rax), %rdi
movl $0x3bc5f, %esi          # imm = 0x3BC5F
movl $0xa8, %edx
callq 0x404c20
movq -0x10(%rbp), %rax
movq (%rax), %rdi
movl $0x3bc60, %esi          # imm = 0x3BC60
movl $0x70, %edx
callq 0x404c20
movq -0x10(%rbp), %rax
movq (%rax), %rdi
movl $0x3bc61, %esi          # imm = 0x3BC61
movl $0x56, %edx
callq 0x404c20
movq -0x10(%rbp), %rax
movq (%rax), %rdi
movl $0x3bc62, %esi          # imm = 0x3BC62
movl $0xab, %edx
callq 0x404c20
movq -0x10(%rbp), %rax
movq (%rax), %rdi
movl $0x3bc63, %esi          # imm = 0x3BC63
movl $0xbc, %edx
callq 0x404c20
addq $0x10, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)
// File: Thilotilo[P]DoaERando/Randomizer.cpp
// Function: DoaERando::PullLuBuIds(std::vector<unsigned char, std::allocator<unsigned char>>&)
static void PullLuBuIds(vector<BYTE>& ids)
{
    // Remove all 4 Lu Bu bytes.
    PullIdFromVector(LU_BU_GEMSWORD_ID, ids);
    PullIdFromVector(LU_BU_NAN_YANG_ID, ids);
    PullIdFromVector(LU_BU_JI_ZHOU_ID, ids);
    PullIdFromVector(LU_BU_SHU_ID, ids);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x10, %rsp
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rsi
movl $0xbc, %edi
callq 0x409810
movq -0x8(%rbp), %rsi
movl $0xc0, %edi
callq 0x409810
movq -0x8(%rbp), %rsi
movl $0xc4, %edi
callq 0x409810
movq -0x8(%rbp), %rsi
movl $0xb7, %edi
callq 0x409810
addq $0x10, %rsp
popq %rbp
retq
nopw (%rax,%rax)
// File: Thilotilo[P]DoaERando/Randomizer.cpp
// Function: DoaERando::numDigits(int)
static int numDigits(int num)
{
    int digits = 0;
    if (num == 0)
    {
        return 1;
    }
    while (num != 0)
    {
        num = num/10;
        digits++;
    }

    return digits;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
movl %edi, -0x8(%rbp)
movl $0x0, -0xc(%rbp)
cmpl $0x0, -0x8(%rbp)
jne 0x40f94d
movl $0x1, -0x4(%rbp)
jmp 0x40f974
jmp 0x40f94f
cmpl $0x0, -0x8(%rbp)
je 0x40f96e
movl -0x8(%rbp), %eax
movl $0xa, %ecx
cltd
idivl %ecx
movl %eax, -0x8(%rbp)
movl -0xc(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xc(%rbp)
jmp 0x40f94f
movl -0xc(%rbp), %eax
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
popq %rbp
retq
nopl (%rax)
// File: Thilotilo[P]DoaERando/Randomizer.cpp
// Function: DoaERando::appendNumber(std::vector<unsigned char, std::allocator<unsigned char>>&, int)
static void appendNumber(std::vector<BYTE>& v, int num)
{
    int digits = numDigits(num);

    int divisor = 1;
    for (int i = 1; i < digits; ++i)
    {
        divisor *= 10;
    }

    while (divisor > 0)
    {
        v.push_back((num / divisor) % 10);
        divisor /= 10;
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movl -0xc(%rbp), %edi
callq 0x40f930
movl %eax, -0x10(%rbp)
movl $0x1, -0x14(%rbp)
movl $0x1, -0x18(%rbp)
movl -0x18(%rbp), %eax
cmpl -0x10(%rbp), %eax
jge 0x40f9c2
imull $0xa, -0x14(%rbp), %eax
movl %eax, -0x14(%rbp)
movl -0x18(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x18(%rbp)
jmp 0x40f9a8
jmp 0x40f9c4
cmpl $0x0, -0x14(%rbp)
jle 0x40f9fb
movq -0x8(%rbp), %rdi
movl -0xc(%rbp), %eax
cltd
idivl -0x14(%rbp)
movl $0xa, %ecx
cltd
idivl %ecx
movb %dl, %al
movb %al, -0x19(%rbp)
leaq -0x19(%rbp), %rsi
callq 0x40fab0
movl -0x14(%rbp), %eax
movl $0xa, %ecx
cltd
idivl %ecx
movl %eax, -0x14(%rbp)
jmp 0x40f9c4
addq $0x20, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)
nopl (%rax,%rax)
// File: Thilotilo[P]DoaERando/General.cpp
// Function: DoaERando::General::General(int, unsigned char, DoaERando::ROM&)
General::General(int address, BYTE id, ROM& rom)
    : address(address)
    , id(id)
    , count(1)
    , encounterable(IsEncounterable(id, rom))
    , recruitable(IsRecruitable(id, rom))
{
    strength = rom.ReadByte(address + STRENGTH_OFFSET);
    intelligence = rom.ReadByte(address + INTELLIGENCE_OFFSET);
    zone = rom.ReadByte(address + ZONE_OFFSET);
    weaponId = rom.ReadByte(address + WEAPON_OFFSET) & WEAPON_BITMASK;
    enemyDefenseId = rom.ReadByte(address + ENEMY_DEFENSE_OFFSET);
    enemySoldierExponent = rom.ReadByte(address + ENEMY_SOLDIERS_OFFSET);
    allySoldierExponent = rom.ReadByte(address + ALLY_SOLDIERS_OFFSET);
    enemyMaxTacticLevel = rom.ReadByte(address + TACTICS_LEVEL_OFFSET);
    agility = rom.ReadByte(address + AGILITY_OFFSET);
    ReadName(rom);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movb %dl, %al
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movb %al, -0xd(%rbp)
movq %rcx, -0x18(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x20(%rbp)
movl -0xc(%rbp), %ecx
movl %ecx, (%rax)
movb -0xd(%rbp), %cl
movb %cl, 0x4(%rax)
movb $0x1, 0x5(%rax)
movb -0xd(%rbp), %al
movq -0x18(%rbp), %rsi
movzbl %al, %edi
callq 0x4147c0
movb %al, %cl
movq -0x20(%rbp), %rax
andb $0x1, %cl
movb %cl, 0x23(%rax)
movb -0xd(%rbp), %al
movq -0x18(%rbp), %rsi
movzbl %al, %edi
callq 0x414830
movb %al, %cl
movq -0x20(%rbp), %rax
andb $0x1, %cl
movb %cl, 0x24(%rax)
movq -0x18(%rbp), %rdi
movl -0xc(%rbp), %esi
addl $0x0, %esi
callq 0x404bb0
movb %al, %cl
movq -0x20(%rbp), %rax
movb %cl, 0x6(%rax)
movq -0x18(%rbp), %rdi
movl -0xc(%rbp), %esi
addl $0x1, %esi
callq 0x404bb0
movb %al, %cl
movq -0x20(%rbp), %rax
movb %cl, 0x7(%rax)
movq -0x18(%rbp), %rdi
movl -0xc(%rbp), %esi
addl $0x2, %esi
callq 0x404bb0
movb %al, %cl
movq -0x20(%rbp), %rax
movb %cl, 0x8(%rax)
movq -0x18(%rbp), %rdi
movl -0xc(%rbp), %esi
addl $0x4, %esi
callq 0x404bb0
movb %al, %cl
movq -0x20(%rbp), %rax
movzbl %cl, %ecx
andl $0x1f, %ecx
movb %cl, 0x9(%rax)
movq -0x18(%rbp), %rdi
movl -0xc(%rbp), %esi
addl $0x5, %esi
callq 0x404bb0
movb %al, %cl
movq -0x20(%rbp), %rax
movb %cl, 0xa(%rax)
movq -0x18(%rbp), %rdi
movl -0xc(%rbp), %esi
addl $0x6, %esi
callq 0x404bb0
movb %al, %cl
movq -0x20(%rbp), %rax
movb %cl, 0xb(%rax)
movq -0x18(%rbp), %rdi
movl -0xc(%rbp), %esi
addl $0x7, %esi
callq 0x404bb0
movb %al, %cl
movq -0x20(%rbp), %rax
movb %cl, 0xc(%rax)
movq -0x18(%rbp), %rdi
movl -0xc(%rbp), %esi
addl $0x8, %esi
callq 0x404bb0
movb %al, %cl
movq -0x20(%rbp), %rax
movb %cl, 0xd(%rax)
movq -0x18(%rbp), %rdi
movl -0xc(%rbp), %esi
addl $0x9, %esi
callq 0x404bb0
movq -0x20(%rbp), %rdi
movb %al, 0xe(%rdi)
movq -0x18(%rbp), %rsi
callq 0x4148a0
addq $0x20, %rsp
popq %rbp
retq
// File: Thilotilo[P]DoaERando/General.cpp
// Function: DoaERando::General::ReadName(DoaERando::ROM&)
void General::ReadName(ROM& rom)
{
    const int NAME_OFFSET = 20;
    int nameOffset = 0;
    while (rom.ReadByte(address + nameOffset + NAME_OFFSET) != 0xFF && nameOffset < 19)
    {
        char character = rom.ReadByte(address + nameOffset + NAME_OFFSET) + 'A' - 0x10;
        switch(rom.ReadByte(address + nameOffset + NAME_OFFSET))
        {
            case 0x2D:
                character = 'r';
                break;
            case 0x2F:
                character = 't';
                break;
            case 0x64:
                character = 'u';
                break;
            case 0x0A:
                character = ' ';
                break;
            default:
                break;
        }

        name[nameOffset++] = character;
    }
    name[nameOffset] = 0x00;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x28(%rbp)
movl $0x14, -0x14(%rbp)
movl $0x0, -0x18(%rbp)
movq -0x28(%rbp), %rax
movq -0x10(%rbp), %rdi
movl (%rax), %esi
addl -0x18(%rbp), %esi
addl $0x14, %esi
callq 0x404bb0
movzbl %al, %ecx
xorl %eax, %eax
cmpl $0xff, %ecx
movb %al, -0x29(%rbp)
je 0x4148f5
cmpl $0x13, -0x18(%rbp)
setl %al
movb %al, -0x29(%rbp)
movb -0x29(%rbp), %al
testb $0x1, %al
jne 0x414901
jmp 0x41499f
movq -0x28(%rbp), %rax
movq -0x10(%rbp), %rdi
movl (%rax), %edx
movl -0x18(%rbp), %eax
movl %eax, %ecx
movl %edx, %eax
leal 0x14(%rax,%rcx), %esi
callq 0x404bb0
movb %al, %cl
movq -0x28(%rbp), %rax
addb $0x31, %cl
movb %cl, -0x19(%rbp)
movq -0x10(%rbp), %rdi
movl (%rax), %edx
movl -0x18(%rbp), %eax
movl %eax, %ecx
movl %edx, %eax
leal 0x14(%rax,%rcx), %esi
callq 0x404bb0
movzbl %al, %ecx
movl %ecx, -0x30(%rbp)
subb $0xa, %al
je 0x414979
jmp 0x414949
movl -0x30(%rbp), %eax
subl $0x2d, %eax
je 0x414967
jmp 0x414953
movl -0x30(%rbp), %eax
subl $0x2f, %eax
je 0x41496d
jmp 0x41495d
movl -0x30(%rbp), %eax
subl $0x64, %eax
je 0x414973
jmp 0x41497f
movb $0x72, -0x19(%rbp)
jmp 0x414981
movb $0x74, -0x19(%rbp)
jmp 0x414981
movb $0x75, -0x19(%rbp)
jmp 0x414981
movb $0x20, -0x19(%rbp)
jmp 0x414981
jmp 0x414981
movq -0x28(%rbp), %rax
movb -0x19(%rbp), %dl
movl -0x18(%rbp), %ecx
movl %ecx, %esi
addl $0x1, %esi
movl %esi, -0x18(%rbp)
movslq %ecx, %rcx
movb %dl, 0xf(%rax,%rcx)
jmp 0x4148c6
movq -0x28(%rbp), %rax
movslq -0x18(%rbp), %rcx
movb $0x0, 0xf(%rax,%rcx)
addq $0x30, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)
// File: Thilotilo[P]DoaERando/General.cpp
// Function: DoaERando::General::WriteEncounterableBit(unsigned char, bool, DoaERando::ROM&)
void General::WriteEncounterableBit(BYTE id, bool isEncounterable, ROM& rom)
{
    const int ENCOUNTERABLE_OFFSET = 0x35722;
    const BYTE bitmask = 1 << (7 - (id % 8));
    BYTE currentByte = rom.ReadByte(ENCOUNTERABLE_OFFSET + (id / 8));
    BYTE newByte;
    if (isEncounterable)
    {
        newByte = currentByte | bitmask;
    }
    else
    {
        newByte = currentByte & (~bitmask);
    }

    rom.WriteByte(ENCOUNTERABLE_OFFSET + (id / 8), newByte);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movb %sil, %al
movb %dil, %cl
movb %cl, -0x1(%rbp)
andb $0x1, %al
movb %al, -0x2(%rbp)
movq %rdx, -0x10(%rbp)
movl $0x35722, -0x14(%rbp)   # imm = 0x35722
movzbl -0x1(%rbp), %eax
movl $0x8, %ecx
cltd
idivl %ecx
movl $0x7, %ecx
subl %edx, %ecx
movl $0x1, %eax
shll %cl, %eax
movb %al, -0x15(%rbp)
movq -0x10(%rbp), %rdi
movzbl -0x1(%rbp), %eax
movl $0x8, %ecx
cltd
idivl %ecx
movl %eax, %esi
addl $0x35722, %esi          # imm = 0x35722
callq 0x404bb0
movb %al, -0x16(%rbp)
testb $0x1, -0x2(%rbp)
je 0x415223
movzbl -0x16(%rbp), %eax
movzbl -0x15(%rbp), %ecx
orl %ecx, %eax
movb %al, -0x17(%rbp)
jmp 0x415233
movzbl -0x16(%rbp), %eax
movzbl -0x15(%rbp), %ecx
xorl $-0x1, %ecx
andl %ecx, %eax
movb %al, -0x17(%rbp)
movq -0x10(%rbp), %rdi
movzbl -0x1(%rbp), %eax
movl $0x8, %ecx
cltd
idivl %ecx
movl %eax, %esi
addl $0x35722, %esi          # imm = 0x35722
movzbl -0x17(%rbp), %edx
callq 0x404c20
addq $0x20, %rsp
popq %rbp
retq
nopw (%rax,%rax)
// File: Thilotilo[P]DoaERando/General.cpp
// Function: DoaERando::General::WriteRecruitableBit(unsigned char, bool, DoaERando::ROM&)
void General::WriteRecruitableBit(BYTE id, bool isRecruitable, ROM& rom)
{
    const int RECRUITABLE_OFFSET = 0x3B153;
    const BYTE bitmask = 1 << (7 - (id % 8));
    BYTE currentByte = rom.ReadByte(RECRUITABLE_OFFSET + (id / 8));
    BYTE newByte;
    if (isRecruitable)
    {
        newByte = currentByte | bitmask;
    }
    else
    {
        newByte = currentByte & (~bitmask);
    }

    rom.WriteByte(RECRUITABLE_OFFSET + (id / 8), newByte);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movb %sil, %al
movb %dil, %cl
movb %cl, -0x1(%rbp)
andb $0x1, %al
movb %al, -0x2(%rbp)
movq %rdx, -0x10(%rbp)
movl $0x3b153, -0x14(%rbp)   # imm = 0x3B153
movzbl -0x1(%rbp), %eax
movl $0x8, %ecx
cltd
idivl %ecx
movl $0x7, %ecx
subl %edx, %ecx
movl $0x1, %eax
shll %cl, %eax
movb %al, -0x15(%rbp)
movq -0x10(%rbp), %rdi
movzbl -0x1(%rbp), %eax
movl $0x8, %ecx
cltd
idivl %ecx
movl %eax, %esi
addl $0x3b153, %esi          # imm = 0x3B153
callq 0x404bb0
movb %al, -0x16(%rbp)
testb $0x1, -0x2(%rbp)
je 0x4152d3
movzbl -0x16(%rbp), %eax
movzbl -0x15(%rbp), %ecx
orl %ecx, %eax
movb %al, -0x17(%rbp)
jmp 0x4152e3
movzbl -0x16(%rbp), %eax
movzbl -0x15(%rbp), %ecx
xorl $-0x1, %ecx
andl %ecx, %eax
movb %al, -0x17(%rbp)
movq -0x10(%rbp), %rdi
movzbl -0x1(%rbp), %eax
movl $0x8, %ecx
cltd
idivl %ecx
movl %eax, %esi
addl $0x3b153, %esi          # imm = 0x3B153
movzbl -0x17(%rbp), %edx
callq 0x404c20
addq $0x20, %rsp
popq %rbp
retq
nopw (%rax,%rax)