// File: /workspace/github_cpp_makefile_star2_O2/sighingnow[P]compile-pascal/pl0_tac_gen.cpp
// Function: pl0_tac_assign_stmt(pl0_ast_assign_stmt const*)
void pl0_tac_assign_stmt(pl0_ast_assign_stmt const *stmt) {
    variable var;
    Value *val = pl0_tac_expr(stmt->val).first;
    if (stmt->idx == nullptr && functb.depth(stmt->id->id) > vartb.depth(stmt->id->id)) {
        // set function's retval
        func f;
        if (functb.find(stmt->id->id, true, f) == false) {
            pl0_ast_error(stmt->id->loc, string("use of undeclared function ") + "\"" + stmt->id->id + "\"");
        }
        irb.emit("=", new Value(f.name, f.rettype), val);
    }
    else {
        // just simple assign.
        if (stmt->id->id.front() == '^') {
            pl0_ast_error(stmt->id->loc, string("illegal assign to loop variable"));
        }
        if (vartb.find(stmt->id->id, true, var) == false) {
            pl0_ast_error(stmt->id->loc, string("use of undeclared identifier ") + "\"" + stmt->id->id + "\"");
        }
        // assign to array element.
        if (stmt->idx) {
            if (var.len == -1) {
                pl0_ast_error(stmt->id->loc, string("treat ordinary variable ") + "\"" + stmt->id->id + "\" as an array");
            }
            Value *idx = pl0_tac_expr(stmt->idx).first;
            irb.emit("[]=", new Value(stmt->id->id, var.dt), idx, val);
        }
        // assign to variable.
        else {
            if (var.len != -1) {
                pl0_ast_error(stmt->id->loc, string("expected an non-array identifier ") + "\"" + stmt->id->id + "\"");
            }
            irb.emit("=", new Value(stmt->id->id, var.dt), val);
        }
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x2f0, %rsp            # imm = 0x2F0
movq %rdi, %r14
leaq 0x288(%rsp), %rdi
callq 0x472c8
movq 0x28(%r14), %rsi
leaq 0x50(%rsp), %rdi
callq 0x44859
leaq 0x58(%rsp), %rdi
movq -0x8(%rdi), %rbx
callq 0x5120
cmpq $0x0, 0x20(%r14)
jne 0x4019d
movq 0x18(%r14), %rsi
addq $0x8, %rsi
leaq 0x4c6bc(%rip), %rdi     # 0x8c6a8
callq 0x47324
movl %eax, %ebp
movq 0x18(%r14), %rsi
addq $0x8, %rsi
leaq 0x4c616(%rip), %rdi     # 0x8c618
callq 0x47422
cmpl %eax, %ebp
jle 0x4019d
leaq 0x50(%rsp), %rdi
callq 0x47520
movq 0x18(%r14), %rsi
addq $0x8, %rsi
leaq 0x4c680(%rip), %rdi     # 0x8c6a8
pushq $0x1
popq %rdx
leaq 0x50(%rsp), %rcx
callq 0x47574
testb %al, %al
jne 0x400e4
movq 0x18(%r14), %rax
movq (%rax), %r15
leaq 0x1a9cc(%rip), %rsi     # 0x5aa17
leaq 0xa8(%rsp), %rdi
leaq 0xf(%rsp), %rdx
callq 0xfa26
leaq 0x1afbf(%rip), %rdx     # 0x5b023
leaq 0x30(%rsp), %rdi
leaq 0xa8(%rsp), %rsi
callq 0xfd14
movq 0x18(%r14), %rdx
addq $0x8, %rdx
leaq 0x10(%rsp), %rdi
leaq 0x30(%rsp), %rsi
callq 0xfda4
leaq 0x1af8f(%rip), %rdx     # 0x5b023
leaq 0x268(%rsp), %rdi
leaq 0x10(%rsp), %rsi
callq 0xfd14
leaq 0x268(%rsp), %rsi
movq %r15, %rdi
callq 0x3da88
leaq 0x268(%rsp), %rdi
callq 0x5120
leaq 0x10(%rsp), %rdi
callq 0x5120
leaq 0x30(%rsp), %rdi
callq 0x5120
leaq 0xa8(%rsp), %rdi
callq 0x5120
leaq 0x1902d(%rip), %rsi     # 0x59118
leaq 0x248(%rsp), %rdi
leaq 0x10(%rsp), %rdx
callq 0xfa26
pushq $0x48
popq %rdi
callq 0x5260
movq %rax, %r14
leaq 0x228(%rsp), %rdi
leaq 0x50(%rsp), %rsi
callq 0x5340
leaq 0x70(%rsp), %rsi
leaq 0x208(%rsp), %rdi
callq 0x5340
movb $0x1, %r15b
leaq 0x228(%rsp), %rsi
leaq 0x208(%rsp), %rdx
movq %r14, %rdi
callq 0x46fc0
xorl %r15d, %r15d
leaq 0x4c47f(%rip), %rdi     # 0x8c5d0
leaq 0x248(%rsp), %rsi
movq %r14, %rdx
movq %rbx, %rcx
xorl %r8d, %r8d
callq 0x46a38
leaq 0x208(%rsp), %rdi
callq 0x5120
leaq 0x228(%rsp), %rdi
callq 0x5120
leaq 0x248(%rsp), %rdi
callq 0x5120
leaq 0x50(%rsp), %rdi
callq 0x4726c
jmp 0x4058e
movq 0x18(%r14), %rsi
movq 0x8(%rsi), %rax
cmpb $0x5e, (%rax)
jne 0x401e7
movq (%rsi), %r15
leaq 0x1a87f(%rip), %rsi     # 0x5aa33
leaq 0x1e8(%rsp), %rdi
leaq 0x50(%rsp), %rdx
callq 0xfa26
leaq 0x1e8(%rsp), %rsi
movq %r15, %rdi
callq 0x3da88
leaq 0x1e8(%rsp), %rdi
callq 0x5120
movq 0x18(%r14), %rsi
addq $0x8, %rsi
leaq 0x4c426(%rip), %rdi     # 0x8c618
pushq $0x1
popq %rdx
leaq 0x288(%rsp), %rcx
callq 0x47682
testb %al, %al
jne 0x402ab
movq 0x18(%r14), %rax
movq (%rax), %r15
leaq 0x1a83b(%rip), %rsi     # 0x5aa53
leaq 0x30(%rsp), %rdi
leaq 0xa8(%rsp), %rdx
callq 0xfa26
leaq 0x1adf2(%rip), %rdx     # 0x5b023
leaq 0x10(%rsp), %rdi
leaq 0x30(%rsp), %rsi
callq 0xfd14
movq 0x18(%r14), %rdx
addq $0x8, %rdx
leaq 0x50(%rsp), %rdi
leaq 0x10(%rsp), %rsi
callq 0xfda4
leaq 0x1adc5(%rip), %rdx     # 0x5b023
leaq 0x1c8(%rsp), %rdi
leaq 0x50(%rsp), %rsi
callq 0xfd14
leaq 0x1c8(%rsp), %rsi
movq %r15, %rdi
callq 0x3da88
leaq 0x1c8(%rsp), %rdi
callq 0x5120
leaq 0x50(%rsp), %rdi
callq 0x5120
leaq 0x10(%rsp), %rdi
callq 0x5120
leaq 0x30(%rsp), %rdi
callq 0x5120
movq 0x20(%r14), %rsi
movl 0x2e8(%rsp), %eax
testq %rsi, %rsi
je 0x40434
cmpl $-0x1, %eax
jne 0x4036d
movq 0x18(%r14), %rax
movq (%rax), %r15
leaq 0x1a79b(%rip), %rsi     # 0x5aa71
leaq 0x30(%rsp), %rdi
leaq 0xa8(%rsp), %rdx
callq 0xfa26
leaq 0x1ad34(%rip), %rdx     # 0x5b023
leaq 0x10(%rsp), %rdi
leaq 0x30(%rsp), %rsi
callq 0xfd14
movq 0x18(%r14), %rdx
addq $0x8, %rdx
leaq 0x50(%rsp), %rdi
leaq 0x10(%rsp), %rsi
callq 0xfda4
leaq 0x1a76e(%rip), %rdx     # 0x5aa8a
leaq 0x1a8(%rsp), %rdi
leaq 0x50(%rsp), %rsi
callq 0xfd14
leaq 0x1a8(%rsp), %rsi
movq %r15, %rdi
callq 0x3da88
leaq 0x1a8(%rsp), %rdi
callq 0x5120
leaq 0x50(%rsp), %rdi
callq 0x5120
leaq 0x10(%rsp), %rdi
callq 0x5120
leaq 0x30(%rsp), %rdi
callq 0x5120
movq 0x20(%r14), %rsi
leaq 0x50(%rsp), %rdi
callq 0x44859
leaq 0x58(%rsp), %rdi
movq -0x8(%rdi), %r12
callq 0x5120
leaq 0x1a70c(%rip), %rsi     # 0x5aa98
leaq 0x188(%rsp), %rdi
leaq 0x50(%rsp), %rdx
callq 0xfa26
pushq $0x48
popq %rdi
callq 0x5260
movq %rax, %r15
movq 0x18(%r14), %rsi
addq $0x8, %rsi
leaq 0x168(%rsp), %rdi
callq 0x5340
leaq 0x2a8(%rsp), %rsi
leaq 0x148(%rsp), %rdi
callq 0x5340
movb $0x1, %bpl
leaq 0x168(%rsp), %rsi
leaq 0x148(%rsp), %rdx
movq %r15, %rdi
callq 0x46fc0
xorl %ebp, %ebp
leaq 0x4c1d9(%rip), %rdi     # 0x8c5d0
leaq 0x188(%rsp), %rsi
movq %r15, %rdx
movq %r12, %rcx
movq %rbx, %r8
callq 0x46a38
leaq 0x148(%rsp), %rdi
callq 0x5120
leaq 0x168(%rsp), %rdi
callq 0x5120
leaq 0x188(%rsp), %rdi
jmp 0x40589
cmpl $-0x1, %eax
je 0x404de
movq 0x18(%r14), %rax
movq (%rax), %r15
leaq 0x1a651(%rip), %rsi     # 0x5aa9c
leaq 0x30(%rsp), %rdi
leaq 0xa8(%rsp), %rdx
callq 0xfa26
leaq 0x1abbf(%rip), %rdx     # 0x5b023
leaq 0x10(%rsp), %rdi
leaq 0x30(%rsp), %rsi
callq 0xfd14
movq 0x18(%r14), %rdx
addq $0x8, %rdx
leaq 0x50(%rsp), %rdi
leaq 0x10(%rsp), %rsi
callq 0xfda4
leaq 0x1ab92(%rip), %rdx     # 0x5b023
leaq 0x128(%rsp), %rdi
leaq 0x50(%rsp), %rsi
callq 0xfd14
leaq 0x128(%rsp), %rsi
movq %r15, %rdi
callq 0x3da88
leaq 0x128(%rsp), %rdi
callq 0x5120
leaq 0x50(%rsp), %rdi
callq 0x5120
leaq 0x10(%rsp), %rdi
callq 0x5120
leaq 0x30(%rsp), %rdi
callq 0x5120
leaq 0x18c33(%rip), %rsi     # 0x59118
leaq 0x108(%rsp), %rdi
leaq 0x50(%rsp), %rdx
callq 0xfa26
pushq $0x48
popq %rdi
callq 0x5260
movq %rax, %r15
movq 0x18(%r14), %rsi
addq $0x8, %rsi
leaq 0xe8(%rsp), %rdi
callq 0x5340
leaq 0x2a8(%rsp), %rsi
leaq 0xc8(%rsp), %rdi
callq 0x5340
movb $0x1, %r14b
leaq 0xe8(%rsp), %rsi
leaq 0xc8(%rsp), %rdx
movq %r15, %rdi
callq 0x46fc0
xorl %r14d, %r14d
leaq 0x4c07f(%rip), %rdi     # 0x8c5d0
leaq 0x108(%rsp), %rsi
movq %r15, %rdx
movq %rbx, %rcx
xorl %r8d, %r8d
callq 0x46a38
leaq 0xc8(%rsp), %rdi
callq 0x5120
leaq 0xe8(%rsp), %rdi
callq 0x5120
leaq 0x108(%rsp), %rdi
callq 0x5120
leaq 0x288(%rsp), %rdi
callq 0x46fa0
addq $0x2f0, %rsp            # imm = 0x2F0
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
leaq 0x268(%rsp), %rdi
callq 0x5120
jmp 0x405c0
movq %rax, %rbx
leaq 0x10(%rsp), %rdi
callq 0x5120
jmp 0x405cf
movq %rax, %rbx
leaq 0x30(%rsp), %rdi
callq 0x5120
jmp 0x405de
movq %rax, %rbx
leaq 0xa8(%rsp), %rdi
jmp 0x406b4
jmp 0x4060a
movq %rax, %rbx
movb $0x1, %r15b
jmp 0x4068f
movq %rax, %rbx
jmp 0x406a1
movq %rax, %rbx
jmp 0x406ac
jmp 0x4060a
movq %rax, %rbx
jmp 0x406b9
jmp 0x407aa
movq %rax, %rbx
leaq 0x128(%rsp), %rdi
jmp 0x406d3
movq %rax, %rbx
leaq 0x1a8(%rsp), %rdi
jmp 0x406d3
jmp 0x406da
jmp 0x406da
jmp 0x406e9
jmp 0x406e9
jmp 0x406f8
jmp 0x406f8
jmp 0x407aa
jmp 0x407aa
movq %rax, %rbx
movb $0x1, %r14b
jmp 0x40745
movq %rax, %rbx
jmp 0x40757
movq %rax, %rbx
jmp 0x40762
jmp 0x407aa
movq %rax, %rbx
leaq 0x208(%rsp), %rdi
callq 0x5120
leaq 0x228(%rsp), %rdi
callq 0x5120
testb %r15b, %r15b
je 0x406ac
pushq $0x48
popq %rsi
movq %r14, %rdi
callq 0x5270
leaq 0x248(%rsp), %rdi
callq 0x5120
leaq 0x50(%rsp), %rdi
callq 0x4726c
jmp 0x407ad
movq %rax, %rbx
leaq 0x1c8(%rsp), %rdi
callq 0x5120
jmp 0x406dd
movq %rax, %rbx
leaq 0x50(%rsp), %rdi
callq 0x5120
jmp 0x406ec
movq %rax, %rbx
leaq 0x10(%rsp), %rdi
callq 0x5120
jmp 0x406fb
movq %rax, %rbx
leaq 0x30(%rsp), %rdi
jmp 0x407a3
jmp 0x407aa
movq %rax, %rbx
leaq 0x1e8(%rsp), %rdi
jmp 0x407a3
jmp 0x407aa
movq %rax, %rbx
movb $0x1, %bpl
jmp 0x4077e
movq %rax, %rbx
jmp 0x40790
movq %rax, %rbx
jmp 0x4079b
jmp 0x407aa
jmp 0x407aa
movq %rax, %rbx
leaq 0xc8(%rsp), %rdi
callq 0x5120
leaq 0xe8(%rsp), %rdi
callq 0x5120
testb %r14b, %r14b
je 0x40762
pushq $0x48
popq %rsi
movq %r15, %rdi
callq 0x5270
leaq 0x108(%rsp), %rdi
jmp 0x407a3
jmp 0x407aa
movq %rax, %rbx
leaq 0x148(%rsp), %rdi
callq 0x5120
leaq 0x168(%rsp), %rdi
callq 0x5120
testb %bpl, %bpl
je 0x4079b
pushq $0x48
popq %rsi
movq %r15, %rdi
callq 0x5270
leaq 0x188(%rsp), %rdi
callq 0x5120
jmp 0x407ad
movq %rax, %rbx
leaq 0x288(%rsp), %rdi
callq 0x46fa0
movq %rbx, %rdi
callq 0x53f0