// File: rurban[P]dgnlib/dgnread.cpp
// Function: DGNInverseTransformPointToInt(DGNInfo*, DGNPoint*, unsigned char*)
void DGNInverseTransformPointToInt( DGNInfo *psDGN, DGNPoint *psPoint,
                                    unsigned char *pabyTarget )

{
    double     adfCT[3];
    int        i;

    adfCT[0] = (psPoint->x + psDGN->origin_x) / psDGN->scale;
    adfCT[1] = (psPoint->y + psDGN->origin_y) / psDGN->scale;
    adfCT[2] = (psPoint->z + psDGN->origin_z) / psDGN->scale;

    for( i = 0; i < psDGN->dimension; i++ )
    {
        GInt32 nCTI;
        unsigned char *pabyCTI = (unsigned char *) &nCTI;

        nCTI = (GInt32) MAX(-2147483647,MIN(2147483647,adfCT[i]));
        
#ifdef WORDS_BIGENDIAN 
        pabyTarget[i*4+0] = pabyCTI[1];
        pabyTarget[i*4+1] = pabyCTI[0];
        pabyTarget[i*4+2] = pabyCTI[3];
        pabyTarget[i*4+3] = pabyCTI[2];
#else
        pabyTarget[i*4+3] = pabyCTI[1];
        pabyTarget[i*4+2] = pabyCTI[0];
        pabyTarget[i*4+1] = pabyCTI[3];
        pabyTarget[i*4+0] = pabyCTI[2];
#endif        
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq -0x10(%rbp), %rax
movsd (%rax), %xmm0
movq -0x8(%rbp), %rax
addsd 0x20028(%rax), %xmm0
movq -0x8(%rbp), %rax
divsd 0x20020(%rax), %xmm0
movsd %xmm0, -0x30(%rbp)
movq -0x10(%rbp), %rax
movsd 0x8(%rax), %xmm0
movq -0x8(%rbp), %rax
addsd 0x20030(%rax), %xmm0
movq -0x8(%rbp), %rax
divsd 0x20020(%rax), %xmm0
movsd %xmm0, -0x28(%rbp)
movq -0x10(%rbp), %rax
movsd 0x10(%rax), %xmm0
movq -0x8(%rbp), %rax
addsd 0x20038(%rax), %xmm0
movq -0x8(%rbp), %rax
divsd 0x20020(%rax), %xmm0
movsd %xmm0, -0x20(%rbp)
movl $0x0, -0x34(%rbp)
movl -0x34(%rbp), %eax
movq -0x8(%rbp), %rcx
cmpl 0x20018(%rcx), %eax
jge 0x1118c
leaq -0x38(%rbp), %rax
movq %rax, -0x40(%rbp)
movslq -0x34(%rbp), %rax
movsd -0x30(%rbp,%rax,8), %xmm0
movsd 0x8833(%rip), %xmm1     # 0x198b8
ucomisd %xmm1, %xmm0
jbe 0x1109a
movsd 0x8825(%rip), %xmm0     # 0x198b8
movsd %xmm0, -0x48(%rbp)
jmp 0x110a9
movslq -0x34(%rbp), %rax
movsd -0x30(%rbp,%rax,8), %xmm0
movsd %xmm0, -0x48(%rbp)
movsd -0x48(%rbp), %xmm1
movsd 0x92aa(%rip), %xmm0     # 0x1a360
ucomisd %xmm1, %xmm0
jbe 0x110cb
movsd 0x929c(%rip), %xmm0     # 0x1a360
movsd %xmm0, -0x50(%rbp)
jmp 0x1110b
movslq -0x34(%rbp), %rax
movsd -0x30(%rbp,%rax,8), %xmm0
movsd 0x87db(%rip), %xmm1     # 0x198b8
ucomisd %xmm1, %xmm0
jbe 0x110f2
movsd 0x87cd(%rip), %xmm0     # 0x198b8
movsd %xmm0, -0x58(%rbp)
jmp 0x11101
movslq -0x34(%rbp), %rax
movsd -0x30(%rbp,%rax,8), %xmm0
movsd %xmm0, -0x58(%rbp)
movsd -0x58(%rbp), %xmm0
movsd %xmm0, -0x50(%rbp)
movsd -0x50(%rbp), %xmm0
cvttsd2si %xmm0, %eax
movl %eax, -0x38(%rbp)
movq -0x40(%rbp), %rax
movb 0x1(%rax), %dl
movq -0x18(%rbp), %rax
movl -0x34(%rbp), %ecx
shll $0x2, %ecx
addl $0x3, %ecx
movslq %ecx, %rcx
movb %dl, (%rax,%rcx)
movq -0x40(%rbp), %rax
movb (%rax), %dl
movq -0x18(%rbp), %rax
movl -0x34(%rbp), %ecx
shll $0x2, %ecx
addl $0x2, %ecx
movslq %ecx, %rcx
movb %dl, (%rax,%rcx)
movq -0x40(%rbp), %rax
movb 0x3(%rax), %dl
movq -0x18(%rbp), %rax
movl -0x34(%rbp), %ecx
shll $0x2, %ecx
addl $0x1, %ecx
movslq %ecx, %rcx
movb %dl, (%rax,%rcx)
movq -0x40(%rbp), %rax
movb 0x2(%rax), %dl
movq -0x18(%rbp), %rax
movl -0x34(%rbp), %ecx
shll $0x2, %ecx
addl $0x0, %ecx
movslq %ecx, %rcx
movb %dl, (%rax,%rcx)
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
jmp 0x11058
popq %rbp
retq
nop