// File: /workspace/github_cpp_makefile_star2_O3/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, %rbp
movq %rdx, %r12
movq %rsi, %r13
movq %rdi, 0x40(%rsp)
leaq 0xd0(%rsp), %rbx
movq %rbx, -0x10(%rbx)
movq 0x20(%rcx), %rsi
movq 0x28(%rcx), %rdx
addq %rsi, %rdx
leaq 0xc0(%rsp), %r14
movq %r14, %rdi
callq 0xc7aa
xorps %xmm0, %xmm0
leaq 0x70(%rsp), %rcx
movaps %xmm0, (%rcx)
movq $0x0, 0x10(%rcx)
movq %r13, %rdi
movq %r14, %rsi
movq %r12, %rdx
movl $0x1, %r8d
xorl %r9d, %r9d
callq 0x7b6c
movq %rax, %r14
movq 0x70(%rsp), %rdi
testq %rdi, %rdi
je 0x24f4d
movq 0x80(%rsp), %rsi
subq %rdi, %rsi
callq 0x42a0
leaq 0x20(%rbp), %r15
movq 0xc0(%rsp), %rdi
cmpq %rbx, %rdi
je 0x24f6e
movq 0xd0(%rsp), %rsi
incq %rsi
callq 0x42a0
movq %r14, %rdi
addq $0x30, %rdi
movq %r15, %rsi
callq 0x4170
movb $0x1, 0x50(%r14)
leaq 0xa8(%rsp), %rdi
movq %r13, %rsi
callq 0x54da
leaq 0x28(%rsp), %rbx
movq %rbx, -0x10(%rbx)
movq 0x10(%r14), %rsi
movq 0x18(%r14), %rdx
addq %rsi, %rdx
leaq 0x18(%rsp), %rdi
callq 0xc7aa
movq %rbp, 0x8(%rsp)
leaq 0x18(%rsp), %rsi
movq $0x0, 0x20(%rsi)
leaq 0x90(%rsp), %rdi
leaq 0x10(%rsp), %rcx
movl $0x1, %edx
callq 0xbf14
movq %r14, 0x48(%rsp)
movq 0x18(%rsp), %rdi
cmpq %rbx, %rdi
je 0x24ff5
movq 0x28(%rsp), %rsi
incq %rsi
callq 0x42a0
movq 0xa8(%rsp), %r14
movq 0xb0(%rsp), %r15
cmpq %r15, %r14
je 0x2507c
leaq 0x1251e(%rip), %r13     # 0x3752f
leaq 0x18(%rsp), %rbp
movq %r12, %rdi
movq %r13, %rsi
callq 0x40d0
testl %eax, %eax
jne 0x2507c
cmpl $0x4, (%r14)
jne 0x25073
movq %rbx, 0x18(%rsp)
movq 0x10(%r14), %rsi
movq 0x18(%r14), %rdx
addq %rsi, %rdx
movq %rbp, %rdi
callq 0xc7aa
movq 0x8(%r14), %rax
movq %rax, 0x38(%rsp)
leaq 0x90(%rsp), %rdi
movq %rbp, %rsi
callq 0x2af80
movq 0x18(%rsp), %rdi
cmpq %rbx, %rdi
je 0x25073
movq 0x28(%rsp), %rsi
incq %rsi
callq 0x42a0
addq $0x58, %r14
cmpq %r15, %r14
jne 0x25016
movq 0x8(%rsp), %rax
movq 0x40(%rax), %rbp
callq 0x4050
movq %rax, %r13
movl (%rax), %r14d
movl $0x0, (%rax)
leaq 0x10(%rsp), %rbx
movq %rbp, %rdi
movq %rbx, %rsi
movl $0xa, %edx
callq 0x43c0
cmpq %rbp, (%rbx)
je 0x2525d
movq %rax, %r15
movl (%r13), %eax
testl %eax, %eax
je 0x250d5
cmpl $0x22, %eax
movq 0x8(%rsp), %rbp
jne 0x250de
leaq 0x12052(%rip), %rdi     # 0x37122
callq 0x43f0
movl %r14d, (%r13)
movq 0x8(%rsp), %rbp
leaq 0xe0(%rsp), %rdi
leaq 0x90(%rsp), %rsi
callq 0x29df8
leaq 0x18(%rsp), %rdi
leaq 0xe0(%rsp), %rdx
movq %r15, %rsi
callq 0x185ac
movq 0x48(%rsp), %r14
leaq 0xe0(%rsp), %rdi
callq 0xbf5e
movq 0x28(%r12), %rsi
addq $0x20, %r12
movq 0x18(%rsp), %rdx
movq 0x20(%rsp), %rcx
movq %r12, %rdi
callq 0xc18c
leaq 0x60(%rsp), %rbx
movq %rbx, -0x10(%rbx)
movq 0x20(%rbp), %rsi
movq 0x28(%rbp), %rdx
addq %rsi, %rdx
leaq 0x50(%rsp), %rdi
callq 0xc7aa
leaq 0x50(%rsp), %r8
movq 0x40(%rsp), %rdi
movq %r14, %rcx
callq 0x28c64
movq 0x50(%rsp), %rdi
cmpq %rbx, %rdi
je 0x2517c
movq 0x60(%rsp), %rsi
incq %rsi
callq 0x42a0
movq 0x40(%rbp), %rbx
movl (%r13), %r12d
movl $0x0, (%r13)
leaq 0x10(%rsp), %r15
movq %rbx, %rdi
movq %r15, %rsi
movl $0xa, %edx
callq 0x43c0
cmpq %rbx, (%r15)
je 0x25269
movl (%r13), %ebp
testl %ebp, %ebp
je 0x251c3
cmpl $0x22, %ebp
jne 0x251ca
leaq 0x11f64(%rip), %rdi     # 0x37122
callq 0x43f0
movl %r12d, (%r13)
movl %r12d, %ebp
movq %rax, 0x8(%r14)
cmpl $0x1, (%r14)
jne 0x25227
movl $0x4, (%r14)
movq 0x8(%rsp), %rax
movq 0x40(%rax), %rbx
movl $0x0, (%r13)
leaq 0x10(%rsp), %r15
movq %rbx, %rdi
movq %r15, %rsi
movl $0xa, %edx
callq 0x43c0
cmpq %rbx, (%r15)
je 0x25275
movl (%r13), %ecx
testl %ecx, %ecx
je 0x2521f
cmpl $0x22, %ecx
jne 0x25223
leaq 0x11f08(%rip), %rdi     # 0x37122
callq 0x43f0
movl %ebp, (%r13)
movq %rax, 0x8(%r14)
leaq 0x18(%rsp), %rdi
callq 0xbcf0
leaq 0x90(%rsp), %rdi
callq 0xbf5e
leaq 0xa8(%rsp), %rdi
callq 0xbbba
addq $0xf8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x11ebe(%rip), %rdi     # 0x37122
callq 0x41a0
leaq 0x11eb2(%rip), %rdi     # 0x37122
callq 0x41a0
leaq 0x11ea6(%rip), %rdi     # 0x37122
callq 0x41a0
movq %rax, %r15
cmpl $0x0, (%r13)
jne 0x25354
movl %ebp, (%r13)
jmp 0x25354
movq %rax, %r15
movq 0x50(%rsp), %rdi
cmpq %rbx, %rdi
je 0x25354
movq 0x60(%rsp), %rsi
incq %rsi
callq 0x42a0
jmp 0x25354
jmp 0x252bd
movq %rax, %r15
jmp 0x25354
movq %rax, %r15
leaq 0xe0(%rsp), %rdi
callq 0xbf5e
jmp 0x2538f
jmp 0x2538c
movq %rax, %r15
movq 0x18(%rsp), %rdi
cmpq %rbx, %rdi
je 0x2539c
movq 0x28(%rsp), %rsi
incq %rsi
callq 0x42a0
jmp 0x2539c
movq %rax, %r15
jmp 0x2539c
movq %rax, %r15
movq 0x70(%rsp), %rdi
testq %rdi, %rdi
je 0x25327
movq 0x80(%rsp), %rsi
subq %rdi, %rsi
callq 0x42a0
movq 0xc0(%rsp), %rdi
cmpq %rbx, %rdi
je 0x253a9
movq 0xd0(%rsp), %rsi
incq %rsi
callq 0x42a0
jmp 0x253a9
movq %rax, %r15
cmpl $0x0, (%r13)
jne 0x25354
movl %r12d, (%r13)
leaq 0x18(%rsp), %rdi
callq 0xbcf0
jmp 0x2538f
movq %rax, %r15
cmpl $0x0, (%r13)
jne 0x2538f
movl %r14d, (%r13)
jmp 0x2538f
movq %rax, %r15
movq 0x18(%rsp), %rdi
cmpq %rbx, %rdi
je 0x2538f
movq 0x28(%rsp), %rsi
incq %rsi
callq 0x42a0
jmp 0x2538f
movq %rax, %r15
leaq 0x90(%rsp), %rdi
callq 0xbf5e
leaq 0xa8(%rsp), %rdi
callq 0xbbba
movq %r15, %rdi
callq 0x44c0
nop