// File: /workspace/github_c_makefile_star2_O0/canboat[P]canboat/n2kd/gps_ais.c
// Function: aisShipDimensions
static long int aisShipDimensions(const char *msg, bool ship)
{
  long int length, beam, refBow, refStarboard, toStern, toPort;

  // Fetch pgn values
  if (ship)
  {
    length       = aisFloat(msg, "Length");
    beam         = aisFloat(msg, "Beam");
    refBow       = aisFloat(msg, "Position reference from Bow");
    refStarboard = aisFloat(msg, "Position reference from Starboard");
  }
  else
  {
    length       = aisFloat(msg, "Length/Diameter");
    beam         = aisFloat(msg, "Beam/Diameter");
    refBow       = aisFloat(msg, "Position Reference from True North Facing Edge");
    refStarboard = aisFloat(msg, "Position Reference from Starboard Edge");
  }

  // Calculate sentence values
  toStern = (length - refBow < 5110) ? length - refBow : 5110;
  toPort  = (beam - refStarboard < 630) ? beam - refStarboard : 630;

  // Pack values into 30 bits of the long integer
  return (((refBow + 5) / 10) << 21) + (((toStern + 5) / 10) << 12) + (((toPort + 5) / 10) << 6) + ((refStarboard + 5) / 10);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x70, %rsp
movb %sil, %al
movq %rdi, -0x8(%rbp)
andb $0x1, %al
movb %al, -0x9(%rbp)
testb $0x1, -0x9(%rbp)
je 0x843c
movq -0x8(%rbp), %rdi
leaq 0x5093(%rip), %rsi      # 0xd488
callq 0x7d10
movq %rax, -0x18(%rbp)
movq -0x8(%rbp), %rdi
leaq 0x5086(%rip), %rsi      # 0xd48f
callq 0x7d10
movq %rax, -0x20(%rbp)
movq -0x8(%rbp), %rdi
leaq 0x5099(%rip), %rsi      # 0xd4b6
callq 0x7d10
movq %rax, -0x28(%rbp)
movq -0x8(%rbp), %rdi
leaq 0x5063(%rip), %rsi      # 0xd494
callq 0x7d10
movq %rax, -0x30(%rbp)
jmp 0x848c
movq -0x8(%rbp), %rdi
leaq 0x508b(%rip), %rsi      # 0xd4d2
callq 0x7d10
movq %rax, -0x18(%rbp)
movq -0x8(%rbp), %rdi
leaq 0x5087(%rip), %rsi      # 0xd4e2
callq 0x7d10
movq %rax, -0x20(%rbp)
movq -0x8(%rbp), %rdi
leaq 0x50a8(%rip), %rsi      # 0xd517
callq 0x7d10
movq %rax, -0x28(%rbp)
movq -0x8(%rbp), %rdi
leaq 0x506d(%rip), %rsi      # 0xd4f0
callq 0x7d10
movq %rax, -0x30(%rbp)
movq -0x18(%rbp), %rax
subq -0x28(%rbp), %rax
cmpq $0x13f6, %rax           # imm = 0x13F6
jge 0x84aa
movq -0x18(%rbp), %rax
subq -0x28(%rbp), %rax
movq %rax, -0x48(%rbp)
jmp 0x84b5
movl $0x13f6, %eax           # imm = 0x13F6
movq %rax, -0x48(%rbp)
jmp 0x84b5
movq -0x48(%rbp), %rax
movq %rax, -0x38(%rbp)
movq -0x20(%rbp), %rax
subq -0x30(%rbp), %rax
cmpq $0x276, %rax            # imm = 0x276
jge 0x84db
movq -0x20(%rbp), %rax
subq -0x30(%rbp), %rax
movq %rax, -0x50(%rbp)
jmp 0x84e6
movl $0x276, %eax            # imm = 0x276
movq %rax, -0x50(%rbp)
jmp 0x84e6
movq -0x50(%rbp), %rax
movq %rax, -0x40(%rbp)
movq -0x28(%rbp), %rax
addq $0x5, %rax
movl $0xa, %ecx
cqto
idivq %rcx
shlq $0x15, %rax
movq %rax, -0x68(%rbp)
movq -0x38(%rbp), %rax
addq $0x5, %rax
movl $0xa, %ecx
cqto
idivq %rcx
movq %rax, %rcx
movq -0x68(%rbp), %rax
shlq $0xc, %rcx
addq %rcx, %rax
movq %rax, -0x60(%rbp)
movq -0x40(%rbp), %rax
addq $0x5, %rax
movl $0xa, %ecx
cqto
idivq %rcx
movq %rax, %rcx
movq -0x60(%rbp), %rax
shlq $0x6, %rcx
addq %rcx, %rax
movq %rax, -0x58(%rbp)
movq -0x30(%rbp), %rax
addq $0x5, %rax
movl $0xa, %ecx
cqto
idivq %rcx
movq %rax, %rcx
movq -0x58(%rbp), %rax
addq %rcx, %rax
addq $0x70, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)