// File: 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:
subq $0x278, %rsp            # imm = 0x278
movq %rdi, 0x270(%rsp)
movq %rsi, 0x268(%rsp)
movq %rdx, 0x260(%rsp)
movq %rcx, 0x258(%rsp)
movq 0x270(%rsp), %rax
movq %rax, 0x98(%rsp)
movq 0x268(%rsp), %rax
movq %rax, 0xa0(%rsp)
movq 0x258(%rsp), %rsi
addq $0x20, %rsi
leaq 0x230(%rsp), %rdi
movq %rdi, 0xa8(%rsp)
callq 0x4180
movq 0x260(%rsp), %rax
movq %rax, 0xb0(%rsp)
xorps %xmm0, %xmm0
movaps %xmm0, 0x210(%rsp)
movq $0x0, 0x220(%rsp)
leaq 0x210(%rsp), %rdi
movq %rdi, 0xb8(%rsp)
callq 0x391c0
movq 0xa0(%rsp), %rdi
movq 0xa8(%rsp), %rsi
movq 0xb0(%rsp), %rdx
movq 0xb8(%rsp), %rcx
movl $0x1, %r8d
xorl %r9d, %r9d
callq 0x7ac0
movq %rax, 0xc0(%rsp)
jmp 0x32f3c
leaq 0x210(%rsp), %rdi
callq 0xd9c0
leaq 0x230(%rsp), %rdi
callq 0x46e8
movq 0xc0(%rsp), %rax
movq %rax, 0x250(%rsp)
movq 0x258(%rsp), %rsi
addq $0x20, %rsi
movq 0x250(%rsp), %rdi
addq $0x30, %rdi
callq 0x4050
movq 0x250(%rsp), %rax
movb $0x1, 0x50(%rax)
movq 0x268(%rsp), %rsi
leaq 0x1e8(%rsp), %rdi
callq 0x5530
leaq 0x198(%rsp), %rdi
movq %rdi, 0x190(%rsp)
movq 0x250(%rsp), %rsi
addq $0x10, %rsi
movl $0x0, 0x18c(%rsp)
leaq 0x18c(%rsp), %rdx
callq 0xdcd0
jmp 0x32fda
leaq 0x198(%rsp), %rax
movq %rax, 0x1c0(%rsp)
movq $0x1, 0x1c8(%rsp)
leaq 0x18b(%rsp), %rdi
movq %rdi, 0x90(%rsp)
callq 0xdbc0
movq 0x90(%rsp), %rcx
movq 0x1c0(%rsp), %rsi
movq 0x1c8(%rsp), %rdx
leaq 0x1d0(%rsp), %rdi
callq 0xdbd0
jmp 0x33032
leaq 0x18b(%rsp), %rdi
callq 0xdcc0
leaq 0x198(%rsp), %rax
movq %rax, 0x80(%rsp)
addq $0x28, %rax
movq %rax, 0x88(%rsp)
movq 0x88(%rsp), %rdi
addq $-0x28, %rdi
movq %rdi, 0x78(%rsp)
callq 0xdbb0
movq 0x80(%rsp), %rcx
movq 0x78(%rsp), %rax
cmpq %rcx, %rax
movq %rax, 0x88(%rsp)
jne 0x3305b
leaq 0x1e8(%rsp), %rax
movq %rax, 0x180(%rsp)
movq 0x180(%rsp), %rdi
callq 0xd710
movq %rax, 0x178(%rsp)
movq 0x180(%rsp), %rdi
callq 0xd740
movq %rax, 0x170(%rsp)
leaq 0x178(%rsp), %rdi
leaq 0x170(%rsp), %rsi
callq 0xd770
testb $0x1, %al
jne 0x330e3
jmp 0x332bf
leaq 0x178(%rsp), %rdi
callq 0xd7b0
movq %rax, 0x168(%rsp)
movq 0x260(%rsp), %rdi
leaq 0x1e469(%rip), %rsi     # 0x51570
callq 0x310a0
movb %al, 0x77(%rsp)
jmp 0x33112
movb 0x77(%rsp), %al
testb $0x1, %al
jne 0x3311f
jmp 0x33230
jmp 0x332bf
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x208(%rsp)
movl %eax, 0x204(%rsp)
leaq 0x210(%rsp), %rdi
callq 0xd9c0
leaq 0x230(%rsp), %rdi
callq 0x46e8
jmp 0x3355f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x208(%rsp)
movl %eax, 0x204(%rsp)
movq 0x190(%rsp), %rax
leaq 0x198(%rsp), %rcx
cmpq %rax, %rcx
movq %rax, 0x68(%rsp)
je 0x331af
movq 0x68(%rsp), %rdi
addq $-0x28, %rdi
movq %rdi, 0x60(%rsp)
callq 0xdbb0
movq 0x60(%rsp), %rax
leaq 0x198(%rsp), %rcx
cmpq %rcx, %rax
movq %rax, 0x68(%rsp)
jne 0x33185
jmp 0x33552
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x208(%rsp)
movl %eax, 0x204(%rsp)
leaq 0x18b(%rsp), %rdi
callq 0xdcc0
leaq 0x198(%rsp), %rax
movq %rax, 0x50(%rsp)
addq $0x28, %rax
movq %rax, 0x58(%rsp)
movq 0x58(%rsp), %rdi
addq $-0x28, %rdi
movq %rdi, 0x48(%rsp)
callq 0xdbb0
movq 0x50(%rsp), %rcx
movq 0x48(%rsp), %rax
cmpq %rcx, %rax
movq %rax, 0x58(%rsp)
jne 0x331eb
jmp 0x33552
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x208(%rsp)
movl %eax, 0x204(%rsp)
jmp 0x33545
movq 0x168(%rsp), %rax
cmpl $0x4, (%rax)
jne 0x332ab
movq 0x168(%rsp), %rdx
movq %rdx, %rsi
addq $0x10, %rsi
addq $0x8, %rdx
leaq 0x140(%rsp), %rdi
callq 0x39200
jmp 0x3325f
leaq 0x1d0(%rsp), %rdi
leaq 0x140(%rsp), %rsi
callq 0x391d0
jmp 0x33276
leaq 0x140(%rsp), %rdi
callq 0xdbb0
jmp 0x332ab
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x208(%rsp)
movl %eax, 0x204(%rsp)
leaq 0x140(%rsp), %rdi
callq 0xdbb0
jmp 0x33545
jmp 0x332ad
leaq 0x178(%rsp), %rdi
callq 0xd7c0
jmp 0x330c5
movq 0x258(%rsp), %rdi
addq $0x40, %rdi
xorl %eax, %eax
movl %eax, %esi
movl $0xa, %edx
callq 0xdd90
movq %rax, 0x40(%rsp)
jmp 0x332e0
leaq 0x110(%rsp), %rdi
leaq 0x1d0(%rsp), %rsi
callq 0x39240
jmp 0x332f7
movq 0x40(%rsp), %rsi
leaq 0x128(%rsp), %rdi
leaq 0x110(%rsp), %rdx
callq 0x1db90
jmp 0x33313
leaq 0x110(%rsp), %rdi
callq 0xdc60
movq 0x260(%rsp), %rdi
addq $0x20, %rdi
movq %rdi, 0x30(%rsp)
callq 0xe380
movq %rax, 0x100(%rsp)
leaq 0x108(%rsp), %rdi
leaq 0x100(%rsp), %rsi
callq 0xe3b0
leaq 0x128(%rsp), %rdi
movq %rdi, 0x28(%rsp)
callq 0xe3f0
movq 0x28(%rsp), %rdi
movq %rax, 0xf8(%rsp)
callq 0xe380
movq 0x30(%rsp), %rdi
movq %rax, 0xf0(%rsp)
movq 0x108(%rsp), %rsi
movq 0xf8(%rsp), %rdx
movq 0xf0(%rsp), %rcx
callq 0xe2c0
movq %rax, 0x38(%rsp)
jmp 0x333a8
movq 0x38(%rsp), %rax
movq %rax, 0xe8(%rsp)
movq 0x260(%rsp), %rax
movq %rax, 0x10(%rsp)
movq 0x268(%rsp), %rax
movq %rax, 0x18(%rsp)
movq 0x250(%rsp), %rax
movq %rax, 0x20(%rsp)
movq 0x258(%rsp), %rsi
addq $0x20, %rsi
leaq 0xc8(%rsp), %rdi
callq 0x4180
jmp 0x333f7
movq 0x20(%rsp), %rcx
movq 0x18(%rsp), %rdx
movq 0x10(%rsp), %rsi
movq 0x98(%rsp), %rdi
leaq 0xc8(%rsp), %r8
callq 0x37870
jmp 0x3341d
leaq 0xc8(%rsp), %rdi
callq 0x46e8
movq 0x258(%rsp), %rdi
addq $0x40, %rdi
xorl %eax, %eax
movl %eax, %esi
movl $0xa, %edx
callq 0xdd90
movq %rax, 0x8(%rsp)
jmp 0x3344b
movq 0x8(%rsp), %rcx
movq 0x250(%rsp), %rax
movq %rcx, 0x8(%rax)
movq 0x250(%rsp), %rax
cmpl $0x1, (%rax)
jne 0x33509
movq 0x250(%rsp), %rax
movl $0x4, (%rax)
movq 0x258(%rsp), %rdi
addq $0x40, %rdi
xorl %eax, %eax
movl %eax, %esi
movl $0xa, %edx
callq 0xdd90
movq %rax, (%rsp)
jmp 0x3349b
movq (%rsp), %rcx
movq 0x250(%rsp), %rax
movq %rcx, 0x8(%rax)
jmp 0x33509
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x208(%rsp)
movl %eax, 0x204(%rsp)
leaq 0x110(%rsp), %rdi
callq 0xdc60
jmp 0x33545
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x208(%rsp)
movl %eax, 0x204(%rsp)
jmp 0x33538
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x208(%rsp)
movl %eax, 0x204(%rsp)
leaq 0xc8(%rsp), %rdi
callq 0x46e8
jmp 0x33538
leaq 0x128(%rsp), %rdi
callq 0xd550
leaq 0x1d0(%rsp), %rdi
callq 0xdc60
leaq 0x1e8(%rsp), %rdi
callq 0xd240
addq $0x278, %rsp            # imm = 0x278
retq
leaq 0x128(%rsp), %rdi
callq 0xd550
leaq 0x1d0(%rsp), %rdi
callq 0xdc60
leaq 0x1e8(%rsp), %rdi
callq 0xd240
movq 0x208(%rsp), %rdi
callq 0x45f0
nopl (%rax)