// File: /workspace/github_c_makefile_star2_O1/Nico01[P]obj2asm/oreport.c
// Function: print_ext
void print_ext( ext_rec )
    EXT_T   *ext_rec;
{
    char            operand[80];
    char            *var_type;
    char            *label;
    int             type;
    NODE_T          *pub_node;
    PUB_T           *pub_rec;

    /*
    ** Make sure name doesn't already exist as a public symbol
    */
    pub_node = start( public_tree, RIGHT );
    while ( pub_node != public_tree ) {
        pub_rec = (PUB_T *)pub_node->data;
        if ( strcmp(pub_rec->name, ext_rec->name) == 0 ) {
            return;
        }
        pub_node = traverse( pub_node, RIGHT );
    }

    if ( ext_rec->scope ) {
        label = "";
    } else {
        label = ";Static";
    }

    if ( ext_rec->com_ext == 0 ) {
        if ( ext_rec->type == UNKNOWN && ext_rec->pos_abs == FALSE ) {
            ext_rec->type = NEAR;
        }
        sprintf( operand, "%s:%s", ext_rec->name, ext_type[ext_rec->type] );
        out_label( label );
        out_opcode( "EXTRN" );
        tab_seek(3);
        out_operand( operand );
    } else {
        switch( ext_rec->var_type ) {
            case 0x61:
                var_type = "COMM FAR";
                break;
            case 0x62:
                var_type = "COMM";
                break;
            default:
                fmt_error( "Unknown Communal Variable Type" );
                break;
        }
        type = ext_rec->type;

        sprintf( operand, "%s:%s:%ld", ext_rec->name, ext_type[type], 
                                                            ext_rec->size );
        out_label( label );
        if ( ext_rec->var_type == 0x62 ) {
            tab_seek(3);
        }
        out_opcode( var_type );
        out_operand( operand );
    }
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x58, %rsp
movq %rdi, %rbx
leaq 0xe417(%rip), %r12      # 0x1cfa8
movq (%r12), %rdi
movl $0x1, %esi
callq 0x127bd
cmpq (%r12), %rax
je 0xebda
movq %rax, %r14
leaq 0x4(%rbx), %r15
movq 0x20(%r14), %rdi
addq $0x10, %rdi
movq %r15, %rsi
callq 0x9120
testl %eax, %eax
je 0xeccb
movq %r14, %rdi
movl $0x1, %esi
callq 0x127da
movq %rax, %r14
cmpq (%r12), %rax
jne 0xebac
cmpl $0x0, 0x4c(%rbx)
leaq 0x5352(%rip), %rax      # 0x13f37
leaq 0x5520(%rip), %r14      # 0x1410c
cmoveq %rax, %r14
cmpl $0x0, 0x34(%rbx)
je 0xec0c
movl 0x38(%rbx), %eax
cmpl $0x61, %eax
je 0xec66
cmpl $0x62, %eax
jne 0xec6f
leaq 0x534a(%rip), %r15      # 0x13f54
jmp 0xec7b
cmpl $0x0, 0x2c(%rbx)
jne 0xec1f
cmpl $0x0, 0x30(%rbx)
jne 0xec1f
movl $0x1, 0x2c(%rbx)
movslq 0x2c(%rbx), %rax
addq $0x4, %rbx
leaq 0xaee2(%rip), %rcx      # 0x19b10
movq (%rcx,%rax,8), %rcx
leaq 0x5306(%rip), %rsi      # 0x13f3f
movq %rsp, %rdi
movq %rbx, %rdx
xorl %eax, %eax
callq 0x91b0
movq %r14, %rdi
callq 0xc982
leaq 0x52f0(%rip), %rdi      # 0x13f45
callq 0xc9aa
movl $0x3, %edi
callq 0xc8e7
jmp 0xecc3
leaq 0x52de(%rip), %r15      # 0x13f4b
jmp 0xec7b
leaq 0x52e3(%rip), %rdi      # 0x13f59
callq 0x12808
movslq 0x2c(%rbx), %rax
leaq 0x4(%rbx), %rdx
leaq 0xae86(%rip), %rcx      # 0x19b10
movq (%rcx,%rax,8), %rcx
movq 0x40(%rbx), %r8
leaq 0x52df(%rip), %rsi      # 0x13f78
movq %rsp, %rdi
xorl %eax, %eax
callq 0x91b0
movq %r14, %rdi
callq 0xc982
cmpl $0x62, 0x38(%rbx)
jne 0xecbb
movl $0x3, %edi
callq 0xc8e7
movq %r15, %rdi
callq 0xc9aa
movq %rsp, %rdi
callq 0xc9d9
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq