// File: /workspace/github_c_makefile_star2_O3/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 0xe3e3(%rip), %r12      # 0x1cfa8
movq (%r12), %rdi
movl $0x1, %esi
callq 0x1286f
cmpq (%r12), %rax
je 0xec0e
movq %rax, %r14
leaq 0x4(%rbx), %r15
movq 0x20(%r14), %rdi
addq $0x10, %rdi
movq %r15, %rsi
callq 0x9120
testl %eax, %eax
je 0xed05
movq %r14, %rdi
movl $0x1, %esi
callq 0x1288c
movq %rax, %r14
cmpq (%r12), %rax
jne 0xebe0
cmpl $0x0, 0x4c(%rbx)
leaq 0x531e(%rip), %rax      # 0x13f37
leaq 0x54ec(%rip), %r14      # 0x1410c
cmoveq %rax, %r14
cmpl $0x0, 0x34(%rbx)
je 0xec40
movl 0x38(%rbx), %eax
cmpl $0x61, %eax
je 0xeca0
cmpl $0x62, %eax
jne 0xeca9
leaq 0x5316(%rip), %r15      # 0x13f54
jmp 0xecb5
movl 0x2c(%rbx), %eax
testl %eax, %eax
jne 0xec5b
xorl %eax, %eax
cmpl $0x0, 0x30(%rbx)
jne 0xec5b
movl $0x1, 0x2c(%rbx)
movl $0x1, %eax
addq $0x4, %rbx
cltq
leaq 0xaea8(%rip), %rcx      # 0x19b10
movq (%rcx,%rax,8), %rcx
leaq 0x52cc(%rip), %rsi      # 0x13f3f
movq %rsp, %rdi
movq %rbx, %rdx
xorl %eax, %eax
callq 0x91b0
movq %r14, %rdi
callq 0xc9ee
leaq 0x52b6(%rip), %rdi      # 0x13f45
callq 0xca16
movl $0x3, %edi
callq 0xc959
jmp 0xecfd
leaq 0x52a4(%rip), %r15      # 0x13f4b
jmp 0xecb5
leaq 0x52a9(%rip), %rdi      # 0x13f59
callq 0x128bc
movslq 0x2c(%rbx), %rax
leaq 0x4(%rbx), %rdx
leaq 0xae4c(%rip), %rcx      # 0x19b10
movq (%rcx,%rax,8), %rcx
movq 0x40(%rbx), %r8
leaq 0x52a5(%rip), %rsi      # 0x13f78
movq %rsp, %rdi
xorl %eax, %eax
callq 0x91b0
movq %r14, %rdi
callq 0xc9ee
cmpl $0x62, 0x38(%rbx)
jne 0xecf5
movl $0x3, %edi
callq 0xc959
movq %r15, %rdi
callq 0xca16
movq %rsp, %rdi
callq 0xca45
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq