LLM4Binary/decompile-bench-makefile huggingface dataset:
// File: /workspace/github_c_makefile_star2_O3/canboat[P]canboat/n2kd/main.c
// Function: writeAndClose
static void writeAndClose(int idx, char *data, size_t len)
{
  int r;

#ifdef O_NONBLOCK
  int flags = fcntl(stream[idx].fd, F_GETFL, 0);
  fcntl(stream[idx].fd, F_SETFL, flags & ~O_NONBLOCK);
#else
  int ioctlOptionValue = 0;
  ioctl(stream[idx].fd, FIONBIO, &ioctlOptionValue);
#endif

  while (len > 0)
  {
    r = write(stream[idx].fd, data, len);
    if (r <= 0)
    {
      break;
    }
    len -= r;
    data += r;
  }
  closeStream(idx);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
movq %rdx, %rbx
movq %rsi, %r14
movl %edi, %ebp
movslq %edi, %rax
imulq $0x8038, %rax, %r12     # imm = 0x8038
leaq 0x9eef(%rip), %r15      # 0xe520
movl (%r12,%r15), %edi
movl $0x3, %esi
xorl %edx, %edx
xorl %eax, %eax
callq 0x20d0
movl (%r12,%r15), %edi
andl $0xfffff7ff, %eax       # imm = 0xFFFFF7FF
movl $0x4, %esi
movl %eax, %edx
xorl %eax, %eax
callq 0x20d0
testq %rbx, %rbx
je 0x4681
addq %r12, %r15
movl (%r15), %edi
movq %r14, %rsi
movq %rbx, %rdx
callq 0x20e0
testl %eax, %eax
jle 0x4681
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
addq %rax, %r14
subq %rax, %rbx
jne 0x4662
movl %ebp, %edi
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
jmp 0x3fe5
// File: /workspace/github_c_makefile_star2_O3/canboat[P]canboat/n2kd/gps_ais.c
// Function: nmea0183VTG
extern void nmea0183VTG(StringBuffer *msg183, int src, const char *msg)
{
  double sog;
  double cog;

  if (getJSONNumber(msg, "SOG", &sog, U_VELOCITY) && getJSONNumber(msg, "COG", &cog, U_ANGLE))
  {
    nmea0183CreateMessage(msg183, src, "VTG,%.1f,T,,M,%.2f,N,%.2f,K", cog, SPEED_M_S_TO_KNOTS(sog), SPEED_M_S_TO_KMH(sog));
    g_sog        = sog;
    g_cog        = cog;
    g_sog_cog_ts = getNow();
  }
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
subq $0x10, %rsp
movq %rdx, %r15
movl %esi, %ebx
movq %rdi, %r14
leaq 0x5a94(%rip), %rsi      # 0xa13c
leaq 0x8(%rsp), %rdx
movq %r15, %rdi
movl $0x2, %ecx
callq 0x726b
testb %al, %al
je 0x472f
leaq 0x5a7b(%rip), %rsi      # 0xa140
movq %rsp, %rdx
movq %r15, %rdi
xorl %ecx, %ecx
callq 0x726b
testb %al, %al
je 0x472f
movsd (%rsp), %xmm0
movsd 0x8(%rsp), %xmm2
movsd 0x5977(%rip), %xmm1     # 0xa060
mulsd %xmm2, %xmm1
mulsd 0x5973(%rip), %xmm2     # 0xa068
leaq 0x5a48(%rip), %rdx      # 0xa144
movq %r14, %rdi
movl %ebx, %esi
movb $0x3, %al
callq 0x6728
movsd 0x8(%rsp), %xmm0
movsd %xmm0, 0x20a5c4a(%rip)  # 0x20aa360
movsd (%rsp), %xmm0
movsd %xmm0, 0x20a5c45(%rip)  # 0x20aa368
callq 0x72e8
movq %rax, 0x20a5c41(%rip)   # 0x20aa370
addq $0x10, %rsp
popq %rbx
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O3/canboat[P]canboat/n2kd/gps_ais.c
// Function: nmea0183GSA
extern void nmea0183GSA(StringBuffer *msg183, int src, const char *msg)
{
  char modeString[OTHER_LENGTH] = "";
  char pdopString[OTHER_LENGTH] = "";
  char hdopString[OTHER_LENGTH] = "";
  char vdopString[OTHER_LENGTH] = "";

  getJSONValue(msg, "Actual Mode", modeString, sizeof(modeString));
  getJSONValue(msg, "PDOP", pdopString, sizeof(pdopString));
  getJSONValue(msg, "HDOP", hdopString, sizeof(hdopString));
  getJSONValue(msg, "VDOP", vdopString, sizeof(vdopString));

  modeString[1] = 0; // Abbreviate string, or still empty if not in N2K PGN

  nmea0183CreateMessage(msg183, src, "GSA,M,%s,,,,,,,,,,,,,%s,%s,%s", modeString, pdopString, hdopString, vdopString);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x88, %rsp
movq %rdx, %rbp
movl %esi, 0xc(%rsp)
movq %rdi, %r15
xorl %eax, %eax
leaq 0x70(%rsp), %r14
movl %eax, 0x10(%r14)
xorps %xmm0, %xmm0
movaps %xmm0, (%r14)
leaq 0x50(%rsp), %r12
movl %eax, 0x10(%r12)
movaps %xmm0, (%r12)
leaq 0x30(%rsp), %r13
movl %eax, 0x10(%r13)
movaps %xmm0, (%r13)
leaq 0x10(%rsp), %rbx
movl %eax, 0x10(%rbx)
movaps %xmm0, (%rbx)
leaq 0x59cb(%rip), %rsi      # 0xa160
movl $0x14, %ecx
movq %rdx, %rdi
movq %r14, %rdx
callq 0x7c22
leaq 0x59c0(%rip), %rsi      # 0xa16c
movl $0x14, %ecx
movq %rbp, %rdi
movq %r12, %rdx
callq 0x7c22
leaq 0x59ae(%rip), %rsi      # 0xa171
movl $0x14, %ecx
movq %rbp, %rdi
movq %r13, %rdx
callq 0x7c22
leaq 0x599c(%rip), %rsi      # 0xa176
movl $0x14, %ecx
movq %rbp, %rdi
movq %rbx, %rdx
callq 0x7c22
movb $0x0, 0x1(%r14)
movq %rbx, (%rsp)
leaq 0x5981(%rip), %rdx      # 0xa17b
movq %r15, %rdi
movl 0xc(%rsp), %esi
movq %r14, %rcx
movq %r12, %r8
movq %r13, %r9
xorl %eax, %eax
callq 0x6728
addq $0x88, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/canboat[P]canboat/n2kd/gps_ais.c
// Function: aisETA
long int aisETA(const char *msg)
{
  char         jstr[11];
  unsigned int month = 0, day = 0, hour = 24, minute = 60;

  // Get ais values from json (sscanf not used as it fails for som values)
  if (getJSONValue(msg, "ETA Date", jstr, sizeof(jstr)))
  {
    month = 10 * ((unsigned char) jstr[5] - '0') + ((unsigned char) jstr[6] - '0');
    day   = 10 * ((unsigned char) jstr[8] - '0') + ((unsigned char) jstr[9] - '0');
    if (month > 12)
      month = 0;
    if (day > 31)
      day = 0;
  }

  if (getJSONValue(msg, "ETA Time", jstr, sizeof(jstr)))
  {
    hour   = 10 * ((unsigned char) jstr[0] - '0') + ((unsigned char) jstr[1] - '0');
    minute = 10 * ((unsigned char) jstr[3] - '0') + ((unsigned char) jstr[4] - '0');
    if (hour > 24)
      hour = 24;
    if (minute > 60)
      minute = 60;
  }

  // Pack into ais integer
  return (month << 16) + (day << 11) + (hour << 6) + minute;
}

// Assembly:
pushq %rbp
pushq %r14
pushq %rbx
subq $0x10, %rsp
movq %rdi, %r14
leaq 0x5672(%rip), %rsi      # 0xa233
leaq 0x5(%rsp), %rdx
movl $0xb, %ecx
callq 0x7c22
xorl %ebp, %ebp
movl $0x0, %ebx
testb %al, %al
je 0x4c1c
movzbl 0xa(%rsp), %eax
leal (%rax,%rax,4), %eax
movzbl 0xb(%rsp), %ecx
leal (%rcx,%rax,2), %eax
movl $0xfffffdf0, %ecx       # imm = 0xFFFFFDF0
addl %ecx, %eax
movzbl 0xd(%rsp), %edx
leal (%rdx,%rdx,4), %edx
movzbl 0xe(%rsp), %esi
leal (%rsi,%rdx,2), %edx
addl %ecx, %edx
movl %eax, %ebp
shll $0x10, %ebp
movl %edx, %ebx
shll $0xb, %ebx
xorl %ecx, %ecx
cmpl $0xd, %eax
cmovael %ecx, %ebp
cmpl $0x20, %edx
cmovael %ecx, %ebx
leaq 0x5619(%rip), %rsi      # 0xa23c
leaq 0x5(%rsp), %rdx
movl $0xb, %ecx
movq %r14, %rdi
callq 0x7c22
testb %al, %al
je 0x4c7d
movzbl 0x5(%rsp), %eax
leal (%rax,%rax,4), %eax
movzbl 0x6(%rsp), %ecx
leal (%rcx,%rax,2), %ecx
movl $0xfffffdf0, %eax       # imm = 0xFFFFFDF0
addl %eax, %ecx
movzbl 0x8(%rsp), %edx
leal (%rdx,%rdx,4), %edx
movzbl 0x9(%rsp), %esi
leal (%rsi,%rdx,2), %edx
addl %eax, %edx
cmpl $0x18, %ecx
movl $0x18, %eax
cmovbl %ecx, %eax
cmpl $0x3c, %edx
movl $0x3c, %ecx
cmovbl %edx, %ecx
shll $0x6, %eax
jmp 0x4c87
movl $0x3c, %ecx
movl $0x600, %eax            # imm = 0x600
addl %ecx, %eax
addl %ebp, %ebx
addl %eax, %ebx
movq %rbx, %rax
addq $0x10, %rsp
popq %rbx
popq %r14
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/canboat[P]canboat/n2kd/gps_ais.c
// Function: aisAtoNName
char *aisAtoNName(const char *msg, bool extended, int *len)
{
  // The name splits in two parts, name and name extension.
  static char jsonString[35];
  int         i;

  // The extended name part is of variable length. Since the len byte has
  // been dropped, we have to rely on NULL termination of the string in
  // the extended part. First 20 chars ordinary name
  for (i = 20; i < 35; i++)
  {
    jsonString[i] = '\0';
  }

  if (!getJSONValue(msg, "AtoN Name", jsonString, sizeof(jsonString)))
    jsonString[0] = '\0';
  jsonString[34] = '\0';

  if (extended)
  {
    char *eName = (char *) jsonString + 20;
    for (i = 0; i <= 14; i++)
    {
      if (*(eName + i) == '\0')
        break;
    }
    // Each ais char is 6 bit. The length shall be padded to a multiple of 8 bits
    i *= 6;
    if (i % 8)
      i += 8 - i % 8;
    *len = i;
    return eName;
  }
  else
  {
    jsonString[20] = '\0';
  }
  return jsonString;
}

// Assembly:
pushq %rbp
pushq %r14
pushq %rbx
movq %rdx, %rbx
movl %esi, %ebp
xorl %eax, %eax
movq %rax, 0x20a56f0(%rip)   # 0x20aa39b
movq %rax, 0x20a56e2(%rip)   # 0x20aa394
leaq 0x20a56c7(%rip), %r14   # 0x20aa380
leaq 0x5585(%rip), %rsi      # 0xa245
movl $0x23, %ecx
movq %r14, %rdx
callq 0x7c22
testb %al, %al
jne 0x4cd8
movb $0x0, 0x20a56a8(%rip)   # 0x20aa380
movb $0x0, 0x20a56c3(%rip)   # 0x20aa3a2
testb %bpl, %bpl
je 0x4d1f
leaq 0x20a56a9(%rip), %rcx   # 0x20aa394
xorl %eax, %eax
cmpb $0x0, (%rcx)
je 0x4d04
addq $0x6, %rax
incq %rcx
cmpq $0x5a, %rax
jne 0x4ced
movl $0x5a, %eax
movl %eax, %ecx
andl $0x7ffffff8, %ecx       # imm = 0x7FFFFFF8
addl $0x8, %ecx
testb $0x6, %al
cmovel %eax, %ecx
movl %ecx, (%rbx)
leaq 0x20a5677(%rip), %r14   # 0x20aa394
jmp 0x4d26
movb $0x0, 0x20a566e(%rip)   # 0x20aa394
movq %r14, %rax
popq %rbx
popq %r14
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/canboat[P]canboat/n2kd/gps_ais.c
// Function: aisEnum
static int aisEnum(const char *msg, const char *fieldName)
{
  int64_t n;

  if (getJSONInt64(msg, fieldName, &n))
  {
    logDebug("getJSONInt64(msg, '%s') = %" PRId64 "\n", fieldName, n);
    return (int) n;
  }
  logDebug("getJSONInt64(msg, '%s') = no result -> -1\n", fieldName);
  return -1;
}

// Assembly:
pushq %rbx
subq $0x10, %rsp
movq %rsi, %rbx
leaq 0x8(%rsp), %rdx
callq 0x8037
testb %al, %al
je 0x6139
movq 0x8(%rsp), %rdx
leaq 0x4345(%rip), %rdi      # 0xa46e
movq %rbx, %rsi
xorl %eax, %eax
callq 0x7509
movl 0x8(%rsp), %eax
jmp 0x614f
leaq 0x434d(%rip), %rdi      # 0xa48d
movq %rbx, %rsi
xorl %eax, %eax
callq 0x7509
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
addq $0x10, %rsp
popq %rbx
retq
// File: /workspace/github_c_makefile_star2_O3/canboat[P]canboat/n2kd/gps_ais.c
// Function: addAisInt
static int addAisInt(long int value, int len, aisVector *payload)
{
  int           i, k;
  unsigned char nibble;

  // Break if overflow, does not treat signed positive value properly
  if (value >= (long int) (1 << len) || value < -(long int) (1 << (len - 1)))
  {
    return 0;
  }

  // AIS uses big endian. Thus most significant bits shall be stored first.
  while (len > 0)
  {
    i = payload->pos / 8;
    k = 8 - payload->pos % 8;
    payload->bitVector[i] &= ~(unsigned char) ((1 << k) - 1);
    if (len >= k)
    {
      nibble = ((1 << k) - 1) & (value >> (len - k));
      payload->pos += k;
    }
    else
    {
      nibble = ((1 << k) - 1) & (value << (k - len));
      payload->pos += len;
    }
    payload->bitVector[i] |= nibble;
    len -= k;
  }
  return 1;
}

// Assembly:
movl $0x1, %eax
movl $0x1, %r8d
movl %esi, %ecx
shll %cl, %r8d
cmpq %rdi, %r8
jle 0x61f1
leal -0x1(%rsi), %ecx
shll %cl, %eax
negq %rax
cmpq %rdi, %rax
setg %al
testl %esi, %esi
setle %cl
orb %al, %cl
jne 0x61f1
movl 0xe4(%rdx), %ecx
leal 0x7(%rcx), %eax
testl %ecx, %ecx
cmovnsl %ecx, %eax
movl %eax, %r8d
sarl $0x3, %r8d
andl $-0x8, %eax
subl %ecx, %eax
addl $0x8, %eax
movl $0xffffffff, %r10d      # imm = 0xFFFFFFFF
movl %eax, %ecx
shll %cl, %r10d
movslq %r8d, %r9
andb %r10b, (%rdx,%r9)
movl %esi, %r8d
subl %eax, %r8d
jae 0x61ca
subl %esi, %eax
movq %rdi, %r11
movl %eax, %ecx
shlq %cl, %r11
movl %esi, %eax
jmp 0x61d3
movq %rdi, %r11
movl %r8d, %ecx
sarq %cl, %r11
notl %r10d
andl %r10d, %r11d
addl 0xe4(%rdx), %eax
movl %eax, 0xe4(%rdx)
orb %r11b, (%rdx,%r9)
movl %r8d, %esi
testl %r8d, %r8d
jg 0x6185
retq
// File: /workspace/github_c_makefile_star2_O3/canboat[P]canboat/n2kd/gps_ais.c
// Function: addAisString
static int addAisString(char *string, int len, aisVector *payload)
{
  int           i, k;
  unsigned char nextchar;

  if (string == NULL)
  {
    return 0;
  }

  while (len >= 6)
  {
    // Encode current char to 6-bit ascii
    // 32 -> 63 => 32 -> 63, 64 -> 95 => 0 -> 31
    nextchar = *string;
    if (nextchar == '\0')
    {
      nextchar = 0;
    }
    else if (nextchar < 32 || nextchar > 95)
    {
      nextchar = 32;
    }
    else if (nextchar >= 64)
    {
      nextchar -= 64;
    }
    // Add 6-bit ascii char to payload
    i = payload->pos / 8;
    k = 8 - payload->pos % 8;
    payload->bitVector[i] &= ~(unsigned char) ((1 << k) - 1);
    if (k >= 6)
    {
      payload->bitVector[i] |= ((1 << k) - 1) & (nextchar << (k - 6));
    }
    else
    {
      payload->bitVector[i] |= ((1 << k) - 1) & (nextchar >> (6 - k));
      payload->bitVector[i + 1] = nextchar << (2 + k);
    }
    payload->pos += 6;
    len -= 6;
    if (*string != '\0')
    {
      string++;
    }
  }
  // A string can be padded with extra bits. These should reasonably be cleared
  payload->bitVector[(payload->pos / 8) + 1] = 0;
  payload->pos += len;
  return 1;
}

// Assembly:
testq %rdi, %rdi
je 0x6551
cmpl $0x6, %esi
jl 0x6530
pushq %rbx
movb (%rdi), %cl
testb %cl, %cl
je 0x649e
leal -0x60(%rcx), %r8d
movl $0x20, %eax
cmpb $-0x40, %r8b
jb 0x64a0
leal -0x40(%rcx), %eax
cmpb $0x40, %cl
movzbl %cl, %ecx
movzbl %al, %eax
cmovbl %ecx, %eax
movzbl %al, %eax
jmp 0x64a0
xorl %eax, %eax
movl 0xe4(%rdx), %r11d
leal 0x7(%r11), %ecx
testl %r11d, %r11d
cmovnsl %r11d, %ecx
movl %ecx, %r9d
sarl $0x3, %r9d
andl $-0x8, %ecx
subl %ecx, %r11d
movb $0x8, %cl
subb %r11b, %cl
movl $0xffffffff, %r8d       # imm = 0xFFFFFFFF
shll %cl, %r8d
movslq %r9d, %r9
movb (%rdx,%r9), %r10b
andb %r8b, %r10b
cmpl $0x2, %r11d
jg 0x64e6
movb $0x2, %cl
subb %r11b, %cl
shll %cl, %eax
jmp 0x64fc
leal -0x2(%r11), %ecx
movl %eax, %ebx
shrl %cl, %ebx
movb $0xa, %cl
subb %r11b, %cl
shll %cl, %eax
movb %al, 0x1(%r9,%rdx)
movl %ebx, %eax
notl %r8d
andl %eax, %r8d
orb %r8b, %r10b
movb %r10b, (%rdx,%r9)
movl 0xe4(%rdx), %eax
addl $0x6, %eax
movl %eax, 0xe4(%rdx)
leal -0x6(%rsi), %ecx
cmpb $0x1, (%rdi)
sbbq $-0x1, %rdi
cmpl $0xb, %esi
movl %ecx, %esi
jg 0x6475
popq %rbx
jmp 0x6538
movl 0xe4(%rdx), %eax
movl %esi, %ecx
leal 0x7(%rax), %esi
testl %eax, %eax
cmovnsl %eax, %esi
sarl $0x3, %esi
movslq %esi, %rax
movb $0x0, 0x1(%rax,%rdx)
addl %ecx, 0xe4(%rdx)
retq
// File: /workspace/github_c_makefile_star2_O3/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 %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
movq %rdi, %r15
leaq 0x3f53(%rip), %rcx      # 0xa4b8
leaq 0x3f96(%rip), %rax      # 0xa502
testl %esi, %esi
cmovneq %rcx, %rax
leaq 0x3f46(%rip), %rcx      # 0xa4bf
leaq 0x3f92(%rip), %rbx      # 0xa512
cmovneq %rcx, %rbx
leaq 0x3f5b(%rip), %rcx      # 0xa4e6
leaq 0x3fb5(%rip), %r12      # 0xa547
cmovneq %rcx, %r12
leaq 0x3f27(%rip), %rcx      # 0xa4c4
leaq 0x3f7c(%rip), %r13      # 0xa520
cmovneq %rcx, %r13
movq %rax, %rsi
callq 0x62bf
movq %rax, %r14
movq %r15, %rdi
movq %rbx, %rsi
callq 0x62bf
movq %rax, %rbx
movq %r15, %rdi
movq %r12, %rsi
callq 0x62bf
movq %rax, %r12
movq %r15, %rdi
movq %r13, %rsi
callq 0x62bf
movq %rax, %rcx
subq %r12, %r14
movl $0x13f6, %eax           # imm = 0x13F6
cmpq %rax, %r14
cmovgeq %rax, %r14
subq %rcx, %rbx
movl $0x276, %eax            # imm = 0x276
cmpq %rax, %rbx
cmovgeq %rax, %rbx
addq $0x5, %r12
movabsq $0x6666666666666667, %rdi # imm = 0x6666666666666667
movq %r12, %rax
imulq %rdi
movq %rdx, %rsi
shrq $0x3f, %rsi
shrq $0x2, %rdx
addq %rdx, %rsi
shlq $0x15, %rsi
addq $0x5, %r14
movq %r14, %rax
imulq %rdi
movq %rdx, %r8
shrq $0x3f, %r8
shrq $0x2, %rdx
addq %rdx, %r8
addq $0x5, %rbx
movq %rbx, %rax
imulq %rdi
shlq $0xc, %r8
movq %rdx, %r9
shrq $0x3f, %r9
shrq $0x2, %rdx
addq %rdx, %r9
shlq $0x6, %r9
addq $0x5, %rcx
movq %rcx, %rax
imulq %rdi
movq %rdx, %rax
shrq $0x3f, %rax
sarq $0x2, %rdx
addq %rdx, %rax
addq %rsi, %rax
addq %r9, %rax
addq %r8, %rax
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O3/canboat[P]canboat/n2kd/gps_ais.c
// Function: addAisLongString
static int addAisLongString(const char *msg, const char *fieldName, int maxSize, bool padd, aisVector *payload)
{
  char *jsonString;
  int   len;

  jsonString = (char *) calloc(maxSize + 1, sizeof(char));
  if (jsonString == NULL)
  {
    return 0;
  }

  if (!getJSONValue(msg, fieldName, jsonString, maxSize))
  {
    free(jsonString);
    return 0;
  }

  for (len = 0; len <= maxSize; len++)
  {
    if (*(jsonString + len) == '\0')
    {
      break;
    }
  }

  len *= 6;
  if (padd)
  {
    if (len % 8)
    {
      len += 8 - (len % 8); // Add padd bits
    }
  }

  addAisString(jsonString, len, payload);
  free(jsonString);
  return len;
}

// Assembly:
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
movq %rdx, %rbx
movl %esi, %r12d
movq %rdi, %r13
leal 0x1(%r12), %r15d
movl $0x1, %esi
movq %r15, %rdi
callq 0x21c0
testq %rax, %rax
je 0x66e1
movq %rax, %r14
movl %r12d, %ecx
leaq 0x3cf8(%rip), %rsi      # 0xa3b2
movq %r13, %rdi
movq %rax, %rdx
callq 0x7c22
testb %al, %al
je 0x6714
testl %r12d, %r12d
js 0x66eb
xorl %eax, %eax
cmpb $0x0, (%r14,%rax)
je 0x66ef
incq %rax
cmpq %rax, %r15
jne 0x66d0
jmp 0x66f2
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
xorl %eax, %eax
jmp 0x66f9
movl %eax, %r15d
addl %r15d, %r15d
leal (%r15,%r15,2), %eax
movl %eax, %esi
andl $0x7ffffff8, %esi       # imm = 0x7FFFFFF8
addl $0x8, %esi
testb $0x6, %al
cmovel %eax, %esi
movq %r14, %rdi
movq %rbx, %rdx
callq 0x6462
movq %r14, %rdi
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
jmp 0x2030
nopl (%rax)
// File: /workspace/github_c_makefile_star2_O3/canboat[P]canboat/n2kd/nmea0183.c
// Function: nmea0183CreateMessage
extern void nmea0183CreateMessage(StringBuffer *msg183, int src, const char *format, ...)
{
  uint8_t chk;
  size_t  i;
  char    first, second;
  va_list ap;

  va_start(ap, format);

  // Convert the 8 bit value 'n' into a valid NMEA0183 style sender.
  // The first implementation sent out a 2 digit hexadecimal number,
  // but that throws some implementations of receivers off as they
  // cannot handle numeric senders. So now we produce a 2 character
  // code with the src value 0-255 translated into
  // A..Q A..P with A representing 0, B representing 1, etc.
  // P is skipped for the initial letter, as that represents 'proprietary'
  // and OpenCPN does not allow this.

  first  = 'A' + ((src >> 4) & 0xf);
  second = 'A' + ((src) & 0xf);
  if (first >= 'P')
  {
    first++;
  }

  // Prepare for calculation of checksum
  i = msg183->len;

  if (src > 255)
    sbAppendFormat(msg183, "!%c%c", first, second);
  else
    sbAppendFormat(msg183, "$%c%c", first, second);
  sbAppendFormatV(msg183, format, ap);

  va_end(ap);

  chk = 0;
  for (i++; i < msg183->len; i++)
  {
    chk ^= (uint8_t) msg183->data[i];
  }
  sbAppendFormat(msg183, "*%02X\r\n", chk);
  logDebug("nmea0183 = %s", sbGet(msg183));
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0xd0, %rsp
movq %rdx, %r14
movq %rdi, %rbx
leaq 0x20(%rsp), %rdx
movq %rcx, 0x18(%rdx)
movq %r8, 0x20(%rdx)
movq %r9, 0x28(%rdx)
testb %al, %al
je 0x6789
movaps %xmm0, 0x50(%rsp)
movaps %xmm1, 0x60(%rsp)
movaps %xmm2, 0x70(%rsp)
movaps %xmm3, 0x80(%rsp)
movaps %xmm4, 0x90(%rsp)
movaps %xmm5, 0xa0(%rsp)
movaps %xmm6, 0xb0(%rsp)
movaps %xmm7, 0xc0(%rsp)
movq %rsp, %r15
movq %rdx, 0x10(%r15)
leaq 0x100(%rsp), %rax
movq %rax, 0x8(%r15)
movabsq $0x3000000018, %rax     # imm = 0x3000000018
movl %esi, %edx
shrb $0x4, %dl
leal 0x41(%rdx), %edi
movl %esi, %ecx
andl $0xf, %ecx
addl $0x41, %ecx
cmpb $0xf, %dl
movzbl %dil, %edx
movl $0x51, %edi
cmovnel %edx, %edi
movq %rax, (%r15)
movq 0x8(%rbx), %r12
cmpl $0x100, %esi            # imm = 0x100
movzbl %dil, %edx
leaq 0x3e7b(%rip), %rax      # 0xa658
leaq 0x3e7a(%rip), %rsi      # 0xa65e
cmovgeq %rax, %rsi
xorl %ebp, %ebp
movq %rbx, %rdi
xorl %eax, %eax
callq 0x79b5
movq %rbx, %rdi
movq %r14, %rsi
movq %r15, %rdx
callq 0x7b71
movq 0x8(%rbx), %rax
incq %r12
cmpq %rax, %r12
jae 0x6822
movq (%rbx), %rdx
xorl %ecx, %ecx
xorb (%rdx,%r12), %cl
incq %r12
cmpq %r12, %rax
jne 0x6813
movzbl %cl, %ebp
leaq 0x3e3b(%rip), %rsi      # 0xa664
movq %rbx, %rdi
movl %ebp, %edx
xorl %eax, %eax
callq 0x79b5
movq (%rbx), %rax
testq %rax, %rax
leaq 0x301d(%rip), %rsi      # 0x985f
cmovneq %rax, %rsi
leaq 0x3e1f(%rip), %rdi      # 0xa66c
xorl %eax, %eax
callq 0x7509
addq $0xd0, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/canboat[P]canboat/n2kd/nmea0183.c
// Function: nmea0183VesselHeading
static void nmea0183VesselHeading(StringBuffer *msg183, int src, const char *msg)
{
  double  heading;
  double  deviation;
  double  variation;
  int64_t reference;

  if (getJSONNumber(msg, "Heading", &heading, U_ANGLE) && getJSONInt64(msg, "Reference", &reference))
  {
    if (getJSONNumber(msg, "Deviation", &deviation, U_ANGLE) && getJSONNumber(msg, "Variation", &variation, U_ANGLE)
        && reference == 1)
    {
      /* Enough info for HDG message */

      nmea0183CreateMessage(msg183,
                            src,
                            "HDG,%.1f,%.1f,%c,%.1f,%c",
                            heading,
                            fabs(deviation),
                            ((deviation < 0.0) ? 'W' : 'E'),
                            fabs(variation),
                            ((variation < 0.0) ? 'W' : 'E'));
    }
    else if (reference == 0)
    {
      nmea0183CreateMessage(msg183, src, "HDT,%.1f,T", heading);
    }
    else if (reference == 1)
    {
      nmea0183CreateMessage(msg183, src, "HDM,%.1f,M", heading);
    }
  }
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
subq $0x20, %rsp
movq %rdx, %r15
movl %esi, %ebx
movq %rdi, %r14
leaq 0x36b9(%rip), %rsi      # 0xa403
movq %rsp, %rdx
movq %r15, %rdi
xorl %ecx, %ecx
callq 0x726b
testb %al, %al
je 0x6e51
leaq 0x39b5(%rip), %rsi      # 0xa71b
leaq 0x8(%rsp), %rdx
movq %r15, %rdi
callq 0x8037
testb %al, %al
je 0x6e51
leaq 0x39a3(%rip), %rsi      # 0xa725
leaq 0x18(%rsp), %rdx
movq %r15, %rdi
xorl %ecx, %ecx
callq 0x726b
testb %al, %al
je 0x6e1b
leaq 0x398f(%rip), %rsi      # 0xa72f
leaq 0x10(%rsp), %rdx
movq %r15, %rdi
xorl %ecx, %ecx
callq 0x726b
movq 0x8(%rsp), %rcx
cmpq $0x1, %rcx
sete %dl
andb %al, %dl
cmpb $0x1, %dl
jne 0x6e20
movsd (%rsp), %xmm0
movsd 0x18(%rsp), %xmm1
movapd 0x385b(%rip), %xmm2     # 0xa630
xorpd %xmm3, %xmm3
ucomisd %xmm1, %xmm3
andpd %xmm2, %xmm1
movl $0x57, %eax
movl $0x45, %ecx
cmoval %eax, %ecx
movl $0x45, %r8d
movsd 0x10(%rsp), %xmm4
ucomisd %xmm4, %xmm3
andpd %xmm4, %xmm2
cmoval %eax, %r8d
leaq 0x392c(%rip), %rdx      # 0xa739
movq %r14, %rdi
movl %ebx, %esi
movb $0x3, %al
callq 0x6728
jmp 0x6e51
movq 0x8(%rsp), %rcx
cmpq $0x1, %rcx
je 0x6e39
testq %rcx, %rcx
jne 0x6e51
movsd (%rsp), %xmm0
leaq 0x391b(%rip), %rdx      # 0xa752
jmp 0x6e45
movsd (%rsp), %xmm0
leaq 0x3918(%rip), %rdx      # 0xa75d
movq %r14, %rdi
movl %ebx, %esi
movb $0x1, %al
callq 0x6728
addq $0x20, %rsp
popq %rbx
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O3/canboat[P]canboat/n2kd/nmea0183.c
// Function: nmea0183WindData
static void nmea0183WindData(StringBuffer *msg183, int src, const char *msg)
{
  double  speed;
  double  angle;
  int64_t reference;

  if (getJSONNumber(msg, "Wind Speed", &speed, U_VELOCITY) && getJSONNumber(msg, "Wind Angle", &angle, U_ANGLE)
      && getJSONInt64(msg, "Reference", &reference))
  {
    if (reference == 3)
    {
      nmea0183CreateMessage(msg183, src, "MWV,%.1f,T,%.1f,K,A", angle, SPEED_M_S_TO_KMH(speed));
    }
    else if (reference == 2)
    {
      nmea0183CreateMessage(msg183, src, "MWV,%.1f,R,%.1f,K,A", angle, SPEED_M_S_TO_KMH(speed));
    }
  }
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
subq $0x20, %rsp
movq %rdx, %r15
movl %esi, %ebx
movq %rdi, %r14
leaq 0x38f5(%rip), %rsi      # 0xa768
leaq 0x10(%rsp), %rdx
movq %r15, %rdi
movl $0x2, %ecx
callq 0x726b
testb %al, %al
je 0x6f14
leaq 0x38df(%rip), %rsi      # 0xa773
leaq 0x8(%rsp), %rdx
movq %r15, %rdi
xorl %ecx, %ecx
callq 0x726b
testb %al, %al
je 0x6f14
leaq 0x386d(%rip), %rsi      # 0xa71b
leaq 0x18(%rsp), %rdx
movq %r15, %rdi
callq 0x8037
testb %al, %al
je 0x6f14
movq 0x18(%rsp), %rax
cmpq $0x2, %rax
je 0x6eed
cmpq $0x3, %rax
jne 0x6f14
movsd 0x8(%rsp), %xmm0
movsd 0x10(%rsp), %xmm1
mulsd 0x3184(%rip), %xmm1     # 0xa068
leaq 0x3893(%rip), %rdx      # 0xa77e
jmp 0x6f08
movsd 0x8(%rsp), %xmm0
movsd 0x10(%rsp), %xmm1
mulsd 0x3167(%rip), %xmm1     # 0xa068
leaq 0x388a(%rip), %rdx      # 0xa792
movq %r14, %rdi
movl %ebx, %esi
movb $0x2, %al
callq 0x6728
addq $0x20, %rsp
popq %rbx
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O3/canboat[P]canboat/n2kd/nmea0183.c
// Function: nmea0183WaterDepth
static void nmea0183WaterDepth(StringBuffer *msg183, int src, const char *msg)
{
  double depth;
  double offset;

  if (getJSONNumber(msg, "Depth", &depth, U_DISTANCE))
  {
    if (getJSONNumber(msg, "Offset", &offset, U_DISTANCE))
    {
      nmea0183CreateMessage(msg183, src, "DPT,%.1f,%.1f", depth, offset);
    }
    else
    {
      nmea0183CreateMessage(msg183, src, "DPT,%.1f,", depth);
    }
  }
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
subq $0x10, %rsp
movq %rdx, %r15
movl %esi, %ebx
movq %rdi, %r14
leaq 0x3870(%rip), %rsi      # 0xa7a6
leaq 0x8(%rsp), %rdx
movq %r15, %rdi
movl $0x3, %ecx
callq 0x726b
testb %al, %al
je 0x6f8e
leaq 0x3859(%rip), %rsi      # 0xa7ac
movq %rsp, %rdx
movq %r15, %rdi
movl $0x3, %ecx
callq 0x726b
movsd 0x8(%rsp), %xmm0
testb %al, %al
je 0x6f98
movsd (%rsp), %xmm1
leaq 0x383a(%rip), %rdx      # 0xa7b3
movq %r14, %rdi
movl %ebx, %esi
movb $0x2, %al
addq $0x10, %rsp
popq %rbx
popq %r14
popq %r15
jmp 0x6728
addq $0x10, %rsp
popq %rbx
popq %r14
popq %r15
retq
leaq 0x3822(%rip), %rdx      # 0xa7c1
movq %r14, %rdi
movl %ebx, %esi
movb $0x1, %al
addq $0x10, %rsp
popq %rbx
popq %r14
popq %r15
jmp 0x6728
// File: /workspace/github_c_makefile_star2_O3/canboat[P]canboat/n2kd/nmea0183.c
// Function: nmea0183SystemTime
static void nmea0183SystemTime(StringBuffer *msg183, int src, const char *msg)
{
  char         dateString[20];
  char         timeString[20];
  char         second[10];
  unsigned int year, month, day, hour, minute;

  if (getJSONValue(msg, "Date", dateString, sizeof(dateString)) && getJSONValue(msg, "Time", timeString, sizeof(timeString))
      && sscanf(dateString, "%u.%u.%u", &year, &month, &day) == 3 && sscanf(timeString, "%u:%u:%9s", &hour, &minute, second) == 3)
  {
    nmea0183CreateMessage(msg183, src, "ZDA,%02u%02u%s,%u,%u,%04u,,", hour, minute, second, day, month, year);
  }
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
subq $0x60, %rsp
movq %rdx, %r15
movl %esi, %ebx
movq %rdi, %r14
leaq 0x309a(%rip), %rsi      # 0xa237
leaq 0x40(%rsp), %rdx
movl $0x14, %ecx
movq %r15, %rdi
callq 0x7c22
testb %al, %al
je 0x7261
leaq 0x3082(%rip), %rsi      # 0xa240
leaq 0x20(%rsp), %rdx
movl $0x14, %ecx
movq %r15, %rdi
callq 0x7c22
testb %al, %al
je 0x7261
leaq 0x3676(%rip), %rsi      # 0xa855
leaq 0x40(%rsp), %rdi
leaq 0x10(%rsp), %rdx
leaq 0xc(%rsp), %rcx
leaq 0x8(%rsp), %r8
xorl %eax, %eax
callq 0x2240
cmpl $0x3, %eax
jne 0x7261
leaq 0x3658(%rip), %rsi      # 0xa85e
leaq 0x20(%rsp), %rdi
leaq 0x4(%rsp), %rdx
movq %rsp, %rcx
leaq 0x16(%rsp), %r8
xorl %eax, %eax
callq 0x2240
cmpl $0x3, %eax
jne 0x7261
movl 0x4(%rsp), %ecx
movl (%rsp), %r8d
movl 0x8(%rsp), %r10d
movl 0xc(%rsp), %r11d
movl 0x10(%rsp), %r15d
subq $0x8, %rsp
leaq 0x3622(%rip), %rdx      # 0xa868
leaq 0x1e(%rsp), %r9
movq %r14, %rdi
movl %ebx, %esi
xorl %eax, %eax
pushq %r15
pushq %r11
pushq %r10
callq 0x6728
addq $0x20, %rsp
addq $0x60, %rsp
popq %rbx
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O3/canboat[P]canboat/n2kd/nmea0183.c
// Function: getJSONNumber
bool getJSONNumber(const char *message, const char *fieldName, double *value, Unit unit)
{
  char valueStr[16];

  // List of conversion values for each unit. When analyser produces SI convert it to 'human standard'.
  static const double UNIT_CONVERSION[U_MAX][2] = {{1, RadianToDegree}, {1, RadianToDegree}, {1, 1}, {1, 1}, {1, 1}, {1, 1}};
  static const double UNIT_OFFSET[U_MAX][2]     = {{0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, -273.15}, {0, 0}};

  if (getJSONValue(message, fieldName, valueStr, sizeof valueStr))
  {
    *value = strtod(valueStr, 0) * UNIT_CONVERSION[unit][unitSI] + UNIT_OFFSET[unit][unitSI];
    return true;
  }
  *value = nan("");
  return false;
}

// Assembly:
pushq %rbp
pushq %r14
pushq %rbx
subq $0x10, %rsp
movl %ecx, %r14d
movq %rdx, %rbx
movq %rsp, %rdx
movl $0x10, %ecx
callq 0x7c22
movl %eax, %ebp
testb %al, %al
je 0x72ca
movq %rsp, %rdi
xorl %esi, %esi
callq 0x20a0
movl %r14d, %eax
leaq 0x70c8(%rip), %rcx      # 0xe368
movzbl (%rcx), %ecx
shlq $0x4, %rax
leaq 0x35e2(%rip), %rdx      # 0xa890
addq %rax, %rdx
shll $0x3, %ecx
leaq 0x3635(%rip), %rsi      # 0xa8f0
addq %rax, %rsi
mulsd (%rcx,%rdx), %xmm0
addsd (%rcx,%rsi), %xmm0
jmp 0x72d6
leaq 0x258e(%rip), %rdi      # 0x985f
callq 0x2330
movsd %xmm0, (%rbx)
movl %ebp, %eax
addq $0x10, %rsp
popq %rbx
popq %r14
popq %rbp
retq
nopl (%rax)
// File: /workspace/github_c_makefile_star2_O3/dasJ[P]sd-zfs/src/mount.initrd_zfs.c
// Function: handleBootfs
int handleBootfs(char **pool) {
	char *rpool = NULL;
	int ret = 1;

	// Handle rpool
	if (strncmp(*pool, "ZFS=AUTO:", strlen("ZFS=AUTO:")) == 0) {
		rpool = malloc((strlen(*pool) - strlen("ZFS=AUTO:") + 1) * sizeof(char));
		strcpy(rpool, &((*pool)[strlen("ZFS=AUTO:")]));
	}

	ret = zfs_get_bootfs(rpool, pool);
	free(rpool);
	return ret;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movq %rdi, %rbx
movq (%rdi), %r14
leaq 0xa2725(%rip), %rsi     # 0x4a4004
movl $0x9, %edx
movq %r14, %rdi
callq 0x401080
testl %eax, %eax
je 0x4018f5
xorl %r15d, %r15d
jmp 0x401918
movq %r14, %rdi
callq 0x4010e0
leaq -0x8(%rax), %rdi
callq 0x420f50
movq %rax, %r15
addq $0x9, %r14
movq %rax, %rdi
movq %r14, %rsi
callq 0x401020
movq %r15, %rdi
movq %rbx, %rsi
callq 0x402411
movl %eax, %ebx
movq %r15, %rdi
callq 0x421290
movl %ebx, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/dasJ[P]sd-zfs/src/zfs-util.c
// Function: zfs_destroy_recursively
int zfs_destroy_recursively(char *dataset) {
	char *lines = NULL;
	char *token;

	// Execute command
	char *cmdline[] = { ZFS_CMD, "list", "-tfilesystem", "-Hro", "name", "-Sname", dataset, NULL };
	executeZfs(1, &lines, cmdline);
	if (lines == NULL) {
		return 0;
	}
	// Destoy all datasets
	token = strtok(lines, "\n");
	do {
		if (zfs_destroy(token) != 0) {
			fprintf(stderr, "Not destroying any more datasets\n");
			free(lines);
			return -2;
		}
	} while ((token = strtok(NULL, "\n")) != NULL);

	free(lines);
	return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %rbx
subq $0x48, %rsp
xorl %ebx, %ebx
leaq -0x20(%rbp), %r14
movq %rbx, (%r14)
leaq 0xa2032(%rip), %rax     # 0x4a4205
leaq -0x60(%rbp), %rcx
movq %rax, (%rcx)
leaq 0xa4bb8(%rip), %rax     # 0x4a6d99
movq %rax, 0x8(%rcx)
leaq 0xa203b(%rip), %rax     # 0x4a4227
movq %rax, 0x10(%rcx)
leaq 0xa203d(%rip), %rax     # 0x4a4234
movq %rax, 0x18(%rcx)
leaq 0xa2039(%rip), %rax     # 0x4a423b
movq %rax, 0x20(%rcx)
leaq 0xa202c(%rip), %rax     # 0x4a4239
movq %rax, 0x28(%rcx)
movq %rdi, 0x30(%rcx)
movq %rbx, 0x38(%rcx)
leaq 0xa1fdc(%rip), %rdi     # 0x4a41fc
movl $0x1, %esi
movq %r14, %rdx
callq 0x401fa4
movq (%r14), %r14
testq %r14, %r14
je 0x40226c
leaq 0xa266e(%rip), %r15     # 0x4a48aa
movq %r14, %rdi
movq %r15, %rsi
callq 0x424170
movq %rax, %rdi
callq 0x402285
testl %eax, %eax
jne 0x402279
xorl %ebx, %ebx
xorl %edi, %edi
movq %r15, %rsi
callq 0x424170
testq %rax, %rax
jne 0x402247
movq %r14, %rdi
callq 0x421290
movl %ebx, %eax
addq $0x48, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
callq 0x401319
movl $0xfffffffe, %ebx       # imm = 0xFFFFFFFE
jmp 0x402264
// File: /workspace/github_c_makefile_star2_O3/dasJ[P]sd-zfs/src/zfs-util.c
// Function: zfs_destroy
int zfs_destroy(char *dataset) {
	int status;
	char *cmdline[] = { ZFS_CMD, "destroy", dataset, NULL };

	status = executeZfs(0, NULL, cmdline);
	if (status != 0) {
		fprintf(stderr, "ZFS returned error %d\n", status);
	}
	return status;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %rbx
subq $0x28, %rsp
leaq 0xa1f70(%rip), %rax     # 0x4a4205
leaq -0x30(%rbp), %rcx
movq %rax, (%rcx)
leaq 0xa1fbf(%rip), %rax     # 0x4a4262
movq %rax, 0x8(%rcx)
movq %rdi, 0x10(%rcx)
movq $0x0, 0x18(%rcx)
leaq 0xa1f42(%rip), %rdi     # 0x4a41fc
xorl %esi, %esi
xorl %edx, %edx
callq 0x401fa4
movl %eax, %ebx
testl %eax, %eax
jne 0x4022d2
movl %ebx, %eax
addq $0x28, %rsp
popq %rbx
popq %rbp
retq
movq $0x4d4708, %rax         # imm = 0x4D4708
movq (%rax), %rdi
leaq 0xa1f87(%rip), %rsi     # 0x4a426a
movl %ebx, %edx
xorl %eax, %eax
callq 0x40c900
jmp 0x4022c9
// File: /workspace/github_c_makefile_star2_O3/dasJ[P]sd-zfs/src/zfs-util.c
// Function: zfs_snapshot_exists
int zfs_snapshot_exists(char *dataset, char *snapshot) {
	int status;
	char *toCheck;

	toCheck = malloc((strlen(dataset) + strlen(snapshot) + 2) * sizeof(char));
	strcpy(toCheck, dataset);
	strcat(toCheck, "@");
	strcat(toCheck, snapshot);
	
	status = zfs_ds_exists(toCheck);
	free(toCheck);
	return status;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %rbx
subq $0x38, %rsp
movq %rsi, %r14
movq %rdi, %r15
callq 0x4010e0
movq %rax, %rbx
movq %r14, %rdi
callq 0x4010e0
leaq (%rbx,%rax), %rdi
addq $0x2, %rdi
callq 0x420f50
movq %rax, %rbx
movq %rax, %rdi
movq %r15, %rsi
callq 0x401020
movq %rbx, %rdi
callq 0x4010e0
movw $0x40, (%rbx,%rax)
movq %rbx, %rdi
movq %r14, %rsi
callq 0x401058
leaq 0xa1eb9(%rip), %rax     # 0x4a4205
leaq -0x50(%rbp), %rcx
movq %rax, (%rcx)
leaq 0xa1f27(%rip), %rax     # 0x4a4281
movq %rax, 0x8(%rcx)
leaq 0xa1f20(%rip), %rax     # 0x4a4285
movq %rax, 0x10(%rcx)
leaq 0xa33d0(%rip), %rax     # 0x4a5740
movq %rax, 0x18(%rcx)
movq %rbx, 0x20(%rcx)
movq $0x0, 0x28(%rcx)
leaq 0xa1e75(%rip), %rdi     # 0x4a41fc
xorl %esi, %esi
xorl %edx, %edx
callq 0x401fa4
xorl %r14d, %r14d
testl %eax, %eax
setne %r14b
movq %rbx, %rdi
callq 0x421290
movl %r14d, %eax
addq $0x38, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/dasJ[P]sd-zfs/src/zfs-util.c
// Function: zfs_ds_exists
int zfs_ds_exists(char *dataset) {
	int status;
	char *cmdline[] = { ZFS_CMD, "get", "-H", "type", dataset, NULL };

	status = executeZfs(0, NULL, cmdline);

	if (status == 0) {
		return 0;
	} else {
		return 1;
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
leaq 0xa1e47(%rip), %rax     # 0x4a4205
leaq -0x30(%rbp), %rcx
movq %rax, (%rcx)
leaq 0xa1eb5(%rip), %rax     # 0x4a4281
movq %rax, 0x8(%rcx)
leaq 0xa1eae(%rip), %rax     # 0x4a4285
movq %rax, 0x10(%rcx)
leaq 0xa335e(%rip), %rax     # 0x4a5740
movq %rax, 0x18(%rcx)
movq %rdi, 0x20(%rcx)
movq $0x0, 0x28(%rcx)
leaq 0xa1e03(%rip), %rdi     # 0x4a41fc
xorl %esi, %esi
xorl %edx, %edx
callq 0x401fa4
xorl %ecx, %ecx
testl %eax, %eax
setne %cl
movl %ecx, %eax
addq $0x30, %rsp
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/dasJ[P]sd-zfs/src/zfs-util.c
// Function: zfs_get_bootfs
int zfs_get_bootfs(char *rpool, char **bootfs) {
	int status;
	char **cmdline;
	char *tok;
	char *line = NULL;

	if (rpool == NULL) {
		cmdline = (char*[]) { ZPOOL_CMD, "list", "-Ho", "bootfs", NULL };
	} else {
		cmdline = (char*[]) { ZPOOL_CMD, "list", "-Ho", "bootfs", rpool, NULL };
	}

	*bootfs = NULL;

	status = executeZpool(1, &line, cmdline);

	if (status != 0) {
		fprintf(stderr, "zpool get returned %d\n", status);
		return status;
	}
	status = 1;

	tok = strtok(line, "\n");
	while (tok != NULL) {
		if (strcmp(tok, "-") != 0) {
			*bootfs = malloc((strlen(tok) + 1) * sizeof(char));
			strcpy(*bootfs, tok);
			status = 0;
			break;
		}
		tok = strtok(NULL, "\n");
	}
	free(line);
	return status;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x68, %rsp
movq %rsi, %rbx
movq $0x0, -0x30(%rbp)
testq %rdi, %rdi
je 0x402472
leaq 0xa1dd9(%rip), %rax     # 0x4a4212
leaq -0x90(%rbp), %rcx
movq %rax, (%rcx)
leaq 0xa494f(%rip), %rax     # 0x4a6d99
movq %rax, 0x8(%rcx)
leaq 0xa1e33(%rip), %rax     # 0x4a4288
movq %rax, 0x10(%rcx)
leaq 0xa1e2c(%rip), %rax     # 0x4a428c
movq %rax, 0x18(%rcx)
movq %rdi, 0x20(%rcx)
movq $0x0, 0x28(%rcx)
jmp 0x402496
movq 0xd053f(%rip), %rax     # 0x4d29b8
leaq -0x60(%rbp), %rcx
movq %rax, 0x20(%rcx)
movups 0xd0520(%rip), %xmm0    # 0x4d29a8
movaps %xmm0, 0x10(%rcx)
movups 0xd0505(%rip), %xmm0    # 0x4d2998
movaps %xmm0, (%rcx)
movq $0x0, (%rbx)
leaq 0xa1d65(%rip), %rdi     # 0x4a4209
movl $0x1, %r14d
leaq -0x30(%rbp), %rdx
movl $0x1, %esi
callq 0x401fa4
testl %eax, %eax
jne 0x402541
movq -0x30(%rbp), %r15
leaq 0xa23df(%rip), %rsi     # 0x4a48aa
movq %r15, %rdi
callq 0x424170
testq %rax, %rax
je 0x402527
movq %rax, %r12
leaq 0xa23c8(%rip), %r13     # 0x4a48aa
cmpb $0x2d, (%r12)
jne 0x402505
cmpb $0x0, 0x1(%r12)
jne 0x402505
xorl %edi, %edi
movq %r13, %rsi
callq 0x424170
movq %rax, %r12
testq %rax, %rax
jne 0x4024e2
jmp 0x402527
movq %r12, %rdi
callq 0x4010e0
leaq 0x1(%rax), %rdi
callq 0x420f50
movq %rax, (%rbx)
movq %rax, %rdi
movq %r12, %rsi
callq 0x401020
xorl %r14d, %r14d
movq %r15, %rdi
callq 0x421290
movl %r14d, %eax
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl %eax, %r15d
movq $0x4d4708, %rax         # imm = 0x4D4708
movq (%rax), %rdi
leaq 0xa1d3e(%rip), %rsi     # 0x4a4293
movl %r15d, %edx
xorl %eax, %eax
callq 0x40c900
movl %r15d, %r14d
jmp 0x40252f
// File: /workspace/github_c_makefile_star2_O3/dasJ[P]sd-zfs/src/zfs-util.c
// Function: zfs_list_datasets_with_mp
int zfs_list_datasets_with_mp(char *dataset, char **datasets) {
	int status;
	char *cmdline[] = { ZFS_CMD, "list", "-r", dataset, "-t", "filesystem", "-Ho", "name,mountpoint", NULL };

	*datasets = NULL;

	status = executeZfs(1, datasets, cmdline);

	if (status != 0) {
		fprintf(stderr, "zfs returned %d\n", status);
	}
	return status;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %rbx
subq $0x48, %rsp
movq %rsi, %rdx
leaq 0xa1c8e(%rip), %rax     # 0x4a4205
leaq -0x50(%rbp), %rcx
movq %rax, (%rcx)
leaq 0xa4814(%rip), %rax     # 0x4a6d99
movq %rax, 0x8(%rcx)
leaq 0xa1d1a(%rip), %rax     # 0x4a42aa
movq %rax, 0x10(%rcx)
movq %rdi, 0x18(%rcx)
leaq 0xa1d0e(%rip), %rax     # 0x4a42ad
movq %rax, 0x20(%rcx)
leaq 0xa1c7f(%rip), %rax     # 0x4a4229
movq %rax, 0x28(%rcx)
leaq 0xa1cd3(%rip), %rax     # 0x4a4288
movq %rax, 0x30(%rcx)
leaq 0xa1cf0(%rip), %rax     # 0x4a42b0
movq %rax, 0x38(%rcx)
xorl %eax, %eax
movq %rax, 0x40(%rcx)
movq %rax, (%rsi)
leaq 0xa1c28(%rip), %rdi     # 0x4a41fc
movl $0x1, %esi
callq 0x401fa4
movl %eax, %ebx
testl %eax, %eax
jne 0x4025ed
movl %ebx, %eax
addq $0x48, %rsp
popq %rbx
popq %rbp
retq
movq $0x4d4708, %rax         # imm = 0x4D4708
movq (%rax), %rdi
leaq 0xa1cc2(%rip), %rsi     # 0x4a42c0
movl %ebx, %edx
xorl %eax, %eax
callq 0x40c900
jmp 0x4025e4
// File: /workspace/github_c_makefile_star2_O3/dasJ[P]sd-zfs/src/zfs-util.c
// Function: zfs_list_snapshots
int zfs_list_snapshots(char *dataset, char *snapshot, char **output) {
	int status;
	char *snaps = NULL;
	char *cmdline[] = { ZFS_CMD, "list", "-Ho", "name", "-tsnapshot", "-r", dataset, NULL };
	char *suffix;
	char *tok;

	status = executeZfs(1, &snaps, cmdline);
	if (status != 0) {
		fprintf(stderr, "zfs returned %d\n", status);
		return status;
	}
	// Filter
	suffix = malloc((strlen(snapshot) + 2) * sizeof(char));
	strcpy(suffix, "@");
	strcat(suffix, snapshot);

	*output = malloc(sizeof(char));
	strcpy(*output, "");

	tok = strtok(snaps, "\n");
	while (tok != NULL) {
		if (strlen(tok) < strlen(suffix)) {
			continue;
		}
		if (strncmp(tok + strlen(tok) - strlen(suffix), suffix, strlen(suffix)) == 0) {
			*output = realloc(*output, strlen(*output) + strlen(tok) + 2);
			strcat(*output, tok);
			strcat(*output, "\n");
		}
		tok = strtok(NULL, "\n");
	}
	free(suffix);
	free(snaps);
	return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x68, %rsp
movq %rdx, %rbx
movq %rsi, %r15
xorl %eax, %eax
leaq -0x48(%rbp), %rdx
movq %rax, (%rdx)
leaq 0xa1bd5(%rip), %rsi     # 0x4a4205
leaq -0x90(%rbp), %rcx
movq %rsi, (%rcx)
leaq 0xa4758(%rip), %rsi     # 0x4a6d99
movq %rsi, 0x8(%rcx)
leaq 0xa1c3c(%rip), %rsi     # 0x4a4288
movq %rsi, 0x10(%rcx)
leaq 0xa1be4(%rip), %rsi     # 0x4a423b
movq %rsi, 0x18(%rcx)
leaq 0xa1c6f(%rip), %rsi     # 0x4a42d1
movq %rsi, 0x20(%rcx)
leaq 0xa1c3d(%rip), %rsi     # 0x4a42aa
movq %rsi, 0x28(%rcx)
movq %rdi, 0x30(%rcx)
movq %rax, 0x38(%rcx)
leaq 0xa1b7c(%rip), %rdi     # 0x4a41fc
movl $0x1, %esi
callq 0x401fa4
testl %eax, %eax
jne 0x4027a8
movq %r15, %rdi
callq 0x4010e0
leaq 0x2(%rax), %rdi
callq 0x420f50
movq %rax, %r14
movw $0x40, (%rax)
movq %rax, %rdi
movq %r15, %rsi
callq 0x401058
movl $0x1, %edi
callq 0x420f50
movq %rbx, -0x40(%rbp)
movq %rax, (%rbx)
movb $0x0, (%rax)
movq -0x48(%rbp), %rdi
leaq 0xa21d5(%rip), %rsi     # 0x4a48aa
movq %rdi, -0x30(%rbp)
callq 0x424170
testq %rax, %rax
je 0x402780
movq %rax, %r13
leaq 0xa21b9(%rip), %rbx     # 0x4a48aa
movq %r14, -0x38(%rbp)
movq %r13, %rdi
callq 0x4010e0
movq %rax, %r15
movq %r14, %rdi
callq 0x4010e0
cmpq %rax, %r15
jb 0x4027a6
leaq (%r15,%r13), %rdi
subq %rax, %rdi
movq %r14, %rsi
movq %rax, %rdx
callq 0x401080
testl %eax, %eax
jne 0x40276a
movq -0x40(%rbp), %r14
movq (%r14), %r12
movq %r12, %rdi
callq 0x4010e0
leaq (%r15,%rax), %rsi
addq $0x2, %rsi
movq %r12, %rdi
callq 0x4215e0
movq %rax, %r15
movq %rax, (%r14)
movq -0x38(%rbp), %r14
movq %rax, %rdi
movq %r13, %rsi
callq 0x401058
movq %r15, %rdi
callq 0x4010e0
movw $0xa, (%r15,%rax)
xorl %edi, %edi
movq %rbx, %rsi
callq 0x424170
movq %rax, %r13
testq %rax, %rax
jne 0x4026f5
movq %r14, %rdi
callq 0x421290
movq -0x30(%rbp), %rdi
callq 0x421290
xorl %r14d, %r14d
movl %r14d, %eax
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x4027a6
movl %eax, %r14d
movq $0x4d4708, %rax         # imm = 0x4D4708
movq (%rax), %rdi
leaq 0xa1b04(%rip), %rsi     # 0x4a42c0
movl %r14d, %edx
xorl %eax, %eax
callq 0x40c900
jmp 0x402794
// File: /workspace/github_c_makefile_star2_O3/dasJ[P]sd-zfs/src/zfs-util.c
// Function: zfs_mount
int zfs_mount(char *what, char *where, char *options) {
	char **cmdline;

	if (options == NULL) {
		cmdline = (char*[]) { MOUNT_CMD, "-t", "zfs", what, where, NULL };
	} else {
		cmdline = (char*[]) { MOUNT_CMD, "-t", "zfs", "-o", options, what, where, NULL };
	}

	return executeMount(0, NULL, cmdline);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x70, %rsp
leaq 0xa1a4a(%rip), %rax     # 0x4a4221
testq %rdx, %rdx
je 0x402816
leaq -0x70(%rbp), %rcx
movq %rax, (%rcx)
leaq 0xa1ac3(%rip), %rax     # 0x4a42ad
movq %rax, 0x8(%rcx)
leaq 0xa1a10(%rip), %rax     # 0x4a4205
movq %rax, 0x10(%rcx)
leaq 0xa1adc(%rip), %rax     # 0x4a42dc
movq %rax, 0x18(%rcx)
movq %rdx, 0x20(%rcx)
movq %rdi, 0x28(%rcx)
movq %rsi, 0x30(%rcx)
leaq -0x38(%rbp), %rax
jmp 0x40283f
leaq -0x30(%rbp), %rcx
movq %rax, (%rcx)
leaq 0xa1a89(%rip), %rax     # 0x4a42ad
movq %rax, 0x8(%rcx)
leaq 0xa19d6(%rip), %rax     # 0x4a4205
movq %rax, 0x10(%rcx)
movq %rdi, 0x18(%rcx)
movq %rsi, 0x20(%rcx)
leaq -0x8(%rbp), %rax
movq $0x0, (%rax)
leaq 0xa19cb(%rip), %rdi     # 0x4a4218
xorl %esi, %esi
xorl %edx, %edx
callq 0x401fa4
addq $0x70, %rsp
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/dasJ[P]sd-zfs/src/zfs-util.c
// Function: zfs_get_mountpoint
int zfs_get_mountpoint(char *dataset, char **mountpoint) {
	int status;
	char *cmdline[] = { ZFS_CMD, "get", "-Ho", "value", "mountpoint", dataset, NULL };

	status = executeZfs(1, mountpoint, cmdline);
	if (status != 0) {
		fprintf(stderr, "zfs returned %d\n", status);
	}
	if (*mountpoint != NULL) {
		(*mountpoint)[strlen(*mountpoint) - 1] = '\0';
	}
	return status;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r14
pushq %rbx
subq $0x40, %rsp
movq %rsi, %rbx
leaq 0xa1994(%rip), %rax     # 0x4a4205
leaq -0x50(%rbp), %rcx
movq %rax, (%rcx)
leaq 0xa1a02(%rip), %rax     # 0x4a4281
movq %rax, 0x8(%rcx)
leaq 0xa19fe(%rip), %rax     # 0x4a4288
movq %rax, 0x10(%rcx)
leaq 0xa1a4a(%rip), %rax     # 0x4a42df
movq %rax, 0x18(%rcx)
leaq 0xa1a15(%rip), %rax     # 0x4a42b5
movq %rax, 0x20(%rcx)
movq %rdi, 0x28(%rcx)
movq $0x0, 0x30(%rcx)
leaq 0xa1945(%rip), %rdi     # 0x4a41fc
movl $0x1, %esi
movq %rbx, %rdx
callq 0x401fa4
movl %eax, %r14d
testl %eax, %eax
jne 0x4028ec
movq (%rbx), %rbx
testq %rbx, %rbx
je 0x4028e0
movq %rbx, %rdi
callq 0x4010e0
movb $0x0, -0x1(%rbx,%rax)
movl %r14d, %eax
addq $0x40, %rsp
popq %rbx
popq %r14
popq %rbp
retq
movq $0x4d4708, %rax         # imm = 0x4D4708
movq (%rax), %rdi
leaq 0xa19c3(%rip), %rsi     # 0x4a42c0
movl %r14d, %edx
xorl %eax, %eax
callq 0x40c900
jmp 0x4028cb
// File: /workspace/github_c_makefile_star2_O3/dasJ[P]sd-zfs/src/zfs-util.c
// Function: zfs_clone_snap
int zfs_clone_snap(char *snapshot, char *datasetTarget, char *mountpoint) {
	int status;
	char **cmdline;
	char *mountpointParam;

	mountpointParam = malloc((strlen("org.zol:mountpoint=") + strlen(mountpoint) + 1) * sizeof(char));
	strcpy(mountpointParam, "org.zol:mountpoint=");
	strcat(mountpointParam, mountpoint);

	cmdline = (char*[]) { ZFS_CMD, "clone",
		"-o", "canmount=noauto",
		"-o", "mountpoint=none",
		"-o", mountpointParam, snapshot, datasetTarget, NULL };

	status = executeZfs(0, NULL, cmdline);
	free(mountpointParam);
	if (status != 0) {
		fprintf(stderr, "zfs returned %d\n", status);
	}

	return status;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x60, %rsp
movq %rdx, %r12
movq %rsi, %r14
movq %rdi, %r15
movq %rdx, %rdi
callq 0x4010e0
leaq 0x14(%rax), %rdi
callq 0x420f50
movq %rax, %rbx
movups 0xa19a9(%rip), %xmm0    # 0x4a42e5
movups %xmm0, (%rax)
movl $0x3d746e, 0x10(%rax)   # imm = 0x3D746E
movq %rax, %rdi
movq %r12, %rsi
callq 0x401058
leaq 0xa18ad(%rip), %rax     # 0x4a4205
leaq -0x78(%rbp), %rcx
movq %rax, (%rcx)
leaq 0xa1993(%rip), %rax     # 0x4a42f9
movq %rax, 0x8(%rcx)
leaq 0xa196b(%rip), %rax     # 0x4a42dc
movq %rax, 0x10(%rcx)
leaq 0xa1983(%rip), %rdx     # 0x4a42ff
movq %rdx, 0x18(%rcx)
movq %rax, 0x20(%rcx)
leaq 0xa1984(%rip), %rdx     # 0x4a430f
movq %rdx, 0x28(%rcx)
movq %rax, 0x30(%rcx)
movq %rbx, 0x38(%rcx)
movq %r15, 0x40(%rcx)
movq %r14, 0x48(%rcx)
movq $0x0, 0x50(%rcx)
leaq 0xa184e(%rip), %rdi     # 0x4a41fc
xorl %esi, %esi
xorl %edx, %edx
callq 0x401fa4
movl %eax, %r14d
movq %rbx, %rdi
callq 0x421290
testl %r14d, %r14d
jne 0x4029d7
movl %r14d, %eax
addq $0x60, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
movq $0x4d4708, %rax         # imm = 0x4D4708
movq (%rax), %rdi
leaq 0xa18d8(%rip), %rsi     # 0x4a42c0
movl %r14d, %edx
xorl %eax, %eax
callq 0x40c900
jmp 0x4029c7
// File: /workspace/github_c_makefile_star2_O3/dasJ[P]sd-zfs/src/zfs-util.c
// Function: zfs_get_alt_mp
int zfs_get_alt_mp(char *dataset, char **mountpoint) {
	int status;
	char *cmdline[] = { ZFS_CMD, "get", "-Ho", "value", "org.zol:mountpoint", dataset, NULL };

	status = executeZfs(1, mountpoint, cmdline);
	if (*mountpoint != NULL) {
		(*mountpoint)[strlen(*mountpoint) - 1] = '\0';
	}
	return status;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r14
pushq %rbx
subq $0x40, %rsp
movq %rsi, %r14
leaq 0xa17fc(%rip), %rax     # 0x4a4205
leaq -0x50(%rbp), %rcx
movq %rax, (%rcx)
leaq 0xa186a(%rip), %rax     # 0x4a4281
movq %rax, 0x8(%rcx)
leaq 0xa1866(%rip), %rax     # 0x4a4288
movq %rax, 0x10(%rcx)
leaq 0xa18b2(%rip), %rax     # 0x4a42df
movq %rax, 0x18(%rcx)
leaq 0xa18e7(%rip), %rax     # 0x4a431f
movq %rax, 0x20(%rcx)
movq %rdi, 0x28(%rcx)
movq $0x0, 0x30(%rcx)
leaq 0xa17ad(%rip), %rdi     # 0x4a41fc
movl $0x1, %esi
movq %r14, %rdx
callq 0x401fa4
movl %eax, %ebx
movq (%r14), %r14
testq %r14, %r14
je 0x402a74
movq %r14, %rdi
callq 0x4010e0
movb $0x0, -0x1(%r14,%rax)
movl %ebx, %eax
addq $0x40, %rsp
popq %rbx
popq %r14
popq %rbp
retq
nop