// File: /workspace/github_cpp_makefile_star2_O1/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, %r15d
movl %edx, %ebx
movl %esi, %ebp
movq %rdi, %r13
xorl %r14d, %r14d
movq %rsp, %rax
movq %r14, (%rax)
callq 0xb37c
movl $0x60, %edi
movl $0x1, %esi
callq 0x2d54
movq %rax, %r12
xorps %xmm0, %xmm0
movups %xmm0, (%rax)
movups %xmm0, 0x10(%rax)
movups %xmm0, 0x40(%rax)
movups %xmm0, 0x20(%rax)
movups %xmm0, 0x30(%rax)
movl $0xffffffff, (%rax)     # imm = 0xFFFFFFFF
movabsq $0x7ffffffff, %rax      # imm = 0x7FFFFFFFF
movq %rax, 0x8(%r12)
movl $0x1, 0x18(%r12)
movl %ebp, 0x14(%r12)
leal -0x4(%rbx), %ebp
movl %ebp, 0x50(%r12)
movl %r15d, 0x54(%r12)
movq %r14, 0x58(%r12)
movl $0x28, 0x40(%r12)
movl $0x28, %edi
movl $0x1, %esi
callq 0x2d54
movq %rax, 0x48(%r12)
movb %bpl, 0x24(%rax)
addl $0xfb, %ebx
testl %ebp, %ebp
cmovnsl %ebp, %ebx
movq 0x48(%r12), %rax
movb %bh, 0x25(%rax)
movq 0x48(%r12), %rax
movb %r15b, 0x26(%rax)
leal 0xff(%r15), %eax
testl %r15d, %r15d
cmovnsl %r15d, %eax
movq 0x48(%r12), %rcx
movb %ah, 0x27(%rcx)
movq %r12, %rsi
callq 0xc46f
movq %r13, %rdi
movq %r12, %rsi
movl $0x8, %edx
movq %rsp, %rcx
callq 0xdb97
movq %r12, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq