// File: DoubleString[P]RtConverter/src/Rtklib/rt17.cpp
// Function: bamboo::DecodeGSOF(bamboo::raw_t*)
static int DecodeGSOF(raw_t *Raw)
{
    rt17_t *rt17 = (rt17_t*) Raw->rcv_data;
    int InputLength, Ret = 0;
    unsigned char RecordLength, RecordType, *p;
    char *RecordType_s = NULL;
 
   /*
    | Reassemble origional message by removing packet headers,
    | trailers and page framing.
    */
    UnwrapGenout(rt17);

    p = rt17->MessageBuffer;
    InputLength = rt17->MessageLength;

    while (InputLength)
    {
        RecordType = p[0];
        RecordLength = p[1];

        if (RecordType < (sizeof(GSOFTable) / sizeof(char*)))
            RecordType_s = (char*) GSOFTable[RecordType];

        if (!RecordType_s)
            RecordType_s = "Unknown";

        tracet(3, "RT17: Trimble packet type=0x40 (GENOUT), GSOF record type=%d (%s), Length=%d.\n", RecordType, RecordType_s, RecordLength);
      
        /* Process (or possibly ignore) the message */
        switch (RecordType)
        {
        case 1:
            Ret = DecodeGSOF1(Raw, p);
            break;
        case 3:
            Ret = DecodeGSOF3(Raw, p);
            break;
        case 15:
            Ret = DecodeGSOF15(Raw, p);
            break;
        case 16:
            Ret = DecodeGSOF16(Raw, p);
            break;
        case 26:
            Ret = DecodeGSOF26(Raw, p);
            break;
        case 41:
            Ret = DecodeGSOF41(Raw, p);
            break;
        default:
            tracet(3, "RT17: GSOF message not processed.\n");    
        }

        RecordLength += 2;
        p += RecordLength;
        InputLength -= RecordLength;
    }

    return Ret;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rax
movq 0x82ba0(%rax), %rax
movq %rax, -0x10(%rbp)
movl $0x0, -0x18(%rbp)
movq $0x0, -0x30(%rbp)
movq -0x10(%rbp), %rdi
callq 0x68b00
movq -0x10(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x28(%rbp)
movq -0x10(%rbp), %rax
movl 0x20(%rax), %eax
movl %eax, -0x14(%rbp)
cmpl $0x0, -0x14(%rbp)
je 0x68a6b
movq -0x28(%rbp), %rax
movb (%rax), %al
movb %al, -0x1a(%rbp)
movq -0x28(%rbp), %rax
movb 0x1(%rax), %al
movb %al, -0x19(%rbp)
movzbl -0x1a(%rbp), %eax
cmpq $0x2a, %rax
jae 0x68964
movzbl -0x1a(%rbp), %eax
movl %eax, %ecx
leaq 0x8f3f4(%rip), %rax     # 0xf7d50
movq (%rax,%rcx,8), %rax
movq %rax, -0x30(%rbp)
cmpq $0x0, -0x30(%rbp)
jne 0x68976
leaq 0x56f40(%rip), %rax     # 0xbf8b2
movq %rax, -0x30(%rbp)
movzbl -0x1a(%rbp), %edx
movq -0x30(%rbp), %rcx
movzbl -0x19(%rbp), %r8d
leaq 0x56f30(%rip), %rsi     # 0xbf8ba
xorl %eax, %eax
movl $0x3, %edi
callq 0x95890
movzbl -0x1a(%rbp), %eax
decl %eax
movl %eax, %ecx
movq %rcx, -0x38(%rbp)
subl $0x28, %eax
ja 0x68a2b
movq -0x38(%rbp), %rax
leaq 0x56afe(%rip), %rcx     # 0xbf4b4
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq -0x8(%rbp), %rdi
movq -0x28(%rbp), %rsi
callq 0x68bc0
movl %eax, -0x18(%rbp)
jmp 0x68a3e
movq -0x8(%rbp), %rdi
movq -0x28(%rbp), %rsi
callq 0x68c50
movl %eax, -0x18(%rbp)
jmp 0x68a3e
movq -0x8(%rbp), %rdi
movq -0x28(%rbp), %rsi
callq 0x68d40
movl %eax, -0x18(%rbp)
jmp 0x68a3e
movq -0x8(%rbp), %rdi
movq -0x28(%rbp), %rsi
callq 0x68dc0
movl %eax, -0x18(%rbp)
jmp 0x68a3e
movq -0x8(%rbp), %rdi
movq -0x28(%rbp), %rsi
callq 0x68e60
movl %eax, -0x18(%rbp)
jmp 0x68a3e
movq -0x8(%rbp), %rdi
movq -0x28(%rbp), %rsi
callq 0x68ef0
movl %eax, -0x18(%rbp)
jmp 0x68a3e
movl $0x3, %edi
leaq 0x56ed2(%rip), %rsi     # 0xbf909
movb $0x0, %al
callq 0x95890
movzbl -0x19(%rbp), %eax
addl $0x2, %eax
movb %al, -0x19(%rbp)
movzbl -0x19(%rbp), %ecx
movq -0x28(%rbp), %rax
movslq %ecx, %rcx
addq %rcx, %rax
movq %rax, -0x28(%rbp)
movzbl -0x19(%rbp), %ecx
movl -0x14(%rbp), %eax
subl %ecx, %eax
movl %eax, -0x14(%rbp)
jmp 0x68928
movl -0x18(%rbp), %eax
addq $0x40, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)