// File: /workspace/github_c_makefile_star2_O2/canboat[P]canboat/n2kd/nmea0183.c
// Function: convertJSONToNMEA0183
extern void convertJSONToNMEA0183(StringBuffer *msg183, const char *msg)
{
  int prn;
  int src;
  int rateType;

  if (!getJSONInteger(msg, "pgn", &prn))
  {
    return;
  }

  switch (prn)
  {
    case PGN_VESSEL_HEADING:
      rateType = RATE_VESSEL_HEADING;
      break;
    case PGN_WIND_DATA:
      rateType = RATE_WIND_DATA;
      break;
    case PGN_WATER_DEPTH:
      rateType = RATE_WATER_DEPTH;
      break;
    case PGN_WATER_SPEED:
      rateType = RATE_WATER_SPEED;
      break;
    case PGN_ENVIRONMENTAL:
      rateType = RATE_ENVIRONMENTAL;
      break;
    case PGN_DISTANCE_LOG:
      rateType = RATE_DISTANCE_LOG;
      break;
    case PGN_RUDDER:
      rateType = RATE_RUDDER;
      break;
    case PGN_SOG_COG:
      rateType = RATE_GPS_SPEED;
      break;
    case PGN_GPS_DOP:
      rateType = RATE_GPS_DOP;
      break;
    case PGN_SYSTEM_TIME:
      rateType = RATE_SYSTEM_TIME;
      break;
    case PGN_POSITION:
      rateType = RATE_GPS_POSITION;
      break;
    case PGN_AIS_A:
    case PGN_AIS_B:
    case PGN_AIS_4:
    case PGN_AIS_5:
    case PGN_AIS_9:
    case PGN_AIS_12:
    case PGN_AIS_14:
    case PGN_AIS_19:
    case PGN_AIS_21:
    case PGN_AIS_24A:
    case PGN_AIS_24B:
      rateType = RATE_NO_LIMIT;
      break;
    default:
      return;
  }

  if (!getJSONInteger(msg, "src", &src))
  {
    return;
  }
  if (srcFilter && !matchFilter(src, srcFilter))
  {
    return;
  }

  logDebug("NMEA passed filter for prn %d src %d\n", prn, src);

  if (rateLimit && rateType != RATE_NO_LIMIT)
  {
    int64_t now = getNow();

    if (rateLimitPassed[src][rateType] > (now - 1000L))
    {
      logDebug("Ratelimit for prn %d src %d not reached\n", prn, src);
      return;
    }
    rateLimitPassed[src][rateType] = now;
    logDebug("Ratelimit passed for prn %d src %d\n", prn, src);
  }

  switch (prn)
  {
    case PGN_VESSEL_HEADING:
      nmea0183VesselHeading(msg183, src, msg);
      break;
    case PGN_WIND_DATA:
      nmea0183WindData(msg183, src, msg);
      break;
    case PGN_WATER_DEPTH:
      nmea0183WaterDepth(msg183, src, msg);
      break;
    case PGN_WATER_SPEED:
      nmea0183WaterSpeed(msg183, src, msg);
      break;
    case PGN_ENVIRONMENTAL:
      nmea0183WaterTemperature(msg183, src, msg);
      break;
    case PGN_DISTANCE_LOG:
      nmea0183DistanceTraveled(msg183, src, msg);
      break;
    case PGN_RUDDER:
      nmea0183Rudder(msg183, src, msg);
      break;
    case PGN_SYSTEM_TIME:
      nmea0183SystemTime(msg183, src, msg);
      break;
    case PGN_SOG_COG:
      nmea0183VTG(msg183, src, msg);
      break;
    case PGN_GPS_DOP:
      nmea0183GSA(msg183, src, msg);
      break;
    case PGN_POSITION:
      nmea0183GLL(msg183, src, msg);
      break;
    case PGN_AIS_A:
    case PGN_AIS_B:
    case PGN_AIS_4:
    case PGN_AIS_5:
    case PGN_AIS_9:
    case PGN_AIS_12:
    case PGN_AIS_14:
    case PGN_AIS_19:
    case PGN_AIS_21:
    case PGN_AIS_24A:
    case PGN_AIS_24B:
      nmea0183AIVDM(msg183, src, msg);
      break;
    default:
      return;
  }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x88, %rsp
movq %rsi, %rbx
movq %rdi, %r14
leaq 0x2791(%rip), %rsi      # 0x8a94
leaq 0xc(%rsp), %rdx
movq %rbx, %rdi
callq 0x6ace
testb %al, %al
je 0x66e5
movl 0xc(%rsp), %eax
leal -0x1fb01(%rax), %ecx
cmpl $0x11, %ecx
jbe 0x638a
leal -0x1f80e(%rax), %ecx
cmpl $0x4, %ecx
jb 0x6394
movb $0x1, %bpl
cmpl $0x1f010, %eax          # imm = 0x1F010
je 0x639e
cmpl $0x1f10d, %eax          # imm = 0x1F10D
je 0x63bf
cmpl $0x1f112, %eax          # imm = 0x1F112
je 0x63a6
cmpl $0x1f503, %eax          # imm = 0x1F503
je 0x63c3
cmpl $0x1f50b, %eax          # imm = 0x1F50B
je 0x63b3
cmpl $0x1f513, %eax          # imm = 0x1F513
je 0x63bb
cmpl $0x1f802, %eax          # imm = 0x1F802
je 0x63b7
cmpl $0x1f805, %eax          # imm = 0x1F805
je 0x63a2
cmpl $0x1fa03, %eax          # imm = 0x1FA03
je 0x63af
cmpl $0x1fd07, %eax          # imm = 0x1FD07
je 0x63ab
cmpl $0x1fd02, %eax          # imm = 0x1FD02
jne 0x66e5
pushq $0x1
jmp 0x63c5
movl $0x30323, %edx          # imm = 0x30323
btl %ecx, %edx
jae 0x6327
movl $0xffffffff, %r15d      # imm = 0xFFFFFFFF
xorl %ebp, %ebp
jmp 0x63c7
pushq $0xa
jmp 0x63c5
pushq $0x7
jmp 0x63c5
xorl %r15d, %r15d
jmp 0x63c7
pushq $0x8
jmp 0x63c5
pushq $0x6
jmp 0x63c5
pushq $0x2
jmp 0x63c5
pushq $0x5
jmp 0x63c5
pushq $0x9
jmp 0x63c5
pushq $0x4
jmp 0x63c5
pushq $0x3
popq %r15
leaq 0x26be(%rip), %rsi      # 0x8a8c
leaq 0x8(%rsp), %rdx
movq %rbx, %rdi
callq 0x6ace
testb %al, %al
je 0x66e5
leaq 0x6f86(%rip), %rax      # 0xd370
movq (%rax), %rdi
testq %rdi, %rdi
je 0x64d5
movq %r15, 0x70(%rsp)
movl %ebp, 0x2c(%rsp)
movq %rbx, 0x78(%rsp)
movq %r14, 0x80(%rsp)
movl 0x8(%rsp), %ebp
xorl %r14d, %r14d
leaq 0x10(%rsp), %r15
pushq $0xa
popq %r12
leaq 0x32ca(%rip), %r13      # 0x96ed
movq %rdi, 0x10(%rsp)
movzbl (%rdi), %eax
cmpl $0x21, %eax
je 0x6436
testl %eax, %eax
jne 0x6441
jmp 0x64b5
incq %rdi
movq %rdi, 0x10(%rsp)
movb $0x1, %r14b
movq %r15, %rsi
movl %r12d, %edx
callq 0x21f0
movq %rax, %rbx
movq %r13, %rdi
movl %ebp, %esi
movl %ebx, %edx
xorl %eax, %eax
callq 0x6d78
cmpl %ebx, %ebp
je 0x6481
movq 0x10(%rsp), %rdi
movzbl (%rdi), %eax
testl %eax, %eax
je 0x6423
cmpl $0x2c, %eax
je 0x6477
incq %rdi
jmp 0x6466
movq %rdi, 0x10(%rsp)
incq %rdi
jmp 0x6423
leaq 0x327a(%rip), %rdi      # 0x9702
movl %ebp, %esi
movl %ebp, %edx
xorl %eax, %eax
callq 0x6d78
testb $0x1, %r14b
movq 0x80(%rsp), %r14
movq 0x78(%rsp), %rbx
movl 0x2c(%rsp), %ebp
movq 0x70(%rsp), %r15
jne 0x66e5
jmp 0x64d5
testb $0x1, %r14b
movq 0x80(%rsp), %r14
movq 0x78(%rsp), %rbx
movl 0x2c(%rsp), %ebp
movq 0x70(%rsp), %r15
je 0x66e5
movl 0xc(%rsp), %esi
movl 0x8(%rsp), %edx
leaq 0x3196(%rip), %rdi      # 0x967a
xorl %eax, %eax
callq 0x6d78
leaq 0x702f(%rip), %rax      # 0xd521
andb (%rax), %bpl
cmpb $0x1, %bpl
jne 0x6550
callq 0x6b84
movslq 0x8(%rsp), %rdx
imulq $0x58, %rdx, %rsi
leaq 0x20a2ed0(%rip), %rcx   # 0x20a93e0
addq %rsi, %rcx
leaq -0x3e8(%rax), %rsi
cmpq %rsi, (%rcx,%r15,8)
jle 0x6537
movl 0xc(%rsp), %esi
leaq 0x3175(%rip), %rdi      # 0x96a0
xorl %eax, %eax
callq 0x6d78
jmp 0x66e5
leaq (%rcx,%r15,8), %rcx
movq %rax, (%rcx)
movl 0xc(%rsp), %esi
leaq 0x3180(%rip), %rdi      # 0x96c9
xorl %eax, %eax
callq 0x6d78
movl 0xc(%rsp), %eax
leal -0x1fb01(%rax), %ecx
cmpl $0x11, %ecx
jbe 0x66c8
leal -0x1f80e(%rax), %ecx
cmpl $0x4, %ecx
jb 0x66d6
cmpl $0x1f010, %eax          # imm = 0x1F010
je 0x66f7
cmpl $0x1f10d, %eax          # imm = 0x1F10D
je 0x69d9
cmpl $0x1fd07, %eax          # imm = 0x1FD07
je 0x67d8
cmpl $0x1f503, %eax          # imm = 0x1F503
je 0x6a12
cmpl $0x1f50b, %eax          # imm = 0x1F50B
je 0x6904
cmpl $0x1f513, %eax          # imm = 0x1F513
je 0x6972
cmpl $0x1f802, %eax          # imm = 0x1F802
je 0x695e
cmpl $0x1f805, %eax          # imm = 0x1F805
je 0x67c4
cmpl $0x1fa03, %eax          # imm = 0x1FA03
je 0x68f0
cmpl $0x1fd02, %eax          # imm = 0x1FD02
je 0x685a
cmpl $0x1f112, %eax          # imm = 0x1F112
jne 0x66e5
movl 0x8(%rsp), %ebp
leaq 0x2e0d(%rip), %rsi      # 0x9403
leaq 0x10(%rsp), %rdx
movq %rbx, %rdi
xorl %ecx, %ecx
callq 0x6b09
testb %al, %al
je 0x66e5
leaq 0x3107(%rip), %rsi      # 0x971b
leaq 0x48(%rsp), %rdx
movq %rbx, %rdi
callq 0x77fd
testb %al, %al
je 0x66e5
leaq 0x30f5(%rip), %rsi      # 0x9725
leaq 0x30(%rsp), %rdx
movq %rbx, %rdi
xorl %ecx, %ecx
callq 0x6b09
testb %al, %al
je 0x6a7f
leaq 0x30e1(%rip), %rsi      # 0x972f
leaq 0x50(%rsp), %rdx
movq %rbx, %rdi
xorl %ecx, %ecx
callq 0x6b09
movq 0x48(%rsp), %rcx
cmpq $0x1, %rcx
sete %dl
andb %al, %dl
cmpb $0x1, %dl
jne 0x6a84
movsd 0x10(%rsp), %xmm0
movsd 0x30(%rsp), %xmm1
movapd 0x2fa8(%rip), %xmm2     # 0x9630
xorpd %xmm3, %xmm3
ucomisd %xmm1, %xmm3
pushq $0x57
popq %rax
pushq $0x45
popq %r8
movl %r8d, %ecx
cmoval %eax, %ecx
andpd %xmm2, %xmm1
movsd 0x50(%rsp), %xmm4
ucomisd %xmm4, %xmm3
andpd %xmm4, %xmm2
cmoval %eax, %r8d
leaq 0x307f(%rip), %rdx      # 0x9739
movq %r14, %rdi
movl %ebp, %esi
movb $0x3, %al
callq 0x61b4
jmp 0x66e5
movl $0x30323, %edx          # imm = 0x30323
btl %ecx, %edx
jae 0x6563
movl 0x8(%rsp), %esi
movq %r14, %rdi
movq %rbx, %rdx
callq 0x4a5e
addq $0x88, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl 0x8(%rsp), %ebp
leaq 0x2b35(%rip), %rsi      # 0x9237
leaq 0x10(%rsp), %rdx
pushq $0x14
popq %rcx
movq %rbx, %rdi
callq 0x7415
testb %al, %al
je 0x66e5
leaq 0x2b23(%rip), %rsi      # 0x9240
leaq 0x30(%rsp), %rdx
pushq $0x14
popq %rcx
movq %rbx, %rdi
callq 0x7415
testb %al, %al
je 0x66e5
leaq 0x311d(%rip), %rsi      # 0x9855
leaq 0x10(%rsp), %rdi
leaq 0x48(%rsp), %rdx
leaq 0x6c(%rsp), %rcx
leaq 0x68(%rsp), %r8
xorl %eax, %eax
callq 0x2240
cmpl $0x3, %eax
jne 0x66e5
leaq 0x30ff(%rip), %rsi      # 0x985e
leaq 0x30(%rsp), %rdi
leaq 0x64(%rsp), %rdx
leaq 0x60(%rsp), %rcx
leaq 0x50(%rsp), %r8
xorl %eax, %eax
callq 0x2240
cmpl $0x3, %eax
jne 0x66e5
movl 0x64(%rsp), %ecx
movl 0x60(%rsp), %r8d
movl 0x68(%rsp), %r10d
movl 0x6c(%rsp), %r11d
movl 0x48(%rsp), %ebx
subq $0x8, %rsp
leaq 0x30c3(%rip), %rdx      # 0x9868
leaq 0x58(%rsp), %r9
movq %r14, %rdi
movl %ebp, %esi
xorl %eax, %eax
pushq %rbx
pushq %r11
pushq %r10
callq 0x61b4
addq $0x20, %rsp
jmp 0x66e5
movl 0x8(%rsp), %esi
movq %r14, %rdi
movq %rbx, %rdx
callq 0x45fe
jmp 0x66e5
movl 0x8(%rsp), %ebp
leaq 0x3016(%rip), %rsi      # 0x97f9
leaq 0x30(%rsp), %rdx
movq %rbx, %rdi
callq 0x77fd
testb %al, %al
je 0x66e5
cmpq $0x0, 0x30(%rsp)
jne 0x66e5
leaq 0x3001(%rip), %rsi      # 0x980c
leaq 0x10(%rsp), %rdx
pushq $0x4
popq %rcx
movq %rbx, %rdi
callq 0x6b09
testb %al, %al
je 0x66e5
movsd 0x10(%rsp), %xmm1
movsd 0x2e17(%rip), %xmm2     # 0x9648
movapd %xmm1, %xmm0
cmpltsd 0x2e12(%rip), %xmm0     # 0x9650
addsd %xmm1, %xmm2
andpd %xmm0, %xmm1
andnpd %xmm2, %xmm0
orpd %xmm1, %xmm0
leaq 0x2fc3(%rip), %rdx      # 0x9818
jmp 0x6a6e
movl 0x8(%rsp), %ebp
leaq 0x2f03(%rip), %rsi      # 0x9768
leaq 0x10(%rsp), %rdx
pushq $0x2
popq %rcx
movq %rbx, %rdi
callq 0x6b09
testb %al, %al
je 0x66e5
leaq 0x2eef(%rip), %rsi      # 0x9773
leaq 0x30(%rsp), %rdx
movq %rbx, %rdi
xorl %ecx, %ecx
callq 0x6b09
testb %al, %al
je 0x66e5
leaq 0x2e79(%rip), %rsi      # 0x971b
leaq 0x50(%rsp), %rdx
movq %rbx, %rdi
callq 0x77fd
testb %al, %al
je 0x66e5
movq 0x50(%rsp), %rax
cmpq $0x2, %rax
je 0x6ab1
cmpq $0x3, %rax
jne 0x66e5
movsd 0x30(%rsp), %xmm0
movsd 0x10(%rsp), %xmm1
mulsd 0x2784(%rip), %xmm1     # 0x9068
leaq 0x2e93(%rip), %rdx      # 0x977e
jmp 0x6a56
movl 0x8(%rsp), %esi
movq %r14, %rdi
movq %rbx, %rdx
callq 0x450f
jmp 0x66e5
movl 0x8(%rsp), %ebp
leaq 0x2e97(%rip), %rsi      # 0x97a6
leaq 0x10(%rsp), %rdx
pushq $0x3
popq %rcx
movq %rbx, %rdi
callq 0x6b09
testb %al, %al
je 0x66e5
leaq 0x2e7e(%rip), %rsi      # 0x97ac
leaq 0x30(%rsp), %rdx
pushq $0x3
popq %rcx
movq %rbx, %rdi
callq 0x6b09
movsd 0x10(%rsp), %xmm0
testb %al, %al
je 0x6a67
movsd 0x30(%rsp), %xmm1
leaq 0x2e5a(%rip), %rdx      # 0x97b3
jmp 0x6a56
movl 0x8(%rsp), %esi
movq %r14, %rdi
movq %rbx, %rdx
callq 0x4468
jmp 0x66e5
movl 0x8(%rsp), %ebp
leaq 0x2eab(%rip), %rsi      # 0x9828
leaq 0x10(%rsp), %rdx
pushq $0x3
popq %rcx
movq %rbx, %rdi
callq 0x6b09
testb %al, %al
je 0x66e5
leaq 0x2e87(%rip), %rsi      # 0x9823
leaq 0x30(%rsp), %rdx
pushq $0x3
popq %rcx
movq %rbx, %rdi
callq 0x6b09
testb %al, %al
je 0x66e5
movsd 0x10(%rsp), %xmm0
movsd 0x2c7e(%rip), %xmm2     # 0x9640
divsd %xmm2, %xmm0
movsd 0x30(%rsp), %xmm1
divsd %xmm2, %xmm1
leaq 0x2e55(%rip), %rdx      # 0x982c
jmp 0x6a56
movl 0x8(%rsp), %ebp
leaq 0x2e5a(%rip), %rsi      # 0x983e
leaq 0x10(%rsp), %rdx
movq %rbx, %rdi
xorl %ecx, %ecx
callq 0x6b09
testb %al, %al
je 0x66e5
movsd 0x10(%rsp), %xmm0
xorpd 0x2687(%rip), %xmm0     # 0x9090
leaq 0x2e37(%rip), %rdx      # 0x9847
jmp 0x6a6e
movl 0x8(%rsp), %ebp
leaq 0x2dae(%rip), %rsi      # 0x97cb
leaq 0x10(%rsp), %rdx
pushq $0x2
popq %rcx
movq %rbx, %rdi
callq 0x6b09
testb %al, %al
je 0x66e5
movsd 0x10(%rsp), %xmm1
movsd 0x261d(%rip), %xmm0     # 0x9060
mulsd %xmm1, %xmm0
mulsd 0x2619(%rip), %xmm1     # 0x9068
leaq 0x2d8c(%rip), %rdx      # 0x97e2
movq %r14, %rdi
movl %ebp, %esi
movb $0x2, %al
callq 0x61b4
jmp 0x66e5
leaq 0x2d53(%rip), %rdx      # 0x97c1
movq %r14, %rdi
movl %ebp, %esi
movb $0x1, %al
callq 0x61b4
jmp 0x66e5
movq 0x48(%rsp), %rcx
cmpq $0x1, %rcx
je 0x6aa2
testq %rcx, %rcx
jne 0x66e5
movsd 0x10(%rsp), %xmm0
leaq 0x2cb2(%rip), %rdx      # 0x9752
jmp 0x6a6e
movsd 0x10(%rsp), %xmm0
leaq 0x2cae(%rip), %rdx      # 0x975d
jmp 0x6a6e
movsd 0x30(%rsp), %xmm0
movsd 0x10(%rsp), %xmm1
mulsd 0x25a3(%rip), %xmm1     # 0x9068
leaq 0x2cc6(%rip), %rdx      # 0x9792
jmp 0x6a56