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

{
    unsigned char abyLinkage[32];
    int           nLinkageSize;

    if( nLinkageType == DGNLT_DMRS )
    {
        nLinkageSize = 8;
        abyLinkage[0] = 0x00;
        abyLinkage[1] = 0x00;
        abyLinkage[2] = (GByte) (nEntityNum % 256);
        abyLinkage[3] = (GByte) (nEntityNum / 256);
        abyLinkage[4] = (GByte) (nMSLink % 256);
        abyLinkage[5] = (GByte) ((nMSLink / 256) % 256);
        abyLinkage[6] = (GByte) (nMSLink / 65536);
        abyLinkage[7] = 0x01;
    }
    else
    {
        nLinkageSize = 16;
        abyLinkage[0] = 0x07;
        abyLinkage[1] = 0x10;
        abyLinkage[2] = (GByte) (nLinkageType % 256);
        abyLinkage[3] = (GByte) (nLinkageType / 256);
        abyLinkage[4] = (GByte) (0x81);
        abyLinkage[5] = (GByte) (0x0F);
        abyLinkage[6] = (GByte) (nEntityNum % 256);
        abyLinkage[7] = (GByte) (nEntityNum / 256);
        abyLinkage[8] = (GByte) (nMSLink % 256);
        abyLinkage[9] = (GByte) ((nMSLink / 256) % 256);
        abyLinkage[10] = (GByte) ((nMSLink / 65536) % 256);
        abyLinkage[11] = (GByte) (nMSLink / 16777216);
        abyLinkage[12] = 0x00;
        abyLinkage[13] = 0x00;
        abyLinkage[14] = 0x00;
        abyLinkage[15] = 0x00;
    }

    return DGNAddRawAttrLink( hDGN, psElement, nLinkageSize, abyLinkage );
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl %edx, -0x14(%rbp)
movl %ecx, -0x18(%rbp)
movl %r8d, -0x1c(%rbp)
cmpl $0x0, -0x14(%rbp)
jne 0x175dc
movl $0x8, -0x44(%rbp)
movb $0x0, -0x40(%rbp)
movb $0x0, -0x3f(%rbp)
movl -0x18(%rbp), %eax
movl $0x100, %ecx            # imm = 0x100
cltd
idivl %ecx
movb %dl, %al
movb %al, -0x3e(%rbp)
movl -0x18(%rbp), %eax
movl $0x100, %ecx            # imm = 0x100
cltd
idivl %ecx
movb %al, -0x3d(%rbp)
movl -0x1c(%rbp), %eax
movl $0x100, %ecx            # imm = 0x100
cltd
idivl %ecx
movb %dl, %al
movb %al, -0x3c(%rbp)
movl -0x1c(%rbp), %eax
movl $0x100, %ecx            # imm = 0x100
cltd
idivl %ecx
movl $0x100, %ecx            # imm = 0x100
cltd
idivl %ecx
movb %dl, %al
movb %al, -0x3b(%rbp)
movl -0x1c(%rbp), %eax
movl $0x10000, %ecx          # imm = 0x10000
cltd
idivl %ecx
movb %al, -0x3a(%rbp)
movb $0x1, -0x39(%rbp)
jmp 0x1768d
movl $0x10, -0x44(%rbp)
movb $0x7, -0x40(%rbp)
movb $0x10, -0x3f(%rbp)
movl -0x14(%rbp), %eax
movl $0x100, %ecx            # imm = 0x100
cltd
idivl %ecx
movb %dl, %al
movb %al, -0x3e(%rbp)
movl -0x14(%rbp), %eax
movl $0x100, %ecx            # imm = 0x100
cltd
idivl %ecx
movb %al, -0x3d(%rbp)
movb $-0x7f, -0x3c(%rbp)
movb $0xf, -0x3b(%rbp)
movl -0x18(%rbp), %eax
movl $0x100, %ecx            # imm = 0x100
cltd
idivl %ecx
movb %dl, %al
movb %al, -0x3a(%rbp)
movl -0x18(%rbp), %eax
movl $0x100, %ecx            # imm = 0x100
cltd
idivl %ecx
movb %al, -0x39(%rbp)
movl -0x1c(%rbp), %eax
movl $0x100, %ecx            # imm = 0x100
cltd
idivl %ecx
movb %dl, %al
movb %al, -0x38(%rbp)
movl -0x1c(%rbp), %eax
movl $0x100, %ecx            # imm = 0x100
cltd
idivl %ecx
movl $0x100, %ecx            # imm = 0x100
cltd
idivl %ecx
movb %dl, %al
movb %al, -0x37(%rbp)
movl -0x1c(%rbp), %eax
movl $0x10000, %ecx          # imm = 0x10000
cltd
idivl %ecx
movl $0x100, %ecx            # imm = 0x100
cltd
idivl %ecx
movb %dl, %al
movb %al, -0x36(%rbp)
movl -0x1c(%rbp), %eax
movl $0x1000000, %ecx        # imm = 0x1000000
cltd
idivl %ecx
movb %al, -0x35(%rbp)
movb $0x0, -0x34(%rbp)
movb $0x0, -0x33(%rbp)
movb $0x0, -0x32(%rbp)
movb $0x0, -0x31(%rbp)
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movl -0x44(%rbp), %edx
leaq -0x40(%rbp), %rcx
callq 0x15fb0
addq $0x50, %rsp
popq %rbp
retq
nopw (%rax,%rax)