// File: rurban[P]dgnlib/dgnwrite.cpp
// Function: DGNUpdateElemCoreExtended
int DGNUpdateElemCoreExtended( DGNHandle hDGN, DGNElemCore *psElement )

{
    GByte *rd = psElement->raw_data;
    int   nWords = (psElement->raw_bytes / 2) - 2;

    if( psElement->raw_data == NULL 
        || psElement->raw_bytes < 36 )
    {
        CPLAssert( FALSE );
        return FALSE;
    }

/* -------------------------------------------------------------------- */
/*      Setup first four bytes.                                         */
/* -------------------------------------------------------------------- */
    rd[0] = (GByte) psElement->level;
    if( psElement->complex )
        rd[0] |= 0x80;

    rd[1] = (GByte) psElement->type;
    if( psElement->deleted )
        rd[1] |= 0x80;

    rd[2] = (GByte) (nWords % 256);
    rd[3] = (GByte) (nWords / 256);

/* -------------------------------------------------------------------- */
/*      If the attribute offset hasn't been set, set it now under       */
/*      the assumption it should point to the end of the element.       */
/* -------------------------------------------------------------------- */
    if( psElement->raw_data[30] == 0 && psElement->raw_data[31] == 0 )
    {
        int     nAttIndex = (psElement->raw_bytes - 32) / 2;
        
        psElement->raw_data[30] = (GByte) (nAttIndex % 256);
        psElement->raw_data[31] = (GByte) (nAttIndex / 256);
    }
/* -------------------------------------------------------------------- */
/*      Handle the graphic properties.                                  */
/* -------------------------------------------------------------------- */
    if( psElement->raw_bytes > 36 && DGNElemTypeHasDispHdr( psElement->type ) )
    {
        rd[28] = (GByte) (psElement->graphic_group % 256);
        rd[29] = (GByte) (psElement->graphic_group / 256);
        rd[32] = (GByte) (psElement->properties % 256);
        rd[33] = (GByte) (psElement->properties / 256);
        rd[34] = (GByte) (psElement->style | (psElement->weight << 3));
        rd[35] = (GByte) psElement->color;
    }
    
    return TRUE;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq -0x18(%rbp), %rax
movq 0x48(%rax), %rax
movq %rax, -0x20(%rbp)
movq -0x18(%rbp), %rax
movl 0x40(%rax), %eax
movl $0x2, %ecx
cltd
idivl %ecx
subl $0x2, %eax
movl %eax, -0x24(%rbp)
movq -0x18(%rbp), %rax
cmpq $0x0, 0x48(%rax)
je 0x12f96
movq -0x18(%rbp), %rax
cmpl $0x24, 0x40(%rax)
jge 0x12fa2
movl $0x0, -0x4(%rbp)
jmp 0x1313a
movq -0x18(%rbp), %rax
movl 0x10(%rax), %eax
movb %al, %cl
movq -0x20(%rbp), %rax
movb %cl, (%rax)
movq -0x18(%rbp), %rax
cmpl $0x0, 0x18(%rax)
je 0x12fca
movq -0x20(%rbp), %rax
movzbl (%rax), %ecx
orl $0x80, %ecx
movb %cl, (%rax)
movq -0x18(%rbp), %rax
movl 0x14(%rax), %eax
movb %al, %cl
movq -0x20(%rbp), %rax
movb %cl, 0x1(%rax)
movq -0x18(%rbp), %rax
cmpl $0x0, 0x1c(%rax)
je 0x12ff5
movq -0x20(%rbp), %rax
movzbl 0x1(%rax), %ecx
orl $0x80, %ecx
movb %cl, 0x1(%rax)
movl -0x24(%rbp), %eax
movl $0x100, %ecx            # imm = 0x100
cltd
idivl %ecx
movb %dl, %cl
movq -0x20(%rbp), %rax
movb %cl, 0x2(%rax)
movl -0x24(%rbp), %eax
movl $0x100, %ecx            # imm = 0x100
cltd
idivl %ecx
movb %al, %cl
movq -0x20(%rbp), %rax
movb %cl, 0x3(%rax)
movq -0x18(%rbp), %rax
movq 0x48(%rax), %rax
movzbl 0x1e(%rax), %eax
cmpl $0x0, %eax
jne 0x13084
movq -0x18(%rbp), %rax
movq 0x48(%rax), %rax
movzbl 0x1f(%rax), %eax
cmpl $0x0, %eax
jne 0x13084
movq -0x18(%rbp), %rax
movl 0x40(%rax), %eax
subl $0x20, %eax
movl $0x2, %ecx
cltd
idivl %ecx
movl %eax, -0x28(%rbp)
movl -0x28(%rbp), %eax
movl $0x100, %ecx            # imm = 0x100
cltd
idivl %ecx
movb %dl, %cl
movq -0x18(%rbp), %rax
movq 0x48(%rax), %rax
movb %cl, 0x1e(%rax)
movl -0x28(%rbp), %eax
movl $0x100, %ecx            # imm = 0x100
cltd
idivl %ecx
movb %al, %cl
movq -0x18(%rbp), %rax
movq 0x48(%rax), %rax
movb %cl, 0x1f(%rax)
movq -0x18(%rbp), %rax
cmpl $0x24, 0x40(%rax)
jle 0x13133
movq -0x18(%rbp), %rax
movl 0x14(%rax), %edi
callq 0x10970
cmpl $0x0, %eax
je 0x13133
movq -0x18(%rbp), %rax
movl 0x20(%rax), %eax
movl $0x100, %ecx            # imm = 0x100
cltd
idivl %ecx
movb %dl, %cl
movq -0x20(%rbp), %rax
movb %cl, 0x1c(%rax)
movq -0x18(%rbp), %rax
movl 0x20(%rax), %eax
movl $0x100, %ecx            # imm = 0x100
cltd
idivl %ecx
movb %al, %cl
movq -0x20(%rbp), %rax
movb %cl, 0x1d(%rax)
movq -0x18(%rbp), %rax
movl 0x24(%rax), %eax
movl $0x100, %ecx            # imm = 0x100
cltd
idivl %ecx
movb %dl, %cl
movq -0x20(%rbp), %rax
movb %cl, 0x20(%rax)
movq -0x18(%rbp), %rax
movl 0x24(%rax), %eax
movl $0x100, %ecx            # imm = 0x100
cltd
idivl %ecx
movb %al, %cl
movq -0x20(%rbp), %rax
movb %cl, 0x21(%rax)
movq -0x18(%rbp), %rax
movl 0x30(%rax), %eax
movq -0x18(%rbp), %rcx
movl 0x2c(%rcx), %ecx
shll $0x3, %ecx
orl %ecx, %eax
movb %al, %cl
movq -0x20(%rbp), %rax
movb %cl, 0x22(%rax)
movq -0x18(%rbp), %rax
movl 0x28(%rax), %eax
movb %al, %cl
movq -0x20(%rbp), %rax
movb %cl, 0x23(%rax)
movl $0x1, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x30, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)