// File: /workspace/github_cpp_makefile_star2_O2/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:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x308, %rsp            # imm = 0x308
movq %rdx, %rbx
movq %rsi, %r14
movq %rdi, 0x38(%rsp)
leaq 0x2319d(%rip), %rdi     # 0x32300
callq 0xfbda
movq (%rbx), %rsi
movq %rbx, 0x10(%rsp)
movq 0x8(%rbx), %rax
leaq 0x28(%rsi), %r15
cmpq %rax, %r15
je 0xf1aa
movq 0x20(%r15), %rbp
movq %r14, %r12
subq %rbp, %r12
jbe 0xf197
movq %r14, %rcx
subq %rbp, %rcx
cmpq $0xe, %rcx
ja 0xf1a4
jmp 0xf1fb
subq %r14, %rbp
cmpq $0xf, %rbp
jb 0xf40e
addq $0x28, %r15
jmp 0xf178
leaq 0x228(%rsp), %rbx
movq %rbx, %rdi
callq 0x4390
movq %r14, %rdi
movq %rbx, %rsi
callq 0xf812
leaq 0x228(%rsp), %rdi
callq 0x4548
leaq 0x23127(%rip), %rsi     # 0x32300
movq 0x38(%rsp), %rbx
movq %rbx, %rdi
callq 0xfc48
movq %rbx, %rax
addq $0x308, %rsp            # imm = 0x308
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x18(%rsp), %rbx
movq %rbx, %rdi
movq %r14, %rsi
callq 0xfc06
leaq 0x14057(%rip), %rsi     # 0x23269
leaq 0x208(%rsp), %rdi
movq %rbx, %rdx
callq 0xfbe2
leaq 0x13eba(%rip), %rsi     # 0x230e3
leaq 0x1e8(%rsp), %rdi
leaq 0xe(%rsp), %rdx
callq 0x4a54
leaq 0x13ea1(%rip), %rsi     # 0x230e3
leaq 0x1c8(%rsp), %rdi
leaq 0xf(%rsp), %rdx
callq 0x4a54
leaq 0x40(%rsp), %rdi
leaq 0x208(%rsp), %rsi
leaq 0x1e8(%rsp), %rdx
leaq 0x1c8(%rsp), %rcx
callq 0x816a
leaq 0x23083(%rip), %rdi     # 0x32300
leaq 0x40(%rsp), %rsi
callq 0x8f90
leaq 0x40(%rsp), %rdi
callq 0x81fe
leaq 0x1c8(%rsp), %rdi
callq 0x4548
leaq 0x1e8(%rsp), %rdi
callq 0x4548
leaq 0x208(%rsp), %rdi
callq 0x4548
leaq 0x18(%rsp), %rdi
callq 0x4548
leaq 0x13dfc(%rip), %rsi     # 0x230c5
leaq 0x1a8(%rsp), %rdi
leaq 0x18(%rsp), %rdx
callq 0x4a54
movq 0x10(%rsp), %rax
movq (%rax), %rsi
leaq 0x188(%rsp), %rdi
callq 0x4390
leaq 0x168(%rsp), %rdi
movq %r15, %rsi
callq 0x4390
leaq 0x40(%rsp), %rdi
leaq 0x1a8(%rsp), %rsi
leaq 0x188(%rsp), %rdx
leaq 0x168(%rsp), %rcx
callq 0x816a
leaq 0x22fd7(%rip), %rdi     # 0x32300
leaq 0x40(%rsp), %rsi
callq 0x8f90
leaq 0x40(%rsp), %r15
movq %r15, %rdi
callq 0x81fe
leaq 0x168(%rsp), %rdi
callq 0x4548
leaq 0x188(%rsp), %rdi
callq 0x4548
leaq 0x1a8(%rsp), %rdi
callq 0x4548
subq %r14, %rbp
leaq 0x2e8(%rsp), %r13
leaq 0x2c8(%rsp), %rbx
leaq 0x2a8(%rsp), %r12
leaq 0x22f77(%rip), %r14     # 0x32300
testq %rbp, %rbp
je 0xf1d2
movq %r13, %rdi
leaq 0x13d02(%rip), %rsi     # 0x2309e
leaq 0x18(%rsp), %rdx
callq 0x4a54
movq 0x10(%rsp), %rax
movq (%rax), %rsi
movq %rbx, %rdi
callq 0x4390
movq %r12, %rdi
leaq 0x13d23(%rip), %rsi     # 0x230e3
leaq 0xe(%rsp), %rdx
callq 0x4a54
movq %r15, %rdi
movq %r13, %rsi
movq %rbx, %rdx
movq %r12, %rcx
callq 0x816a
movq %r14, %rdi
movq %r15, %rsi
callq 0x8f90
movq %r15, %rdi
callq 0x81fe
movq %r12, %rdi
callq 0x4548
movq %rbx, %rdi
callq 0x4548
movq %r13, %rdi
callq 0x4548
incq %rbp
jmp 0xf389
leaq 0x18(%rsp), %rbx
movq %rbx, %rdi
movq %r14, %rsi
callq 0xfc06
leaq 0x13e44(%rip), %rsi     # 0x23269
leaq 0x148(%rsp), %rdi
movq %rbx, %rdx
callq 0xfbe2
leaq 0x13ca7(%rip), %rsi     # 0x230e3
leaq 0x128(%rsp), %rdi
leaq 0xe(%rsp), %rdx
callq 0x4a54
leaq 0x13c8e(%rip), %rsi     # 0x230e3
leaq 0x108(%rsp), %rdi
leaq 0xf(%rsp), %rdx
callq 0x4a54
leaq 0x40(%rsp), %rdi
leaq 0x148(%rsp), %rsi
leaq 0x128(%rsp), %rdx
leaq 0x108(%rsp), %rcx
callq 0x816a
leaq 0x22e70(%rip), %rdi     # 0x32300
leaq 0x40(%rsp), %rsi
callq 0x8f90
leaq 0x40(%rsp), %rdi
callq 0x81fe
leaq 0x108(%rsp), %rdi
callq 0x4548
leaq 0x128(%rsp), %rdi
callq 0x4548
leaq 0x148(%rsp), %rdi
callq 0x4548
leaq 0x18(%rsp), %rdi
callq 0x4548
leaq 0x13be9(%rip), %rsi     # 0x230c5
leaq 0xe8(%rsp), %rdi
leaq 0x18(%rsp), %rdx
callq 0x4a54
movq 0x10(%rsp), %rax
movq (%rax), %rsi
leaq 0xc8(%rsp), %rdi
callq 0x4390
leaq 0xa8(%rsp), %rdi
movq %r15, %rsi
callq 0x4390
leaq 0x40(%rsp), %rdi
leaq 0xe8(%rsp), %rsi
leaq 0xc8(%rsp), %rdx
leaq 0xa8(%rsp), %rcx
callq 0x816a
leaq 0x22dc4(%rip), %rdi     # 0x32300
leaq 0x40(%rsp), %rsi
callq 0x8f90
leaq 0x40(%rsp), %r15
movq %r15, %rdi
callq 0x81fe
leaq 0xa8(%rsp), %rdi
callq 0x4548
leaq 0xc8(%rsp), %rdi
callq 0x4548
leaq 0xe8(%rsp), %rdi
callq 0x4548
leaq 0x288(%rsp), %r13
leaq 0x268(%rsp), %rbx
leaq 0x248(%rsp), %rbp
leaq 0x22d67(%rip), %r14     # 0x32300
testq %r12, %r12
je 0xf1d2
movq %r13, %rdi
leaq 0x13aee(%rip), %rsi     # 0x2309a
leaq 0x18(%rsp), %rdx
callq 0x4a54
movq 0x10(%rsp), %rax
movq (%rax), %rsi
movq %rbx, %rdi
callq 0x4390
movq %rbp, %rdi
leaq 0x13b13(%rip), %rsi     # 0x230e3
leaq 0xe(%rsp), %rdx
callq 0x4a54
movq %r15, %rdi
movq %r13, %rsi
movq %rbx, %rdx
movq %rbp, %rcx
callq 0x816a
movq %r14, %rdi
movq %r15, %rsi
callq 0x8f90
movq %r15, %rdi
callq 0x81fe
movq %rbp, %rdi
callq 0x4548
movq %rbx, %rdi
callq 0x4548
movq %r13, %rdi
callq 0x4548
incq %r12
jmp 0xf599
movq %rax, %rbx
leaq 0x40(%rsp), %rdi
callq 0x81fe
jmp 0xf63f
movq %rax, %rbx
leaq 0x40(%rsp), %rdi
callq 0x81fe
jmp 0xf651
movq %rax, %rbx
leaq 0xa8(%rsp), %rdi
callq 0x4548
jmp 0xf663
movq %rax, %rbx
leaq 0x168(%rsp), %rdi
callq 0x4548
jmp 0xf675
movq %rax, %rbx
leaq 0xc8(%rsp), %rdi
callq 0x4548
jmp 0xf687
movq %rax, %rbx
leaq 0x188(%rsp), %rdi
callq 0x4548
jmp 0xf697
movq %rax, %rbx
leaq 0xe8(%rsp), %rdi
jmp 0xf7cd
movq %rax, %rbx
leaq 0x1a8(%rsp), %rdi
jmp 0xf7cd
jmp 0xf7dc
jmp 0xf7dc
movq %rax, %rbx
leaq 0x40(%rsp), %rdi
callq 0x81fe
jmp 0xf6cf
movq %rax, %rbx
leaq 0x40(%rsp), %rdi
callq 0x81fe
jmp 0xf6e1
movq %rax, %rbx
leaq 0x108(%rsp), %rdi
callq 0x4548
jmp 0xf6f3
movq %rax, %rbx
leaq 0x1c8(%rsp), %rdi
callq 0x4548
jmp 0xf705
movq %rax, %rbx
leaq 0x128(%rsp), %rdi
callq 0x4548
jmp 0xf717
movq %rax, %rbx
leaq 0x1e8(%rsp), %rdi
callq 0x4548
jmp 0xf724
movq %rax, %rbx
leaq 0x148(%rsp), %rdi
jmp 0xf72c
movq %rax, %rbx
leaq 0x208(%rsp), %rdi
callq 0x4548
jmp 0xf738
jmp 0xf735
movq %rax, %rbx
leaq 0x18(%rsp), %rdi
jmp 0xf7cd
movq %rax, %rbx
leaq 0x228(%rsp), %rdi
jmp 0xf7cd
movq %rax, %rbx
jmp 0xf794
movq %rax, %rbx
jmp 0xf7c5
movq %rax, %rbx
jmp 0xf787
movq %rax, %rbx
jmp 0xf7b8
movq %rax, %rbx
jmp 0xf77a
movq %rax, %rbx
jmp 0xf7ab
movq %rax, %rbx
leaq 0x40(%rsp), %rdi
callq 0x81fe
leaq 0x248(%rsp), %rdi
callq 0x4548
leaq 0x268(%rsp), %rdi
callq 0x4548
leaq 0x288(%rsp), %rdi
jmp 0xf7cd
movq %rax, %rbx
leaq 0x40(%rsp), %rdi
callq 0x81fe
leaq 0x2a8(%rsp), %rdi
callq 0x4548
leaq 0x2c8(%rsp), %rdi
callq 0x4548
leaq 0x2e8(%rsp), %rdi
callq 0x4548
movq %rbx, %rdi
callq 0x4490
jmp 0xf7dc
movq %rax, %rbx
jmp 0xf7d2
nop