// File: /workspace/github_c_makefile_star2_O1/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 0x6c79
movl %edx, %r14d
movq %rsi, %r15
movl (%rsi), %eax
decl %eax
cmpl $0xc, %eax
ja 0x6e50
leaq 0x9692(%rip), %rcx      # 0x102cc
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq 0x10(%r15), %r15
movq (%r15), %r12
movq %r15, %rdi
callq 0x9f32
movl 0x8(%r15), %r8d
movq 0x18(%r15), %rcx
movq (%rcx), %r9
leaq 0x979a(%rip), %rsi      # 0x103fe
movq %rbx, %rdi
movq %r12, %rdx
movq %rax, %rcx
xorl %eax, %eax
callq 0x21e0
jmp 0x6e50
leaq 0x9774(%rip), %rdi      # 0x103f4
movl $0x6, %esi
movl $0x1, %edx
movq %rbx, %rcx
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
jmp 0x22d0
movl $0x3c, %edi
movq %rbx, %rsi
callq 0x2170
movq 0x10(%r15), %rsi
leal 0x4(%r14), %ebp
movq %rbx, %rdi
movl %ebp, %edx
callq 0x6c10
movl $0x26, %edi
jmp 0x6e2d
leaq 0x9751(%rip), %rdi      # 0x1041b
movl $0x3, %esi
jmp 0x6d96
movl $0x3c, %edi
movq %rbx, %rsi
callq 0x2170
movq 0x10(%r15), %rsi
leal 0x4(%r14), %ebp
movq %rbx, %rdi
movl %ebp, %edx
callq 0x6c10
movl $0x21, %edi
jmp 0x6e2d
movl $0x3c, %edi
movq %rbx, %rsi
callq 0x2170
movq 0x10(%r15), %rsi
leal 0x4(%r14), %ebp
movq %rbx, %rdi
movl %ebp, %edx
callq 0x6c10
movl $0x2a, %edi
jmp 0x6e2d
movzwl 0x10(%r15), %edx
leaq 0x96c9(%rip), %rsi      # 0x103fb
movq %rbx, %rdi
xorl %eax, %eax
callq 0x21e0
jmp 0x6e50
movq 0x10(%r15), %rax
movq (%rax), %rdx
movl 0x8(%rax), %ecx
leaq 0x96b8(%rip), %rsi      # 0x1040a
movq %rbx, %rdi
xorl %eax, %eax
callq 0x21e0
jmp 0x6e50
movl $0x3c, %edi
movq %rbx, %rsi
callq 0x2170
movq 0x10(%r15), %rsi
leal 0x4(%r14), %ebp
movq %rbx, %rdi
movl %ebp, %edx
callq 0x6c10
movl $0x2b, %edi
jmp 0x6e2d
leaq 0x968e(%rip), %rdi      # 0x1041f
movl $0x2, %esi
movl $0x1, %edx
movq %rbx, %rcx
callq 0x22d0
jmp 0x6dd6
leaq 0x9676(%rip), %rdi      # 0x10422
movl $0x12, %esi
movl $0x1, %edx
movq %rbx, %rcx
callq 0x22d0
cmpq $0x0, 0x10(%r15)
je 0x6e50
movl $0x3c, %edi
movq %rbx, %rsi
callq 0x2170
movq 0x10(%r15), %rsi
leal 0x4(%r14), %edx
movq %rbx, %rdi
jmp 0x6e3e
movl $0x3c, %edi
movq %rbx, %rsi
callq 0x2170
movq 0x10(%r15), %rsi
leal 0x4(%r14), %ebp
movq %rbx, %rdi
movl %ebp, %edx
callq 0x6c10
movl $0x2f, %edi
jmp 0x6e2d
movl $0x3c, %edi
movq %rbx, %rsi
callq 0x2170
movq 0x10(%r15), %rsi
leal 0x4(%r14), %ebp
movq %rbx, %rdi
movl %ebp, %edx
callq 0x6c10
movl $0x2d, %edi
movq %rbx, %rsi
callq 0x2170
movq 0x18(%r15), %rsi
movq %rbx, %rdi
movl %ebp, %edx
callq 0x6c10
movl $0x3e, %edi
movq %rbx, %rsi
callq 0x2170
testl %r14d, %r14d
je 0x6e5e
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
movl $0xa, %edi
movq %rbx, %rsi
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
jmp 0x2170