// File: DoubleString[P]RtConverter/src/Rtklib/rt17.cpp
// Function: bamboo::DecodeIONAndUTCData(bamboo::raw_t*)
static int DecodeIONAndUTCData(raw_t *Raw)
{
    rt17_t *rt17 = (rt17_t*) Raw->rcv_data;
    int week;
    unsigned char *p = rt17->PacketBuffer;
    nav_t *nav = &Raw->nav;
    double *ion_gps = nav->ion_gps;
    double *utc_gps = nav->utc_gps;

    tracet(3, "RT17: DecodeIONAndUTCData, Length=%d.\n", rt17->PacketLength);

    if (rt17->PacketLength < 129)
    {
        tracet(2, "RT17: RETSVDATA packet length %d < 129 bytes. GPS ION / UTC data packet discarded.\n", rt17->PacketLength);
        return -1;
    }

    /* ION / UTC data does not have the current GPS week number. Punt! */
    week = GetWeek(Raw, 0.0);
 
    ion_gps[0] = R8(p+6);  /* 006-013: ALPHA 0 (seconds) */
    ion_gps[1] = R8(p+14); /* 014-021: ALPHA 1 (seconds/semi-circle) */
    ion_gps[2] = R8(p+22); /* 022-029: ALPHA 2 (seconds/semi-circle)^2 */ 
    ion_gps[3] = R8(p+30); /* 030-037: ALPHA 3 (seconds/semi-circle)^3 */
    ion_gps[4] = R8(p+38); /* 038-045: BETA 0  (seconds) */
    ion_gps[5] = R8(p+46); /* 046-053: BETA 1  (seconds/semi-circle) */
    ion_gps[6] = R8(p+54); /* 054-061: BETA 2  (seconds/semi-circle)^2 */
    ion_gps[7] = R8(p+62); /* 062-069: BETA 3  (seconds/semi-circle)^3 */
    utc_gps[0] = R8(p+70); /* 070-077: ASUB0   (seconds)*/ 
    utc_gps[1] = R8(p+78); /* 078-085: ASUB1   (seconds/seconds) */     
    utc_gps[2] = R8(p+86); /* 086-093: TSUB0T */ 
    utc_gps[3] = week;
    nav->leaps =(int) R8(p+94); /* 094-101: DELTATLS (seconds) */
    /* Unused by RTKLIB R8 */   /* 102-109: DELTATLSF */
    /* Unused by RTKLIB R8 */   /* 110-117: IONTIME */
    /* Unused by RTKLIB U1 */   /* 118-118: WNSUBT */
    /* Unused by RTKLIB U1 */   /* 119-119: WNSUBLSF */
    /* Unused by RTKLIB U1 */   /* 120-120: DN */
    /* Reserved six bytes */    /* 121-126: RESERVED */
   
   return 9;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x10(%rbp)
movq -0x10(%rbp), %rax
movq 0x82ba0(%rax), %rax
movq %rax, -0x18(%rbp)
movq -0x18(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x28(%rbp)
movq -0x10(%rbp), %rax
addq $0x1d40, %rax           # imm = 0x1D40
movq %rax, -0x30(%rbp)
movq -0x30(%rbp), %rax
addq $0x170, %rax            # imm = 0x170
movq %rax, -0x38(%rbp)
movq -0x30(%rbp), %rax
addq $0x90, %rax
movq %rax, -0x40(%rbp)
movq -0x18(%rbp), %rax
movl 0x28(%rax), %edx
movl $0x3, %edi
leaq 0x55c56(%rip), %rsi     # 0xc02fa
movb $0x0, %al
callq 0x95890
movq -0x18(%rbp), %rax
cmpl $0x81, 0x28(%rax)
jae 0x6a6de
movq -0x18(%rbp), %rax
movl 0x28(%rax), %edx
movl $0x2, %edi
leaq 0x55c56(%rip), %rsi     # 0xc0321
movb $0x0, %al
callq 0x95890
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x6a80d
movq -0x10(%rbp), %rdi
xorps %xmm0, %xmm0
callq 0x69b10
movl %eax, -0x1c(%rbp)
movq -0x28(%rbp), %rdi
addq $0x6, %rdi
callq 0x69120
movq -0x38(%rbp), %rax
movsd %xmm0, (%rax)
movq -0x28(%rbp), %rdi
addq $0xe, %rdi
callq 0x69120
movq -0x38(%rbp), %rax
movsd %xmm0, 0x8(%rax)
movq -0x28(%rbp), %rdi
addq $0x16, %rdi
callq 0x69120
movq -0x38(%rbp), %rax
movsd %xmm0, 0x10(%rax)
movq -0x28(%rbp), %rdi
addq $0x1e, %rdi
callq 0x69120
movq -0x38(%rbp), %rax
movsd %xmm0, 0x18(%rax)
movq -0x28(%rbp), %rdi
addq $0x26, %rdi
callq 0x69120
movq -0x38(%rbp), %rax
movsd %xmm0, 0x20(%rax)
movq -0x28(%rbp), %rdi
addq $0x2e, %rdi
callq 0x69120
movq -0x38(%rbp), %rax
movsd %xmm0, 0x28(%rax)
movq -0x28(%rbp), %rdi
addq $0x36, %rdi
callq 0x69120
movq -0x38(%rbp), %rax
movsd %xmm0, 0x30(%rax)
movq -0x28(%rbp), %rdi
addq $0x3e, %rdi
callq 0x69120
movq -0x38(%rbp), %rax
movsd %xmm0, 0x38(%rax)
movq -0x28(%rbp), %rdi
addq $0x46, %rdi
callq 0x69120
movq -0x40(%rbp), %rax
movsd %xmm0, (%rax)
movq -0x28(%rbp), %rdi
addq $0x4e, %rdi
callq 0x69120
movq -0x40(%rbp), %rax
movsd %xmm0, 0x8(%rax)
movq -0x28(%rbp), %rdi
addq $0x56, %rdi
callq 0x69120
movq -0x40(%rbp), %rax
movsd %xmm0, 0x10(%rax)
cvtsi2sdl -0x1c(%rbp), %xmm0
movq -0x40(%rbp), %rax
movsd %xmm0, 0x18(%rax)
movq -0x28(%rbp), %rdi
addq $0x5e, %rdi
callq 0x69120
cvttsd2si %xmm0, %ecx
movq -0x30(%rbp), %rax
movl %ecx, 0x290(%rax)
movl $0x9, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x40, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)