// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x10(%rbp), %rdi
leaq 0x3ee5(%rip), %rsi      # 0xca60
leaq -0x14(%rbp), %rdx
callq 0x8ff0
testb $0x1, %al
jne 0x8b8d
jmp 0x8fe1
movl -0x14(%rbp), %eax
movl %eax, -0x2c(%rbp)
subl $0x1f010, %eax          # imm = 0x1F010
je 0x8ce1
jmp 0x8ba0
movl -0x2c(%rbp), %eax
subl $0x1f10d, %eax          # imm = 0x1F10D
je 0x8cc6
jmp 0x8bb0
movl -0x2c(%rbp), %eax
subl $0x1f112, %eax          # imm = 0x1F112
je 0x8c90
jmp 0x8bc0
movl -0x2c(%rbp), %eax
subl $0x1f503, %eax          # imm = 0x1F503
je 0x8cab
jmp 0x8bd0
movl -0x2c(%rbp), %eax
subl $0x1f50b, %eax          # imm = 0x1F50B
je 0x8ca2
jmp 0x8be0
movl -0x2c(%rbp), %eax
subl $0x1f513, %eax          # imm = 0x1F513
je 0x8cbd
jmp 0x8bf0
movl -0x2c(%rbp), %eax
subl $0x1f802, %eax          # imm = 0x1F802
je 0x8ccf
jmp 0x8c00
movl -0x2c(%rbp), %eax
subl $0x1f805, %eax          # imm = 0x1F805
je 0x8cea
jmp 0x8c10
movl -0x2c(%rbp), %eax
addl $0xfffe07f2, %eax       # imm = 0xFFFE07F2
subl $0x4, %eax
jb 0x8cf3
jmp 0x8c23
movl -0x2c(%rbp), %eax
subl $0x1fa03, %eax          # imm = 0x1FA03
je 0x8cd8
jmp 0x8c33
movl -0x2c(%rbp), %eax
addl $0xfffe04ff, %eax       # imm = 0xFFFE04FF
subl $0x2, %eax
jb 0x8cf3
jmp 0x8c46
movl -0x2c(%rbp), %eax
subl $0x1fb06, %eax          # imm = 0x1FB06
je 0x8cf3
jmp 0x8c56
movl -0x2c(%rbp), %eax
addl $0xfffe04f7, %eax       # imm = 0xFFFE04F7
subl $0x2, %eax
jb 0x8cf3
jmp 0x8c69
movl -0x2c(%rbp), %eax
addl $0xfffe04ef, %eax       # imm = 0xFFFE04EF
subl $0x2, %eax
jb 0x8cf3
jmp 0x8c78
movl -0x2c(%rbp), %eax
subl $0x1fd02, %eax          # imm = 0x1FD02
je 0x8c99
jmp 0x8c84
movl -0x2c(%rbp), %eax
subl $0x1fd07, %eax          # imm = 0x1FD07
je 0x8cb4
jmp 0x8cfc
movl $0x0, -0x1c(%rbp)
jmp 0x8d01
movl $0x1, -0x1c(%rbp)
jmp 0x8d01
movl $0x2, -0x1c(%rbp)
jmp 0x8d01
movl $0x3, -0x1c(%rbp)
jmp 0x8d01
movl $0x8, -0x1c(%rbp)
jmp 0x8d01
movl $0x9, -0x1c(%rbp)
jmp 0x8d01
movl $0x4, -0x1c(%rbp)
jmp 0x8d01
movl $0x5, -0x1c(%rbp)
jmp 0x8d01
movl $0x6, -0x1c(%rbp)
jmp 0x8d01
movl $0xa, -0x1c(%rbp)
jmp 0x8d01
movl $0x7, -0x1c(%rbp)
jmp 0x8d01
movl $0xffffffff, -0x1c(%rbp) # imm = 0xFFFFFFFF
jmp 0x8d01
jmp 0x8fe1
movq -0x10(%rbp), %rdi
leaq 0x3d4c(%rip), %rsi      # 0xca58
leaq -0x18(%rbp), %rdx
callq 0x8ff0
testb $0x1, %al
jne 0x8d1e
jmp 0x8fe1
leaq 0x86bb(%rip), %rax      # 0x113e0
cmpq $0x0, (%rax)
je 0x8d46
movl -0x18(%rbp), %edi
leaq 0x86ab(%rip), %rax      # 0x113e0
movq (%rax), %rsi
callq 0x9060
testb $0x1, %al
jne 0x8d46
jmp 0x8fe1
movl -0x14(%rbp), %esi
movl -0x18(%rbp), %edx
leaq 0x48f7(%rip), %rdi      # 0xd64a
movb $0x0, %al
callq 0x9ae0
leaq 0x8830(%rip), %rax      # 0x11591
testb $0x1, (%rax)
je 0x8dee
cmpl $-0x1, -0x1c(%rbp)
je 0x8dee
callq 0x9820
movq %rax, -0x28(%rbp)
movslq -0x18(%rbp), %rcx
leaq 0x20a46cc(%rip), %rax   # 0x20ad450
imulq $0x58, %rcx, %rcx
addq %rcx, %rax
movslq -0x1c(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq -0x28(%rbp), %rcx
subq $0x3e8, %rcx            # imm = 0x3E8
cmpq %rcx, %rax
jle 0x8dbc
movl -0x14(%rbp), %esi
movl -0x18(%rbp), %edx
leaq 0x48c0(%rip), %rdi      # 0xd670
movb $0x0, %al
callq 0x9ae0
jmp 0x8fe1
movq -0x28(%rbp), %rdx
movslq -0x18(%rbp), %rcx
leaq 0x20a4685(%rip), %rax   # 0x20ad450
imulq $0x58, %rcx, %rcx
addq %rcx, %rax
movslq -0x1c(%rbp), %rcx
movq %rdx, (%rax,%rcx,8)
movl -0x14(%rbp), %esi
movl -0x18(%rbp), %edx
leaq 0x48b2(%rip), %rdi      # 0xd699
movb $0x0, %al
callq 0x9ae0
movl -0x14(%rbp), %eax
movl %eax, -0x30(%rbp)
subl $0x1f010, %eax          # imm = 0x1F010
je 0x8f85
jmp 0x8e01
movl -0x30(%rbp), %eax
subl $0x1f10d, %eax          # imm = 0x1F10D
je 0x8f73
jmp 0x8e11
movl -0x30(%rbp), %eax
subl $0x1f112, %eax          # imm = 0x1F112
je 0x8ef8
jmp 0x8e21
movl -0x30(%rbp), %eax
subl $0x1f503, %eax          # imm = 0x1F503
je 0x8f37
jmp 0x8e31
movl -0x30(%rbp), %eax
subl $0x1f50b, %eax          # imm = 0x1F50B
je 0x8f22
jmp 0x8e41
movl -0x30(%rbp), %eax
subl $0x1f513, %eax          # imm = 0x1F513
je 0x8f61
jmp 0x8e51
movl -0x30(%rbp), %eax
subl $0x1f802, %eax          # imm = 0x1F802
je 0x8f97
jmp 0x8e61
movl -0x30(%rbp), %eax
subl $0x1f805, %eax          # imm = 0x1F805
je 0x8fbb
jmp 0x8e71
movl -0x30(%rbp), %eax
addl $0xfffe07f2, %eax       # imm = 0xFFFE07F2
subl $0x4, %eax
jb 0x8fcd
jmp 0x8e84
movl -0x30(%rbp), %eax
subl $0x1fa03, %eax          # imm = 0x1FA03
je 0x8fa9
jmp 0x8e94
movl -0x30(%rbp), %eax
addl $0xfffe04ff, %eax       # imm = 0xFFFE04FF
subl $0x2, %eax
jb 0x8fcd
jmp 0x8ea7
movl -0x30(%rbp), %eax
subl $0x1fb06, %eax          # imm = 0x1FB06
je 0x8fcd
jmp 0x8eb7
movl -0x30(%rbp), %eax
addl $0xfffe04f7, %eax       # imm = 0xFFFE04F7
subl $0x2, %eax
jb 0x8fcd
jmp 0x8eca
movl -0x30(%rbp), %eax
addl $0xfffe04ef, %eax       # imm = 0xFFFE04EF
subl $0x2, %eax
jb 0x8fcd
jmp 0x8edd
movl -0x30(%rbp), %eax
subl $0x1fd02, %eax          # imm = 0x1FD02
je 0x8f0d
jmp 0x8ee9
movl -0x30(%rbp), %eax
subl $0x1fd07, %eax          # imm = 0x1FD07
je 0x8f4c
jmp 0x8fdf
movq -0x8(%rbp), %rdi
movl -0x18(%rbp), %esi
movq -0x10(%rbp), %rdx
callq 0x9160
jmp 0x8fe1
movq -0x8(%rbp), %rdi
movl -0x18(%rbp), %esi
movq -0x10(%rbp), %rdx
callq 0x92c0
jmp 0x8fe1
movq -0x8(%rbp), %rdi
movl -0x18(%rbp), %esi
movq -0x10(%rbp), %rdx
callq 0x93a0
jmp 0x8fe1
movq -0x8(%rbp), %rdi
movl -0x18(%rbp), %esi
movq -0x10(%rbp), %rdx
callq 0x9440
jmp 0x8fe1
movq -0x8(%rbp), %rdi
movl -0x18(%rbp), %esi
movq -0x10(%rbp), %rdx
callq 0x94b0
jmp 0x8fe1
movq -0x8(%rbp), %rdi
movl -0x18(%rbp), %esi
movq -0x10(%rbp), %rdx
callq 0x9570
jmp 0x8fe1
movq -0x8(%rbp), %rdi
movl -0x18(%rbp), %esi
movq -0x10(%rbp), %rdx
callq 0x9600
jmp 0x8fe1
movq -0x8(%rbp), %rdi
movl -0x18(%rbp), %esi
movq -0x10(%rbp), %rdx
callq 0x9670
jmp 0x8fe1
movq -0x8(%rbp), %rdi
movl -0x18(%rbp), %esi
movq -0x10(%rbp), %rdx
callq 0x5d30
jmp 0x8fe1
movq -0x8(%rbp), %rdi
movl -0x18(%rbp), %esi
movq -0x10(%rbp), %rdx
callq 0x5de0
jmp 0x8fe1
movq -0x8(%rbp), %rdi
movl -0x18(%rbp), %esi
movq -0x10(%rbp), %rdx
callq 0x5ee0
jmp 0x8fe1
movq -0x8(%rbp), %rdi
movl -0x18(%rbp), %esi
movq -0x10(%rbp), %rdx
callq 0x6500
jmp 0x8fe1
jmp 0x8fe1
addq $0x30, %rsp
popq %rbp
retq
nopw (%rax,%rax)