// File: /workspace/github_cpp_makefile_star2_O3/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
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq 0x82ba0(%rdi), %rax
movl 0x20(%rax), %r13d
testl %r13d, %r13d
je 0x386cc
movq %rdi, -0x38(%rbp)
movq %rax, -0x40(%rbp)
movq (%rax), %r14
xorl %ecx, %ecx
movq %r14, %r12
movq %rcx, -0x30(%rbp)
movzbl 0x3(%r14), %ebx
leaq 0x6(%rbx), %rax
movq %rax, -0x48(%rbp)
leal -0x3(%rbx), %r15d
leaq 0x7(%r14), %rsi
movq %r12, %rdi
movq %r15, %rdx
callq 0x8a40
movq -0x30(%rbp), %rcx
addq %rbx, %r14
addq $0x6, %r14
addq %r15, %r12
addl %ebx, %ecx
addl $-0x3, %ecx
subl -0x48(%rbp), %r13d
jne 0x383d8
movq -0x40(%rbp), %rax
movl %ecx, 0x20(%rax)
movl %ecx, 0x1c(%rax)
testl %ecx, %ecx
je 0x386d3
movq (%rax), %r14
movq -0x38(%rbp), %rax
leaq 0x70db8(%rax), %rdx
movq %rdx, -0x48(%rbp)
addq $0x70e20, %rax          # imm = 0x70E20
movq %rax, -0x40(%rbp)
xorl %r13d, %r13d
movl $0x0, -0x30(%rbp)
movq %rcx, %rbx
movzbl (%r14), %r15d
cmpq $0x29, %r15
ja 0x38465
leaq 0x5523f(%rip), %rax     # 0x8d6a0
movq (%rax,%r15,8), %r13
movzbl 0x1(%r14), %r12d
testq %r13, %r13
leaq 0x351ee(%rip), %rax     # 0x6d662
cmoveq %rax, %r13
movl $0x3, %edi
leaq 0x351e6(%rip), %rsi     # 0x6d66a
movl %r15d, %edx
movq %r13, %rcx
movl %r12d, %r8d
xorl %eax, %eax
callq 0x5342c
cmpl $0xf, %r15d
jg 0x384da
cmpl $0x1, %r15d
je 0x38516
cmpl $0x3, %r15d
je 0x38574
cmpl $0xf, %r15d
jne 0x3855c
movzbl 0x1(%r14), %edx
cmpl $0xe, %edx
ja 0x38643
movl $0x0, -0x30(%rbp)
movl $0x2, %edi
leaq 0x354fc(%rip), %rsi     # 0x6d9d1
jmp 0x385b7
cmpl $0x10, %r15d
je 0x38539
cmpl $0x1a, %r15d
je 0x3859a
cmpl $0x29, %r15d
jne 0x3855c
movzbl 0x1(%r14), %edx
cmpl $0x5, %edx
ja 0x385c3
movl $0x0, -0x30(%rbp)
movl $0x2, %edi
leaq 0x355b8(%rip), %rsi     # 0x6dac9
jmp 0x385b7
movzbl 0x1(%r14), %edx
cmpl $0x5, %edx
ja 0x385c3
movl $0x0, -0x30(%rbp)
movl $0x2, %edi
leaq 0x3538a(%rip), %rsi     # 0x6d8c1
jmp 0x385b7
movzbl 0x1(%r14), %edx
cmpl $0x8, %edx
ja 0x385ff
movl $0x0, -0x30(%rbp)
movl $0x2, %edi
leaq 0x354cc(%rip), %rsi     # 0x6da26
jmp 0x385b7
movl $0x3, %edi
leaq 0x35151(%rip), %rsi     # 0x6d6b9
xorl %eax, %eax
callq 0x5342c
jmp 0x386b4
movzbl 0x1(%r14), %edx
cmpl $0x17, %edx
ja 0x38664
movl $0x2, %edi
leaq 0x353fa(%rip), %rsi     # 0x6d988
xorl %eax, %eax
callq 0x5342c
jmp 0x386ad
movzbl 0x1(%r14), %edx
cmpl $0x5, %edx
ja 0x385c3
movl $0x0, -0x30(%rbp)
movl $0x2, %edi
leaq 0x354be(%rip), %rsi     # 0x6da75
xorl %eax, %eax
callq 0x5342c
jmp 0x386b4
movzbl 0x7(%r14), %eax
movzbl 0x6(%r14), %ecx
shll $0x8, %ecx
movswl %cx, %esi
orl %eax, %esi
movl 0x2(%r14), %eax
bswapl %eax
xorps %xmm0, %xmm0
cvtsi2sd %eax, %xmm0
mulsd 0x3378e(%rip), %xmm0    # 0x6bd78
movq -0x38(%rbp), %rdi
callq 0x38737
movl $0x0, -0x30(%rbp)
jmp 0x386b4
movl $0x0, -0x30(%rbp)
testb $0x1, 0xa(%r14)
je 0x386b4
movzbl 0x7(%r14), %eax
movzbl 0x6(%r14), %ecx
shll $0x8, %ecx
movswl %cx, %esi
orl %eax, %esi
movl 0x2(%r14), %eax
bswapl %eax
xorps %xmm0, %xmm0
cvtsi2sd %eax, %xmm0
mulsd 0x33740(%rip), %xmm0    # 0x6bd78
movq -0x38(%rbp), %rdi
callq 0x38737
jmp 0x386b4
movl 0x2(%r14), %edx
bswapl %edx
movl $0x0, -0x30(%rbp)
movq -0x48(%rbp), %rdi
leaq 0x353c8(%rip), %rsi     # 0x6da23
xorl %eax, %eax
callq 0x8120
jmp 0x386b4
movq 0x2(%r14), %rax
bswapq %rax
movq -0x38(%rbp), %rcx
movq %rax, 0x70e08(%rcx)
movq 0xa(%r14), %rax
bswapq %rax
movq %rax, 0x70e10(%rcx)
movq 0x12(%r14), %rax
bswapq %rax
movq %rax, 0x70e18(%rcx)
movl $0x0, 0x70e00(%rcx)
movq -0x40(%rbp), %rax
xorpd %xmm0, %xmm0
movupd %xmm0, 0x10(%rax)
movupd %xmm0, (%rax)
movl $0x5, -0x30(%rbp)
movq %rbx, %rcx
addb $0x2, %r12b
movzbl %r12b, %eax
addq %rax, %r14
subl %eax, %ecx
jne 0x3844d
jmp 0x386da
movl $0x0, 0x1c(%rax)
movl $0x0, -0x30(%rbp)
movl -0x30(%rbp), %eax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq