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

    b.lines.push_back({"PUT", r.name});     
    updateRegisterState(b, rb, r, l.one);

    if (_symbolTable->isConst(l.one) && _removeConsts)
    {
        r.variableName = "";
        r.state = RegisterState::UNKNOWN;
    }
}

// Assembly:
subq $0x218, %rsp            # imm = 0x218
movq %rdi, 0x210(%rsp)
movq %rsi, 0x208(%rsp)
movq %rdx, 0x200(%rsp)
movq %rcx, 0x1f8(%rsp)
movq 0x210(%rsp), %rax
movq %rax, 0x58(%rsp)
movq 0x208(%rsp), %rax
movq %rax, 0x60(%rsp)
movq 0x1f8(%rsp), %rsi
addq $0x20, %rsi
leaq 0x1d0(%rsp), %rdi
movq %rdi, 0x68(%rsp)
callq 0x4180
movq 0x200(%rsp), %rax
movq %rax, 0x70(%rsp)
xorps %xmm0, %xmm0
movaps %xmm0, 0x1b0(%rsp)
movq $0x0, 0x1c0(%rsp)
leaq 0x1b0(%rsp), %rdi
movq %rdi, 0x78(%rsp)
callq 0x391c0
movq 0x60(%rsp), %rdi
movq 0x68(%rsp), %rsi
movq 0x70(%rsp), %rdx
movq 0x78(%rsp), %rcx
movl $0x1, %r9d
movl %r9d, %r8d
callq 0x7ac0
movq %rax, 0x80(%rsp)
jmp 0x33631
leaq 0x1b0(%rsp), %rdi
callq 0xd9c0
leaq 0x1d0(%rsp), %rdi
callq 0x46e8
movq 0x80(%rsp), %rax
movq %rax, 0x1f0(%rsp)
movq 0x1f8(%rsp), %rsi
addq $0x20, %rsi
movq 0x1f0(%rsp), %rdi
addq $0x30, %rdi
callq 0x4050
movq 0x200(%rsp), %rax
addq $0x20, %rax
movq %rax, 0x48(%rsp)
leaq 0x117(%rsp), %rdi
movq %rdi, 0x50(%rsp)
callq 0x4600
movq 0x50(%rsp), %rdx
leaq 0x1dec1(%rip), %rsi     # 0x51568
leaq 0x118(%rsp), %rdi
callq 0x4f10
jmp 0x336b6
movq 0x1f0(%rsp), %rsi
addq $0x10, %rsi
leaq 0xf0(%rsp), %rdi
callq 0x4180
jmp 0x336d1
leaq 0xcf(%rsp), %rdi
movq %rdi, 0x40(%rsp)
callq 0x4600
movq 0x40(%rsp), %rdx
leaq 0x1da2c(%rip), %rsi     # 0x5111b
leaq 0xd0(%rsp), %rdi
callq 0x4f10
jmp 0x336fe
leaq 0x138(%rsp), %rdi
leaq 0x118(%rsp), %rsi
leaq 0xf0(%rsp), %rdx
leaq 0xd0(%rsp), %rcx
callq 0xd3b0
jmp 0x33725
movq 0x48(%rsp), %rdi
leaq 0x138(%rsp), %rsi
callq 0xd380
jmp 0x33739
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 0x200(%rsp), %rax
movq %rax, 0x20(%rsp)
movq 0x208(%rsp), %rax
movq %rax, 0x28(%rsp)
movq 0x1f0(%rsp), %rax
movq %rax, 0x30(%rsp)
movq 0x1f8(%rsp), %rsi
addq $0x20, %rsi
leaq 0xa8(%rsp), %rdi
movq %rdi, 0x38(%rsp)
callq 0x4180
movq 0x58(%rsp), %rdi
movq 0x20(%rsp), %rsi
movq 0x28(%rsp), %rdx
movq 0x30(%rsp), %rcx
movq 0x38(%rsp), %r8
callq 0x37870
jmp 0x337ec
leaq 0xa8(%rsp), %rdi
callq 0x46e8
movq 0x58(%rsp), %rdi
callq 0xdde0
movq %rax, 0x8(%rsp)
movq 0x1f8(%rsp), %rsi
addq $0x20, %rsi
leaq 0x88(%rsp), %rdi
movq %rdi, 0x10(%rsp)
callq 0x4180
movq 0x8(%rsp), %rdi
movq 0x10(%rsp), %rsi
callq 0x20600
movb %al, 0x1f(%rsp)
jmp 0x3383b
movb 0x1f(%rsp), %cl
xorl %eax, %eax
testb $0x1, %cl
movb %al, 0x7(%rsp)
jne 0x3384c
jmp 0x3385b
movq 0x58(%rsp), %rax
movb 0xd0(%rax), %al
movb %al, 0x7(%rsp)
movb 0x7(%rsp), %al
movb %al, 0x6(%rsp)
leaq 0x88(%rsp), %rdi
callq 0x46e8
movb 0x6(%rsp), %al
testb $0x1, %al
jne 0x3387d
jmp 0x339e0
movq 0x1f0(%rsp), %rdi
addq $0x30, %rdi
leaq 0x1d88b(%rip), %rsi     # 0x5111b
callq 0x44a0
movq 0x1f0(%rsp), %rax
movl $0x0, (%rax)
jmp 0x339e0
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x1a8(%rsp)
movl %eax, 0x1a4(%rsp)
leaq 0x1b0(%rsp), %rdi
callq 0xd9c0
leaq 0x1d0(%rsp), %rdi
callq 0x46e8
jmp 0x339e8
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x1a8(%rsp)
movl %eax, 0x1a4(%rsp)
jmp 0x3398b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x1a8(%rsp)
movl %eax, 0x1a4(%rsp)
jmp 0x3397e
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x1a8(%rsp)
movl %eax, 0x1a4(%rsp)
jmp 0x33964
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x1a8(%rsp)
movl %eax, 0x1a4(%rsp)
jmp 0x33957
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x1a8(%rsp)
movl %eax, 0x1a4(%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 0x339e8
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x1a8(%rsp)
movl %eax, 0x1a4(%rsp)
leaq 0xa8(%rsp), %rdi
callq 0x46e8
jmp 0x339e8
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x1a8(%rsp)
movl %eax, 0x1a4(%rsp)
leaq 0x88(%rsp), %rdi
callq 0x46e8
jmp 0x339e8
addq $0x218, %rsp            # imm = 0x218
retq
movq 0x1a8(%rsp), %rdi
callq 0x45f0
nopw %cs:(%rax,%rax)