// File: /workspace/github_c_makefile_star2_O1/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, %r12
leaq 0x3195(%rip), %rsi      # 0x9a84
leaq 0x4(%rsp), %rdx
movq %rbx, %rdi
callq 0x6d42
testb %al, %al
je 0x6c08
movb $0x1, %bpl
movl 0x4(%rsp), %eax
cmpl $0x1fa02, %eax          # imm = 0x1FA02
jg 0x694a
cmpl $0x1f801, %eax          # imm = 0x1F801
jg 0x697d
cmpl $0x1f502, %eax          # imm = 0x1F502
jg 0x6ada
cmpl $0x1f010, %eax          # imm = 0x1F010
je 0x6c2d
cmpl $0x1f10d, %eax          # imm = 0x1F10D
je 0x6c17
cmpl $0x1f112, %eax          # imm = 0x1F112
jne 0x6c08
xorl %r14d, %r14d
jmp 0x6994
cmpl $0x1fd01, %eax          # imm = 0x1FD01
jg 0x6b06
leal -0x1fb01(%rax), %ecx
cmpl $0x11, %ecx
ja 0x696a
movl $0x30323, %edx          # imm = 0x30323
btl %ecx, %edx
jb 0x698c
cmpl $0x1fa03, %eax          # imm = 0x1FA03
jne 0x6c08
movl $0x6, %r14d
jmp 0x6994
leal -0x1f80e(%rax), %ecx
cmpl $0x4, %ecx
jae 0x6b27
movl $0xffffffff, %r14d      # imm = 0xFFFFFFFF
xorl %ebp, %ebp
leaq 0x30e1(%rip), %rsi      # 0x9a7c
movq %rsp, %rdx
movq %rbx, %rdi
callq 0x6d42
testb %al, %al
je 0x6c08
leaq 0x79ab(%rip), %rax      # 0xe360
movq (%rax), %rax
testq %rax, %rax
je 0x6a77
movq %r14, 0x18(%rsp)
movl %ebp, 0x14(%rsp)
movq %r12, 0x20(%rsp)
movl (%rsp), %ebp
xorl %r14d, %r14d
leaq 0x8(%rsp), %r15
leaq 0x3d0c(%rip), %r12      # 0xa6ed
movq %rax, 0x8(%rsp)
movzbl (%rax), %ecx
cmpl $0x21, %ecx
je 0x69f4
testl %ecx, %ecx
jne 0x69ff
jmp 0x6a5f
incq %rax
movq %rax, 0x8(%rsp)
movb $0x1, %r14b
movq 0x8(%rsp), %rdi
movq %r15, %rsi
movl $0xa, %edx
callq 0x21f0
movq %rax, %r13
movq %r12, %rdi
movl %ebp, %esi
movl %r13d, %edx
xorl %eax, %eax
callq 0x7549
cmpl %r13d, %ebp
je 0x6a48
movq 0x8(%rsp), %rax
movzbl (%rax), %ecx
testl %ecx, %ecx
je 0x69e1
cmpl $0x2c, %ecx
je 0x6a3e
incq %rax
jmp 0x6a2d
movq %rax, 0x8(%rsp)
incq %rax
jmp 0x69e1
leaq 0x3cb3(%rip), %rdi      # 0xa702
movl %ebp, %esi
movl %r13d, %edx
xorl %eax, %eax
callq 0x7549
xorb $0x1, %r14b
testb $0x1, %r14b
movq 0x20(%rsp), %r12
movl 0x14(%rsp), %ebp
movq 0x18(%rsp), %r14
je 0x6c08
movl 0x4(%rsp), %esi
movl (%rsp), %edx
leaq 0x3bf5(%rip), %rdi      # 0xa67a
xorl %eax, %eax
callq 0x7549
leaq 0x7a7e(%rip), %rax      # 0xe511
andb (%rax), %bpl
cmpb $0x1, %bpl
jne 0x6b6a
callq 0x7328
movslq (%rsp), %rdx
imulq $0x58, %rdx, %rsi
leaq 0x20a391c(%rip), %rcx   # 0x20aa3d0
addq %rsi, %rcx
movq %r14, %rsi
movq (%rcx,%r14,8), %r14
leaq -0x3e8(%rax), %r15
cmpq %r15, %r14
jle 0x6b48
movl 0x4(%rsp), %esi
leaq 0x3bcb(%rip), %rdi      # 0xa6a0
jmp 0x6b5a
cmpl $0x1f503, %eax          # imm = 0x1F503
je 0x6c38
cmpl $0x1f50b, %eax          # imm = 0x1F50B
je 0x6c22
cmpl $0x1f513, %eax          # imm = 0x1F513
jne 0x6c08
movl $0x9, %r14d
jmp 0x6994
cmpl $0x1fd07, %eax          # imm = 0x1FD07
je 0x6c43
cmpl $0x1fd02, %eax          # imm = 0x1FD02
jne 0x6c08
movl $0x1, %r14d
jmp 0x6994
cmpl $0x1f802, %eax          # imm = 0x1F802
je 0x6c4e
cmpl $0x1f805, %eax          # imm = 0x1F805
jne 0x6c08
movl $0x7, %r14d
jmp 0x6994
leaq (%rcx,%rsi,8), %rcx
movq %rax, (%rcx)
movl 0x4(%rsp), %esi
leaq 0x3b6f(%rip), %rdi      # 0xa6c9
xorl %eax, %eax
callq 0x7549
cmpq %r15, %r14
jg 0x6c08
movl 0x4(%rsp), %eax
cmpl $0x1fa02, %eax          # imm = 0x1FA02
jg 0x6bb4
cmpl $0x1f801, %eax          # imm = 0x1F801
jg 0x6beb
cmpl $0x1f502, %eax          # imm = 0x1F502
jg 0x6c59
cmpl $0x1f010, %eax          # imm = 0x1F010
je 0x6cf6
cmpl $0x1f10d, %eax          # imm = 0x1F10D
je 0x6cd0
cmpl $0x1f112, %eax          # imm = 0x1F112
jne 0x6c08
movl (%rsp), %esi
movq %r12, %rdi
movq %rbx, %rdx
callq 0x6d7f
jmp 0x6c08
cmpl $0x1fd01, %eax          # imm = 0x1FD01
jg 0x6c82
leal -0x1fb01(%rax), %ecx
cmpl $0x11, %ecx
ja 0x6bd4
movl $0x30323, %edx          # imm = 0x30323
btl %ecx, %edx
jb 0x6bfa
cmpl $0x1fa03, %eax          # imm = 0x1FA03
jne 0x6c08
movl (%rsp), %esi
movq %r12, %rdi
movq %rbx, %rdx
callq 0x4789
jmp 0x6c08
leal -0x1f80e(%rax), %ecx
cmpl $0x4, %ecx
jae 0x6cab
movl (%rsp), %esi
movq %r12, %rdi
movq %rbx, %rdx
callq 0x4d98
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl $0x4, %r14d
jmp 0x6994
movl $0x2, %r14d
jmp 0x6994
movl $0xa, %r14d
jmp 0x6994
movl $0x3, %r14d
jmp 0x6994
movl $0x8, %r14d
jmp 0x6994
movl $0x5, %r14d
jmp 0x6994
cmpl $0x1f503, %eax          # imm = 0x1F503
je 0x6d09
cmpl $0x1f50b, %eax          # imm = 0x1F50B
je 0x6ce3
cmpl $0x1f513, %eax          # imm = 0x1F513
jne 0x6c08
movl (%rsp), %esi
movq %r12, %rdi
movq %rbx, %rdx
callq 0x70eb
jmp 0x6c08
cmpl $0x1fd02, %eax          # imm = 0x1FD02
je 0x6d1c
cmpl $0x1fd07, %eax          # imm = 0x1FD07
jne 0x6c08
movl (%rsp), %esi
movq %r12, %rdi
movq %rbx, %rdx
callq 0x7058
jmp 0x6c08
cmpl $0x1f802, %eax          # imm = 0x1F802
je 0x6d2f
cmpl $0x1f805, %eax          # imm = 0x1F805
jne 0x6c08
movl (%rsp), %esi
movq %r12, %rdi
movq %rbx, %rdx
callq 0x4873
jmp 0x6c08
movl (%rsp), %esi
movq %r12, %rdi
movq %rbx, %rdx
callq 0x7175
jmp 0x6c08
movl (%rsp), %esi
movq %r12, %rdi
movq %rbx, %rdx
callq 0x6f60
jmp 0x6c08
movl (%rsp), %esi
movq %r12, %rdi
movq %rbx, %rdx
callq 0x71c7
jmp 0x6c08
movl (%rsp), %esi
movq %r12, %rdi
movq %rbx, %rdx
callq 0x6ff6
jmp 0x6c08
movl (%rsp), %esi
movq %r12, %rdi
movq %rbx, %rdx
callq 0x6e9d
jmp 0x6c08
movl (%rsp), %esi
movq %r12, %rdi
movq %rbx, %rdx
callq 0x46e0
jmp 0x6c08