LLM4Binary/decompile-bench-makefile huggingface dataset:
// File: /workspace/github_c_makefile_star2_O1/canboat[P]canboat/nmea0183/../common/common.c
// Function: sbDelete
void sbDelete(StringBuffer *sb, size_t start, size_t end)
{
  if (end >= sb->len)
  {
    sbTruncate(sb, start);
  }
  else if (start < sb->len && sb->data)
  {
    end = CB_MIN(sb->len, end);
    if (end < sb->len)
    {
      memmove(sb->data + start, sb->data + end, sb->len - end);
    }
    sb->len -= end - start;
    sbTerminate(sb);
  }
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
movq %rdx, %r15
movq %rsi, %rbx
movq %rdi, %r14
movq 0x8(%rdi), %rdx
cmpq %r15, %rdx
jbe 0x2c0f
cmpq %rbx, %rdx
jbe 0x2c28
movq (%r14), %rsi
testq %rsi, %rsi
je 0x2c28
cmpq %r15, %rdx
cmovbq %rdx, %r15
jbe 0x2c06
leaq (%rsi,%rbx), %rdi
addq %r15, %rsi
subq %r15, %rdx
callq 0x21e0
subq %r15, %rbx
addq 0x8(%r14), %rbx
jmp 0x2c16
cmpq %rbx, %rdx
cmovbq %rdx, %rbx
movq %rbx, 0x8(%r14)
movq (%r14), %rax
testq %rax, %rax
je 0x2c28
addq %rbx, %rax
movb $0x0, (%rax)
popq %rbx
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O1/canboat[P]canboat/nmea0183/../common/common.c
// Function: sbAppendData
void sbAppendData(StringBuffer *sb, const void *data, size_t len)
{
  sbEnsureCapacity(sb, sb->len + len);
  memcpy(sb->data + sb->len, data, len);
  sb->len += len;
  sb->data[sb->len] = 0;
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
movq %rdx, %rbx
movq %rsi, %r14
movq %rdi, %r15
movq 0x8(%rdi), %rsi
addq %rdx, %rsi
callq 0x2b53
movq (%r15), %rdi
addq 0x8(%r15), %rdi
movq %r14, %rsi
movq %rbx, %rdx
callq 0x2170
addq 0x8(%r15), %rbx
movq %rbx, 0x8(%r15)
movq (%r15), %rax
movb $0x0, (%rax,%rbx)
popq %rbx
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O1/canboat[P]canboat/nmea0183/../common/common.c
// Function: sbAppendEncodeHex
void sbAppendEncodeHex(StringBuffer *sb, const void *data, size_t len, char separator)
{
  sbEnsureCapacity(sb, sb->len + len * 3);

  for (; len > 0; len--, data++)
  {
    sbAppendFormat(sb, "%c%c", hexDigit(((uint8_t *) data)[0] >> 4), hexDigit(((uint8_t *) data)[0] & 0x0f));
    if (len > 1 && separator != '\0')
    {
      sbAppendData(sb, &separator, 1);
    }
  }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movl %ecx, %ebx
movq %rdx, %r14
movq %rsi, 0x10(%rsp)
movq %rdi, %r12
leaq (%rdx,%rdx,2), %rsi
addq 0x8(%rdi), %rsi
callq 0x2b53
testq %r14, %r14
je 0x2d64
leaq -0x1(%r14), %rax
movq %rax, 0x8(%rsp)
movl $0xff, %r13d
xorl %r15d, %r15d
testb %bl, %bl
sete %bpl
movq 0x10(%rsp), %rax
movb (%rax,%r15), %al
movl %eax, %ecx
shrb $0x4, %cl
leal 0x57(%rcx), %edx
orb $0x30, %cl
cmpb $-0x60, %al
movzbl %dl, %esi
movzbl %cl, %edx
cmovael %esi, %edx
andl %r13d, %edx
andb $0xf, %al
leal 0x57(%rax), %ecx
leal 0x30(%rax), %esi
cmpb $0xa, %al
movzbl %cl, %eax
movzbl %sil, %ecx
cmovael %eax, %ecx
andl %r13d, %ecx
movq %r12, %rdi
leaq 0x1767(%rip), %rsi      # 0x4478
xorl %eax, %eax
callq 0x2d73
cmpq %r15, 0x8(%rsp)
sete %al
orb %bpl, %al
jne 0x2d58
movq 0x8(%r12), %rsi
incq %rsi
movq %r12, %rdi
callq 0x2b53
movq (%r12), %rax
movq 0x8(%r12), %rcx
movb %bl, (%rax,%rcx)
movq (%r12), %rax
movq 0x8(%r12), %rcx
leaq 0x1(%rcx), %rdx
movq %rdx, 0x8(%r12)
movb $0x0, 0x1(%rax,%rcx)
incq %r15
cmpq %r15, %r14
jne 0x2cc8
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/canboat[P]canboat/nmea0183/../common/common.c
// Function: sbAppendDecodeHex
void sbAppendDecodeHex(StringBuffer *sb, const char *data, size_t len)
{
  uint8_t  nibble1;
  uint8_t  nibble2;
  uint8_t *d;

  sbEnsureCapacity(sb, len / 2 + 1 + sbGetLength(sb));
  d = (uint8_t *) sbGet(sb) + sbGetLength(sb);

  while (len >= 2)
  {
    nibble1 = (*data >= 'a') ? (*data - 'a' + 10) : (*data >= 'A' ? (*data - 'A' + 10) : (*data - '0'));
    data++;
    nibble2 = (*data >= 'a') ? (*data - 'a' + 10) : (*data >= 'A' ? (*data - 'A' + 10) : (*data - '0'));
    data++;
    *d++ = nibble1 << 4 | nibble2;
    len -= 2;
  }

  sb->len = d - (uint8_t *) sbGet(sb);
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
movq %rdx, %r14
movq %rsi, %r15
movq %rdi, %rbx
movq %rdx, %rax
shrq %rax
movq 0x8(%rdi), %rcx
leaq (%rax,%rcx), %rsi
incq %rsi
callq 0x2b53
movq (%rbx), %rax
testq %rax, %rax
leaq 0x1549(%rip), %rcx      # 0x4371
cmoveq %rcx, %rax
addq 0x8(%rbx), %rax
cmpq $0x2, %r14
jb 0x2e8d
movl $0xa9, %edx
movb (%r15), %sil
movl $0x9, %edi
cmpb $0x41, %sil
jge 0x2e4e
movl $0x40, %edi
movb 0x1(%r15), %r9b
movl $0xc9, %r8d
cmpb $0x41, %r9b
jge 0x2e64
movl $0xd0, %r8d
addb %dil, %sil
cmpb $0x61, %r9b
cmovgel %edx, %r8d
addb %r9b, %r8b
shlb $0x4, %sil
orb %r8b, %sil
movb %sil, (%rax)
incq %rax
addq $-0x2, %r14
addq $0x2, %r15
cmpq $0x1, %r14
ja 0x2e3b
movq (%rbx), %rdx
testq %rdx, %rdx
cmovneq %rdx, %rcx
subq %rcx, %rax
movq %rax, 0x8(%rbx)
popq %rbx
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O1/canboat[P]canboat/nmea0183/../common/common.c
// Function: sbAppendFormatV
void sbAppendFormatV(StringBuffer *const sb, const char *const format, va_list ap)
{
  int     n;
  size_t  len;
  va_list ap2;

  len = 128;

  while (len < 4 * 1024 * 1024)
  {
    sbEnsureCapacity(sb, sb->len + len);

    va_copy(ap2, ap);
    n = vsnprintf(sb->data + sb->len, len, format, ap2);
    va_end(ap2);
    /*
     * Platform returned not an error, and the number of bytes was less
     * than the size of the buffer -> we're done
     * Note that some implementations (tru64) nicely guarantee zero terminated strings,
     * so we test for len - 1, not len.
     */
    if (n > -1 && (size_t) n < len - 1)
    {
      sb->len += n;
      sbTerminate(sb);
      break;
    }

    /*
     * Otherwise, increase the buffer smartly
     */

    if (n == -1)
    {
      len *= 2;
    }
    else
    {
      len = n + 2;
    }
  }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rdx, %r14
movq %rsi, %r15
movq %rdi, %rbx
movl $0x80, %r12d
movq %rsp, %r13
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
movq 0x8(%rbx), %rsi
addq %r12, %rsi
movq %rbx, %rdi
callq 0x2b53
movq 0x10(%r14), %rax
movq %rax, 0x10(%rsp)
movups (%r14), %xmm0
movaps %xmm0, (%rsp)
movq (%rbx), %rdi
addq 0x8(%rbx), %rdi
movq %r12, %rsi
movq %r15, %rdx
movq %r13, %rcx
callq 0x2090
testl %eax, %eax
setns %cl
movl %eax, %eax
leaq -0x1(%r12), %rdx
cmpq %rax, %rdx
seta %dl
andb %cl, %dl
cmpb $0x1, %dl
je 0x2fba
addq %r12, %r12
leal 0x2(%rax), %ecx
cmpq %rbp, %rax
movslq %ecx, %rax
cmovneq %rax, %r12
cmpq $0x400000, %r12         # imm = 0x400000
jb 0x2f51
jmp 0x2fce
addq 0x8(%rbx), %rax
movq %rax, 0x8(%rbx)
movq (%rbx), %rcx
testq %rcx, %rcx
je 0x2fce
movb $0x0, (%rcx,%rax)
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/canboat[P]canboat/nmea0183/../common/common.c
// Function: getJSONLookupList
static bool getJSONLookupList(const char *message, const char *fieldName, char *value, size_t len)
{
  const char *loc      = message + 1;
  size_t      fieldLen = strlen(fieldName);
  const char *end;

  for (;;)
  {
    loc = strstr(loc, fieldName);
    if (!loc)
    {
      return false;
    }
    if (loc[-1] == '"' && loc[fieldLen] == '"' && loc[fieldLen + 1] == ':')
    {
      break;
    }
    loc += fieldLen;
  }

  /* field has been found */
  loc += fieldLen + 2;

  while (isspace((unsigned char) *loc))
  {
    loc++;
  }

  if (strncmp(loc, "null", 4) == 0)
  {
    return false;
  }

  end = strchr(loc, '}');

  if (*loc != '{' || end == NULL)
  {
    logError("Cannot extract lookup for field '%s': it is not a -nv style lookup\n%s\n", fieldName, loc);
    return false;
  }
  end++;
  len--;
  if (end - loc < len)
  {
    len = end - loc;
  }
  memcpy(value, loc, len);
  value[len] = '\0';

  return true;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rcx, %r14
movq %rdx, %rbx
movq %rsi, %r15
movq %rdi, %r13
incq %r13
movq %rsi, %rdi
callq 0x20b0
movq %rax, %r12
movq %r13, %rdi
movq %r15, %rsi
callq 0x2280
testq %rax, %rax
je 0x331d
movq %rax, %rbp
cmpb $0x22, -0x1(%rbp)
jne 0x3307
cmpb $0x22, (%rbp,%r12)
jne 0x3307
cmpb $0x3a, 0x1(%rbp,%r12)
je 0x3330
addq %r12, %rbp
movq %rbp, %rdi
movq %r15, %rsi
callq 0x2280
movq %rax, %rbp
testq %rax, %rax
jne 0x32f1
xorl %ebx, %ebx
movl %ebx, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rbx, (%rsp)
callq 0x2290
movq (%rax), %rax
leaq (%r12,%rbp), %r13
incq %r13
addq %rbp, %r12
movzbl 0x1(%r13), %ebx
incq %r13
incq %r12
testb $0x20, 0x1(%rax,%rbx,2)
jne 0x3346
leaq 0x114d(%rip), %rsi      # 0x44ac
movl $0x4, %edx
movq %r13, %rdi
callq 0x2070
testl %eax, %eax
je 0x331d
movq %r13, %rdi
movl $0x7d, %esi
callq 0x20d0
movq %rax, %rbp
cmpb $0x7b, %bl
setne %al
testq %rbp, %rbp
sete %cl
orb %al, %cl
cmpb $0x1, %cl
jne 0x33ae
leaq 0x12b4(%rip), %rdi      # 0x464e
xorl %ebx, %ebx
movq %r15, %rsi
movq %r13, %rdx
xorl %eax, %eax
callq 0x2938
jmp 0x331f
decq %r14
subq %r12, %rbp
cmpq %r14, %rbp
cmovaeq %r14, %rbp
movq (%rsp), %rbx
movq %rbx, %rdi
movq %r13, %rsi
movq %rbp, %rdx
callq 0x2170
movb $0x0, (%rbx,%rbp)
movb $0x1, %bl
jmp 0x331f
// File: /workspace/github_c_makefile_star2_O1/canboat[P]canboat/nmea0183/../common/common.c
// Function: sbSearchChar
char *sbSearchChar(const StringBuffer *const in, char c)
{
  char  *p = sbGet(in);
  size_t i;

  for (i = 0; i < in->len; i++)
  {
    if (p[i] == c)
    {
      return p + i;
    }
  }
  return 0;
}

// Assembly:
movq (%rdi), %rdx
movq 0x8(%rdi), %rcx
testq %rdx, %rdx
leaq 0xf4b(%rip), %rax       # 0x4371
cmovneq %rdx, %rax
testq %rcx, %rcx
je 0x343c
cmpb %sil, (%rax)
je 0x343e
incq %rax
decq %rcx
jne 0x342f
xorl %eax, %eax
retq
// File: /workspace/github_c_makefile_star2_O1/canboat[P]canboat/nmea0183/../common/common.c
// Function: getISO11783BitsFromCanId
void getISO11783BitsFromCanId(unsigned int id, unsigned int *prio, unsigned int *pgn, unsigned int *src, unsigned int *dst)
{
  unsigned char PF  = (unsigned char) (id >> 16);
  unsigned char PS  = (unsigned char) (id >> 8);
  unsigned char RDP = (unsigned char) (id >> 24) & 3; // Use R + DP bits

  if (src)
  {
    *src = (unsigned char) id >> 0;
  }
  if (prio)
  {
    *prio = (unsigned char) ((id >> 26) & 0x7);
  }

  if (PF < 240)
  {
    /* PDU1 format, the PS contains the destination address */
    if (dst)
    {
      *dst = PS;
    }
    if (pgn)
    {
      *pgn = (RDP << 16) + (PF << 8);
    }
  }
  else
  {
    /* PDU2 format, the destination is implied global and the PGN is extended */
    if (dst)
    {
      *dst = 0xff;
    }
    if (pgn)
    {
      *pgn = (RDP << 16) + (PF << 8) + PS;
    }
  }
}

// Assembly:
testq %rcx, %rcx
je 0x344a
movzbl %dil, %eax
movl %eax, (%rcx)
movl %edi, %eax
shrl $0x10, %eax
testq %rsi, %rsi
je 0x345e
movl %edi, %ecx
shrl $0x1a, %ecx
andl $0x7, %ecx
movl %ecx, (%rsi)
movl %edi, %ecx
shrl $0x8, %ecx
shrl $0x18, %edi
movzbl %al, %eax
cmpl $0xef, %eax
ja 0x348d
testq %r8, %r8
je 0x347b
movzbl %cl, %ecx
movl %ecx, (%r8)
testq %rdx, %rdx
je 0x34b0
andl $0x3, %edi
shll $0x10, %edi
shll $0x8, %eax
orl %edi, %eax
jmp 0x34ae
testq %r8, %r8
je 0x3499
movl $0xff, (%r8)
testq %rdx, %rdx
je 0x34b0
andl $0x3, %edi
shll $0x10, %edi
shll $0x8, %eax
orl %edi, %eax
movzbl %cl, %ecx
orl %ecx, %eax
movl %eax, (%rdx)
retq
// File: /workspace/github_c_makefile_star2_O1/canboat[P]canboat/nmea0183/../common/common.c
// Function: open_socket_stream
SOCKET open_socket_stream(const char *url)
{
  SOCKET          sockfd = INVALID_SOCKET;
  int             n;
  struct addrinfo hints, *res, *addr;
  char           *host;
  const char     *service;

  resolve_address(url, &host, &service);

  memset(&hints, 0, sizeof(hints));
  hints.ai_family   = AF_UNSPEC;
  hints.ai_socktype = SOCK_STREAM;

  n = getaddrinfo(host, service, &hints, &res);
  if (n != 0)
  {
    logError("Unable to open connection to %s:%s: %s\n", host, service, gai_strerror(n));
  }
  else
  {
    for (addr = res; addr; addr = addr->ai_next)
    {
      sockfd = socket(addr->ai_family, addr->ai_socktype, addr->ai_protocol);
      if (sockfd == INVALID_SOCKET)
      {
        continue;
      }

      if (!connect(sockfd, res->ai_addr, res->ai_addrlen))
      {
        break;
      }
      close(sockfd);
      sockfd = INVALID_SOCKET;
    }
    if (!addr)
    {
      logError("Unable to open connection to %s:%s: %s\n", host, service, strerror(errno));
    }
  }

  freeaddrinfo(res);
  free(host);

  return sockfd;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movq %rdi, %rbx
leaq 0x119c(%rip), %rsi      # 0x4695
movl $0x4, %edx
callq 0x2070
xorl %ecx, %ecx
testl %eax, %eax
sete %cl
leaq (%rbx,%rcx,4), %rbx
decq %rbx
movq %rbx, %r14
incq %rbx
cmpb $0x2f, 0x1(%r14)
leaq 0x1(%r14), %r14
je 0x3514
movq %r14, %rdi
movl $0x3a, %esi
callq 0x20d0
testq %rax, %rax
je 0x3542
movq %rax, %r15
movq %rax, %r12
subq %rbx, %r12
incq %r15
jmp 0x3550
movq %r14, %rdi
callq 0x20b0
movq %rax, %r12
xorl %r15d, %r15d
leaq 0x1(%r12), %rdi
callq 0x2190
testq %rax, %rax
je 0x3664
movq %rax, %rbx
movq %rax, %rdi
movq %r14, %rsi
movq %r12, %rdx
callq 0x2170
movb $0x0, (%rbx,%r12)
testq %r15, %r15
leaq 0x1125(%rip), %r14      # 0x46a8
cmovneq %r15, %r14
xorps %xmm0, %xmm0
leaq 0x10(%rsp), %rdx
movaps %xmm0, (%rdx)
movaps %xmm0, 0x10(%rdx)
movaps %xmm0, 0x20(%rdx)
movl $0x1, 0x8(%rdx)
leaq 0x8(%rsp), %rcx
movq %rbx, %rdi
movq %r14, %rsi
callq 0x2250
testl %eax, %eax
je 0x35c3
movl %eax, %edi
callq 0x20f0
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
jmp 0x362a
movq 0x8(%rsp), %r13
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
testq %r13, %r13
sete %r12b
je 0x3618
movl 0x4(%r13), %edi
movl 0x8(%r13), %esi
movl 0xc(%r13), %edx
callq 0x22c0
cmpl $-0x1, %eax
je 0x360f
movl %eax, %r15d
movq 0x8(%rsp), %rax
movq 0x18(%rax), %rsi
movl 0x10(%rax), %edx
movl %r15d, %edi
callq 0x2230
testl %eax, %eax
je 0x3615
movl %r15d, %edi
callq 0x2130
movq 0x28(%r13), %r13
jmp 0x35cd
movl %r15d, %ebp
testb $0x1, %r12b
je 0x3641
callq 0x2050
movl (%rax), %edi
callq 0x2260
leaq 0xf40(%rip), %rdi       # 0x4571
movq %rbx, %rsi
movq %r14, %rdx
movq %rax, %rcx
xorl %eax, %eax
callq 0x2938
movq 0x8(%rsp), %rdi
callq 0x22b0
movq %rbx, %rdi
callq 0x2030
movl %ebp, %eax
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x102f(%rip), %rdi      # 0x469a
callq 0x2a7b
// File: /workspace/github_c_makefile_star2_O1/canboat[P]canboat/nmea0183/../common/common.c
// Function: scanNibble
uint8_t scanNibble(char c)
{
  if (isdigit((unsigned char) c))
  {
    return c - '0';
  }
  if (c >= 'A' && c <= 'F')
  {
    return c - 'A' + 10;
  }
  if (c >= 'a' && c <= 'f')
  {
    return c - 'a' + 10;
  }
  return 16;
}

// Assembly:
pushq %rbx
movl %edi, %ebx
callq 0x2290
movq (%rax), %rax
movzbl %bl, %ecx
testb $0x8, 0x1(%rax,%rcx,2)
jne 0x3691
leal -0x41(%rbx), %eax
cmpb $0x5, %al
ja 0x3696
addb $-0x37, %bl
jmp 0x36a9
addb $-0x30, %bl
jmp 0x36a9
leal -0x61(%rbx), %eax
addb $-0x57, %bl
cmpb $0x6, %al
movzbl %bl, %eax
movl $0x10, %ebx
cmovbl %eax, %ebx
movl %ebx, %eax
popq %rbx
retq
// File: /workspace/github_c_makefile_star2_O1/canboat[P]canboat/nmea0183/../common/common.c
// Function: scanHex
int scanHex(char **p, uint8_t *m)
{
  uint8_t hi, lo;

  if (!(*p)[0] || !(*p)[1])
  {
    return 1;
  }

  hi = scanNibble((*p)[0]);
  if (hi > 15)
  {
    return 1;
  }
  lo = scanNibble((*p)[1]);
  if (lo > 15)
  {
    return 1;
  }
  (*p) += 2;
  *m = hi << 4 | lo;
  /* printf("(b=%02X,p=%p) ", *m, *p); */
  return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq (%rdi), %r12
movb (%r12), %al
movl $0x1, %ebx
testb %al, %al
je 0x3706
movb 0x1(%r12), %r13b
testb %r13b, %r13b
je 0x3706
movq %rsi, %r14
movq %rdi, %r15
movsbl %al, %edi
callq 0x3670
cmpb $0xf, %al
ja 0x3706
movl %eax, %ebp
movsbl %r13b, %edi
callq 0x3670
cmpb $0xf, %al
ja 0x3706
addq $0x2, %r12
movq %r12, (%r15)
shlb $0x4, %bpl
orb %bpl, %al
movb %al, (%r14)
xorl %ebx, %ebx
movl %ebx, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/canboat[P]canboat/nmea0183/../common/common.c
// Function: writeSerial
int writeSerial(SOCKET handle, const uint8_t *data, size_t len)
{
  int     retryCount = 5;
  ssize_t written;

  do
  {
    written = write(handle, data, len);
    if (written != -1)
    {
      data += written;
      len -= written;
    }
    else if (errno == EAGAIN)
    {
      retryCount--;
      usleep(25000);
    }
    else
    {
      break;
    }
  } while (len > 0 && retryCount >= 0);

  if (written == -1)
  {
    logError("Write failed: %s\n", strerror(errno));
    return -1;
  }
  else if (len > 0)
  {
    logError("Write timeout: %s\n", strerror(errno));
    return -1;
  }
  return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
movq %rdx, %rbx
movq %rsi, %r14
movl %edi, %ebp
movl $0x5, %r12d
movl %ebp, %edi
movq %r14, %rsi
movq %rbx, %rdx
callq 0x20a0
movq %rax, %r15
cmpq $-0x1, %rax
je 0x3908
addq %r15, %r14
subq %r15, %rbx
jmp 0x391f
callq 0x2050
cmpl $0xb, (%rax)
jne 0x3929
decl %r12d
movl $0x61a8, %edi           # imm = 0x61A8
callq 0x22a0
testq %rbx, %rbx
je 0x3929
testl %r12d, %r12d
jns 0x38ea
cmpq $-0x1, %r15
je 0x393d
testq %rbx, %rbx
je 0x3964
leaq 0xcb2(%rip), %rbx       # 0x45ed
jmp 0x3944
leaq 0xc97(%rip), %rbx       # 0x45db
callq 0x2050
movl (%rax), %edi
callq 0x2260
movq %rbx, %rdi
movq %rax, %rsi
xorl %eax, %eax
callq 0x2938
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
jmp 0x3966
xorl %eax, %eax
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/canboat[P]canboat/nmea0183/../common/common.c
// Function: parseInt
bool parseInt(const char **msg, int *value, int defValue)
{
  char *end;

  *value = strtol(*msg, &end, 10);
  if (end == *msg)
  {
    *value = defValue;
  }
  *msg = end;
  if (*end == ',')
  {
    *msg = end + 1;
  }
  else if (*end != '\0')
  {
    return false;
  }
  return true;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movl %edx, %ebp
movq %rsi, %r14
movq %rdi, %rbx
movq (%rdi), %rdi
movq %rsp, %r15
movq %r15, %rsi
movl $0xa, %edx
callq 0x2160
movl %eax, (%r14)
movq (%r15), %rcx
cmpq (%rbx), %rcx
cmovnel %eax, %ebp
movl %ebp, (%r14)
movq %rcx, (%rbx)
movzbl (%rcx), %eax
testl %eax, %eax
je 0x39b5
cmpl $0x2c, %eax
jne 0x39b9
incq %rcx
movq %rcx, (%rbx)
movb $0x1, %al
jmp 0x39bb
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/eric-lo[P]3150/9-File/read_part.c
// Function: main
int main(int argc, char **argv) {
	FILE *fp;
	unsigned char buf[1000];
	struct ptable *ptr;
	int i;

	if(argc != 2) {
		fprintf(stderr, "Usage: %s [disk image]\n", argv[0]);
		exit(1);
	}

	if( (fp = fopen(argv[1], "r")) == NULL ) {
		perror(argv[1]);
		exit(1);
	}

	fseek(fp, PTABLE_START, SEEK_SET);	// skip boot code
	fread(buf, sizeof(struct ptable), 4, fp);

	ptr = (struct ptable *) buf;

	for(i = 0; i < 4; i++) {
		printf("Partition table #%d\n", i + 1);
		printf("------------------\n");

		printf("Bootable\t");
		if(ptr[i].flag == 0x80)
			printf("Yes\n");
		else
			printf("No\n");

		printf("LBA start addr\t%u\n", ptr[i].lba_start_addr);
		printf("type\t\t0x%02x\n", ptr[i].type);
		printf("size\t\t%u\n", ptr[i].size_in_sector);
		printf("\n");
	}
	return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x3e8, %rsp            # imm = 0x3E8
movq %rsi, %rbx
cmpl $0x2, %edi
jne 0x131e
movq 0x8(%rbx), %rdi
leaq 0xdf8(%rip), %rsi       # 0x201c
callq 0x1080
testq %rax, %rax
je 0x1326
movq %rax, %r14
movl $0x1be, %esi            # imm = 0x1BE
movq %rax, %rdi
xorl %edx, %edx
callq 0x1090
movq %rsp, %rdi
movl $0x10, %esi
movl $0x4, %edx
movq %r14, %rcx
callq 0x1050
movl $0xc, %r15d
movl $0x1, %ebx
leaq 0xe10(%rip), %r12       # 0x207b
leaq 0xdcb(%rip), %r13       # 0x203d
leaq 0xdd7(%rip), %rbp       # 0x2050
leaq 0xdde(%rip), %r14       # 0x205e
leaq 0xd97(%rip), %rdi       # 0x201e
movl %ebx, %esi
xorl %eax, %eax
callq 0x1060
leaq 0xdd1(%rip), %rdi       # 0x2068
callq 0x1040
leaq 0xd90(%rip), %rdi       # 0x2033
xorl %eax, %eax
callq 0x1060
cmpb $-0x80, -0xc(%rsp,%r15)
movq %r12, %rdi
leaq 0xdc4(%rip), %rax       # 0x207e
cmoveq %rax, %rdi
callq 0x1040
movl -0x4(%rsp,%r15), %esi
movq %r13, %rdi
xorl %eax, %eax
callq 0x1060
movzbl -0x8(%rsp,%r15), %esi
movq %rbp, %rdi
xorl %eax, %eax
callq 0x1060
movl (%rsp,%r15), %esi
movq %r14, %rdi
xorl %eax, %eax
callq 0x1060
movl $0xa, %edi
callq 0x1030
addq $0x10, %r15
incl %ebx
cmpq $0x4c, %r15
jne 0x1280
xorl %eax, %eax
addq $0x3e8, %rsp            # imm = 0x3E8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rbx, %rdi
callq 0x10d0
addq $0x8, %rbx
movq %rbx, %rdi
callq 0x10f7
// File: /workspace/github_c_makefile_star2_O1/FastFilter[P]BlockBloomSimulator/src/blockmodel.h
// Function: findBestBitsPerKeyPerBlock
size_t findBestBitsPerKeyPerBlock(size_t HowManyKeys, size_t bitbudget,
                                  size_t BlockSizeInBits,
                                  sim_stats_t *beststats, bool verbose) {
  model_t m;
  m.NumberOfBlocks = bitbudget / BlockSizeInBits;
  m.BlockSizeInBits = BlockSizeInBits;
  size_t howmanytests = 100000;
  bitset_t *b = bitset_create_with_capacity(bitbudget);
  beststats->collision_rate = 1.0;
  size_t BestBitsPerKeyPerBlock = 0;
  for (size_t BitsPerKeyPerBlock = 1;
       (BitsPerKeyPerBlock <= 16) ||
       (BestBitsPerKeyPerBlock == BitsPerKeyPerBlock);
       BitsPerKeyPerBlock++) {
    m.BitsPerKeyPerBlock = BitsPerKeyPerBlock;
    // we take the average of several attempts
    //double collisionrate = 0;
    sim_stats_t s;
    s.collision_rate = 0;
    s.density = 0;
    size_t attempts = HowManyKeys < 10000000 ? 5 : 1;
    for (int i = 0; i < attempts; i++) {
      sim_stats_t ts = simulate(HowManyKeys, m, howmanytests, b);
      s.density += ts.density;
      s.collision_rate += ts.collision_rate;
    }
    s.collision_rate /= attempts;
    s.density /= attempts;

    if (s.collision_rate * 1.01 <
        beststats->collision_rate) { // has to be at least one percent better
      beststats->collision_rate = s.collision_rate;
      beststats->density = s.density; 
      BestBitsPerKeyPerBlock = BitsPerKeyPerBlock;
    }
  }
  bitset_free(b);
  return BestBitsPerKeyPerBlock;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x58, %rsp
movq %rcx, %rbx
movq %rdx, %rcx
movq %rdi, %r14
xorl %r15d, %r15d
movq %rsi, %rax
xorl %edx, %edx
divq %rcx
movq %rax, 0x50(%rsp)
movq %rcx, 0x48(%rsp)
movq %rsi, %rdi
callq 0x27c4
movq %rax, %r12
movabsq $0x3ff0000000000000, %rax # imm = 0x3FF0000000000000
movq %rax, (%rbx)
xorl %eax, %eax
cmpq $0x989680, %r14         # imm = 0x989680
setb %al
leaq 0x1(,%rax,4), %rax
movq %rax, 0x28(%rsp)
cvtsi2sd %eax, %xmm0
movsd %xmm0, 0x20(%rsp)
movl $0x1, %ebp
movq %rbp, 0x40(%rsp)
xorps %xmm2, %xmm2
movq 0x28(%rsp), %r13
xorps %xmm3, %xmm3
movsd %xmm3, 0x30(%rsp)
movsd %xmm2, 0x38(%rsp)
movq 0x50(%rsp), %rax
movq %rax, 0x10(%rsp)
movupd 0x40(%rsp), %xmm0
movupd %xmm0, (%rsp)
movl $0x186a0, %esi          # imm = 0x186A0
movq %r14, %rdi
movq %r12, %rdx
callq 0x1271
movsd 0x30(%rsp), %xmm3
movsd 0x38(%rsp), %xmm2
addsd %xmm1, %xmm3
addsd %xmm0, %xmm2
decq %r13
jne 0x158b
divsd 0x20(%rsp), %xmm2
movapd %xmm2, %xmm0
mulsd 0x2a99(%rip), %xmm0     # 0x4080
movsd (%rbx), %xmm1
ucomisd %xmm0, %xmm1
jbe 0x1603
divsd 0x20(%rsp), %xmm3
movsd %xmm2, (%rbx)
movsd %xmm3, 0x8(%rbx)
movq %rbp, %r15
incq %rbp
cmpq $0x11, %rbp
setb %al
cmpq %rbp, %r15
sete %cl
orb %al, %cl
jne 0x157b
movq %r12, %rdi
callq 0x2af1
movq %r15, %rax
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/FastFilter[P]BlockBloomSimulator/src/blockmodel.h
// Function: assessBlockSize
void assessBlockSize(size_t HowManyKeys, size_t BlockSizeInBits, bool verbose) {
  for (size_t bitsperkey = 8; bitsperkey <= 16; bitsperkey += 4) {
    size_t bitbudget = bitsperkey * HowManyKeys;
    sim_stats_t beststats;
    size_t bestbitsperbucket = findBestBitsPerKeyPerBlock(
        HowManyKeys, bitbudget, BlockSizeInBits, &beststats, verbose);
    double density = bestbitsperbucket * 1.0 / bitsperkey;

    double theoretical_best_bits = log(1.0/beststats.collision_rate) / log(2.0);
    double inefficiency = (bitsperkey/theoretical_best_bits - 1.0) * 100.0;
    

    printf("bits per key %3zu best bits per bucket = %zu, max density = %0.0f %%, density = %0.0f %%, collision rate = "
           "%0.3f %%, inefficiency = %0.1f %% \n",
           bitsperkey, bestbitsperbucket,density * 100,   beststats.density * 100, beststats.collision_rate * 100, inefficiency);
  }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movq %rsi, %rbx
movq %rdi, %r14
leaq (,%rdi,8), %r15
leaq (,%rdi,4), %rbp
movl $0x4, %r12d
addq $0x4, %r12
movq %r14, %rdi
movq %r15, %rsi
movq %rbx, %rdx
leaq 0x10(%rsp), %rcx
xorl %r8d, %r8d
callq 0x150f
movq %rax, %r13
movq %rax, %xmm0
punpckldq 0x2987(%rip), %xmm0 # xmm0 = xmm0[0],mem[0],xmm0[1],mem[1]
subpd 0x298f(%rip), %xmm0     # 0x4020
movapd %xmm0, %xmm1
unpckhpd %xmm0, %xmm1            # xmm1 = xmm1[1],xmm0[1]
addsd %xmm0, %xmm1
xorps %xmm0, %xmm0
cvtsi2sd %r12, %xmm0
movsd %xmm0, (%rsp)
divsd %xmm0, %xmm1
movapd %xmm1, 0x20(%rsp)
movsd 0x10(%rsp), %xmm1
movsd %xmm1, 0x8(%rsp)
movsd 0x29c0(%rip), %xmm0     # 0x4088
divsd %xmm1, %xmm0
callq 0x10a0
divsd 0x29b7(%rip), %xmm0     # 0x4090
movsd (%rsp), %xmm3
divsd %xmm0, %xmm3
addsd 0x29ae(%rip), %xmm3     # 0x4098
movsd 0x29ae(%rip), %xmm4     # 0x40a0
mulsd %xmm4, %xmm3
movapd 0x20(%rsp), %xmm0
mulsd %xmm4, %xmm0
movsd 0x18(%rsp), %xmm1
mulsd %xmm4, %xmm1
movsd 0x8(%rsp), %xmm2
mulsd %xmm4, %xmm2
leaq 0x2995(%rip), %rdi      # 0x40b0
movq %r12, %rsi
movq %r13, %rdx
movb $0x4, %al
callq 0x1080
addq %rbp, %r15
cmpq $0xd, %r12
jb 0x165f
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/FastFilter[P]BlockBloomSimulator/src/bloommodel.h
// Function: describeBloom
void describeBloom(size_t bitsperkey) {
  double bestbitsperbucket = bitsperkey * log(2);
  double density = bestbitsperbucket * 1.0 / bitsperkey;

  double bestcollisionrate = pow(2, -bestbitsperbucket);
  printf("bits per key %3zu best bits per bucket = %4.1f, best density = %0.0f %%, collision rate = "
         "%0.3f %% [theory]\n",
         bitsperkey, bestbitsperbucket, density * 100, bestcollisionrate * 100);
}

// Assembly:
pushq %rbx
subq $0x20, %rsp
movq %rdi, %rbx
movq %rdi, %xmm0
punpckldq 0x28b7(%rip), %xmm0 # xmm0 = xmm0[0],mem[0],xmm0[1],mem[1]
subpd 0x28bf(%rip), %xmm0     # 0x4020
movapd %xmm0, %xmm1
unpckhpd %xmm0, %xmm1            # xmm1 = xmm1[1],xmm0[1]
addsd %xmm0, %xmm1
movsd 0x291b(%rip), %xmm2     # 0x4090
mulsd %xmm1, %xmm2
movapd %xmm2, 0x10(%rsp)
movapd %xmm2, %xmm0
divsd %xmm1, %xmm0
movapd %xmm0, (%rsp)
movapd 0x28dc(%rip), %xmm0     # 0x4070
xorpd %xmm2, %xmm0
callq 0x1030
movsd 0x28fb(%rip), %xmm2     # 0x40a0
movapd (%rsp), %xmm1
mulsd %xmm2, %xmm1
mulsd %xmm0, %xmm2
leaq 0x2986(%rip), %rdi      # 0x413f
movq %rbx, %rsi
movaps 0x10(%rsp), %xmm0
movb $0x3, %al
addq $0x20, %rsp
popq %rbx
jmp 0x1080
// File: /workspace/github_c_makefile_star2_O1/FastFilter[P]BlockBloomSimulator/src/bloommodel.h
// Function: assessBloomCase
void assessBloomCase(size_t HowManyKeys, bool verbose) {
  for (size_t bitsperkey = 8; bitsperkey <= 16; bitsperkey += 1) {
    size_t bitbudget = bitsperkey * HowManyKeys;
    sim_stats_t beststats;
    size_t bestbitsperbucket = findBestBitsPerKeyPerBlock(
        HowManyKeys, bitbudget, bitbudget, &beststats, verbose);
    double density = bestbitsperbucket * 1.0 / bitsperkey;

    printf("bits per key %3zu best bits per bucket = %4.1f, max density = %0.0f %%, density = %0.0f %%, collision rate = "
           "%0.3f %% [measured]\n",
           bitsperkey, (float)bestbitsperbucket, density * 100, beststats.density * 100, beststats.collision_rate * 100);
    describeBloom(bitsperkey);
  }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movq %rdi, %rbx
leaq (,%rdi,8), %r14
movl $0x8, %r15d
leaq 0x10(%rsp), %r12
leaq 0x29b4(%rip), %r13      # 0x41ac
leaq 0x2940(%rip), %rbp      # 0x413f
movq %rbx, %rdi
movq %r14, %rsi
movq %r14, %rdx
movq %r12, %rcx
xorl %r8d, %r8d
callq 0x150f
movq %rax, %xmm0
punpckldq 0x27f0(%rip), %xmm0 # xmm0 = xmm0[0],mem[0],xmm0[1],mem[1]
subpd 0x27f8(%rip), %xmm0     # 0x4020
testq %rax, %rax
js 0x1837
xorps %xmm2, %xmm2
cvtsi2ss %rax, %xmm2
jmp 0x184f
movq %rax, %rcx
shrq %rcx
andl $0x1, %eax
orq %rcx, %rax
xorps %xmm2, %xmm2
cvtsi2ss %rax, %xmm2
addss %xmm2, %xmm2
movapd %xmm0, %xmm1
unpckhpd %xmm0, %xmm1            # xmm1 = xmm1[1],xmm0[1]
xorps %xmm3, %xmm3
cvtsi2sd %r15, %xmm3
movsd %xmm3, (%rsp)
addsd %xmm0, %xmm1
divsd %xmm3, %xmm1
xorps %xmm0, %xmm0
cvtss2sd %xmm2, %xmm0
movsd 0x2825(%rip), %xmm4     # 0x40a0
mulsd %xmm4, %xmm1
movsd 0x18(%rsp), %xmm2
mulsd %xmm4, %xmm2
movsd 0x10(%rsp), %xmm3
mulsd %xmm4, %xmm3
movq %r13, %rdi
movq %r15, %rsi
movb $0x4, %al
callq 0x1080
movsd (%rsp), %xmm0
movapd %xmm0, %xmm1
mulsd 0x27df(%rip), %xmm1     # 0x4090
movapd %xmm1, 0x20(%rsp)
movapd %xmm1, %xmm2
divsd %xmm0, %xmm2
movapd %xmm2, (%rsp)
movapd %xmm1, %xmm0
xorpd 0x27a0(%rip), %xmm0     # 0x4070
callq 0x1030
movapd %xmm0, %xmm2
movsd 0x27bf(%rip), %xmm0     # 0x40a0
movapd (%rsp), %xmm1
mulsd %xmm0, %xmm1
mulsd %xmm0, %xmm2
movq %rbp, %rdi
movq %r15, %rsi
movaps 0x20(%rsp), %xmm0
movb $0x3, %al
callq 0x1080
incq %r15
addq %rbx, %r14
cmpq $0x11, %r15
jne 0x17ff
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/FastFilter[P]BlockBloomSimulator/src/laneblockmodel.h
// Function: findBestLaneSize
size_t findBestLaneSize(size_t HowManyKeys, size_t bitbudget,
                        size_t BlockSizeInBits, sim_stats_t *beststats,
                        bool verbose) {
  model_t m;
  m.NumberOfBlocks = bitbudget / BlockSizeInBits;
  m.BlockSizeInBits = BlockSizeInBits;
  size_t howmanytests = 100000;
  bitset_t *b = bitset_create_with_capacity(bitbudget);
  beststats->collision_rate = 1.0;
  size_t BestLanes = 0;
  size_t valid_lanes[] = {8, 16, 32, 64};
  for (size_t laneindex = 0;
       laneindex < sizeof(valid_lanes) / sizeof(valid_lanes[0]); laneindex++) {
    size_t lanesize = valid_lanes[laneindex];
    if (lanesize > m.BlockSizeInBits)
      continue;
    m.BitsPerKeyPerBlock = m.BlockSizeInBits / lanesize;
    // we take the averge of several attempts
    sim_stats_t s;
    s.collision_rate = 0;
    s.density = 0;
    size_t attempts = HowManyKeys < 10000000 ? 5 : 1;
    for (int i = 0; i < attempts; i++) {
      sim_stats_t ts = simulate_lane(HowManyKeys, m, howmanytests, b);
      s.density += ts.density;
      s.collision_rate += ts.collision_rate;

    }
    s.collision_rate /= attempts;
    s.density /= attempts;
    if (s.collision_rate * 1.01 <
        beststats->collision_rate) { // has to be at least one percent better
      beststats->collision_rate = s.collision_rate;
      beststats->density = s.density;
      BestLanes = lanesize;
    }
  }
  bitset_free(b);
  return BestLanes;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x68, %rsp
movq %rcx, %rbx
movq %rdx, %r14
movq %rdi, %r15
movq $0x0, 0x18(%rsp)
movq %rsi, %rax
xorl %edx, %edx
divq %r14
movq %rax, 0x60(%rsp)
movq %r14, 0x58(%rsp)
movq %rsi, %rdi
callq 0x27c4
movq %r14, %rdx
movq %rax, %r13
movabsq $0x3ff0000000000000, %rax # imm = 0x3FF0000000000000
xorl %ecx, %ecx
cmpq $0x989680, %r15         # imm = 0x989680
setb %cl
leaq 0x1(,%rcx,4), %rcx
movq %rcx, 0x38(%rsp)
cvtsi2sd %ecx, %xmm0
movsd %xmm0, 0x20(%rsp)
movq %rbx, 0x28(%rsp)
movq %rax, (%rbx)
leaq 0x28e8(%rip), %r14      # 0x4570
xorl %r12d, %r12d
movq %rdx, 0x30(%rsp)
movq (%r14,%r12,8), %rbp
cmpq %rdx, %rbp
ja 0x1d3e
movq %rdx, %rax
xorl %edx, %edx
divq %rbp
movq %rax, 0x50(%rsp)
xorps %xmm2, %xmm2
movq 0x38(%rsp), %rbx
xorps %xmm3, %xmm3
movsd %xmm3, 0x40(%rsp)
movsd %xmm2, 0x48(%rsp)
movq 0x60(%rsp), %rax
movq %rax, 0x10(%rsp)
movupd 0x50(%rsp), %xmm0
movupd %xmm0, (%rsp)
movl $0x186a0, %esi          # imm = 0x186A0
movq %r15, %rdi
movq %r13, %rdx
callq 0x191f
movsd 0x40(%rsp), %xmm3
movsd 0x48(%rsp), %xmm2
addsd %xmm1, %xmm3
addsd %xmm0, %xmm2
decq %rbx
jne 0x1cb5
divsd 0x20(%rsp), %xmm2
movapd %xmm2, %xmm0
mulsd 0x236f(%rip), %xmm0     # 0x4080
movq 0x28(%rsp), %rax
movsd (%rax), %xmm1
ucomisd %xmm0, %xmm1
movq 0x30(%rsp), %rdx
jbe 0x1d3e
divsd 0x20(%rsp), %xmm3
movq 0x28(%rsp), %rax
movsd %xmm2, (%rax)
movsd %xmm3, 0x8(%rax)
movq %rbp, 0x18(%rsp)
incq %r12
cmpq $0x4, %r12
jne 0x1c90
movq %r13, %rdi
callq 0x2af1
movq 0x18(%rsp), %rax
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/FastFilter[P]BlockBloomSimulator/src/laneblockmodel.h
// Function: findLaneCollisionRateAndDensity
sim_stats_t findLaneCollisionRateAndDensity(size_t HowManyKeys, size_t bitbudget,
                             size_t BlockSizeInBits, size_t lanesize,
                             bool verbose) {
  model_t m;
  m.NumberOfBlocks = bitbudget / BlockSizeInBits;
  m.BlockSizeInBits = BlockSizeInBits;
  size_t howmanytests = 100000;
  bitset_t *b = bitset_create_with_capacity(bitbudget);
  m.BitsPerKeyPerBlock = m.BlockSizeInBits / lanesize;
  // we take the averge of several attempts
  sim_stats_t s; 
  s.collision_rate = 0;
  s.density = 0;
  size_t attempts = HowManyKeys < 10000000 ? 5 : 1;
  for (int i = 0; i < attempts; i++) {
    sim_stats_t ts = simulate_lane(HowManyKeys, m, howmanytests, b);
    s.density += ts.density;
    s.collision_rate += ts.collision_rate;
  }
  s.collision_rate /= attempts;
  s.density /= attempts;
  bitset_free(b);
  return s;
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x48, %rsp
movq %rcx, %r15
movq %rdx, %r12
movq %rdi, %rbx
movq %rsi, %rax
xorl %edx, %edx
divq %r12
movq %rax, 0x40(%rsp)
movq %r12, 0x38(%rsp)
movq %rsi, %rdi
callq 0x27c4
movq %rax, %r14
movq %r12, %rax
xorl %edx, %edx
divq %r15
movq %rax, 0x30(%rsp)
xorl %eax, %eax
cmpq $0x989680, %rbx         # imm = 0x989680
setb %al
leaq 0x1(,%rax,4), %r15
xorpd %xmm1, %xmm1
movq %r15, %r12
movapd %xmm1, 0x20(%rsp)
movq 0x40(%rsp), %rax
movq %rax, 0x10(%rsp)
movupd 0x30(%rsp), %xmm0
movupd %xmm0, (%rsp)
movl $0x186a0, %esi          # imm = 0x186A0
movq %rbx, %rdi
movq %r14, %rdx
callq 0x191f
unpcklpd %xmm1, %xmm0            # xmm0 = xmm0[0],xmm1[0]
movapd 0x20(%rsp), %xmm1
addpd %xmm0, %xmm1
decq %r12
jne 0x1dc0
xorps %xmm0, %xmm0
cvtsi2sd %r15d, %xmm0
unpcklpd %xmm0, %xmm0            # xmm0 = xmm0[0,0]
divpd %xmm0, %xmm1
movapd %xmm1, 0x20(%rsp)
movq %r14, %rdi
callq 0x2af1
movaps 0x20(%rsp), %xmm0
movaps %xmm0, %xmm1
unpckhpd %xmm0, %xmm1            # xmm1 = xmm1[1],xmm0[1]
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O1/FastFilter[P]BlockBloomSimulator/src/softblockmodel.h
// Function: findBestFold
size_t findBestFold(size_t HowManyKeys, size_t bitbudget,
                                  size_t BlockSizeInBits,
                                  sim_stats_t *beststats, bool verbose) {
  softmodel_t m;
  m.NumberOfBlocks = bitbudget / BlockSizeInBits;
  m.BlockSizeInBits = BlockSizeInBits;
  size_t howmanytests = 100000;
  bitset_t *b = bitset_create_with_capacity(bitbudget);
  beststats->collision_rate = 1.0;
  size_t BestFold = 0;
  for (size_t fold = 0; fold <= 16; fold++) {
    m.FoldCount = fold;
    // we take the average of several attempts
    //double collisionrate = 0;
    sim_stats_t s;
    s.collision_rate = 0;
    s.density = 0;
    size_t attempts = HowManyKeys < 10000000 ? 5 : 1;
    for (int i = 0; i < attempts; i++) {
      sim_stats_t ts = simulate_soft(HowManyKeys, m, howmanytests, b);
      s.density += ts.density;
      s.collision_rate += ts.collision_rate;
    }
    s.collision_rate /= attempts;
    s.density /= attempts;

    if (s.collision_rate * 1.01 <
        beststats->collision_rate) { // has to be at least one percent better
      beststats->collision_rate = s.collision_rate;
      beststats->density = s.density; 
      BestFold = fold;
    }
  }
  bitset_free(b);
  return BestFold;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x58, %rsp
movq %rcx, %rbx
movq %rdx, %rcx
movq %rdi, %r14
movq $0x0, 0x20(%rsp)
movq %rsi, %rax
xorl %edx, %edx
divq %rcx
movq %rax, 0x50(%rsp)
movq %rcx, 0x48(%rsp)
movq %rsi, %rdi
callq 0x27c4
movq %rax, %r12
movabsq $0x3ff0000000000000, %rax # imm = 0x3FF0000000000000
movq %rax, (%rbx)
xorl %eax, %eax
cmpq $0x989680, %r14         # imm = 0x989680
setb %al
leaq 0x1(,%rax,4), %r15
cvtsi2sd %r15d, %xmm0
movsd %xmm0, 0x28(%rsp)
xorl %ebp, %ebp
movq %rbp, 0x40(%rsp)
xorps %xmm2, %xmm2
movq %r15, %r13
xorps %xmm3, %xmm3
movsd %xmm3, 0x30(%rsp)
movsd %xmm2, 0x38(%rsp)
movq 0x50(%rsp), %rax
movq %rax, 0x10(%rsp)
movupd 0x40(%rsp), %xmm0
movupd %xmm0, (%rsp)
movl $0x186a0, %esi          # imm = 0x186A0
movq %r14, %rdi
movq %r12, %rdx
callq 0x1f90
movsd 0x30(%rsp), %xmm3
movsd 0x38(%rsp), %xmm2
addsd %xmm1, %xmm3
addsd %xmm0, %xmm2
decq %r13
jne 0x2388
divsd 0x28(%rsp), %xmm2
movapd %xmm2, %xmm0
mulsd 0x1c9c(%rip), %xmm0     # 0x4080
movsd (%rbx), %xmm1
ucomisd %xmm0, %xmm1
jbe 0x2402
divsd 0x28(%rsp), %xmm3
movsd %xmm2, (%rbx)
movsd %xmm3, 0x8(%rbx)
movq %rbp, 0x20(%rsp)
incq %rbp
cmpq $0x11, %rbp
jne 0x237a
movq %r12, %rdi
callq 0x2af1
movq 0x20(%rsp), %rax
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/FastFilter[P]BlockBloomSimulator/src/softblockmodel.h
// Function: findSoftCollisionRateAndDensity
sim_stats_t findSoftCollisionRateAndDensity(size_t HowManyKeys, size_t bitbudget,
                             size_t BlockSizeInBits, size_t fold,
                             bool verbose) {
  softmodel_t m;
  m.NumberOfBlocks = bitbudget / BlockSizeInBits;
  m.BlockSizeInBits = BlockSizeInBits;
  size_t howmanytests = 100000;
  bitset_t *b = bitset_create_with_capacity(bitbudget);
  m.FoldCount = fold;
  // we take the averge of several attempts
  sim_stats_t s; 
  s.collision_rate = 0;
  s.density = 0;
  size_t attempts = HowManyKeys < 10000000 ? 5 : 1;
  for (int i = 0; i < attempts; i++) {
    sim_stats_t ts = simulate_soft(HowManyKeys, m, howmanytests, b);
    s.density += ts.density;
    s.collision_rate += ts.collision_rate;
  }
  s.collision_rate /= attempts;
  s.density /= attempts;
  bitset_free(b);
  return s;
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x48, %rsp
movq %rcx, %r15
movq %rdx, %rcx
movq %rdi, %rbx
movq %rsi, %rax
xorl %edx, %edx
divq %rcx
movq %rax, 0x40(%rsp)
movq %rcx, 0x38(%rsp)
movq %rsi, %rdi
callq 0x27c4
movq %rax, %r14
movq %r15, 0x30(%rsp)
xorl %eax, %eax
cmpq $0x989680, %rbx         # imm = 0x989680
setb %al
leaq 0x1(,%rax,4), %r15
xorpd %xmm1, %xmm1
movq %r15, %r12
movapd %xmm1, 0x20(%rsp)
movq 0x40(%rsp), %rax
movq %rax, 0x10(%rsp)
movupd 0x30(%rsp), %xmm0
movupd %xmm0, (%rsp)
movl $0x186a0, %esi          # imm = 0x186A0
movq %rbx, %rdi
movq %r14, %rdx
callq 0x1f90
unpcklpd %xmm1, %xmm0            # xmm0 = xmm0[0],xmm1[0]
movapd 0x20(%rsp), %xmm1
addpd %xmm0, %xmm1
decq %r12
jne 0x247c
xorps %xmm0, %xmm0
cvtsi2sd %r15d, %xmm0
unpcklpd %xmm0, %xmm0            # xmm0 = xmm0[0,0]
divpd %xmm0, %xmm1
movapd %xmm1, 0x20(%rsp)
movq %r14, %rdi
callq 0x2af1
movaps 0x20(%rsp), %xmm0
movaps %xmm0, %xmm1
unpckhpd %xmm0, %xmm1            # xmm1 = xmm1[1],xmm0[1]
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O1/FastFilter[P]BlockBloomSimulator/src/softblockmodel.h
// Function: assessFold
void assessFold(size_t HowManyKeys, size_t BlockSizeInBits,
                          bool verbose) {
  for (size_t bitsperkey = 8; bitsperkey <= 10; bitsperkey += 1) {
    size_t bitbudget = bitsperkey * HowManyKeys;
    sim_stats_t beststats;
    size_t bestfold = findBestFold(HowManyKeys, bitbudget, BlockSizeInBits,
                                       &beststats, verbose);
    printf("bits per key %3zu best fold = %zu,  density = %0.0f %%, collision rate = "
           "%0.3f %% \n",
           bitsperkey, bestfold, beststats.density * 100, beststats.collision_rate * 100);
  }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rsi, %rbx
movq %rdi, %r14
leaq (,%rdi,8), %r15
movl $0x8, %r12d
leaq 0x8(%rsp), %r13
leaq 0x1e0b(%rip), %rbp      # 0x4329
movq %r14, %rdi
movq %r15, %rsi
movq %rbx, %rdx
movq %r13, %rcx
xorl %r8d, %r8d
callq 0x230f
movsd 0x10(%rsp), %xmm0
movsd 0x1b60(%rip), %xmm2     # 0x40a0
mulsd %xmm2, %xmm0
movsd 0x8(%rsp), %xmm1
mulsd %xmm2, %xmm1
movq %rbp, %rdi
movq %r12, %rsi
movq %rax, %rdx
movb $0x2, %al
callq 0x1080
incq %r12
addq %r14, %r15
cmpq $0xb, %r12
jne 0x251e
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/FastFilter[P]BlockBloomSimulator/src/blockmodel.c
// Function: main
int main() {
  printf("bits per key indicates storage (bits used per key): smaller is "
         "better\n");
  printf("best bits per bucket indicates the number of bits to check per key: "
         "smaller is better\n");
  printf("collision rate is the false negative rate: smaller is better\n");
  printf("In the 'lane' model you have one bit set per lane.\n");
  printf("\n");

  compute(1000);
  printf("==========\n\n");

  compute(1000000);
  printf("==========\n\n");

  compute(10000000);
  printf("==========\n\n");

  return EXIT_SUCCESS;
}

// Assembly:
pushq %rbx
leaq 0x1d26(%rip), %rdi      # 0x444f
callq 0x1070
leaq 0x1d60(%rip), %rdi      # 0x4495
callq 0x1070
leaq 0x1daa(%rip), %rdi      # 0x44eb
callq 0x1070
leaq 0x1ddb(%rip), %rdi      # 0x4528
callq 0x1070
movl $0xa, %edi
callq 0x1050
movl $0x3e8, %edi            # imm = 0x3E8
callq 0x2579
leaq 0x1dee(%rip), %rbx      # 0x455b
movq %rbx, %rdi
callq 0x1070
movl $0xf4240, %edi          # imm = 0xF4240
callq 0x2579
movq %rbx, %rdi
callq 0x1070
movl $0x989680, %edi         # imm = 0x989680
callq 0x2579
movq %rbx, %rdi
callq 0x1070
xorl %eax, %eax
popq %rbx
retq
nopl (%rax)
// File: /workspace/github_c_makefile_star2_O1/FastFilter[P]BlockBloomSimulator/src/bitset.c
// Function: bitset_create_with_capacity
bitset_t *bitset_create_with_capacity( size_t size ) {
  bitset_t *bitset = NULL;
  /* Allocate the bitset itself. */
  if( ( bitset = (bitset_t*) malloc( sizeof( bitset_t ) ) ) == NULL ) {
      return NULL;
  }
  bitset->arraysize = (size + sizeof(uint64_t) * 8 - 1) / (sizeof(uint64_t) * 8);
  bitset->capacity = bitset->arraysize;
  if ((bitset->array = (uint64_t *) malloc(sizeof(uint64_t) * bitset->arraysize)) == NULL) {
    free( bitset);
    return NULL;
  }
  memset(bitset->array,0,sizeof(uint64_t) * bitset->arraysize);
  return bitset;
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq %rdi, %r14
movl $0x18, %edi
callq 0x10c0
testq %rax, %rax
je 0x2818
movq %rax, %rbx
addq $0x3f, %r14
shrq $0x6, %r14
movq %r14, 0x8(%rax)
movq %r14, 0x10(%rax)
shlq $0x3, %r14
movq %r14, %rdi
callq 0x10c0
movq %rax, (%rbx)
testq %rax, %rax
je 0x2810
movq %rax, %rdi
xorl %esi, %esi
movq %r14, %rdx
callq 0x1090
jmp 0x281a
movq %rbx, %rdi
callq 0x1040
xorl %ebx, %ebx
movq %rbx, %rax
addq $0x8, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_c_makefile_star2_O1/FastFilter[P]BlockBloomSimulator/src/bitset.c
// Function: bitset_copy
bitset_t *bitset_copy( const bitset_t * bitset ) {
  bitset_t *copy = NULL;
  /* Allocate the bitset itself. */
  if( ( copy = (bitset_t*) malloc( sizeof( bitset_t ) ) ) == NULL ) {
      return NULL;
  }
  memcpy(copy,bitset,sizeof(bitset_t));
  copy->capacity = copy->arraysize;
  if ((copy->array = (uint64_t *) malloc(sizeof(uint64_t) * bitset->arraysize)) == NULL) {
    free(copy);
    return NULL;
  }
  memcpy(copy->array,bitset->array,sizeof(uint64_t) * bitset->arraysize);
  return copy;
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
movq %rdi, %r14
movl $0x18, %edi
callq 0x10c0
testq %rax, %rax
je 0x2886
movq %rax, %rbx
movups (%r14), %xmm0
movups %xmm0, (%rax)
movq 0x10(%r14), %rax
movq %rax, 0x10(%rbx)
movq 0x8(%rbx), %rax
movq %rax, 0x10(%rbx)
movq 0x8(%r14), %r15
shlq $0x3, %r15
movq %r15, %rdi
callq 0x10c0
movq %rax, (%rbx)
testq %rax, %rax
je 0x287e
movq (%r14), %rsi
movq %rax, %rdi
movq %r15, %rdx
callq 0x10b0
jmp 0x2888
movq %rbx, %rdi
callq 0x1040
xorl %ebx, %ebx
movq %rbx, %rax
popq %rbx
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O1/FastFilter[P]BlockBloomSimulator/src/bitset.c
// Function: bitset_shift_left
void bitset_shift_left(bitset_t *bitset, size_t s) {
  size_t extra_words = s / 64;
  int inword_shift = s % 64;
  size_t as = bitset->arraysize;
  if(inword_shift == 0) {
    bitset_resize(bitset,as + extra_words, false);
    // could be done with a memmove
    for(size_t i = as + extra_words ; i > extra_words; i--) {
      bitset->array[i - 1] = bitset->array[i - 1 - extra_words];
    }
  } else {
    bitset_resize(bitset,as + extra_words + 1, true);
    bitset->array[as + extra_words] =
     bitset->array[as - 1] >> (64 - inword_shift);
    for(size_t i = as + extra_words ; i >= extra_words + 2; i--) {
      bitset->array[i - 1] = (bitset->array[i - 1 - extra_words] << inword_shift)
      | (bitset->array[i - 2 - extra_words]>>(64 - inword_shift));
    }
    bitset->array[extra_words] = bitset->array[0] <<  inword_shift;
  }
  for(size_t i = 0; i < extra_words; i++) {
    bitset->array[i] = 0;
  }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rsi, %r15
movq %rdi, %r14
movq %rsi, %rbx
shrq $0x6, %rbx
movq 0x8(%rdi), %r13
leaq (%rbx,%r13), %r12
movl %r15d, %ebp
andl $0x3f, %ebp
je 0x2945
leaq 0x1(%r12), %rsi
movq %r14, %rdi
movl $0x1, %edx
callq 0x29aa
movq (%r14), %rsi
movq -0x8(%rsi,%r13,8), %rax
movl %ebp, %ecx
negl %ecx
shrq %cl, %rax
movq %rax, (%rsi,%r12,8)
leaq 0x2(%rbx), %rdi
cmpq %rdi, %r12
jb 0x2936
movl $0x40, %eax
subl %ebp, %eax
movl %r15d, %edx
andl $0x3f, %edx
leaq (%rsi,%r13,8), %r8
addq $-0x8, %r8
movq -0x8(%r8), %r9
movq (%r8), %r10
movl %edx, %ecx
shlq %cl, %r10
addq $-0x8, %r8
movl %eax, %ecx
shrq %cl, %r9
orq %r10, %r9
movq %r9, -0x8(%rsi,%r12,8)
decq %r12
cmpq %rdi, %r12
jae 0x2911
movq (%rsi), %rax
movl %r15d, %ecx
shlq %cl, %rax
movq %rax, (%rsi,%rbx,8)
jmp 0x2976
movq %r14, %rdi
movq %r12, %rsi
xorl %edx, %edx
callq 0x29aa
cmpq %rbx, %r12
jbe 0x2976
movq (%r14), %rax
leaq (%rax,%r13,8), %rcx
addq $-0x8, %rcx
movq (%rcx), %rdx
movq %rdx, -0x8(%rax,%r12,8)
decq %r12
addq $-0x8, %rcx
cmpq %rbx, %r12
ja 0x2962
cmpq $0x40, %r15
jae 0x298b
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq (%r14), %rdi
shlq $0x3, %rbx
xorl %esi, %esi
movq %rbx, %rdx
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x1090