// File: /workspace/github_c_makefile_star2_O2/nimble-code[P]Modex/Src/tree.c
// Function: leftmost
leafnode *
leftmost(treenode *root)
{
    if_node *ifn;
    for_node *forn;

	if (!root) return (leafnode *) 0;

    switch (root->hdr.which){

    case LEAF_T:
        return((leafnode *) root);
        break;

    case NODE_T:
        if (root->lnode)
            return(leftmost(root->lnode));
        else if (root->rnode)
            return(leftmost(root->rnode));
        fprintf(stderr,
            "Tree node %s with no children reached in leftmost.\n",
                print_ptr(root));
        break;

    case IF_T:
        ifn = (if_node *) root;
        if (ifn->cond)
            return(leftmost(ifn->cond));
        else if (ifn->then_n)
            return(leftmost(ifn->then_n));
        else if (ifn->else_n)
            return(leftmost(ifn->else_n));
        fprintf(stderr,
            "If-node %s with no children reached in leftmost.\n",
                print_ptr(root));
        break;

    case FOR_T:
        forn = (for_node *) root;
        if (forn->init)
            return(leftmost(forn->init));
        else if (forn->test)
            return(leftmost(forn->test));
        else if (forn->incr)
            return(leftmost(forn->incr));
        else if (forn->stemnt)
            return(leftmost(forn->stemnt));
        fprintf(stderr,
            "For-node %s with no children reached in leftmost.\n",
                print_ptr(root));
        break;

    case NONE_T:
	break;

    default:
        fprintf(stderr, "%s: parse error: unknown node %s in leftmost; "
         "  type: %s\n", progname, print_ptr(root), name_of_nodetype(root->hdr.which));
        break;
    }

    return((leafnode *) NULL);
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
leaq 0x10223(%rip), %rax     # 0x24614
testq %rdi, %rdi
je 0x1448b
movq %rdi, %rbx
movl (%rdi), %ecx
cmpq $0x4, %rcx
ja 0x14496
movslq (%rax,%rcx,4), %rcx
addq %rax, %rcx
jmpq *%rcx
movq 0x30(%rbx), %rdi
testq %rdi, %rdi
jne 0x143f1
movq 0x38(%rbx), %rdi
testq %rdi, %rdi
jne 0x143f1
movq 0x40(%rbx), %rdi
testq %rdi, %rdi
jne 0x143f1
jmp 0x144f6
movq 0x30(%rbx), %rdi
testq %rdi, %rdi
jne 0x143f1
movq 0x38(%rbx), %rdi
testq %rdi, %rdi
jne 0x143f1
jmp 0x144db
movq 0x30(%rbx), %rdi
testq %rdi, %rdi
jne 0x143f1
movq 0x38(%rbx), %rdi
testq %rdi, %rdi
jne 0x143f1
movq 0x40(%rbx), %rdi
testq %rdi, %rdi
jne 0x143f1
movq 0x48(%rbx), %rdi
testq %rdi, %rdi
jne 0x143f1
movq 0x1fb84(%rip), %rax     # 0x33ff8
movq (%rax), %r14
movq %rbx, %rdi
callq 0x141e8
leaq 0x10480(%rip), %rsi     # 0x24906
jmp 0x1450f
xorl %ebx, %ebx
movq %rbx, %rax
popq %rbx
popq %r14
popq %r15
retq
movq 0x1fb5b(%rip), %rax     # 0x33ff8
movq (%rax), %r14
leaq 0x1fcf9(%rip), %rax     # 0x341a0
movq (%rax), %r15
movq %rbx, %rdi
callq 0x141e8
movl (%rbx), %edi
callq 0x14527
leaq 0x10479(%rip), %rsi     # 0x24939
leaq 0x31959(%rip), %rcx     # 0x45e20
xorl %ebx, %ebx
movq %r14, %rdi
movq %r15, %rdx
movq %rax, %r8
xorl %eax, %eax
callq 0x41c0
jmp 0x1448d
movq 0x1fb16(%rip), %rax     # 0x33ff8
movq (%rax), %r14
movq %rbx, %rdi
callq 0x141e8
leaq 0x103ac(%rip), %rsi     # 0x248a0
jmp 0x1450f
movq 0x1fafb(%rip), %rax     # 0x33ff8
movq (%rax), %r14
movq %rbx, %rdi
callq 0x141e8
leaq 0x103c5(%rip), %rsi     # 0x248d4
leaq 0x3190a(%rip), %rdx     # 0x45e20
xorl %ebx, %ebx
movq %r14, %rdi
xorl %eax, %eax
callq 0x41c0
jmp 0x1448d