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

    CPLAssert( nType == DGNT_3DSURFACE_HEADER 
               || nType == DGNT_3DSOLID_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 solid header specific information in the structure.         */
/* -------------------------------------------------------------------- */
    psCH->totlength = nTotLength - 4;
    psCH->numelems = nNumElems;
    psCH->surftype = nSurfType;
    psCH->boundelms = nBoundElems;

/* -------------------------------------------------------------------- */
/*      Setup Raw data for the solid specific portion.                  */
/* -------------------------------------------------------------------- */
    psCore->raw_bytes = 42;

    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);
    psCore->raw_data[40] = (unsigned char) psCH->surftype;
    psCore->raw_data[41] = (unsigned char) psCH->boundelms - 1;

/* -------------------------------------------------------------------- */
/*      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
subq $0x18, %rsp
movl %ecx, %ebp
movl %edx, %r13d
movl %r9d, %r12d
movl %esi, %r14d
movl %r8d, %ebx
movq %rdi, 0x8(%rsp)
leaq 0x10(%rsp), %rax
movq $0x0, (%rax)
callq 0xb37c
movl $0x60, %edi
movl $0x1, %esi
callq 0x2d54
movq %rax, %r15
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(%r15)
movl $0x1, 0x18(%r15)
movl %r14d, 0x14(%r15)
leal -0x4(%rbx), %r14d
movl %r14d, 0x50(%r15)
movl %r12d, 0x54(%r15)
movl %r13d, 0x58(%r15)
movl %ebp, 0x5c(%r15)
movl $0x2a, 0x40(%r15)
movl $0x2a, %edi
movl $0x1, %esi
callq 0x2d54
movq %rax, 0x48(%r15)
movb %r14b, 0x24(%rax)
addl $0xfb, %ebx
testl %r14d, %r14d
cmovnsl %r14d, %ebx
movq 0x48(%r15), %rax
movb %bh, 0x25(%rax)
movq 0x48(%r15), %rax
movb %r12b, 0x26(%rax)
leal 0xff(%r12), %eax
testl %r12d, %r12d
cmovnsl %r12d, %eax
movq 0x48(%r15), %rcx
movb %ah, 0x27(%rcx)
movb 0x58(%r15), %al
movq 0x48(%r15), %rcx
movb %al, 0x28(%rcx)
movb 0x5c(%r15), %al
decb %al
movq 0x48(%r15), %rcx
movb %al, 0x29(%rcx)
movq %r15, %rsi
callq 0xc46f
movq 0x8(%rsp), %rdi
movq %r15, %rsi
movl $0x8, %edx
leaq 0x10(%rsp), %rcx
callq 0xdb97
movq %r15, %rax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq