// File: /workspace/github_c_makefile_star2_O0/Oric4ever[P]lcc65/6502/build/../src/gen.c
// Function: tmpalloc
static void tmpalloc(Node p) {
    Node left = p->kids[0], right = p->kids[1];
    p->x.optimized=0;
    p->x.name="*******";
    p->x.adrmode='*';
    releasetmp(left); releasetmp(right);

    switch (generic(p->op)) {
    case ARG:
        p->x.argoffset = argoffset;
        argoffset += p->syms[0]->u.c.v.i;
        break;
    case CALL:
        p->x.argoffset = argoffset;
        p->x.busy      = busy;
        argoffset = 0;
        break;
    case ASGN:
        if (optimizelevel>=3) {
        /* these conditions must be true to optimize (=get rid of) an ASGN node:
         * - it gets its value (right child node) from a temporary variable,
         * - the right child child has not been eliminated (optimized)
         * - the ASGN node comes just after its right child node
         *   (TODO: could it be more general? => re-ordering ?)
         * - the left value is de-referenceable,
         * - and the temporary variable is not used afterwards,
         *
         * In this case, we try to directly assign the result inside the right child node
         * (as the result of this child node)
         */
            if (optype(p->op)!=B        // no optimization on ASGNB (struct) nodes
                && !right->x.optimized
                && p==right->x.next
                && is_temporary(right->x.result)
                && is_dereferenceable(left->x.adrmode)
                && right->count==0
                )
            {
                p->x.optimized     = 1;
                right->x.result    = left->x.result;
                right->x.name      = left->x.name;
                right->x.adrmode   = dereference(left->x.adrmode);
            }
        }
        break;
    }
    if (needtmp(p)) gettmp(p);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rax
movq 0x20(%rax), %rax
movq %rax, -0x10(%rbp)
movq -0x8(%rbp), %rax
movq 0x28(%rax), %rax
movq %rax, -0x18(%rbp)
movq -0x8(%rbp), %rax
movb $0x0, 0x60(%rax)
movq -0x8(%rbp), %rax
leaq 0x8d9e(%rip), %rcx      # 0x34405
movq %rcx, 0x38(%rax)
movq -0x8(%rbp), %rax
movb $0x2a, 0x40(%rax)
movq -0x10(%rbp), %rdi
callq 0x2d3b0
movq -0x18(%rbp), %rdi
callq 0x2d3b0
movq -0x8(%rbp), %rax
movl (%rax), %eax
andl $-0x10, %eax
movl %eax, -0x1c(%rbp)
subl $0x20, %eax
je 0x2b6b1
jmp 0x2b698
movl -0x1c(%rbp), %eax
subl $0x30, %eax
je 0x2b703
jmp 0x2b6a2
movl -0x1c(%rbp), %eax
subl $0xd0, %eax
je 0x2b6da
jmp 0x2b7af
movl 0x19255(%rip), %ecx     # 0x4490c
movq -0x8(%rbp), %rax
movl %ecx, 0x50(%rax)
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rax
movl 0x48(%rax), %eax
addl 0x1923d(%rip), %eax     # 0x4490c
movl %eax, 0x19237(%rip)     # 0x4490c
jmp 0x2b7af
movl 0x1922c(%rip), %ecx     # 0x4490c
movq -0x8(%rbp), %rax
movl %ecx, 0x50(%rax)
movl 0x19213(%rip), %ecx     # 0x44900
movq -0x8(%rbp), %rax
movl %ecx, 0x54(%rax)
movl $0x0, 0x1920e(%rip)     # 0x4490c
jmp 0x2b7af
cmpl $0x3, 0x1021a(%rip)     # 0x3b924
jl 0x2b7ad
movq -0x8(%rbp), %rax
movl (%rax), %eax
andl $0xf, %eax
cmpl $0x9, %eax
je 0x2b7ab
movq -0x18(%rbp), %rax
cmpb $0x0, 0x60(%rax)
jne 0x2b7ab
movq -0x8(%rbp), %rax
movq -0x18(%rbp), %rcx
cmpq 0x58(%rcx), %rax
jne 0x2b7ab
movq -0x18(%rbp), %rax
movq 0x48(%rax), %rdi
callq 0x2d500
testb $0x1, %al
jne 0x2b74d
jmp 0x2b7ab
movq -0x10(%rbp), %rax
movsbl 0x40(%rax), %edi
callq 0x2d550
testb $0x1, %al
jne 0x2b760
jmp 0x2b7ab
movq -0x18(%rbp), %rax
movswl 0x4(%rax), %eax
cmpl $0x0, %eax
jne 0x2b7ab
movq -0x8(%rbp), %rax
movb $0x1, 0x60(%rax)
movq -0x10(%rbp), %rax
movq 0x48(%rax), %rcx
movq -0x18(%rbp), %rax
movq %rcx, 0x48(%rax)
movq -0x10(%rbp), %rax
movq 0x38(%rax), %rcx
movq -0x18(%rbp), %rax
movq %rcx, 0x38(%rax)
movq -0x10(%rbp), %rax
movsbl 0x40(%rax), %edi
callq 0x2d5a0
movb %al, %cl
movq -0x18(%rbp), %rax
movb %cl, 0x40(%rax)
jmp 0x2b7ad
jmp 0x2b7af
movq -0x8(%rbp), %rdi
callq 0x2d630
cmpl $0x0, %eax
je 0x2b7c6
movq -0x8(%rbp), %rdi
callq 0x2d8f0
addq $0x20, %rsp
popq %rbp
retq
nopl (%rax)