// File: /workspace/github_c_makefile_star2_O2/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 %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x50, %rsp
movq %rdi, %rbx
leaq 0xdaf2(%rip), %r12      # 0x1bfa8
movq (%r12), %rdi
pushq $0x1
popq %rbp
movl %ebp, %esi
callq 0x11e9b
movq %rax, %r15
leaq 0x4(%rbx), %r14
cmpq (%r12), %r15
je 0xe4f8
movq 0x20(%r15), %rdi
addq $0x10, %rdi
movq %r14, %rsi
callq 0x9120
testl %eax, %eax
je 0xe5e3
movq %r15, %rdi
movl %ebp, %esi
callq 0x11ebc
movq %rax, %r15
jmp 0xe4cb
cmpl $0x0, 0x4c(%rbx)
leaq 0x4a34(%rip), %rax      # 0x12f37
leaq 0x4c02(%rip), %r15      # 0x1310c
cmoveq %rax, %r15
cmpl $0x0, 0x34(%rbx)
je 0xe52a
movl 0x38(%rbx), %eax
cmpl $0x61, %eax
je 0xe581
cmpl $0x62, %eax
jne 0xe58a
leaq 0x4a2c(%rip), %r12      # 0x12f54
jmp 0xe596
movl 0x2c(%rbx), %eax
testl %eax, %eax
jne 0xe542
xorl %eax, %eax
cmpl $0x0, 0x30(%rbx)
jne 0xe542
movl $0x1, 0x2c(%rbx)
movl %ebp, %eax
cltq
leaq 0xa5c5(%rip), %rcx      # 0x18b10
movq (%rcx,%rax,8), %rcx
leaq 0x49e9(%rip), %rsi      # 0x12f3f
movq %rsp, %rdi
movq %r14, %rdx
xorl %eax, %eax
callq 0x91b0
movq %r15, %rdi
callq 0xc471
leaq 0x49d3(%rip), %rdi      # 0x12f45
callq 0xc497
pushq $0x3
popq %rdi
callq 0xc3e5
jmp 0xe5db
leaq 0x49c3(%rip), %r12      # 0x12f4b
jmp 0xe596
leaq 0x49c8(%rip), %rdi      # 0x12f59
callq 0x11eec
movslq 0x2c(%rbx), %rax
leaq 0xa56f(%rip), %rcx      # 0x18b10
movq (%rcx,%rax,8), %rcx
movq 0x40(%rbx), %r8
leaq 0x49c8(%rip), %rsi      # 0x12f78
movq %rsp, %rdi
movq %r14, %rdx
xorl %eax, %eax
callq 0x91b0
movq %r15, %rdi
callq 0xc471
cmpl $0x62, 0x38(%rbx)
jne 0xe5d3
pushq $0x3
popq %rdi
callq 0xc3e5
movq %r12, %rdi
callq 0xc497
movq %rsp, %rdi
callq 0xc4c6
addq $0x50, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq