// File: /workspace/github_c_makefile_star2_O0/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 %rbp
movq %rsp, %rbp
subq $0x60, %rsp
movq %rdi, -0x10(%rbp)
cmpq $0x0, -0x10(%rbp)
jne 0x1b750
movq $0x0, -0x8(%rbp)
jmp 0x1b9b5
movq -0x10(%rbp), %rax
movl (%rax), %eax
movq %rax, -0x28(%rbp)
subq $0x4, %rax
ja 0x1b95c
movq -0x28(%rbp), %rax
leaq 0x1c3c1(%rip), %rcx     # 0x37b30
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq -0x10(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0x1b9b5
movq -0x10(%rbp), %rax
cmpq $0x0, 0x30(%rax)
je 0x1b7a6
movq -0x10(%rbp), %rax
movq 0x30(%rax), %rdi
callq 0x1b730
movq %rax, -0x8(%rbp)
jmp 0x1b9b5
movq -0x10(%rbp), %rax
cmpq $0x0, 0x38(%rax)
je 0x1b7c7
movq -0x10(%rbp), %rax
movq 0x38(%rax), %rdi
callq 0x1b730
movq %rax, -0x8(%rbp)
jmp 0x1b9b5
jmp 0x1b7c9
movq 0x29828(%rip), %rax     # 0x44ff8
movq (%rax), %rax
movq %rax, -0x30(%rbp)
movq -0x10(%rbp), %rdi
callq 0x1b360
movq -0x30(%rbp), %rdi
movq %rax, %rdx
leaq 0x1c672(%rip), %rsi     # 0x37e60
movb $0x0, %al
callq 0x4190
jmp 0x1b9ad
movq -0x10(%rbp), %rax
movq %rax, -0x18(%rbp)
movq -0x18(%rbp), %rax
cmpq $0x0, 0x30(%rax)
je 0x1b823
movq -0x18(%rbp), %rax
movq 0x30(%rax), %rdi
callq 0x1b730
movq %rax, -0x8(%rbp)
jmp 0x1b9b5
movq -0x18(%rbp), %rax
cmpq $0x0, 0x38(%rax)
je 0x1b844
movq -0x18(%rbp), %rax
movq 0x38(%rax), %rdi
callq 0x1b730
movq %rax, -0x8(%rbp)
jmp 0x1b9b5
movq -0x18(%rbp), %rax
cmpq $0x0, 0x40(%rax)
je 0x1b865
movq -0x18(%rbp), %rax
movq 0x40(%rax), %rdi
callq 0x1b730
movq %rax, -0x8(%rbp)
jmp 0x1b9b5
jmp 0x1b867
jmp 0x1b869
movq 0x29788(%rip), %rax     # 0x44ff8
movq (%rax), %rax
movq %rax, -0x38(%rbp)
movq -0x10(%rbp), %rdi
callq 0x1b360
movq -0x38(%rbp), %rdi
movq %rax, %rdx
leaq 0x1c606(%rip), %rsi     # 0x37e94
movb $0x0, %al
callq 0x4190
jmp 0x1b9ad
movq -0x10(%rbp), %rax
movq %rax, -0x20(%rbp)
movq -0x20(%rbp), %rax
cmpq $0x0, 0x30(%rax)
je 0x1b8c3
movq -0x20(%rbp), %rax
movq 0x30(%rax), %rdi
callq 0x1b730
movq %rax, -0x8(%rbp)
jmp 0x1b9b5
movq -0x20(%rbp), %rax
cmpq $0x0, 0x38(%rax)
je 0x1b8e4
movq -0x20(%rbp), %rax
movq 0x38(%rax), %rdi
callq 0x1b730
movq %rax, -0x8(%rbp)
jmp 0x1b9b5
movq -0x20(%rbp), %rax
cmpq $0x0, 0x40(%rax)
je 0x1b905
movq -0x20(%rbp), %rax
movq 0x40(%rax), %rdi
callq 0x1b730
movq %rax, -0x8(%rbp)
jmp 0x1b9b5
movq -0x20(%rbp), %rax
cmpq $0x0, 0x48(%rax)
je 0x1b926
movq -0x20(%rbp), %rax
movq 0x48(%rax), %rdi
callq 0x1b730
movq %rax, -0x8(%rbp)
jmp 0x1b9b5
jmp 0x1b928
jmp 0x1b92a
jmp 0x1b92c
movq 0x296c5(%rip), %rax     # 0x44ff8
movq (%rax), %rax
movq %rax, -0x40(%rbp)
movq -0x10(%rbp), %rdi
callq 0x1b360
movq -0x40(%rbp), %rdi
movq %rax, %rdx
leaq 0x1c575(%rip), %rsi     # 0x37ec6
movb $0x0, %al
callq 0x4190
jmp 0x1b9ad
jmp 0x1b9ad
movq 0x29695(%rip), %rax     # 0x44ff8
movq (%rax), %rax
movq %rax, -0x58(%rbp)
leaq 0x297ff(%rip), %rax     # 0x45170
movq (%rax), %rax
movq %rax, -0x50(%rbp)
movq -0x10(%rbp), %rdi
callq 0x1b360
movq %rax, -0x48(%rbp)
movq -0x10(%rbp), %rax
movl (%rax), %edi
callq 0x1b9c0
movq -0x58(%rbp), %rdi
movq -0x50(%rbp), %rdx
movq -0x48(%rbp), %rcx
movq %rax, %r8
leaq 0x1c553(%rip), %rsi     # 0x37ef9
movb $0x0, %al
callq 0x4190
movq $0x0, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x60, %rsp
popq %rbp
retq
nop