// File: rurban[P]dgnlib/cpl_conv.cpp
// Function: CPLDecToDMS
const char *CPLDecToDMS( double dfAngle, const char * pszAxis,
                         int nPrecision )

{
    int         nDegrees, nMinutes;
    double      dfSeconds, dfABSAngle, dfEpsilon;
    char        szFormat[30];
    static CPL_THREADLOCAL char szBuffer[50];
    const char  *pszHemisphere;
    
    dfEpsilon = (0.5/3600.0) * pow(0.1,nPrecision);

    dfABSAngle = ABS(dfAngle) + dfEpsilon;

    nDegrees = (int) dfABSAngle;
    nMinutes = (int) ((dfABSAngle - nDegrees) * 60);
    dfSeconds = dfABSAngle * 3600 - nDegrees*3600 - nMinutes*60;

    if( dfSeconds > dfEpsilon * 3600.0 )
        dfSeconds -= dfEpsilon * 3600.0;

    if( EQUAL(pszAxis,"Long") && dfAngle < 0.0 )
        pszHemisphere = "W";
    else if( EQUAL(pszAxis,"Long") )
        pszHemisphere = "E";
    else if( dfAngle < 0.0 )
        pszHemisphere = "S";
    else
        pszHemisphere = "N";

    sprintf( szFormat, "%%3dd%%2d\'%%.%df\"%s", nPrecision, pszHemisphere );
    sprintf( szBuffer, szFormat, nDegrees, nMinutes, dfSeconds );

    return( szBuffer );
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x70, %rsp
movsd %xmm0, -0x8(%rbp)
movq %rdi, -0x10(%rbp)
movl %esi, -0x14(%rbp)
movl -0x14(%rbp), %edi
movsd 0x14b59(%rip), %xmm0    # 0x19238
callq 0x5670
movaps %xmm0, %xmm1
movsd 0x14b41(%rip), %xmm0    # 0x19230
mulsd %xmm1, %xmm0
movsd %xmm0, -0x38(%rbp)
xorps %xmm0, %xmm0
ucomisd -0x8(%rbp), %xmm0
jbe 0x4716
movsd 0x14b36(%rip), %xmm0    # 0x19240
mulsd -0x8(%rbp), %xmm0
movsd %xmm0, -0x70(%rbp)
jmp 0x4720
movsd -0x8(%rbp), %xmm0
movsd %xmm0, -0x70(%rbp)
movsd -0x70(%rbp), %xmm0
addsd -0x38(%rbp), %xmm0
movsd %xmm0, -0x30(%rbp)
cvttsd2si -0x30(%rbp), %eax
movl %eax, -0x18(%rbp)
movsd -0x30(%rbp), %xmm0
cvtsi2sdl -0x18(%rbp), %xmm1
subsd %xmm1, %xmm0
movsd 0x14b03(%rip), %xmm1    # 0x19250
mulsd %xmm1, %xmm0
cvttsd2si %xmm0, %eax
movl %eax, -0x1c(%rbp)
movsd -0x30(%rbp), %xmm0
imull $0xe10, -0x18(%rbp), %eax # imm = 0xE10
cvtsi2sd %eax, %xmm1
movq %xmm1, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm1
movsd 0x14ac1(%rip), %xmm2    # 0x19248
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
imull $0x3c, -0x1c(%rbp), %eax
cvtsi2sd %eax, %xmm1
subsd %xmm1, %xmm0
movsd %xmm0, -0x28(%rbp)
movsd -0x28(%rbp), %xmm0
movsd 0x14a9b(%rip), %xmm1    # 0x19248
mulsd -0x38(%rbp), %xmm1
ucomisd %xmm1, %xmm0
jbe 0x47ee
movsd -0x38(%rbp), %xmm0
movsd -0x28(%rbp), %xmm1
movq %xmm0, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm0
movsd 0x14a67(%rip), %xmm2    # 0x19248
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, -0x28(%rbp)
movq -0x10(%rbp), %rdi
leaq 0x14c0f(%rip), %rsi     # 0x19408
callq 0x2300
cmpl $0x0, %eax
jne 0x481a
xorps %xmm0, %xmm0
ucomisd -0x8(%rbp), %xmm0
jbe 0x481a
leaq 0x151a8(%rip), %rax     # 0x199bc
movq %rax, -0x68(%rbp)
jmp 0x4862
movq -0x10(%rbp), %rdi
leaq 0x14be3(%rip), %rsi     # 0x19408
callq 0x2300
cmpl $0x0, %eax
jne 0x483c
leaq 0x15156(%rip), %rax     # 0x1998c
movq %rax, -0x68(%rbp)
jmp 0x4860
xorps %xmm0, %xmm0
ucomisd -0x8(%rbp), %xmm0
jbe 0x4853
leaq 0x15160(%rip), %rax     # 0x199ad
movq %rax, -0x68(%rbp)
jmp 0x485e
leaq 0x15147(%rip), %rax     # 0x199a1
movq %rax, -0x68(%rbp)
jmp 0x4860
jmp 0x4862
leaq -0x60(%rbp), %rdi
movl -0x14(%rbp), %edx
movq -0x68(%rbp), %rcx
leaq 0x14b99(%rip), %rsi     # 0x1940d
movb $0x0, %al
callq 0x20a0
leaq -0x60(%rbp), %rsi
movl -0x18(%rbp), %edx
movl -0x1c(%rbp), %ecx
movsd -0x28(%rbp), %xmm0
leaq 0x1ad7f(%rip), %rdi     # 0x1f610
movb $0x1, %al
callq 0x20a0
leaq 0x1ad71(%rip), %rax     # 0x1f610
addq $0x70, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)