// File: /workspace/github_c_makefile_star2_O2/simh[P]simtools/crossassemblers/macro11/extree.c
// Function: print_tree
void print_tree(
    FILE *printfile,
    EX_TREE *tp,
    int depth)
{
    SYMBOL         *sym;

    if (tp == NULL) {
        fprintf(printfile, "(null)");
        return;
    }

    switch (tp->type) {
    case EX_LIT:
        fprintf(printfile, "%o", tp->data.lit & 0177777);
        break;

    case EX_SYM:
    case EX_TEMP_SYM:
        sym = tp->data.symbol;
        fprintf(printfile, "%s{%s%o:%s}", tp->data.symbol->label, symflags(sym), sym->value,
                sym->section->label);
        break;

    case EX_UNDEFINED_SYM:
        fprintf(printfile, "%s{%o:undefined}", tp->data.symbol->label, tp->data.symbol->value);
        break;

    case EX_COM:
        fprintf(printfile, "^C<");
        print_tree(printfile, tp->data.child.left, depth + 4);
        fprintf(printfile, ">");
        break;

    case EX_NEG:
        fprintf(printfile, "-<");
        print_tree(printfile, tp->data.child.left, depth + 4);
        fputc('>', printfile);
        break;

    case EX_ERR:
        fprintf(printfile, "{expression error}");
        if (tp->data.child.left) {
            fputc('<', printfile);
            print_tree(printfile, tp->data.child.left, depth + 4);
            fputc('>', printfile);
        }
        break;

    case EX_ADD:
        fputc('<', printfile);
        print_tree(printfile, tp->data.child.left, depth + 4);
        fputc('+', printfile);
        print_tree(printfile, tp->data.child.right, depth + 4);
        fputc('>', printfile);
        break;

    case EX_SUB:
        fputc('<', printfile);
        print_tree(printfile, tp->data.child.left, depth + 4);
        fputc('-', printfile);
        print_tree(printfile, tp->data.child.right, depth + 4);
        fputc('>', printfile);
        break;

    case EX_MUL:
        fputc('<', printfile);
        print_tree(printfile, tp->data.child.left, depth + 4);
        fputc('*', printfile);
        print_tree(printfile, tp->data.child.right, depth + 4);
        fputc('>', printfile);
        break;

    case EX_DIV:
        fputc('<', printfile);
        print_tree(printfile, tp->data.child.left, depth + 4);
        fputc('/', printfile);
        print_tree(printfile, tp->data.child.right, depth + 4);
        fputc('>', printfile);
        break;

    case EX_AND:
        fputc('<', printfile);
        print_tree(printfile, tp->data.child.left, depth + 4);
        fputc('&', printfile);
        print_tree(printfile, tp->data.child.right, depth + 4);
        fputc('>', printfile);
        break;

    case EX_OR:
        fputc('<', printfile);
        print_tree(printfile, tp->data.child.left, depth + 4);
        fputc('!', printfile);
        print_tree(printfile, tp->data.child.right, depth + 4);
        fputc('>', printfile);
        break;
    }

    if (depth == 0)
        fputc('\n', printfile);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
movq %rdi, %rbx
testq %rsi, %rsi
je 0x6919
movl %edx, %r14d
movq %rsi, %r15
movl (%rsi), %eax
decl %eax
cmpl $0xc, %eax
ja 0x6abc
leaq 0x8a36(%rip), %rcx      # 0xf310
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq 0x10(%r15), %r15
movq (%r15), %r12
movq %r15, %rdi
callq 0x96be
movl 0x8(%r15), %r8d
movq 0x18(%r15), %rcx
movq (%rcx), %r9
leaq 0x8b1e(%rip), %rsi      # 0xf422
movq %rbx, %rdi
movq %r12, %rdx
movq %rax, %rcx
xorl %eax, %eax
callq 0x21e0
jmp 0x6abc
leaq 0x8af8(%rip), %rdi      # 0xf418
pushq $0x6
popq %rsi
pushq $0x1
popq %rdx
movq %rbx, %rcx
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
jmp 0x22d0
pushq $0x3c
popq %rdi
movq %rbx, %rsi
callq 0x2170
movq 0x10(%r15), %rsi
leal 0x4(%r14), %ebp
movq %rbx, %rdi
movl %ebp, %edx
callq 0x68b0
pushq $0x26
jmp 0x6a9a
leaq 0x8ade(%rip), %rdi      # 0xf43f
pushq $0x3
jmp 0x6a18
pushq $0x3c
popq %rdi
movq %rbx, %rsi
callq 0x2170
movq 0x10(%r15), %rsi
leal 0x4(%r14), %ebp
movq %rbx, %rdi
movl %ebp, %edx
callq 0x68b0
pushq $0x21
jmp 0x6a9a
pushq $0x3c
popq %rdi
movq %rbx, %rsi
callq 0x2170
movq 0x10(%r15), %rsi
leal 0x4(%r14), %ebp
movq %rbx, %rdi
movl %ebp, %edx
callq 0x68b0
pushq $0x2a
jmp 0x6a9a
movzwl 0x10(%r15), %edx
leaq 0x8a63(%rip), %rsi      # 0xf41f
movq %rbx, %rdi
xorl %eax, %eax
callq 0x21e0
jmp 0x6abc
movq 0x10(%r15), %rax
movq (%rax), %rdx
movl 0x8(%rax), %ecx
leaq 0x8a52(%rip), %rsi      # 0xf42e
movq %rbx, %rdi
xorl %eax, %eax
callq 0x21e0
jmp 0x6abc
pushq $0x3c
popq %rdi
movq %rbx, %rsi
callq 0x2170
movq 0x10(%r15), %rsi
leal 0x4(%r14), %ebp
movq %rbx, %rdi
movl %ebp, %edx
callq 0x68b0
pushq $0x2b
jmp 0x6a9a
leaq 0x8a2d(%rip), %rdi      # 0xf443
pushq $0x2
popq %rsi
pushq $0x1
popq %rdx
movq %rbx, %rcx
callq 0x22d0
jmp 0x6a4d
leaq 0x8a19(%rip), %rdi      # 0xf446
pushq $0x12
popq %rsi
pushq $0x1
popq %rdx
movq %rbx, %rcx
callq 0x22d0
cmpq $0x0, 0x10(%r15)
je 0x6abc
pushq $0x3c
popq %rdi
movq %rbx, %rsi
callq 0x2170
movq 0x10(%r15), %rsi
leal 0x4(%r14), %edx
movq %rbx, %rdi
jmp 0x6aac
pushq $0x3c
popq %rdi
movq %rbx, %rsi
callq 0x2170
movq 0x10(%r15), %rsi
leal 0x4(%r14), %ebp
movq %rbx, %rdi
movl %ebp, %edx
callq 0x68b0
pushq $0x2f
jmp 0x6a9a
pushq $0x3c
popq %rdi
movq %rbx, %rsi
callq 0x2170
movq 0x10(%r15), %rsi
leal 0x4(%r14), %ebp
movq %rbx, %rdi
movl %ebp, %edx
callq 0x68b0
pushq $0x2d
popq %rdi
movq %rbx, %rsi
callq 0x2170
movq 0x18(%r15), %rsi
movq %rbx, %rdi
movl %ebp, %edx
callq 0x68b0
pushq $0x3e
popq %rdi
movq %rbx, %rsi
callq 0x2170
testl %r14d, %r14d
je 0x6aca
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
pushq $0xa
popq %rdi
movq %rbx, %rsi
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
jmp 0x2170