// File: /workspace/github_c_makefile_star2_O0/canboat[P]canboat/n2kd/gps_ais.c
// Function: aisInteger
static long int aisInteger(const char *msg, const char *fieldName)
{
  typedef struct
  {
    int         hash;
    const char *value;
    long int    min;
    long int    max;
    long int    defValue;
  } intParam;

  // Initialisation of type keys, done at most once
  static const int p1 = 'U' + 's' + 'e' + 'r' + ' ' + 'I' + 'D';
  static const int p2
      = 'C' + 'o' + 'm' + 'm' + 'u' + 'n' + 'i' + 'c' + 'a' + 't' + 'i' + 'o' + 'n' + ' ' + 'S' + 't' + 'a' + 't' + 'e';
  static const int p3 = 'I' + 'M' + 'O' + ' ' + 'n' + 'u' + 'm' + 'b' + 'e' + 'r';
  static const int p4 = 'M' + 'o' + 't' + 'h' + 'e' + 'r' + 's' + 'h' + 'i' + 'p' + ' ' + 'U' + 's' + 'e' + 'r' + ' ' + 'I' + 'D';
  static const int p5 = 'S' + 'o' + 'u' + 'r' + 'c' + 'e' + ' ' + 'I' + 'D';
  static const int p6 = 'S' + 'e' + 'q' + 'u' + 'e' + 'n' + 'c' + 'e' + ' ' + 'N' + 'u' + 'm' + 'b' + 'e' + 'r';
  static const int p7 = 'D' + 'e' + 's' + 't' + 'i' + 'n' + 'a' + 't' + 'i' + 'o' + 'n' + ' ' + 'I' + 'D';
  static const int p8 = 'R' + 'e' + 't' + 'r' + 'a' + 'n' + 's' + 'm' + 'i' + 't' + ' ' + 'f' + 'l' + 'a' + 'g';

  char     jsonString[40];
  int      i, h = 0;
  long int value;

  intParam paramRange[] = {{p1, "User ID", 0, 999999999, 0},
                           {p2, "Communication State", 0, 524287, 393222},
                           {p3, "IMO number", 1000000, 9999999, 0},
                           {p4, "Mothership User ID", 0, 999999999, 0},
                           {p5, "Source ID", 0, 999999999, 0},
                           {p6, "Sequence Number", 0, 3, 0},
                           {p7, "Destination ID", 0, 999999999, 0},
                           {p8, "Retransmit flag", 0, 1, 0}};

  // Calculate index
  for (i = 0; fieldName[i] != '\0'; i++)
  {
    h += fieldName[i];
  }
  for (i = 0; i < sizeof(paramRange) / sizeof(intParam); i++)
  {
    if (paramRange[i].hash == h && !strcmp(fieldName, paramRange[i].value))
    {
      break;
    }
  }

  if (!getJSONValue(msg, fieldName, jsonString, sizeof(jsonString)))
  {
    return paramRange[i].defValue;
  }
  if (jsonString[0] == '\0')
  {
    return paramRange[i].defValue;
  }
  value = atol(jsonString);
  if (value >= paramRange[i].min && value <= paramRange[i].max)
  {
    return value;
  }
  return paramRange[i].defValue;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x190, %rsp            # imm = 0x190
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movl $0x0, -0x48(%rbp)
leaq -0x190(%rbp), %rdi
leaq 0x8dc8(%rip), %rsi      # 0x10960
movl $0x140, %edx            # imm = 0x140
callq 0x2220
movl $0x0, -0x44(%rbp)
movq -0x18(%rbp), %rax
movslq -0x44(%rbp), %rcx
movsbl (%rax,%rcx), %eax
cmpl $0x0, %eax
je 0x7bd7
movq -0x18(%rbp), %rax
movslq -0x44(%rbp), %rcx
movsbl (%rax,%rcx), %eax
addl -0x48(%rbp), %eax
movl %eax, -0x48(%rbp)
movl -0x44(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x44(%rbp)
jmp 0x7ba9
movl $0x0, -0x44(%rbp)
movslq -0x44(%rbp), %rax
cmpq $0x8, %rax
jae 0x7c34
movslq -0x44(%rbp), %rcx
leaq -0x190(%rbp), %rax
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movl (%rax), %eax
cmpl -0x48(%rbp), %eax
jne 0x7c27
movq -0x18(%rbp), %rdi
movslq -0x44(%rbp), %rcx
leaq -0x190(%rbp), %rax
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movq 0x8(%rax), %rsi
callq 0x21f0
cmpl $0x0, %eax
jne 0x7c27
jmp 0x7c34
jmp 0x7c29
movl -0x44(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x44(%rbp)
jmp 0x7bde
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
leaq -0x40(%rbp), %rdx
movl $0x28, %ecx
callq 0xa660
testb $0x1, %al
jne 0x7c6d
movslq -0x44(%rbp), %rcx
leaq -0x190(%rbp), %rax
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movq 0x20(%rax), %rax
movq %rax, -0x8(%rbp)
jmp 0x7cfb
movsbl -0x40(%rbp), %eax
cmpl $0x0, %eax
jne 0x7c92
movslq -0x44(%rbp), %rcx
leaq -0x190(%rbp), %rax
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movq 0x20(%rax), %rax
movq %rax, -0x8(%rbp)
jmp 0x7cfb
leaq -0x40(%rbp), %rdi
callq 0x22c0
movq %rax, -0x50(%rbp)
movq -0x50(%rbp), %rax
movslq -0x44(%rbp), %rdx
leaq -0x190(%rbp), %rcx
imulq $0x28, %rdx, %rdx
addq %rdx, %rcx
cmpq 0x10(%rcx), %rax
jl 0x7ce1
movq -0x50(%rbp), %rax
movslq -0x44(%rbp), %rdx
leaq -0x190(%rbp), %rcx
imulq $0x28, %rdx, %rdx
addq %rdx, %rcx
cmpq 0x18(%rcx), %rax
jg 0x7ce1
movq -0x50(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0x7cfb
movslq -0x44(%rbp), %rcx
leaq -0x190(%rbp), %rax
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movq 0x20(%rax), %rax
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x190, %rsp            # imm = 0x190
popq %rbp
retq
nopl (%rax,%rax)