// File: Merulo[P]CompilerJFTT/src/Calculators/NumberGenerator.cpp
// Function: NumberGenerator::generateConstFrom(unsigned long long, std::vector<std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, unsigned long long>, std::allocator<std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, unsigned long long>>>)
std::vector<Line> NumberGenerator::generateConstFrom(
    unsigned long long target, 
    std::vector<std::pair<std::string, unsigned long long>> values)
{
    _result.clear();
    
    for(auto option = values.begin() + 1; option != values.end(); option++)
    {
        if(target > option->second)
        {
            unsigned long long diff = target - option->second;
            if (diff < 15)
            {
                _result.push_back({"#PERFORMING COPY TO REACH " + std::to_string(target)});
                _result.push_back({"COPY", values.front().first, option->first});
                while(diff > 0)
                {
                    _result.push_back({"INC", values.front().first});
                    diff --;
                }
                return _result;
            }
        }
        else if (target <= option->second)
        {
            unsigned long long diff = option->second - target;
            if (diff < 15)
            {
                _result.push_back({"#PERFORMING COPY TO REACH " + std::to_string(target)});                
                _result.push_back({"COPY", values.front().first, option->first});
                while(diff > 0)
                {
                    _result.push_back({"DEC", values.front().first});
                    diff --;
                }
                return _result;
            }
        }
    }


    getCostWithIncAndAdd(target);
    generateWithIncAndAdd(target, values[0].first);

    return _result;
}

