// File: /workspace/github_cpp_makefile_star2_O2/rurban[P]dgnlib/dgnwrite.cpp
// Function: DGNCreateComplexHeaderElem
DGNElemCore *
DGNCreateComplexHeaderElem( DGNHandle hDGN, int nType, 
                            int nTotLength, int nNumElems )
{
    DGNElemComplexHeader *psCH;
    DGNElemCore *psCore;
    unsigned char abyRawZeroLinkage[8] = {0,0,0,0,0,0,0,0};

    CPLAssert( nType == DGNT_COMPLEX_CHAIN_HEADER 
               || nType == DGNT_COMPLEX_SHAPE_HEADER );

    DGNLoadTCB( hDGN );

/* -------------------------------------------------------------------- */
/*      Allocate element.                                               */
/* -------------------------------------------------------------------- */
    psCH = (DGNElemComplexHeader *) 
        CPLCalloc( sizeof(DGNElemComplexHeader), 1 );
    psCore = &(psCH->core);

    DGNInitializeElemCore( hDGN, psCore );
    psCore->complex = TRUE;
    psCore->stype = DGNST_COMPLEX_HEADER;
    psCore->type = nType;

/* -------------------------------------------------------------------- */
/*      Set complex header specific information in the structure.       */
/* -------------------------------------------------------------------- */
    psCH->totlength = nTotLength - 4;
    psCH->numelems = nNumElems;
    psCH->surftype = 0;
    psCH->boundelms = 0;

/* -------------------------------------------------------------------- */
/*      Setup Raw data for the complex specific portion.                */
/* -------------------------------------------------------------------- */
    psCore->raw_bytes = 40;
    psCore->raw_data = (unsigned char*) CPLCalloc(psCore->raw_bytes,1);

    psCore->raw_data[36] = (unsigned char) ((nTotLength-4) % 256);
    psCore->raw_data[37] = (unsigned char) ((nTotLength-4) / 256);
    psCore->raw_data[38] = (unsigned char) (nNumElems % 256);
    psCore->raw_data[39] = (unsigned char) (nNumElems / 256);

/* -------------------------------------------------------------------- */
/*      Set the core raw data.                                          */
/* -------------------------------------------------------------------- */
    DGNUpdateElemCoreExtended( hDGN, psCore );

/* -------------------------------------------------------------------- */
/*      Elements have to be at least 48 bytes long, so we have to       */
/*      add a dummy bit of attribute data to fill out the length.       */
/* -------------------------------------------------------------------- */
    DGNAddRawAttrLink( hDGN, psCore, 8, abyRawZeroLinkage );
    
    return psCore;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movl %ecx, %ebp
movl %edx, %r12d
movl %esi, %r13d
movq %rdi, %r14
movq %rsp, %rax
andq $0x0, (%rax)
callq 0xa500
pushq $0x60
popq %rdi
pushq $0x1
popq %rbx
movq %rbx, %rsi
callq 0x2c6c
movq %rax, %r15
xorps %xmm0, %xmm0
movups %xmm0, (%rax)
movups %xmm0, 0x10(%rax)
movups %xmm0, 0x40(%rax)
movups %xmm0, 0x20(%rax)
orl $-0x1, (%rax)
movups %xmm0, 0x30(%rax)
movabsq $0x7ffffffff, %rax      # imm = 0x7FFFFFFFF
movq %rax, 0x8(%r15)
movl $0x1, 0x18(%r15)
movl %r13d, 0x14(%r15)
addl $-0x4, %r12d
movl %r12d, 0x50(%r15)
movl %ebp, 0x54(%r15)
andq $0x0, 0x58(%r15)
movl $0x28, 0x40(%r15)
pushq $0x28
popq %rdi
movq %rbx, %rsi
callq 0x2c6c
movq %rax, 0x48(%r15)
movb %r12b, 0x24(%rax)
movl $0x100, %ecx            # imm = 0x100
movl %r12d, %eax
cltd
idivl %ecx
movq 0x48(%r15), %rdx
movb %al, 0x25(%rdx)
movq 0x48(%r15), %rax
movb %bpl, 0x26(%rax)
movl %ebp, %eax
cltd
idivl %ecx
movq 0x48(%r15), %rcx
movb %al, 0x27(%rcx)
movq %r15, %rsi
callq 0xb380
pushq $0x8
popq %rdx
movq %r14, %rdi
movq %r15, %rsi
movq %rsp, %rcx
callq 0xc7b3
movq %r15, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq