// File: /workspace/github_cpp_makefile_star2_O2/Merulo[P]CompilerJFTT/src/IRs/FourthIR.cpp
// Function: FourthIR::handleConst(RegisterBlock&, Block&, Line&)
void FourthIR::handleConst(RegisterBlock& rb, Block& b, Line& l)
{
    Register& r = rb.getRegister(l.one, b, {}, true, false);
    r.variableName = l.one;
    r.needToSafe = true;

    auto regs = rb.getRegisters();
    std::vector<std::pair<std::string, unsigned long long>> options = {{r.name, 0}};
    for(auto& reg : regs)
    {
        if (b.blockName != "Block_0")
        {
            break;
        }
        if (reg.state == RegisterState::CONSTVARIABLE)
        {
            options.push_back({reg.name, reg.constValue});
        }
    }

    auto lines = NumberGenerator::generateConstFrom(std::stoull(l.two), options);
    b.lines.insert(b.lines.end(), lines.begin(), lines.end()); 

    updateRegisterState(b, rb, r, l.one);
    r.constValue = std::stoull(l.two);
    if (r.state == RegisterState::VARIABLE)
    {
        r.state = RegisterState::CONSTVARIABLE;
        r.constValue = std::stoull(l.two);
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xf8, %rsp
movq %rcx, %rbx
movq %rdx, %r13
movq %rsi, %r15
movq %rdi, 0x10(%rsp)
leaq 0x20(%rcx), %r12
leaq 0xd8(%rsp), %r14
movq %r14, %rdi
movq %r12, %rsi
callq 0x4390
xorps %xmm0, %xmm0
leaq 0xa0(%rsp), %rcx
movaps %xmm0, (%rcx)
andq $0x0, 0x10(%rcx)
pushq $0x1
popq %r8
movq %r15, %rdi
movq %r14, %rsi
movq %r13, %rdx
xorl %r9d, %r9d
callq 0x5ec6
movq %rax, %r14
leaq 0xa0(%rsp), %rdi
callq 0x9106
leaq 0xd8(%rsp), %rdi
callq 0x4548
leaq 0x30(%r14), %rdi
movq %r12, %rsi
callq 0x4180
movb $0x1, 0x50(%r14)
leaq 0x70(%rsp), %rdi
movq %r15, %rsi
callq 0x4c1e
movq %r14, %rsi
addq $0x10, %rsi
leaq 0x30(%rsp), %rdi
callq 0x4390
movq %r12, 0x18(%rsp)
movq %r14, 0x20(%rsp)
movq %rbx, 0x28(%rsp)
leaq 0x30(%rsp), %rsi
andq $0x0, 0x20(%rsi)
leaq 0x58(%rsp), %rdi
pushq $0x1
popq %rdx
leaq 0xf(%rsp), %rcx
callq 0x83f8
leaq 0x30(%rsp), %rbp
movq %rbp, %rdi
callq 0x4548
movq 0x70(%rsp), %rbx
movq 0x78(%rsp), %r14
leaq 0xc382(%rip), %r15      # 0x2352f
leaq 0x58(%rsp), %r12
cmpq %r14, %rbx
je 0x171f4
movq %r13, %rdi
movq %r15, %rsi
callq 0x16742
testb %al, %al
jne 0x171f4
cmpl $0x4, (%rbx)
jne 0x171ee
leaq 0x10(%rbx), %rsi
leaq 0x8(%rbx), %rdx
movq %rbp, %rdi
callq 0x19e4a
movq %r12, %rdi
movq %rbp, %rsi
callq 0x1abd4
movq %rbp, %rdi
callq 0x4548
addq $0x58, %rbx
jmp 0x171b2
movq 0x28(%rsp), %rbx
addq $0x40, %rbx
pushq $0xa
popq %rdx
movq %rbx, %rdi
xorl %esi, %esi
callq 0x8476
movq %rax, %r15
leaq 0x88(%rsp), %rdi
leaq 0x58(%rsp), %rsi
callq 0x19e68
leaq 0x30(%rsp), %rdi
leaq 0x88(%rsp), %rdx
movq %r15, %rsi
callq 0xf140
movq 0x20(%rsp), %r14
movq 0x18(%rsp), %r15
leaq 0x88(%rsp), %rdi
callq 0x8432
movq 0x28(%r13), %rsi
addq $0x20, %r13
movq 0x30(%rsp), %rdx
movq 0x38(%rsp), %rcx
movq %r13, %rdi
callq 0x85b6
leaq 0xb8(%rsp), %rdi
movq %r15, %rsi
callq 0x4390
leaq 0xb8(%rsp), %r8
movq 0x10(%rsp), %rdi
movq %r14, %rcx
callq 0x192a6
leaq 0xb8(%rsp), %rdi
callq 0x4548
pushq $0xa
popq %rdx
movq %rbx, %rdi
xorl %esi, %esi
callq 0x8476
movq %rax, 0x8(%r14)
cmpl $0x1, (%r14)
jne 0x172c6
movl $0x4, (%r14)
pushq $0xa
popq %rdx
movq %rbx, %rdi
xorl %esi, %esi
callq 0x8476
movq %rax, 0x8(%r14)
leaq 0x30(%rsp), %rdi
callq 0x8236
leaq 0x58(%rsp), %rdi
callq 0x8432
leaq 0x70(%rsp), %rdi
callq 0x8120
addq $0xf8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
leaq 0xb8(%rsp), %rdi
callq 0x4548
jmp 0x17354
jmp 0x17351
movq %rax, %rbx
leaq 0x88(%rsp), %rdi
callq 0x8432
jmp 0x17372
movq %rax, %rbx
leaq 0x30(%rsp), %rdi
callq 0x4548
jmp 0x1737c
movq %rax, %rbx
jmp 0x1737c
movq %rax, %rbx
leaq 0xa0(%rsp), %rdi
callq 0x9106
leaq 0xd8(%rsp), %rdi
callq 0x4548
jmp 0x17386
jmp 0x1736f
movq %rax, %rbx
leaq 0x30(%rsp), %rdi
callq 0x8236
jmp 0x17372
movq %rax, %rbx
leaq 0x30(%rsp), %rdi
callq 0x4548
jmp 0x17372
movq %rax, %rbx
leaq 0x58(%rsp), %rdi
callq 0x8432
leaq 0x70(%rsp), %rdi
callq 0x8120
movq %rbx, %rdi
callq 0x4490