// File: /workspace/github_c_makefile_star2_O3/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 $0x28, %rsp
movq %rsi, %rbx
movq %rdi, %r14
leaq 0x3215(%rip), %rsi      # 0x9a94
leaq 0x8(%rsp), %rdx
movq %rbx, %rdi
callq 0x6cf5
testb %al, %al
je 0x6baa
movb $0x1, %bpl
movl 0x8(%rsp), %eax
cmpl $0x1fa02, %eax          # imm = 0x1FA02
jg 0x68da
cmpl $0x1f801, %eax          # imm = 0x1F801
jg 0x690d
cmpl $0x1f502, %eax          # imm = 0x1F502
jg 0x6a04
cmpl $0x1f010, %eax          # imm = 0x1F010
je 0x6bcf
cmpl $0x1f10d, %eax          # imm = 0x1F10D
je 0x6bb9
cmpl $0x1f112, %eax          # imm = 0x1F112
jne 0x6baa
xorl %r15d, %r15d
jmp 0x6924
cmpl $0x1fd01, %eax          # imm = 0x1FD01
jg 0x6aae
leal -0x1fb01(%rax), %ecx
cmpl $0x11, %ecx
ja 0x68fa
movl $0x30323, %edx          # imm = 0x30323
btl %ecx, %edx
jb 0x691c
cmpl $0x1fa03, %eax          # imm = 0x1FA03
jne 0x6baa
movl $0x6, %r15d
jmp 0x6924
leal -0x1f80e(%rax), %ecx
cmpl $0x4, %ecx
jae 0x6acf
movl $0xffffffff, %r15d      # imm = 0xFFFFFFFF
xorl %ebp, %ebp
leaq 0x3161(%rip), %rsi      # 0x9a8c
leaq 0x4(%rsp), %rdx
movq %rbx, %rdi
callq 0x6cf5
testb %al, %al
je 0x6baa
leaq 0x7a19(%rip), %rax      # 0xe360
movq (%rax), %rdi
testq %rdi, %rdi
je 0x6a48
movq %r15, 0x18(%rsp)
movl %ebp, 0xc(%rsp)
movq %r14, 0x20(%rsp)
movl 0x4(%rsp), %ebp
xorl %r14d, %r14d
leaq 0x10(%rsp), %r15
leaq 0x3d79(%rip), %r12      # 0xa6ed
movq %rdi, 0x10(%rsp)
movzbl (%rdi), %eax
cmpl $0x21, %eax
je 0x698a
testl %eax, %eax
jne 0x6995
jmp 0x6a30
incq %rdi
movq %rdi, 0x10(%rsp)
movb $0x1, %r14b
movq %r15, %rsi
movl $0xa, %edx
callq 0x21f0
movq %rax, %r13
movq %r12, %rdi
movl %ebp, %esi
movl %r13d, %edx
xorl %eax, %eax
callq 0x7509
cmpl %r13d, %ebp
je 0x69d9
movq 0x10(%rsp), %rdi
movzbl (%rdi), %eax
testl %eax, %eax
je 0x6974
cmpl $0x2c, %eax
je 0x69cf
incq %rdi
jmp 0x69be
movq %rdi, 0x10(%rsp)
incq %rdi
jmp 0x6974
leaq 0x3d22(%rip), %rdi      # 0xa702
movl %ebp, %esi
movl %ebp, %edx
xorl %eax, %eax
callq 0x7509
testb $0x1, %r14b
movq 0x20(%rsp), %r14
movl 0xc(%rsp), %ebp
movq 0x18(%rsp), %r15
je 0x6a48
jmp 0x6baa
cmpl $0x1f503, %eax          # imm = 0x1F503
je 0x6bda
cmpl $0x1f50b, %eax          # imm = 0x1F50B
je 0x6bc4
cmpl $0x1f513, %eax          # imm = 0x1F513
jne 0x6baa
movl $0x9, %r15d
jmp 0x6924
testb $0x1, %r14b
movq 0x20(%rsp), %r14
movl 0xc(%rsp), %ebp
movq 0x18(%rsp), %r15
je 0x6baa
movl 0x8(%rsp), %esi
movl 0x4(%rsp), %edx
leaq 0x3c23(%rip), %rdi      # 0xa67a
xorl %eax, %eax
callq 0x7509
leaq 0x7aac(%rip), %rax      # 0xe511
andb (%rax), %bpl
cmpb $0x1, %bpl
jne 0x6b09
callq 0x72e8
movslq 0x4(%rsp), %rdx
imulq $0x58, %rdx, %rsi
leaq 0x20a3949(%rip), %rcx   # 0x20aa3d0
addq %rsi, %rcx
leaq -0x3e8(%rax), %rsi
cmpq %rsi, (%rcx,%r15,8)
jle 0x6af0
movl 0x8(%rsp), %esi
leaq 0x3bfe(%rip), %rdi      # 0xa6a0
xorl %eax, %eax
callq 0x7509
jmp 0x6baa
cmpl $0x1fd07, %eax          # imm = 0x1FD07
je 0x6be5
cmpl $0x1fd02, %eax          # imm = 0x1FD02
jne 0x6baa
movl $0x1, %r15d
jmp 0x6924
cmpl $0x1f802, %eax          # imm = 0x1F802
je 0x6bf0
cmpl $0x1f805, %eax          # imm = 0x1F805
jne 0x6baa
movl $0x7, %r15d
jmp 0x6924
leaq (%rcx,%r15,8), %rcx
movq %rax, (%rcx)
movl 0x8(%rsp), %esi
leaq 0x3bc7(%rip), %rdi      # 0xa6c9
xorl %eax, %eax
callq 0x7509
movl 0x8(%rsp), %eax
cmpl $0x1fa02, %eax          # imm = 0x1FA02
jg 0x6b54
cmpl $0x1f801, %eax          # imm = 0x1F801
jg 0x6b8c
cmpl $0x1f502, %eax          # imm = 0x1F502
jg 0x6bfb
cmpl $0x1f010, %eax          # imm = 0x1F010
je 0x6ca5
cmpl $0x1f10d, %eax          # imm = 0x1F10D
je 0x6c7d
cmpl $0x1f112, %eax          # imm = 0x1F112
jne 0x6baa
movl 0x4(%rsp), %esi
movq %r14, %rdi
movq %rbx, %rdx
callq 0x6d32
jmp 0x6baa
cmpl $0x1fd01, %eax          # imm = 0x1FD01
jg 0x6c29
leal -0x1fb01(%rax), %ecx
cmpl $0x11, %ecx
ja 0x6b74
movl $0x30323, %edx          # imm = 0x30323
btl %ecx, %edx
jb 0x6b9b
cmpl $0x1fa03, %eax          # imm = 0x1FA03
jne 0x6baa
movl 0x4(%rsp), %esi
movq %r14, %rdi
movq %rbx, %rdx
callq 0x4739
jmp 0x6baa
leal -0x1f80e(%rax), %ecx
cmpl $0x4, %ecx
jae 0x6c53
movl 0x4(%rsp), %esi
movq %r14, %rdi
movq %rbx, %rdx
callq 0x4d2e
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl $0x4, %r15d
jmp 0x6924
movl $0x2, %r15d
jmp 0x6924
movl $0xa, %r15d
jmp 0x6924
movl $0x3, %r15d
jmp 0x6924
movl $0x8, %r15d
jmp 0x6924
movl $0x5, %r15d
jmp 0x6924
cmpl $0x1f503, %eax          # imm = 0x1F503
je 0x6cb9
cmpl $0x1f50b, %eax          # imm = 0x1F50B
je 0x6c91
cmpl $0x1f513, %eax          # imm = 0x1F513
jne 0x6baa
movl 0x4(%rsp), %esi
movq %r14, %rdi
movq %rbx, %rdx
callq 0x70a9
jmp 0x6baa
cmpl $0x1fd02, %eax          # imm = 0x1FD02
je 0x6ccd
cmpl $0x1fd07, %eax          # imm = 0x1FD07
jne 0x6baa
movl 0x4(%rsp), %esi
movq %r14, %rdi
movq %rbx, %rdx
callq 0x7016
jmp 0x6baa
cmpl $0x1f802, %eax          # imm = 0x1F802
je 0x6ce1
cmpl $0x1f805, %eax          # imm = 0x1F805
jne 0x6baa
movl 0x4(%rsp), %esi
movq %r14, %rdi
movq %rbx, %rdx
callq 0x4823
jmp 0x6baa
movl 0x4(%rsp), %esi
movq %r14, %rdi
movq %rbx, %rdx
callq 0x7133
jmp 0x6baa
movl 0x4(%rsp), %esi
movq %r14, %rdi
movq %rbx, %rdx
callq 0x6f1e
jmp 0x6baa
movl 0x4(%rsp), %esi
movq %r14, %rdi
movq %rbx, %rdx
callq 0x7185
jmp 0x6baa
movl 0x4(%rsp), %esi
movq %r14, %rdi
movq %rbx, %rdx
callq 0x6fb4
jmp 0x6baa
movl 0x4(%rsp), %esi
movq %r14, %rdi
movq %rbx, %rdx
callq 0x6e5b
jmp 0x6baa
movl 0x4(%rsp), %esi
movq %r14, %rdi
movq %rbx, %rdx
callq 0x4690
jmp 0x6baa