// Assembly:
subq $0x658, %rsp            # imm = 0x658
movq %rdx, 0x98(%rsp)
movq %rdi, 0x88(%rsp)
movq %rdi, %rax
movq %rax, 0x90(%rsp)
movq %rdi, 0x650(%rsp)
movq %rsi, 0x648(%rsp)
movq %rdx, 0x640(%rsp)
leaq 0x4b7ff(%rip), %rdi     # 0x693d0
callq 0x1f100
movq 0x98(%rsp), %rdi
callq 0x1f120
movq %rax, 0x630(%rsp)
leaq 0x630(%rsp), %rdi
movl $0x1, %esi
callq 0x1f150
movq %rax, 0x638(%rsp)
movq 0x98(%rsp), %rdi
callq 0x1f1d0
movq %rax, 0x628(%rsp)
leaq 0x638(%rsp), %rdi
leaq 0x628(%rsp), %rsi
callq 0x1f190
testb $0x1, %al
jne 0x1dc38
jmp 0x1e860
movq 0x648(%rsp), %rax
movq %rax, 0x80(%rsp)
leaq 0x638(%rsp), %rdi
callq 0x1f200
movq %rax, %rcx
movq 0x80(%rsp), %rax
cmpq 0x20(%rcx), %rax
jbe 0x1e247
movq 0x648(%rsp), %rax
movq %rax, 0x78(%rsp)
leaq 0x638(%rsp), %rdi
callq 0x1f200
movq %rax, %rcx
movq 0x78(%rsp), %rax
subq 0x20(%rcx), %rax
movq %rax, 0x620(%rsp)
cmpq $0xf, 0x620(%rsp)
jae 0x1e242
movq 0x648(%rsp), %rsi
leaq 0x578(%rsp), %rdi
movq %rdi, 0x70(%rsp)
callq 0x1f260
movq 0x70(%rsp), %rdx
leaq 0x335cc(%rip), %rsi     # 0x51299
leaq 0x598(%rsp), %rdi
callq 0x1f210
jmp 0x1dcdc
leaq 0x547(%rsp), %rdi
movq %rdi, 0x68(%rsp)
callq 0x4600
movq 0x68(%rsp), %rdx
leaq 0x33421(%rip), %rsi     # 0x5111b
leaq 0x548(%rsp), %rdi
callq 0x4f10
jmp 0x1dd09
leaq 0x51f(%rsp), %rdi
movq %rdi, 0x60(%rsp)
callq 0x4600
movq 0x60(%rsp), %rdx
leaq 0x333f4(%rip), %rsi     # 0x5111b
leaq 0x520(%rsp), %rdi
callq 0x4f10
jmp 0x1dd36
leaq 0x5b8(%rsp), %rdi
leaq 0x598(%rsp), %rsi
leaq 0x548(%rsp), %rdx
leaq 0x520(%rsp), %rcx
callq 0xd3b0
jmp 0x1dd5d
leaq 0x4b66c(%rip), %rdi     # 0x693d0
leaq 0x5b8(%rsp), %rsi
callq 0xd380
jmp 0x1dd73
leaq 0x5b8(%rsp), %rdi
callq 0xd490
leaq 0x520(%rsp), %rdi
callq 0x46e8
leaq 0x51f(%rsp), %rdi
callq 0x43b0
leaq 0x548(%rsp), %rdi
callq 0x46e8
leaq 0x547(%rsp), %rdi
callq 0x43b0
leaq 0x598(%rsp), %rdi
callq 0x46e8
leaq 0x578(%rsp), %rdi
callq 0x46e8
leaq 0x48f(%rsp), %rdi
movq %rdi, 0x58(%rsp)
callq 0x4600
movq 0x58(%rsp), %rdx
leaq 0x33311(%rip), %rsi     # 0x510fd
leaq 0x490(%rsp), %rdi
callq 0x4f10
jmp 0x1ddfb
movq 0x98(%rsp), %rdi
callq 0x1f360
movq %rax, %rsi
leaq 0x468(%rsp), %rdi
callq 0x4180
jmp 0x1de1a
leaq 0x638(%rsp), %rdi
callq 0x1f200
movq %rax, %rsi
leaq 0x448(%rsp), %rdi
callq 0x4180
jmp 0x1de39
leaq 0x4b0(%rsp), %rdi
leaq 0x490(%rsp), %rsi
leaq 0x468(%rsp), %rdx
leaq 0x448(%rsp), %rcx
callq 0xd3b0
jmp 0x1de60
leaq 0x4b569(%rip), %rdi     # 0x693d0
leaq 0x4b0(%rsp), %rsi
callq 0xd380
jmp 0x1de76
leaq 0x4b0(%rsp), %rdi
callq 0xd490
leaq 0x448(%rsp), %rdi
callq 0x46e8
leaq 0x468(%rsp), %rdi
callq 0x46e8
leaq 0x490(%rsp), %rdi
callq 0x46e8
leaq 0x48f(%rsp), %rdi
callq 0x43b0
cmpq $0x0, 0x620(%rsp)
jbe 0x1e229
leaq 0x3bf(%rsp), %rdi
movq %rdi, 0x50(%rsp)
callq 0x4600
movq 0x50(%rsp), %rdx
leaq 0x331f2(%rip), %rsi     # 0x510d6
leaq 0x3c0(%rsp), %rdi
callq 0x4f10
jmp 0x1def3
movq 0x98(%rsp), %rdi
callq 0x1f360
movq %rax, %rsi
leaq 0x398(%rsp), %rdi
callq 0x4180
jmp 0x1df12
leaq 0x377(%rsp), %rdi
movq %rdi, 0x48(%rsp)
callq 0x4600
movq 0x48(%rsp), %rdx
leaq 0x331eb(%rip), %rsi     # 0x5111b
leaq 0x378(%rsp), %rdi
callq 0x4f10
jmp 0x1df3f
leaq 0x3e0(%rsp), %rdi
leaq 0x3c0(%rsp), %rsi
leaq 0x398(%rsp), %rdx
leaq 0x378(%rsp), %rcx
callq 0xd3b0
jmp 0x1df66
leaq 0x4b463(%rip), %rdi     # 0x693d0
leaq 0x3e0(%rsp), %rsi
callq 0xd380
jmp 0x1df7c
leaq 0x3e0(%rsp), %rdi
callq 0xd490
leaq 0x378(%rsp), %rdi
callq 0x46e8
leaq 0x377(%rsp), %rdi
callq 0x43b0
leaq 0x398(%rsp), %rdi
callq 0x46e8
leaq 0x3c0(%rsp), %rdi
callq 0x46e8
leaq 0x3bf(%rsp), %rdi
callq 0x43b0
movq 0x620(%rsp), %rax
addq $-0x1, %rax
movq %rax, 0x620(%rsp)
jmp 0x1deb7
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x570(%rsp)
movl %eax, 0x56c(%rsp)
jmp 0x1e0a0
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x570(%rsp)
movl %eax, 0x56c(%rsp)
jmp 0x1e086
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x570(%rsp)
movl %eax, 0x56c(%rsp)
jmp 0x1e06c
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x570(%rsp)
movl %eax, 0x56c(%rsp)
jmp 0x1e05f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x570(%rsp)
movl %eax, 0x56c(%rsp)
leaq 0x5b8(%rsp), %rdi
callq 0xd490
leaq 0x520(%rsp), %rdi
callq 0x46e8
leaq 0x51f(%rsp), %rdi
callq 0x43b0
leaq 0x548(%rsp), %rdi
callq 0x46e8
leaq 0x547(%rsp), %rdi
callq 0x43b0
leaq 0x598(%rsp), %rdi
callq 0x46e8
leaq 0x578(%rsp), %rdi
callq 0x46e8
jmp 0x1e905
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x570(%rsp)
movl %eax, 0x56c(%rsp)
jmp 0x1e155
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x570(%rsp)
movl %eax, 0x56c(%rsp)
jmp 0x1e148
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x570(%rsp)
movl %eax, 0x56c(%rsp)
jmp 0x1e13b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x570(%rsp)
movl %eax, 0x56c(%rsp)
jmp 0x1e12e
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x570(%rsp)
movl %eax, 0x56c(%rsp)
leaq 0x4b0(%rsp), %rdi
callq 0xd490
leaq 0x448(%rsp), %rdi
callq 0x46e8
leaq 0x468(%rsp), %rdi
callq 0x46e8
leaq 0x490(%rsp), %rdi
callq 0x46e8
leaq 0x48f(%rsp), %rdi
callq 0x43b0
jmp 0x1e905
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x570(%rsp)
movl %eax, 0x56c(%rsp)
jmp 0x1e217
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x570(%rsp)
movl %eax, 0x56c(%rsp)
jmp 0x1e20a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x570(%rsp)
movl %eax, 0x56c(%rsp)
jmp 0x1e1f0
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x570(%rsp)
movl %eax, 0x56c(%rsp)
jmp 0x1e1e3
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x570(%rsp)
movl %eax, 0x56c(%rsp)
leaq 0x3e0(%rsp), %rdi
callq 0xd490
leaq 0x378(%rsp), %rdi
callq 0x46e8
leaq 0x377(%rsp), %rdi
callq 0x43b0
leaq 0x398(%rsp), %rdi
callq 0x46e8
leaq 0x3c0(%rsp), %rdi
callq 0x46e8
leaq 0x3bf(%rsp), %rdi
callq 0x43b0
jmp 0x1e905
movq 0x88(%rsp), %rdi
leaq 0x4b198(%rip), %rsi     # 0x693d0
callq 0x1f390
jmp 0x1e8f5
jmp 0x1e842
movq 0x648(%rsp), %rax
movq %rax, 0x40(%rsp)
leaq 0x638(%rsp), %rdi
callq 0x1f200
movq %rax, %rcx
movq 0x40(%rsp), %rax
cmpq 0x20(%rcx), %rax
ja 0x1e840
leaq 0x638(%rsp), %rdi
callq 0x1f200
movq 0x20(%rax), %rax
subq 0x648(%rsp), %rax
movq %rax, 0x368(%rsp)
cmpq $0xf, 0x368(%rsp)
jae 0x1e83e
movq 0x648(%rsp), %rsi
leaq 0x2c0(%rsp), %rdi
movq %rdi, 0x38(%rsp)
callq 0x1f260
movq 0x38(%rsp), %rdx
leaq 0x32fd0(%rip), %rsi     # 0x51299
leaq 0x2e0(%rsp), %rdi
callq 0x1f210
jmp 0x1e2d8
leaq 0x29f(%rsp), %rdi
movq %rdi, 0x30(%rsp)
callq 0x4600
movq 0x30(%rsp), %rdx
leaq 0x32e25(%rip), %rsi     # 0x5111b
leaq 0x2a0(%rsp), %rdi
callq 0x4f10
jmp 0x1e305
leaq 0x277(%rsp), %rdi
movq %rdi, 0x28(%rsp)
callq 0x4600
movq 0x28(%rsp), %rdx
leaq 0x32df8(%rip), %rsi     # 0x5111b
leaq 0x278(%rsp), %rdi
callq 0x4f10
jmp 0x1e332
leaq 0x300(%rsp), %rdi
leaq 0x2e0(%rsp), %rsi
leaq 0x2a0(%rsp), %rdx
leaq 0x278(%rsp), %rcx
callq 0xd3b0
jmp 0x1e359
leaq 0x4b070(%rip), %rdi     # 0x693d0
leaq 0x300(%rsp), %rsi
callq 0xd380
jmp 0x1e36f
leaq 0x300(%rsp), %rdi
callq 0xd490
leaq 0x278(%rsp), %rdi
callq 0x46e8
leaq 0x277(%rsp), %rdi
callq 0x43b0
leaq 0x2a0(%rsp), %rdi
callq 0x46e8
leaq 0x29f(%rsp), %rdi
callq 0x43b0
leaq 0x2e0(%rsp), %rdi
callq 0x46e8
leaq 0x2c0(%rsp), %rdi
callq 0x46e8
leaq 0x1e7(%rsp), %rdi
movq %rdi, 0x20(%rsp)
callq 0x4600
movq 0x20(%rsp), %rdx
leaq 0x32d15(%rip), %rsi     # 0x510fd
leaq 0x1e8(%rsp), %rdi
callq 0x4f10
jmp 0x1e3f7
movq 0x98(%rsp), %rdi
callq 0x1f360
movq %rax, %rsi
leaq 0x1c0(%rsp), %rdi
callq 0x4180
jmp 0x1e416
leaq 0x638(%rsp), %rdi
callq 0x1f200
movq %rax, %rsi
leaq 0x1a0(%rsp), %rdi
callq 0x4180
jmp 0x1e435
leaq 0x208(%rsp), %rdi
leaq 0x1e8(%rsp), %rsi
leaq 0x1c0(%rsp), %rdx
leaq 0x1a0(%rsp), %rcx
callq 0xd3b0
jmp 0x1e45c
leaq 0x4af6d(%rip), %rdi     # 0x693d0
leaq 0x208(%rsp), %rsi
callq 0xd380
jmp 0x1e472
leaq 0x208(%rsp), %rdi
callq 0xd490
leaq 0x1a0(%rsp), %rdi
callq 0x46e8
leaq 0x1c0(%rsp), %rdi
callq 0x46e8
leaq 0x1e8(%rsp), %rdi
callq 0x46e8
leaq 0x1e7(%rsp), %rdi
callq 0x43b0
cmpq $0x0, 0x368(%rsp)
jbe 0x1e825
leaq 0x117(%rsp), %rdi
movq %rdi, 0x18(%rsp)
callq 0x4600
movq 0x18(%rsp), %rdx
leaq 0x32bf2(%rip), %rsi     # 0x510d2
leaq 0x118(%rsp), %rdi
callq 0x4f10
jmp 0x1e4ef
movq 0x98(%rsp), %rdi
callq 0x1f360
movq %rax, %rsi
leaq 0xf0(%rsp), %rdi
callq 0x4180
jmp 0x1e50e
leaq 0xcf(%rsp), %rdi
movq %rdi, 0x10(%rsp)
callq 0x4600
movq 0x10(%rsp), %rdx
leaq 0x32bef(%rip), %rsi     # 0x5111b
leaq 0xd0(%rsp), %rdi
callq 0x4f10
jmp 0x1e53b
leaq 0x138(%rsp), %rdi
leaq 0x118(%rsp), %rsi
leaq 0xf0(%rsp), %rdx
leaq 0xd0(%rsp), %rcx
callq 0xd3b0
jmp 0x1e562
leaq 0x4ae67(%rip), %rdi     # 0x693d0
leaq 0x138(%rsp), %rsi
callq 0xd380
jmp 0x1e578
leaq 0x138(%rsp), %rdi
callq 0xd490
leaq 0xd0(%rsp), %rdi
callq 0x46e8
leaq 0xcf(%rsp), %rdi
callq 0x43b0
leaq 0xf0(%rsp), %rdi
callq 0x46e8
leaq 0x118(%rsp), %rdi
callq 0x46e8
leaq 0x117(%rsp), %rdi
callq 0x43b0
movq 0x368(%rsp), %rax
addq $-0x1, %rax
movq %rax, 0x368(%rsp)
jmp 0x1e4b3
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x570(%rsp)
movl %eax, 0x56c(%rsp)
jmp 0x1e69c
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x570(%rsp)
movl %eax, 0x56c(%rsp)
jmp 0x1e682
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x570(%rsp)
movl %eax, 0x56c(%rsp)
jmp 0x1e668
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x570(%rsp)
movl %eax, 0x56c(%rsp)
jmp 0x1e65b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x570(%rsp)
movl %eax, 0x56c(%rsp)
leaq 0x300(%rsp), %rdi
callq 0xd490
leaq 0x278(%rsp), %rdi
callq 0x46e8
leaq 0x277(%rsp), %rdi
callq 0x43b0
leaq 0x2a0(%rsp), %rdi
callq 0x46e8
leaq 0x29f(%rsp), %rdi
callq 0x43b0
leaq 0x2e0(%rsp), %rdi
callq 0x46e8
leaq 0x2c0(%rsp), %rdi
callq 0x46e8
jmp 0x1e905
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x570(%rsp)
movl %eax, 0x56c(%rsp)
jmp 0x1e751
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x570(%rsp)
movl %eax, 0x56c(%rsp)
jmp 0x1e744
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x570(%rsp)
movl %eax, 0x56c(%rsp)
jmp 0x1e737
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x570(%rsp)
movl %eax, 0x56c(%rsp)
jmp 0x1e72a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x570(%rsp)
movl %eax, 0x56c(%rsp)
leaq 0x208(%rsp), %rdi
callq 0xd490
leaq 0x1a0(%rsp), %rdi
callq 0x46e8
leaq 0x1c0(%rsp), %rdi
callq 0x46e8
leaq 0x1e8(%rsp), %rdi
callq 0x46e8
leaq 0x1e7(%rsp), %rdi
callq 0x43b0
jmp 0x1e905
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x570(%rsp)
movl %eax, 0x56c(%rsp)
jmp 0x1e813
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x570(%rsp)
movl %eax, 0x56c(%rsp)
jmp 0x1e806
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x570(%rsp)
movl %eax, 0x56c(%rsp)
jmp 0x1e7ec
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x570(%rsp)
movl %eax, 0x56c(%rsp)
jmp 0x1e7df
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x570(%rsp)
movl %eax, 0x56c(%rsp)
leaq 0x138(%rsp), %rdi
callq 0xd490
leaq 0xd0(%rsp), %rdi
callq 0x46e8
leaq 0xcf(%rsp), %rdi
callq 0x43b0
leaq 0xf0(%rsp), %rdi
callq 0x46e8
leaq 0x118(%rsp), %rdi
callq 0x46e8
leaq 0x117(%rsp), %rdi
callq 0x43b0
jmp 0x1e905
movq 0x88(%rsp), %rdi
leaq 0x4ab9c(%rip), %rsi     # 0x693d0
callq 0x1f390
jmp 0x1e8f5
jmp 0x1e840
jmp 0x1e842
jmp 0x1e844
leaq 0x638(%rsp), %rdi
xorl %esi, %esi
callq 0x1f490
movq %rax, 0xc0(%rsp)
jmp 0x1dc05
movq 0x648(%rsp), %rdi
callq 0x1e920
movq 0x98(%rsp), %rdi
movq 0x648(%rsp), %rax
movq %rax, (%rsp)
xorl %eax, %eax
movl %eax, %esi
callq 0x1f4d0
movq %rax, %rsi
leaq 0xa0(%rsp), %rdi
movq %rdi, 0x8(%rsp)
callq 0x4180
movq (%rsp), %rdi
movq 0x8(%rsp), %rsi
callq 0x1e990
jmp 0x1e8af
leaq 0xa0(%rsp), %rdi
callq 0x46e8
movq 0x88(%rsp), %rdi
leaq 0x4ab05(%rip), %rsi     # 0x693d0
callq 0x1f390
jmp 0x1e8f5
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x570(%rsp)
movl %eax, 0x56c(%rsp)
leaq 0xa0(%rsp), %rdi
callq 0x46e8
jmp 0x1e905
movq 0x90(%rsp), %rax
addq $0x658, %rsp            # imm = 0x658
retq
movq 0x570(%rsp), %rdi
callq 0x45f0
nopw %cs:(%rax,%rax)