// File: Merulo[P]CompilerJFTT/src/Register/RegisterBlock.cpp
// Function: RegisterBlock::generateNumber(unsigned long long&, unsigned long long, Register&)
std::vector<Line> RegisterBlock::generateNumber(unsigned long long& firstNumber, unsigned long long second, Register& usedRegister)
{
    if (firstNumber > second)
    {
        if (firstNumber - second < 15)
        {
            std::vector<Line> lines;
            while(firstNumber > second)
            {
                lines.push_back({"DEC", "A"});
                firstNumber--;
            }
            return lines;
        }
        else
        {         
            return generateNumberShift(firstNumber - second, usedRegister, "SUB");     
        }
    }
    else if (firstNumber < second )
    {
        if (second - firstNumber < 15)
        {
            std::vector<Line> lines;
            while( firstNumber < second)
            {
                lines.push_back({"INC", "A"});
                firstNumber++;
            }
            return lines;
        }
        else
        {         
            return generateNumberShift(second - firstNumber, usedRegister, "ADD"); 
        }
    }
    return {{}};
}

// Assembly:
subq $0x398, %rsp            # imm = 0x398
movq %rdi, 0xa8(%rsp)
movq %rdi, %rax
movq %rax, 0xb0(%rsp)
movq %rdi, 0x390(%rsp)
movq %rsi, 0x388(%rsp)
movq %rdx, 0x380(%rsp)
movq %rcx, 0x378(%rsp)
movq %r8, 0x370(%rsp)
movq 0x388(%rsp), %rax
movq %rax, 0xb8(%rsp)
movq 0x380(%rsp), %rax
movq (%rax), %rax
cmpq 0x378(%rsp), %rax
jbe 0x8c21
movq 0x380(%rsp), %rax
movq (%rax), %rax
subq 0x378(%rsp), %rax
cmpq $0xf, %rax
jae 0x8b2f
movq 0xa8(%rsp), %rdi
movb $0x0, 0x36f(%rsp)
callq 0xda20
movq 0x380(%rsp), %rax
movq (%rax), %rax
cmpq 0x378(%rsp), %rax
jbe 0x8b0b
leaq 0x2df(%rsp), %rdi
movq %rdi, 0xa0(%rsp)
callq 0x4600
movq 0xa0(%rsp), %rdx
leaq 0x487c8(%rip), %rsi     # 0x510d2
leaq 0x2e0(%rsp), %rdi
callq 0x4f10
jmp 0x8919
leaq 0x2a7(%rsp), %rdi
movq %rdi, 0x98(%rsp)
callq 0x4600
movq 0x98(%rsp), %rdx
leaq 0x4878f(%rip), %rsi     # 0x510cc
leaq 0x2a8(%rsp), %rdi
callq 0x4f10
jmp 0x894c
leaq 0x27f(%rsp), %rdi
movq %rdi, 0x90(%rsp)
callq 0x4600
movq 0x90(%rsp), %rdx
leaq 0x487ab(%rip), %rsi     # 0x5111b
leaq 0x280(%rsp), %rdi
callq 0x4f10
jmp 0x897f
leaq 0x300(%rsp), %rdi
leaq 0x2e0(%rsp), %rsi
leaq 0x2a8(%rsp), %rdx
leaq 0x280(%rsp), %rcx
callq 0xd3b0
jmp 0x89a6
movq 0xa8(%rsp), %rdi
leaq 0x300(%rsp), %rsi
callq 0xd380
jmp 0x89bd
leaq 0x300(%rsp), %rdi
callq 0xd490
leaq 0x280(%rsp), %rdi
callq 0x46e8
leaq 0x27f(%rsp), %rdi
callq 0x43b0
leaq 0x2a8(%rsp), %rdi
callq 0x46e8
leaq 0x2a7(%rsp), %rdi
callq 0x43b0
leaq 0x2e0(%rsp), %rdi
callq 0x46e8
leaq 0x2df(%rsp), %rdi
callq 0x43b0
movq 0x380(%rsp), %rax
movq (%rax), %rcx
addq $-0x1, %rcx
movq %rcx, (%rax)
jmp 0x88cd
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x2d0(%rsp)
movl %eax, 0x2cc(%rsp)
jmp 0x8aec
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x2d0(%rsp)
movl %eax, 0x2cc(%rsp)
jmp 0x8ad2
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x2d0(%rsp)
movl %eax, 0x2cc(%rsp)
jmp 0x8ab8
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x2d0(%rsp)
movl %eax, 0x2cc(%rsp)
jmp 0x8aab
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x2d0(%rsp)
movl %eax, 0x2cc(%rsp)
leaq 0x300(%rsp), %rdi
callq 0xd490
leaq 0x280(%rsp), %rdi
callq 0x46e8
leaq 0x27f(%rsp), %rdi
callq 0x43b0
leaq 0x2a8(%rsp), %rdi
callq 0x46e8
leaq 0x2a7(%rsp), %rdi
callq 0x43b0
leaq 0x2e0(%rsp), %rdi
callq 0x46e8
leaq 0x2df(%rsp), %rdi
callq 0x43b0
movq 0xa8(%rsp), %rdi
callq 0xd550
jmp 0x9124
movb $0x1, 0x36f(%rsp)
testb $0x1, 0x36f(%rsp)
jne 0x8b2a
movq 0xa8(%rsp), %rdi
callq 0xd550
jmp 0x9114
movq 0x380(%rsp), %rax
movq (%rax), %rax
movq 0x378(%rsp), %rcx
subq %rcx, %rax
movq %rax, 0x78(%rsp)
movq 0x370(%rsp), %rax
movq %rax, 0x80(%rsp)
leaq 0x257(%rsp), %rdi
movq %rdi, 0x88(%rsp)
callq 0x4600
movq 0x88(%rsp), %rdx
leaq 0x48550(%rip), %rsi     # 0x510ce
leaq 0x258(%rsp), %rdi
callq 0x4f10
jmp 0x8b8d
movq 0x80(%rsp), %rcx
movq 0x78(%rsp), %rdx
movq 0xb8(%rsp), %rsi
movq 0xa8(%rsp), %rdi
leaq 0x258(%rsp), %r8
callq 0x9140
jmp 0x8bb9
leaq 0x258(%rsp), %rdi
callq 0x46e8
leaq 0x257(%rsp), %rdi
callq 0x43b0
jmp 0x9114
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x2d0(%rsp)
movl %eax, 0x2cc(%rsp)
jmp 0x8c0f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x2d0(%rsp)
movl %eax, 0x2cc(%rsp)
leaq 0x258(%rsp), %rdi
callq 0x46e8
leaq 0x257(%rsp), %rdi
callq 0x43b0
jmp 0x9124
movq 0x380(%rsp), %rax
movq (%rax), %rax
cmpq 0x378(%rsp), %rax
jae 0x8fa2
movq 0x378(%rsp), %rax
movq 0x380(%rsp), %rcx
subq (%rcx), %rax
cmpq $0xf, %rax
jae 0x8ebc
movq 0xa8(%rsp), %rdi
movb $0x0, 0x256(%rsp)
callq 0xda20
movq 0x380(%rsp), %rax
movq (%rax), %rax
cmpq 0x378(%rsp), %rax
jae 0x8e98
leaq 0x1c7(%rsp), %rdi
movq %rdi, 0x70(%rsp)
callq 0x4600
movq 0x70(%rsp), %rdx
leaq 0x48433(%rip), %rsi     # 0x510d6
leaq 0x1c8(%rsp), %rdi
callq 0x4f10
jmp 0x8cb2
leaq 0x19f(%rsp), %rdi
movq %rdi, 0x68(%rsp)
callq 0x4600
movq 0x68(%rsp), %rdx
leaq 0x483fc(%rip), %rsi     # 0x510cc
leaq 0x1a0(%rsp), %rdi
callq 0x4f10
jmp 0x8cdf
leaq 0x177(%rsp), %rdi
movq %rdi, 0x60(%rsp)
callq 0x4600
movq 0x60(%rsp), %rdx
leaq 0x4841e(%rip), %rsi     # 0x5111b
leaq 0x178(%rsp), %rdi
callq 0x4f10
jmp 0x8d0c
leaq 0x1e8(%rsp), %rdi
leaq 0x1c8(%rsp), %rsi
leaq 0x1a0(%rsp), %rdx
leaq 0x178(%rsp), %rcx
callq 0xd3b0
jmp 0x8d33
movq 0xa8(%rsp), %rdi
leaq 0x1e8(%rsp), %rsi
callq 0xd380
jmp 0x8d4a
leaq 0x1e8(%rsp), %rdi
callq 0xd490
leaq 0x178(%rsp), %rdi
callq 0x46e8
leaq 0x177(%rsp), %rdi
callq 0x43b0
leaq 0x1a0(%rsp), %rdi
callq 0x46e8
leaq 0x19f(%rsp), %rdi
callq 0x43b0
leaq 0x1c8(%rsp), %rdi
callq 0x46e8
leaq 0x1c7(%rsp), %rdi
callq 0x43b0
movq 0x380(%rsp), %rax
movq (%rax), %rcx
addq $0x1, %rcx
movq %rcx, (%rax)
jmp 0x8c6c
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x2d0(%rsp)
movl %eax, 0x2cc(%rsp)
jmp 0x8e79
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x2d0(%rsp)
movl %eax, 0x2cc(%rsp)
jmp 0x8e5f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x2d0(%rsp)
movl %eax, 0x2cc(%rsp)
jmp 0x8e45
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x2d0(%rsp)
movl %eax, 0x2cc(%rsp)
jmp 0x8e38
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x2d0(%rsp)
movl %eax, 0x2cc(%rsp)
leaq 0x1e8(%rsp), %rdi
callq 0xd490
leaq 0x178(%rsp), %rdi
callq 0x46e8
leaq 0x177(%rsp), %rdi
callq 0x43b0
leaq 0x1a0(%rsp), %rdi
callq 0x46e8
leaq 0x19f(%rsp), %rdi
callq 0x43b0
leaq 0x1c8(%rsp), %rdi
callq 0x46e8
leaq 0x1c7(%rsp), %rdi
callq 0x43b0
movq 0xa8(%rsp), %rdi
callq 0xd550
jmp 0x9124
movb $0x1, 0x256(%rsp)
testb $0x1, 0x256(%rsp)
jne 0x8eb7
movq 0xa8(%rsp), %rdi
callq 0xd550
jmp 0x9114
movq 0x378(%rsp), %rax
movq 0x380(%rsp), %rcx
movq (%rcx), %rcx
subq %rcx, %rax
movq %rax, 0x48(%rsp)
movq 0x370(%rsp), %rax
movq %rax, 0x50(%rsp)
leaq 0x14f(%rsp), %rdi
movq %rdi, 0x58(%rsp)
callq 0x4600
movq 0x58(%rsp), %rdx
leaq 0x481d8(%rip), %rsi     # 0x510da
leaq 0x150(%rsp), %rdi
callq 0x4f10
jmp 0x8f11
movq 0x50(%rsp), %rcx
movq 0x48(%rsp), %rdx
movq 0xb8(%rsp), %rsi
movq 0xa8(%rsp), %rdi
leaq 0x150(%rsp), %r8
callq 0x9140
jmp 0x8f3a
leaq 0x150(%rsp), %rdi
callq 0x46e8
leaq 0x14f(%rsp), %rdi
callq 0x43b0
jmp 0x9114
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x2d0(%rsp)
movl %eax, 0x2cc(%rsp)
jmp 0x8f90
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x2d0(%rsp)
movl %eax, 0x2cc(%rsp)
leaq 0x150(%rsp), %rdi
callq 0x46e8
leaq 0x14f(%rsp), %rdi
callq 0x43b0
jmp 0x9124
jmp 0x8fa4
leaq 0xd0(%rsp), %rdi
movq %rdi, 0xc8(%rsp)
callq 0xda30
jmp 0x8fbb
leaq 0xd0(%rsp), %rax
movq %rax, 0x138(%rsp)
movq $0x1, 0x140(%rsp)
leaq 0xc7(%rsp), %rdi
movq %rdi, 0x40(%rsp)
callq 0xda70
movq 0xa8(%rsp), %rdi
movq 0x40(%rsp), %rcx
movq 0x138(%rsp), %rsi
movq 0x140(%rsp), %rdx
callq 0xda80
jmp 0x900d
leaq 0xc7(%rsp), %rdi
callq 0xdb10
leaq 0xd0(%rsp), %rax
movq %rax, 0x30(%rsp)
addq $0x68, %rax
movq %rax, 0x38(%rsp)
movq 0x38(%rsp), %rdi
addq $-0x68, %rdi
movq %rdi, 0x28(%rsp)
callq 0xd490
movq 0x30(%rsp), %rcx
movq 0x28(%rsp), %rax
cmpq %rcx, %rax
movq %rax, 0x38(%rsp)
jne 0x9030
jmp 0x9114
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x2d0(%rsp)
movl %eax, 0x2cc(%rsp)
movq 0xc8(%rsp), %rax
leaq 0xd0(%rsp), %rcx
cmpq %rax, %rcx
movq %rax, 0x20(%rsp)
je 0x90b4
movq 0x20(%rsp), %rdi
addq $-0x68, %rdi
movq %rdi, 0x18(%rsp)
callq 0xd490
movq 0x18(%rsp), %rax
leaq 0xd0(%rsp), %rcx
cmpq %rcx, %rax
movq %rax, 0x20(%rsp)
jne 0x908a
jmp 0x9124
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x2d0(%rsp)
movl %eax, 0x2cc(%rsp)
leaq 0xc7(%rsp), %rdi
callq 0xdb10
leaq 0xd0(%rsp), %rax
movq %rax, 0x8(%rsp)
addq $0x68, %rax
movq %rax, 0x10(%rsp)
movq 0x10(%rsp), %rdi
addq $-0x68, %rdi
movq %rdi, (%rsp)
callq 0xd490
movq 0x8(%rsp), %rcx
movq (%rsp), %rax
cmpq %rcx, %rax
movq %rax, 0x10(%rsp)
jne 0x90ed
jmp 0x9124
movq 0xb0(%rsp), %rax
addq $0x398, %rsp            # imm = 0x398
retq
movq 0x2d0(%rsp), %rdi
callq 0x45f0
nopw %cs:(%rax,%rax)