LLM4Binary/decompile-bench-makefile huggingface dataset:
// File: /workspace/github_cpp_makefile_star2_O3/madpilot[P]mDNSResolver/src/Response.cpp
// Function: mDNSResolver::Response::Response(char const*, unsigned long)
Response::Response(const char* name, unsigned long ttl) {
    strncpy(this->name, name, MDNS_MAX_NAME_LEN + 1);
    this->name[MDNS_MAX_NAME_LEN + 1] = '\0';
    this->ttl = ttl;
    this->resolved = false;
    this->cname = NULL;
    this->ipAddress = INADDR_NONE;
  }

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movq %rdx, %rbx
movq %rsi, %r14
movq %rdi, %r15
addq $0x10c, %rdi            # imm = 0x10C
callq 0x4b474
movl $0x100, %edx            # imm = 0x100
movq %r15, %rdi
movq %r14, %rsi
callq 0xa1b0
movq %rbx, 0x100(%r15)
movb $0x0, 0x108(%r15)
movq $0x0, 0x110(%r15)
movl 0x2d571(%rip), %eax     # 0x68690
movl %eax, 0x10c(%r15)
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
nop
// File: /workspace/github_cpp_makefile_star2_O3/madpilot[P]mDNSResolver/src/Answer.cpp
// Function: mDNSResolver::Answer::process(unsigned char*, unsigned int, mDNSResolver::Cache&)
MDNS_RESULT Answer::process(unsigned char* buffer, unsigned int len, Cache& cache) {
    if((buffer[2] & 0b10000000) != 0b10000000) {
      // Not an answer packet
      return E_MDNS_OK;
    }

    if(buffer[2] & 0b00000010) {
      // Truncated - we don't know what to do with these
      return E_MDNS_TRUNCATED;
    }

    if (buffer[3] & 0b00001111) {
      return E_MDNS_PACKET_ERROR;
    }

    unsigned int answerCount = (buffer[6] << 8) + buffer[7];
    if(answerCount == 0) {
      return E_MDNS_OK;
    }

    unsigned int offset = 0;

    MDNS_RESULT questionResult = skipQuestions(buffer, len, &offset);
    if(questionResult != E_MDNS_OK) {
      return questionResult;
    }

    MDNS_RESULT answerResult;
    for(int i = 0; i < answerCount; i++) {
      answerResult = resolve(buffer, len, &offset, cache);
      if(answerResult != E_MDNS_OK) {
        return answerResult;
      }
    }

    resolveCnames(cache);

    return answerResult;
  }

// Assembly:
movb 0x2(%rdi), %cl
movl $0x20, %eax
testb %cl, %cl
js 0x48a3d
retq
movl $0x25, %eax
testb $0x2, %cl
jne 0x48a3c
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdi, %r15
movl $0x23, %eax
testb $0xf, 0x3(%rdi)
je 0x48a72
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movzwl 0x6(%r15), %r12d
rolw $0x8, %r12w
movl $0x20, %eax
testw %r12w, %r12w
je 0x48a63
movq %rdx, %rbx
movl %esi, %r14d
leaq -0x2c(%rbp), %rdx
movl $0x0, (%rdx)
movq %r15, %rdi
callq 0x48ad6
cmpl $0x20, %eax
jne 0x48a63
movzwl %r12w, %r13d
leaq -0x2c(%rbp), %r12
movq %r15, %rdi
movl %r14d, %esi
movq %r12, %rdx
movq %rbx, %rcx
callq 0x48b50
cmpl $0x20, %eax
jne 0x48a63
decl %r13d
jne 0x48aac
movq %rbx, %rdi
callq 0x48e36
movl $0x20, %eax
jmp 0x48a63
// File: /workspace/github_cpp_makefile_star2_O3/madpilot[P]mDNSResolver/src/Answer.cpp
// Function: mDNSResolver::Answer::skipQuestions(unsigned char*, unsigned int, unsigned int*)
MDNS_RESULT Answer::skipQuestions(unsigned char* buffer, unsigned int len, unsigned int* offset) {
    unsigned int questionCount = (buffer[4] << 8) + buffer[5];

    *offset += 12;
    for(int i = 0; i < questionCount; i++) {

      while(buffer[*offset] != '\0') {
        // If it's a pointer, add two to the counter
        if((buffer[*offset] & 0xc0) == 0xc0) {
          (*offset) += 2;
          break;
        } else {
          unsigned int labelLength = (unsigned int)buffer[*offset];

          if(labelLength > 0x3f) {
            return E_MDNS_INVALID_LABEL_LENGTH;
          }

          (*offset) += 1; // Increment to move to the next byte
          (*offset) += labelLength;

          if(*offset > len) {
            return E_MDNS_PACKET_ERROR;
          }
        }
      }

      (*offset) += 5; // 2 bytes for the qtypes and 2 bytes qclass + plus one to land us on the next bit
    }

    if(*offset > len + 1) {
      return E_MDNS_PACKET_ERROR;
    }

    return E_MDNS_OK;
  }

// Assembly:
pushq %rbp
movq %rsp, %rbp
movzwl 0x4(%rdi), %ecx
rolw $0x8, %cx
movl (%rdx), %eax
addl $0xc, %eax
movl %eax, (%rdx)
testw %cx, %cx
je 0x48b30
movzwl %cx, %ecx
xorl %r8d, %r8d
movl %eax, %r9d
movzbl (%rdi,%r9), %r9d
testl %r9d, %r9d
je 0x48b23
movl %r9d, %r10d
notl %r10d
testb $-0x40, %r10b
je 0x48b20
cmpb $0x3f, %r9b
ja 0x48b41
addl %r9d, %eax
incl %eax
movl %eax, (%rdx)
cmpl %esi, %eax
jbe 0x48af4
jmp 0x48b48
addl $0x2, %eax
addl $0x5, %eax
movl %eax, (%rdx)
incl %r8d
cmpl %ecx, %r8d
jne 0x48af4
incl %esi
xorl %ecx, %ecx
cmpl %esi, %eax
seta %cl
leal (%rcx,%rcx,2), %eax
addl $0x20, %eax
jmp 0x48b4d
movl $0x26, %eax
jmp 0x48b4d
movl $0x23, %eax
popq %rbp
retq
nop
// File: /workspace/github_cpp_makefile_star2_O3/madpilot[P]mDNSResolver/src/Answer.cpp
// Function: mDNSResolver::Answer::resolveCnames(mDNSResolver::Cache&)
MDNS_RESULT Answer::resolveCnames(Cache &cache) {
    for(int i = 0; i < cache.length(); i++) {
      if(cache[i].cname != NULL && cache[i].cname->resolved) {
        cache[i].ipAddress = cache[i].cname->ipAddress;
        cache[i].resolved = true;
        cache[i].cname = NULL;
      }
    }
    return E_MDNS_OK;
  }

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movq %rdi, %rbx
callq 0x39496
testl %eax, %eax
jle 0x48ee9
xorl %r14d, %r14d
movq %rbx, %rdi
movl %r14d, %esi
callq 0x39132
cmpq $0x0, 0x110(%rax)
je 0x48ed5
movq %rbx, %rdi
movl %r14d, %esi
callq 0x39132
movq 0x110(%rax), %rax
cmpb $0x1, 0x108(%rax)
jne 0x48ed5
movq %rbx, %rdi
movl %r14d, %esi
callq 0x39132
movq 0x110(%rax), %r15
movq %rbx, %rdi
movl %r14d, %esi
callq 0x39132
movl 0x10c(%r15), %ecx
movl %ecx, 0x10c(%rax)
movq %rbx, %rdi
movl %r14d, %esi
callq 0x39132
movb $0x1, 0x108(%rax)
movq %rbx, %rdi
movl %r14d, %esi
callq 0x39132
movq $0x0, 0x110(%rax)
incl %r14d
movq %rbx, %rdi
callq 0x39496
cmpl %eax, %r14d
jl 0x48e53
movl $0x20, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
nop
// File: /workspace/github_cpp_makefile_star2_O3/madpilot[P]mDNSResolver/src/Answer.cpp
// Function: mDNSResolver::Answer::resolveAName(unsigned char*, unsigned int, unsigned int*, mDNSResolver::Response&, long, int)
MDNS_RESULT Answer::resolveAName(unsigned char *buffer, unsigned int len, unsigned int *offset, Response& response, long ttl, int dataLen) {
    if(dataLen == 4) {
      unsigned int a = (unsigned int)*(buffer + (*offset)++);
      unsigned int b = (unsigned int)*(buffer + (*offset)++);
      unsigned int c = (unsigned int)*(buffer + (*offset)++);
      unsigned int d = (unsigned int)*(buffer + (*offset)++);

      response.resolved = true;
      response.ttl = ttl;
      response.ipAddress = IPAddress(a, b, c, d);

    } else {
      (*offset) += dataLen;
    }

    return E_MDNS_OK;
  }

// Assembly:
movl (%rdx), %r10d
cmpl $0x4, %r9d
jne 0x48f6f
pushq %rbp
movq %rsp, %rbp
pushq %r14
pushq %rbx
subq $0x10, %rsp
movq %rcx, %rbx
leal 0x1(%r10), %eax
movl %eax, (%rdx)
movzbl (%rdi,%r10), %esi
leal 0x2(%r10), %ecx
movl %ecx, (%rdx)
movzbl (%rdi,%rax), %eax
leal 0x3(%r10), %r9d
movl %r9d, (%rdx)
movzbl (%rdi,%rcx), %ecx
addl $0x4, %r10d
movl %r10d, (%rdx)
movzbl (%rdi,%r9), %r9d
movb $0x1, 0x108(%rbx)
movq %r8, 0x100(%rbx)
leaq -0x14(%rbp), %r14
movq %r14, %rdi
movl %eax, %edx
movl %r9d, %r8d
callq 0x4b480
movl (%r14), %eax
movl %eax, 0x10c(%rbx)
addq $0x10, %rsp
popq %rbx
popq %r14
popq %rbp
jmp 0x48f75
addl %r9d, %r10d
movl %r10d, (%rdx)
movl $0x20, %eax
retq
nop
// File: /workspace/github_cpp_makefile_star2_O3/madpilot[P]mDNSResolver/src/Answer.cpp
// Function: mDNSResolver::Answer::parseName(char**, char const*, unsigned int)
MDNS_RESULT Answer::parseName(char** name, const char* mapped, unsigned int len) {
    unsigned int namePointer = 0;
    unsigned int mapPointer = 0;

    while(mapPointer < len) {
      int labelLength = mapped[mapPointer++];

      if(labelLength > 0x3f) {
        return E_MDNS_INVALID_LABEL_LENGTH;
      }

      if(namePointer + labelLength > len - 1) {
        return E_MDNS_PACKET_ERROR;
      }

      if(namePointer != 0) {
        (*name)[namePointer++] = '.';
      }

      for(int i = 0; i < labelLength; i++) {
        (*name)[namePointer++] = mapped[mapPointer++];
      }
    }

    (*name)[len - 1] = '\0';

    return E_MDNS_OK;
  }

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r14
pushq %rbx
testl %edx, %edx
je 0x48fff
leal -0x1(%rdx), %eax
xorl %ecx, %ecx
xorl %r8d, %r8d
movl %ecx, %r9d
movsbl (%rsi,%r9), %r9d
cmpl $0x3f, %r9d
jg 0x49012
leal (%r8,%r9), %r10d
cmpl %eax, %r10d
ja 0x49019
testl %r8d, %r8d
je 0x48fcb
movq (%rdi), %r10
movl %r8d, %r11d
incl %r8d
movb $0x2e, (%r10,%r11)
jmp 0x48fce
xorl %r8d, %r8d
incl %ecx
testb %r9b, %r9b
jle 0x48ff7
leal (%rcx,%r9), %r10d
movl %ecx, %r11d
movb (%rsi,%r11), %r11b
movq (%rdi), %rbx
movl %r8d, %r14d
incl %r8d
movb %r11b, (%rbx,%r14)
incl %ecx
decl %r9d
jne 0x48fd9
movl %r10d, %ecx
cmpl %edx, %ecx
jb 0x48f9f
movl %eax, %eax
jmp 0x49004
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
movq (%rdi), %rcx
movb $0x0, (%rcx,%rax)
movl $0x20, %eax
jmp 0x4901e
movl $0x26, %eax
jmp 0x4901e
movl $0x23, %eax
popq %rbx
popq %r14
popq %rbp
retq
nop
// File: /workspace/github_cpp_makefile_star2_O3/madpilot[P]mDNSResolver/src/Answer.cpp
// Function: mDNSResolver::Answer::assembleName(unsigned char*, unsigned int, unsigned int*, char**, unsigned int)
int Answer::assembleName(unsigned char *buffer, unsigned int len, unsigned int *offset, char **name, unsigned int maxlen) {
    unsigned int index = 0;
    unsigned int nameLength = 0;

    while(index < maxlen) {
      if((buffer[*offset] & 0xc0) == 0xc0) {
        unsigned int pointerOffset = ((buffer[(*offset)++] & 0x3f) << 8) + buffer[(*offset)++];
        if(pointerOffset > len) {
          // Points to somewhere beyond the packet
          return -1 * E_MDNS_POINTER_OVERFLOW;
        }

        char *namePointer = *name + nameLength;
        int pointerLen = assembleName(buffer, len, &pointerOffset, &namePointer, MDNS_MAX_NAME_LEN - nameLength);

        if(pointerLen < 0) {
          return pointerLen;
        }

        nameLength += pointerLen;

        break;
      } else if(buffer[*offset] == '\0') {
        (*name)[nameLength++] = buffer[(*offset)++];
        break;
      } else {
        (*name)[nameLength++] = buffer[(*offset)++];
      }
      index++;
    }

    return nameLength;
  }

// Assembly:
testl %r8d, %r8d
je 0x49065
pushq %rbp
movq %rsp, %rbp
pushq %rbx
subq $0x18, %rsp
movl %r8d, %eax
xorl %ebx, %ebx
movl (%rdx), %r8d
movb (%rdi,%r8), %r9b
cmpb $-0x40, %r9b
jae 0x49068
testb %r9b, %r9b
je 0x49097
leal 0x1(%r8), %r9d
movl %r9d, (%rdx)
movb (%rdi,%r8), %r8b
movq (%rcx), %r9
movb %r8b, (%r9,%rbx)
incq %rbx
cmpq %rbx, %rax
jne 0x49037
jmp 0x490d6
xorl %eax, %eax
retq
leal 0x1(%r8), %eax
movl %eax, (%rdx)
movzbl (%rdi,%r8), %r9d
andl $0x3f, %r9d
shll $0x8, %r9d
addl $0x2, %r8d
movl %r8d, (%rdx)
movzbl (%rdi,%rax), %eax
orl %r9d, %eax
movl %eax, -0xc(%rbp)
cmpl %esi, %eax
jbe 0x490ac
movl $0xffffffde, %eax       # imm = 0xFFFFFFDE
jmp 0x490d6
leal 0x1(%r8), %eax
movl %eax, (%rdx)
movb (%rdi,%r8), %dl
movq (%rcx), %rcx
leal 0x1(%rbx), %eax
movb %dl, (%rcx,%rbx)
jmp 0x490d6
movq (%rcx), %rax
addq %rbx, %rax
leaq -0x18(%rbp), %rcx
movq %rax, (%rcx)
movl $0xff, %r8d
subl %ebx, %r8d
leaq -0xc(%rbp), %rdx
callq 0x49024
movl %eax, %ecx
xorl %eax, %eax
testl %ecx, %ecx
cmovnsl %ebx, %eax
addl %ecx, %eax
addq $0x18, %rsp
popq %rbx
popq %rbp
retq
nopl (%rax)
// File: /workspace/github_cpp_makefile_star2_O3/madpilot[P]mDNSResolver/src/mDNSResolver.cpp
// Function: mDNSResolver::Resolver::search(char const*)
IPAddress Resolver::search(const char* name) {
    if(!isMDNSName(name)) {
      return INADDR_NONE;
    }

    cache.expire();

    int attempts = 0;

    while(attempts < MDNS_ATTEMPTS) {
      int index = cache.search(name);

      if(index == -1) {
        cache.insert(Response(name, 5));
        continue;
      } else if(cache[index].resolved) {
        return cache[index].ipAddress;
      }

      long now = millis();

      // Send a query packet every second
      if(now - timeout > MDNS_RETRY) {
        query(name);
        timeout = now;
        attempts++;
      }

      MDNS_RESULT result = read();
      if(result != E_MDNS_OK) {
        return INADDR_NONE;
      }
    }

    return INADDR_NONE;
  }

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x128, %rsp            # imm = 0x128
movq %rsi, %r14
movq %rdi, %rbx
callq 0x4afb8
leaq 0x1d7f6(%rip), %rcx     # 0x686a8
testb %al, %al
je 0x4af8d
movq %rbx, -0x38(%rbp)
leaq 0x1d7eb(%rip), %r13     # 0x686b0
movq %r13, %rdi
callq 0x39416
movl $0x0, -0x2c(%rbp)
leaq -0x150(%rbp), %r12
movq %r13, %rdi
movq %r14, %rsi
callq 0x393ba
cmpl $-0x1, %eax
je 0x4af3f
movl %eax, %ebx
movq %r13, %r15
movq %r13, %rdi
movl %eax, %esi
callq 0x39132
cmpb $0x1, 0x108(%rax)
je 0x4af75
callq 0x4b4d0
movq %rax, %rbx
movq -0x38(%rbp), %r13
subq 0x28(%r13), %rax
cmpq $0x3e9, %rax            # imm = 0x3E9
jl 0x4af2d
movq %r13, %rdi
movq %r14, %rsi
callq 0x4aff8
movq %rbx, 0x28(%r13)
incl -0x2c(%rbp)
movq %r13, %rdi
callq 0x4b07a
cmpl $0x20, %eax
movq %r15, %r13
je 0x4af62
jmp 0x4af6c
movl $0x5, %edx
movq %r12, %rdi
movq %r14, %rsi
callq 0x3b0d0
movq %r13, %rdi
movq %r12, %rsi
callq 0x39146
movq %r12, %rdi
callq 0x3b132
cmpl $0x5, -0x2c(%rbp)
jl 0x4aedb
leaq 0x1d735(%rip), %rcx     # 0x686a8
jmp 0x4af8d
leaq 0x1d734(%rip), %rdi     # 0x686b0
movl %ebx, %esi
callq 0x39132
movq %rax, %rcx
addq $0x10c, %rcx            # imm = 0x10C
movl (%rcx), %eax
addq $0x128, %rsp            # imm = 0x128
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
leaq -0x150(%rbp), %rdi
callq 0x3b132
movq %rbx, %rdi
callq 0xa6d0
// File: /workspace/github_cpp_makefile_star2_O3/madpilot[P]mDNSResolver/src/mDNSResolver.cpp
// Function: mDNSResolver::Resolver::isMDNSName(char const*)
bool Resolver::isMDNSName(const char* name) {
    int len = strlen(name);
    int tldLen = strlen(MDNS_TLD);

    if(len < tldLen) {
      return false;
    }

    return strcmp(name + len - tldLen, MDNS_TLD) == 0;
  }

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %rbx
pushq %rax
movq %rsi, %rbx
movq %rsi, %rdi
callq 0xa180
cmpl $0x6, %eax
jge 0x4afd2
xorl %eax, %eax
jmp 0x4aff0
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
leaq (%rbx,%rax), %rdi
addq $-0x6, %rdi
leaq 0x3aa7(%rip), %rsi      # 0x4ea8d
callq 0xa510
testl %eax, %eax
sete %al
addq $0x8, %rsp
popq %rbx
popq %rbp
retq
nop
// File: /workspace/github_cpp_makefile_star2_O3/madpilot[P]mDNSResolver/src/mDNSResolver.cpp
// Function: mDNSResolver::Resolver::query(char const*)
void Resolver::query(const char* name) {
    Query query(name);
    
#if defined(ESP32)
	udp.beginMulticast(MDNS_BROADCAST_IP, MDNS_PORT);
	udp.beginMulticastPacket();
#else
	udp.beginPacketMulticast(MDNS_BROADCAST_IP, MDNS_PORT, localIP, UDP_TIMEOUT);
#endif
    query.sendPacket(udp);
    udp.endPacket();
  }

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %rbx
subq $0x18, %rsp
movq %rdi, %rbx
leaq -0x10(%rbp), %rdi
callq 0x31c14
leaq -0x14(%rbp), %rdi
movl $0xe0, %esi
xorl %edx, %edx
xorl %ecx, %ecx
movl $0xfb, %r8d
callq 0x4b480
movl 0x20(%rbx), %ecx
addq $0x8, %rbx
movl -0x14(%rbp), %esi
movq %rbx, %rdi
movl $0x14e9, %edx           # imm = 0x14E9
movl $0xff, %r8d
callq 0x4b3c6
leaq -0x10(%rbp), %rdi
movq %rbx, %rsi
callq 0x31c24
movq %rbx, %rdi
callq 0x4b3ce
leaq -0x10(%rbp), %rdi
callq 0x31c1e
addq $0x18, %rsp
popq %rbx
popq %rbp
retq
movq %rax, %rbx
leaq -0x10(%rbp), %rdi
callq 0x31c1e
movq %rbx, %rdi
callq 0xa6d0
// File: /workspace/github_cpp_makefile_star2_O3/madpilot[P]mDNSResolver/src/mDNSResolver.cpp
// Function: mDNSResolver::Resolver::read()
MDNS_RESULT Resolver::read() {
    cache.expire();

    if(!init) {
      init = true;
#if defined(ESP32)
	udp.beginMulticast(MDNS_BROADCAST_IP, MDNS_PORT);
#else
	udp.beginMulticast(localIP, MDNS_BROADCAST_IP, MDNS_PORT);
#endif
    }

    unsigned int len = udp.parsePacket();

    if(len > 0) {
      unsigned char *buffer = (unsigned char *)malloc(sizeof(unsigned char) * len);

      if(buffer == NULL) {
        // Out of memory - the packet is probably too big to parse. Probably.
        // Silently bombing out, possibly isn't great, but it'll do for the moment.
        return E_MDNS_OUT_OF_MEMORY;
      }

      udp.read(buffer, len);
      lastResult = Answer::process(buffer, len, cache);

      free(buffer);
      return lastResult;
    }

    return E_MDNS_OK;
  }

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdi, %rbx
leaq 0x1d61e(%rip), %rdi     # 0x686b0
callq 0x39416
cmpb $0x0, 0x24(%rbx)
jne 0x4b0d8
movb $0x1, 0x24(%rbx)
leaq 0x8(%rbx), %r14
movl 0x20(%rbx), %r15d
leaq -0x2c(%rbp), %r12
movq %r12, %rdi
movl $0xe0, %esi
xorl %edx, %edx
xorl %ecx, %ecx
movl $0xfb, %r8d
callq 0x4b480
movl (%r12), %edx
movq %r14, %rdi
movl %r15d, %esi
movl $0x14e9, %ecx           # imm = 0x14E9
callq 0x4b3ae
leaq 0x8(%rbx), %r12
movq %r12, %rdi
callq 0x4b468
testl %eax, %eax
je 0x4b12d
movl %eax, %r14d
movl %eax, %r13d
movq %r13, %rdi
callq 0xa4e0
testq %rax, %rax
je 0x4b135
movq %rax, %r15
movq %r12, %rdi
movq %rax, %rsi
movq %r13, %rdx
callq 0x4b3f2
leaq 0x1d59d(%rip), %rdx     # 0x686b0
movq %r15, %rdi
movl %r14d, %esi
callq 0x48a30
movl %eax, %r14d
movl %eax, (%rbx)
movq %r15, %rdi
callq 0xa480
jmp 0x4b13b
movl $0x20, %r14d
jmp 0x4b13b
movl $0x27, %r14d
movl %r14d, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop
// File: /workspace/github_cpp_makefile_star2_O3/madpilot[P]mDNSResolver/src/mDNSResolver.cpp
// Function: mDNSResolver::Resolver::loop()
void Resolver::loop() {
    // Clear the buffers out.
    // This wouldn't be needed if the UDP library had the ability to
    // leave a multicast group
    unsigned int len = udp.parsePacket();
    unsigned char *buffer = (unsigned char *)malloc(sizeof(unsigned char) * len);
    if(buffer != NULL) {
      udp.read(buffer, len);
      free(buffer);
    }
  }

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movq %rdi, %rbx
addq $0x8, %rbx
movq %rbx, %rdi
callq 0x4b468
movl %eax, %r14d
movq %r14, %rdi
callq 0xa4e0
testq %rax, %rax
je 0x4b19a
movq %rax, %r15
movq %rbx, %rdi
movq %rax, %rsi
movq %r14, %rdx
callq 0x4b3f2
movq %r15, %rdi
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
jmp 0xa480
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
nopl (%rax)
// File: /workspace/github_cpp_makefile_star2_O3/madpilot[P]mDNSResolver/mocks/WiFiUdp.cpp
// Function: WiFiUDP::WiFiUDP(unsigned char*, int)
WiFiUDP::WiFiUDP(unsigned char *buffer, int length) {
  this->readBuffer = NULL;
  this->writeBuffer = NULL;
  this->readBufferLength = 0;
  this->writeBufferLength = 0;
  this->setReadBuffer(buffer, length);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movq %rsi, %rbx
movq %rdi, %r14
movslq %edx, %r15
movq %r15, %rdi
callq 0xa4e0
xorps %xmm0, %xmm0
movups %xmm0, 0x8(%r14)
movq %rax, (%r14)
movq %rax, %rdi
movq %rbx, %rsi
movq %r15, %rdx
callq 0xa2f0
movl %r15d, 0x10(%r14)
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
nop
// File: /workspace/github_cpp_makefile_star2_O3/madpilot[P]mDNSResolver/mocks/WiFiUdp.cpp
// Function: WiFiUDP::setReadBuffer(unsigned char*, int)
void WiFiUDP::setReadBuffer(unsigned char *buffer, int length) {
  //if(this->readBuffer != NULL) {
    //free(this->readBuffer);
    //this->readBuffer = NULL;
  //}

  this->readBuffer = (unsigned char *)malloc(sizeof(unsigned char) * length);
  memcpy(this->readBuffer, buffer, length);
  this->readBufferLength = length;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movq %rsi, %rbx
movq %rdi, %r14
movslq %edx, %r15
movq %r15, %rdi
callq 0xa4e0
movq %rax, (%r14)
movq %rax, %rdi
movq %rbx, %rsi
movq %r15, %rdx
callq 0xa2f0
movl %r15d, 0x10(%r14)
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
nop
// File: /workspace/github_cpp_makefile_star2_O3/madpilot[P]mDNSResolver/mocks/WiFiUdp.cpp
// Function: WiFiUDP::loadFromFile(char const*)
WiFiUDP* WiFiUDP::loadFromFile(const char *path) {
  unsigned char *source = NULL;
  WiFiUDP* udp = new WiFiUDP;

  FILE *fp = fopen(path, "rb");

  if(fp != NULL) {
    if(fseek(fp, 0L, SEEK_END) != 0) {
      fprintf(stderr, "ERROR: Unable to seek to the end of the file: %s\n", path);
      fclose(fp);
      return udp;
    }

    long bufsize = ftell(fp);
    if(bufsize == -1) {
      fprintf(stderr, "ERROR: Unable to get file position\n");
      fclose(fp);
      return udp;
    }

    // Need to do something more c++ friendly, as this is a memory leak
    source = (unsigned char *)malloc(sizeof(unsigned char) * (bufsize + 1));
    if(fseek(fp, 0L, SEEK_SET) != 0) {
      fprintf(stderr, "ERROR: Unable to see to the beginning of the file: %s\n", path);
      fclose(fp);
      return udp;
    }

    size_t len = fread(source, sizeof(unsigned char), bufsize, fp);
    if(ferror(fp) != 0) {
      fprintf(stderr, "ERROR: Unable to read the file (%i): %s\n", ferror(fp), path);
      fclose(fp);
      return udp;
    }

    udp->setReadBuffer(source, len);
    fclose(fp);
    return udp;
  } else {
    fprintf(stderr, "ERROR: Unable to seek to open file: %s\n", path);
  }

  return udp;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdi, %r15
movl $0x18, %edi
callq 0xa3b0
movq %rax, %rbx
xorps %xmm0, %xmm0
movups %xmm0, (%rax)
movq $0x0, 0x10(%rax)
leaq 0x4e17(%rip), %rsi      # 0x5008c
movq %r15, %rdi
callq 0xa460
testq %rax, %rax
je 0x4b335
movq %rax, %r14
movq %rax, %rdi
xorl %esi, %esi
movl $0x2, %edx
callq 0xa410
testl %eax, %eax
jne 0x4b352
movq %r14, %rdi
callq 0xa030
cmpq $-0x1, %rax
je 0x4b365
movq %rax, %r13
leaq 0x1(%rax), %rdi
callq 0xa4e0
movq %rax, %r12
movq %r14, %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0xa410
testl %eax, %eax
jne 0x4b36f
movl $0x1, %esi
movq %r12, %rdi
movq %r13, %rdx
movq %r14, %rcx
callq 0xa590
movq %rax, %r13
movq %r14, %rdi
callq 0xa730
testl %eax, %eax
jne 0x4b38c
movslq %r13d, %r15
movq %r15, %rdi
callq 0xa4e0
movq %rax, (%rbx)
movq %rax, %rdi
movq %r12, %rsi
movq %r15, %rdx
callq 0xa2f0
movl %r15d, 0x10(%rbx)
movq %r14, %rdi
callq 0xa3a0
movq %rbx, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x1cc84(%rip), %rax     # 0x67fc0
movq (%rax), %rdi
leaq 0x4dff(%rip), %rsi      # 0x50145
movq %r15, %rdx
xorl %eax, %eax
callq 0xa530
jmp 0x4b323
movq 0x1cc67(%rip), %rax     # 0x67fc0
movq (%rax), %rdi
leaq 0x4d2c(%rip), %rsi      # 0x5008f
jmp 0x4b380
movq %r14, %rdi
callq 0xaa61
jmp 0x4b323
movq 0x1cc4a(%rip), %rax     # 0x67fc0
movq (%rax), %rdi
leaq 0x4d65(%rip), %rsi      # 0x500e5
movq %r15, %rdx
xorl %eax, %eax
callq 0xa530
jmp 0x4b31b
movq 0x1cc2d(%rip), %rcx     # 0x67fc0
movq (%rcx), %rdi
leaq 0x4d7f(%rip), %rsi      # 0x5011c
movl %eax, %edx
movq %r15, %rcx
xorl %eax, %eax
callq 0xa530
jmp 0x4b31b
// File: /workspace/github_cpp_makefile_star2_O3/madpilot[P]mDNSResolver/mocks/WiFiUdp.cpp
// Function: WiFiUDP::write(unsigned char const*, unsigned long)
size_t WiFiUDP::write(const uint8_t *buffer, size_t size) {
  //if(this->writeBuffer != NULL) {
    //free(this->writeBuffer);
    //this->writeBuffer = NULL;
  //}

  this->writeBuffer = (unsigned char *)malloc(sizeof(unsigned char) * size);
  memcpy(this->writeBuffer, buffer, size);
  this->writeBufferLength = size;

  return size;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movq %rdx, %rbx
movq %rsi, %r14
movq %rdi, %r15
movq %rdx, %rdi
callq 0xa4e0
movq %rax, 0x8(%r15)
movq %rax, %rdi
movq %r14, %rsi
movq %rbx, %rdx
callq 0xa2f0
movl %ebx, 0x14(%r15)
movq %rbx, %rax
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
nop
// File: /workspace/github_cpp_makefile_star2_O3/dvjdjvu[P]bntree/./src/bntree.cpp
// Function: bntree::clear(node_s*)
void bntree::clear(node_t *p) {
    if (p != NULL) {
        if (p->right) {
            this->clear(p->right);
            this->node_free(p->right);
        }

        if (p->left) {
            this->clear(p->left);
            this->node_free(p->left);
        }
    }
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
testq %rsi, %rsi
je 0x2436
movq %rsi, %rbx
movq %rdi, %r14
movq 0x50(%rsi), %rsi
testq %rsi, %rsi
je 0x2415
movq %r14, %rdi
callq 0x23ec
movq 0x50(%rbx), %rsi
callq 0x247e
movq 0x48(%rbx), %rsi
testq %rsi, %rsi
je 0x2436
movq %r14, %rdi
callq 0x23ec
movq 0x48(%rbx), %rsi
addq $0x8, %rsp
popq %rbx
popq %r14
jmp 0x247e
addq $0x8, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_cpp_makefile_star2_O3/dvjdjvu[P]bntree/./src/bntree.cpp
// Function: bntree::search(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>)
uint64_t bntree::search(string key) {
    if (!this->tree->root) {
        return -1;
    }

    node_t *search_node = this->tree->root;
    uint64_t index_node = this->get_child_weight(search_node->left);

    for (;;) {
        if (key == search_node->data.key) {
            return index_node; // найден узел с таким ключем, вернем его индекс
        } else if (key > search_node->data.key) {
            search_node = search_node->right;

            if (search_node == NULL)
                return -1;

            index_node += (this->get_child_weight(search_node->left) + 1);
        } else {
            search_node = search_node->left;

            if (search_node == NULL)
                return -1;

            index_node -= (this->get_child_weight(search_node->left) + 1);
        }
    }
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
pushq %rax
movq (%rdi), %rax
movq (%rax), %r15
movq $-0x1, %rbx
testq %r15, %r15
je 0x2560
movq %rsi, %r14
movq 0x48(%r15), %rax
testq %rax, %rax
je 0x24e4
movq 0x40(%rax), %r12
jmp 0x24e7
xorl %r12d, %r12d
movq 0x8(%r14), %rdx
cmpq 0x8(%r15), %rdx
jne 0x2505
testq %rdx, %rdx
je 0x255d
movq (%r15), %rsi
movq (%r14), %rdi
callq 0x2180
testl %eax, %eax
je 0x255d
movq %r14, %rdi
movq %r15, %rsi
callq 0x2040
testl %eax, %eax
jle 0x252f
movq 0x50(%r15), %r15
testq %r15, %r15
je 0x2560
movq 0x48(%r15), %rax
testq %rax, %rax
je 0x254a
movq 0x40(%rax), %rax
incq %rax
jmp 0x2558
movq 0x48(%r15), %r15
testq %r15, %r15
je 0x2560
movq 0x48(%r15), %rax
testq %rax, %rax
je 0x2551
movq 0x40(%rax), %rax
notq %rax
jmp 0x2558
movl $0x1, %eax
jmp 0x2558
movq $-0x1, %rax
addq %rax, %r12
jmp 0x24e7
movq %r12, %rbx
movq %rbx, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
movq %rax, %rdi
callq 0x2f3d
nop
// File: /workspace/github_cpp_makefile_star2_O3/dvjdjvu[P]bntree/./src/bntree.cpp
// Function: bntree::erase_simple(node_s*)
bool bntree::erase_simple(node_t *search_node) {

    node_t *prev_node = search_node->parent;

    if (!search_node->left && !search_node->right) {
        // Удаляемый узел является листом.

        // Обнуляем соответствующую ссылку родителя.
        if (prev_node == NULL) {
            // Удаляемый узел корень.
            this->tree->root = NULL;
        } else if (prev_node->left == search_node) {
            prev_node->left = NULL;
        } else if (prev_node->right == search_node) {
            prev_node->right = NULL;
        }

    } else if (search_node->left && !search_node->right) {
        // Удаляемый узел имеет только левого ребенка.

        // Перекомпануем ссылки родителя на левого внука.
        if (prev_node == NULL) {
            // Удаляемый узел корень.
            this->tree->root = search_node->left;
            this->tree->root->parent = NULL;
        } else if (prev_node->left == search_node) {
            prev_node->left = search_node->left;
            search_node->left->parent = prev_node;
        } else if (prev_node->right == search_node) {
            prev_node->right = search_node->left;
            search_node->left->parent = prev_node;
        }

    } else if (!search_node->left && search_node->right) {
        // Удаляемый узел имеет только правого ребенка.

        // Перекомпануем ссылки родителя на правого внука.
        if (prev_node == NULL) {
            // Удаляемый узел корень.
            this->tree->root = search_node->right;
            this->tree->root->parent = NULL;
        } else if (prev_node->left == search_node) {
            prev_node->left = search_node->right;
            search_node->right->parent = prev_node;
        } else if (prev_node->right == search_node) {
            prev_node->right = search_node->right;
            search_node->right->parent = prev_node;
        }

    } else {
        // Удаляемый узел имеет двух детей. Здесь не обрабатываем.

        return false;
    }

    return true;
}

// Assembly:
movq 0x58(%rsi), %rcx
movq 0x48(%rsi), %r8
movq 0x50(%rsi), %rdx
testq %r8, %r8
je 0x2875
testq %rdx, %rdx
je 0x289a
xorl %eax, %eax
retq
testq %rdx, %rdx
je 0x28b6
testq %rcx, %rcx
je 0x28d2
cmpq %rsi, 0x48(%rcx)
je 0x28f2
movb $0x1, %al
cmpq %rsi, 0x50(%rcx)
jne 0x2874
movq %rdx, 0x50(%rcx)
movq 0x50(%rsi), %rdx
movq %rcx, 0x58(%rdx)
retq
testq %rcx, %rcx
je 0x28e2
cmpq %rsi, 0x48(%rcx)
je 0x28fc
movb $0x1, %al
cmpq %rsi, 0x50(%rcx)
jne 0x2874
movq %r8, 0x50(%rcx)
movq %rcx, 0x58(%r8)
retq
testq %rcx, %rcx
je 0x290a
cmpq %rsi, 0x48(%rcx)
je 0x2916
movb $0x1, %al
cmpq %rsi, 0x50(%rcx)
jne 0x2874
movq $0x0, 0x50(%rcx)
retq
movq (%rdi), %rax
movq %rdx, (%rax)
movq $0x0, 0x58(%rdx)
jmp 0x291e
movq (%rdi), %rax
movq %r8, (%rax)
movq $0x0, 0x58(%r8)
jmp 0x291e
movq %rdx, 0x48(%rcx)
movq %rcx, 0x58(%rdx)
jmp 0x291e
movq %r8, 0x48(%rcx)
movq 0x48(%rsi), %rax
movq %rcx, 0x58(%rax)
jmp 0x291e
movq (%rdi), %rax
movq $0x0, (%rax)
jmp 0x291e
movq $0x0, 0x48(%rcx)
movb $0x1, %al
retq
nop
// File: /workspace/github_cpp_makefile_star2_O3/dvjdjvu[P]bntree/./src/bntree.cpp
// Function: bntree::get(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>)
data_t *bntree::get(string key) {
    node_t *search_node = this->tree->root;
    uint64_t index_node = this->get_child_weight(search_node->left);

    for (;;) {
        if (key == search_node->data.key) {
            return &search_node->data;
        } else if (key > search_node->data.key) {
            search_node = search_node->right;
            index_node += (this->get_child_weight(search_node->left) + 1);
        } else {
            search_node = search_node->left;
            index_node -= (this->get_child_weight(search_node->right) + 1);
        }
    }

    return NULL;
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq %rsi, %rbx
movq (%rdi), %rax
movq (%rax), %r14
movq 0x8(%rbx), %rdx
cmpq 0x8(%r14), %rdx
jne 0x2ca7
testq %rdx, %rdx
je 0x2cc3
movq (%r14), %rsi
movq (%rbx), %rdi
callq 0x2180
testl %eax, %eax
je 0x2cc3
movq %rbx, %rdi
movq %r14, %rsi
callq 0x2040
xorl %ecx, %ecx
testl %eax, %eax
setg %cl
leaq (%r14,%rcx,8), %rax
addq $0x48, %rax
jmp 0x2c86
movq %r14, %rax
addq $0x8, %rsp
popq %rbx
popq %r14
retq
movq %rax, %rdi
callq 0x2f3d
// File: /workspace/github_cpp_makefile_star2_O3/dvjdjvu[P]bntree/./src/bntree.cpp
// Function: bntree::print(node_s*, int)
void bntree::print(node_t *p, int indent) {
    if (p != NULL) {
        if (p->right) {
            this->print(p->right, indent + 4);
        }
        if (indent) {
            //std::cout << std::setw(indent) << ' ' << p->weight << ' ';
            std::cout << std::setw(indent) << ' ';
        }
        if (p->right) {
            std::cout << " /\n" << std::setw(indent) << ' ';
        }
        //std::cout << p->data.key << ":" << p->data.val << "\n ";
        std::cout << p->data.key << ":" << p << ":" << p->parent << "\n ";
        if (p->left) {
            std::cout << std::setw(indent) << ' ' << " \\\n";
            this->print(p->left, indent + 4);
        }
    }
}

// Assembly:
testq %rsi, %rsi
je 0x2e5d
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movl %edx, %ebx
movq %rsi, %r15
movq %rdi, %r12
movq 0x50(%rsi), %rsi
testq %rsi, %rsi
je 0x2d19
leal 0x4(%rbx), %edx
movq %r12, %rdi
callq 0x2ce6
movslq %ebx, %r14
testl %ebx, %ebx
je 0x2d45
movq 0x32b1(%rip), %rdi      # 0x5fd8
movq (%rdi), %rax
movq -0x18(%rax), %rax
movq %r14, 0x10(%rdi,%rax)
leaq 0xd(%rsp), %rsi
movb $0x20, (%rsi)
movl $0x1, %edx
callq 0x2190
movq %r12, 0x10(%rsp)
cmpq $0x0, 0x50(%r15)
je 0x2d8e
movq 0x3280(%rip), %r12      # 0x5fd8
leaq 0x12c1(%rip), %rsi      # 0x4020
movl $0x3, %edx
movq %r12, %rdi
callq 0x2190
movq (%r12), %rax
movq -0x18(%rax), %rax
movq %r14, 0x10(%r12,%rax)
leaq 0xe(%rsp), %rsi
movb $0x20, (%rsi)
movl $0x1, %edx
movq %r12, %rdi
callq 0x2190
movq (%r15), %rsi
movq 0x8(%r15), %rdx
movq 0x323c(%rip), %r12      # 0x5fd8
movq %r12, %rdi
callq 0x2190
movq %rax, %r13
leaq 0x1276(%rip), %rbp      # 0x4024
movl $0x1, %edx
movq %rax, %rdi
movq %rbp, %rsi
callq 0x2190
movq %r13, %rdi
movq %r15, %rsi
callq 0x2100
movq %rax, %r13
movl $0x1, %edx
movq %rax, %rdi
movq %rbp, %rsi
callq 0x2190
movq 0x58(%r15), %rsi
movq %r13, %rdi
callq 0x2100
leaq 0x1237(%rip), %rsi      # 0x4026
movl $0x2, %edx
movq %rax, %rdi
callq 0x2190
cmpq $0x0, 0x48(%r15)
movq 0x10(%rsp), %r13
je 0x2e4f
movq (%r12), %rax
movq -0x18(%rax), %rax
movq %r14, 0x10(%r12,%rax)
leaq 0xf(%rsp), %rsi
movb $0x20, (%rsi)
movl $0x1, %edx
movq %r12, %rdi
callq 0x2190
leaq 0x11f8(%rip), %rsi      # 0x4029
movl $0x3, %edx
movq %rax, %rdi
callq 0x2190
movq 0x48(%r15), %rsi
addl $0x4, %ebx
movq %r13, %rdi
movl %ebx, %edx
callq 0x2ce6
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O3/dvjdjvu[P]bntree/./src/bntree.cpp
// Function: bntree::weight_to_depth(node_s*)
uint64_t bntree::weight_to_depth(node_t *p) {
    if (p == NULL) {
        return 0;
    }

    if (p->weight == 1) {
        return 1;
    } else if (p->weight == 2) {
        return 2;
    }

    return this->ilog2(this->cpl2(p->weight));
}

// Assembly:
testq %rsi, %rsi
je 0x2ed2
movq 0x40(%rsi), %rax
leaq -0x1(%rax), %rcx
cmpq $0x2, %rcx
jb 0x2ed1
pushq %rbx
subq $0x10, %rsp
movq %rcx, %rax
shrq %rax
orq %rcx, %rax
movq %rax, %rcx
shrq $0x2, %rcx
orq %rax, %rcx
movq %rcx, %rax
shrq $0x4, %rax
orq %rcx, %rax
movq %rax, %rcx
shrq $0x8, %rcx
orq %rax, %rcx
movq %rcx, %rax
shrq $0x10, %rax
orq %rcx, %rax
movq %rax, %rcx
shrq $0x20, %rcx
orq %rax, %rcx
incq %rcx
cvtsi2sd %rcx, %xmm0
leaq 0xc(%rsp), %rbx
movq %rbx, %rdi
callq 0x2200
movl (%rbx), %eax
decl %eax
cltq
addq $0x10, %rsp
popq %rbx
retq
xorl %eax, %eax
retq
nop
// File: /workspace/github_cpp_makefile_star2_O3/dvjdjvu[P]bntree/./src/test.cpp
// Function: std::vector<std::pair<unsigned long, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>>, std::allocator<std::pair<unsigned long, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>>>> get_sequence<std::vector<std::pair<unsigned long, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>>, std::allocator<std::pair<unsigned long, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>>>>>(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&)
S get_sequence(const string& _file_name)
{
    ifstream infile(_file_name);
    S result;

    typename S::value_type item;

    while (infile >> item)
    {
        result.emplace_back(move(item));
    }

    return result;
}

// Assembly:
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x230, %rsp            # imm = 0x230
movq %rdi, %rbx
leaq 0x28(%rsp), %r14
movq %r14, %rdi
movl $0x8, %edx
callq 0x21c0
xorl %eax, %eax
movq %rax, 0x10(%rbx)
xorps %xmm0, %xmm0
movups %xmm0, (%rbx)
leaq 0x8(%rsp), %r15
movq %rax, -0x8(%r15)
leaq 0x18(%rsp), %r13
movq %r13, -0x10(%r13)
movq %rax, -0x8(%r13)
movb $0x0, (%r13)
movq %rsp, %r12
movq %r14, %rdi
movq %r12, %rsi
callq 0x20c0
movq %r14, %rdi
movq %r15, %rsi
callq 0x21a0
movq 0x28(%rsp), %rax
movq -0x18(%rax), %rax
testb $0x5, 0x48(%rsp,%rax)
jne 0x3844
movq %rbx, %rdi
movq %r12, %rsi
callq 0x3cc0
jmp 0x3811
movq 0x8(%rsp), %rdi
cmpq %r13, %rdi
je 0x3853
callq 0x2140
leaq 0x28(%rsp), %rdi
callq 0x2060
movq %rbx, %rax
addq $0x230, %rsp            # imm = 0x230
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
movq %rax, %r14
movq 0x8(%rsp), %rdi
cmpq %r13, %rdi
je 0x3883
callq 0x2140
movq %rbx, %rdi
callq 0x389e
leaq 0x28(%rsp), %rdi
callq 0x2060
movq %r14, %rdi
callq 0x21e0
nop
// File: /workspace/github_cpp_makefile_star2_O3/yiboyang[P]VirtualMemory/TLB.cpp
// Function: TLB::operator[](int)
int& TLB::operator[] (const int pnum) {
	// before returning a reference to tb[pnum], update the queue according to LRU policy
	if (tb.count(pnum))
		// if pnum is in tb
		q.remove(pnum);
	else {
		// TLB miss; tb[pnum] will create a new entry in tb and reference 0 (default int)
		if (q.size() == TLB_SIZE) {
			// if queue (TLB) full
			int victim = q.front();	// victim page number
			tb.erase(tb.find(victim));	// remove victim entry
			q.pop_front();
		}
	}
	q.push_back(pnum);	// add pnum at the end of queue

	return tb[pnum];
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movl %esi, %eax
movq %rdi, %rbx
movl %esi, -0x1c(%rbp)
movq 0x10(%rdi), %rcx
leaq 0x8(%rdi), %rsi
testq %rcx, %rcx
je 0x25f9
movq %rcx, %rdi
movq %rsi, %rdx
xorl %r8d, %r8d
cmpl %eax, 0x20(%rdi)
setl %r8b
cmovgeq %rdi, %rdx
movq 0x10(%rdi,%r8,8), %rdi
testq %rdi, %rdi
jne 0x25a1
cmpq %rsi, %rdx
je 0x25c3
cmpl %eax, 0x20(%rdx)
jle 0x2622
cmpq $0x10, 0x40(%rbx)
jne 0x262f
movq 0x30(%rbx), %rax
movl 0x10(%rax), %eax
movq %rsi, %rdx
xorl %edi, %edi
cmpl %eax, 0x20(%rcx)
setl %dil
cmovgeq %rcx, %rdx
movq 0x10(%rcx,%rdi,8), %rcx
testq %rcx, %rcx
jne 0x25d4
cmpq %rsi, %rdx
je 0x2600
cmpl 0x20(%rdx), %eax
cmovgeq %rdx, %rsi
jmp 0x2600
cmpq $0x10, 0x40(%rbx)
jne 0x262f
movq %rbx, %rdi
callq 0x2772
movq 0x30(%rbx), %r14
decq 0x40(%rbx)
movq %r14, %rdi
callq 0x2330
movq %r14, %rdi
callq 0x2200
jmp 0x262f
leaq 0x30(%rbx), %rdi
leaq -0x1c(%rbp), %rsi
callq 0x266c
leaq 0x30(%rbx), %r14
movl $0x18, %edi
callq 0x2220
leaq -0x1c(%rbp), %r15
movl (%r15), %ecx
movl %ecx, 0x10(%rax)
movq %rax, %rdi
movq %r14, %rsi
callq 0x2060
incq 0x40(%rbx)
movq %rbx, %rdi
movq %r15, %rsi
callq 0x26fc
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O3/yiboyang[P]VirtualMemory/PageTable.cpp
// Function: PageTable::~PageTable()
PageTable::~PageTable() {
	// commit all dirty pages to backing store
	for (auto const& kv : pt) {
		if (kv.second.second)
			bs.write(kv.first, kv.second.first);
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
movq %rdi, %rbx
movq 0x18(%rdi), %r15
leaq 0x8(%rdi), %r12
cmpq %r12, %r15
je 0x2c79
leaq 0x98(%rbx), %r14
cmpb $0x1, 0x28(%r15)
jne 0x2c69
movl 0x20(%r15), %esi
movl 0x24(%r15), %edx
movq %r14, %rdi
callq 0x3954
movq %r15, %rdi
callq 0x21a0
movq %rax, %r15
cmpq %r12, %rax
jne 0x2c52
leaq 0x3a8(%rbx), %r14
leaq 0x3d8(%rbx), %r15
movq 0x3d8(%rbx), %rdi
cmpq %r15, %rdi
je 0x2ca3
movq (%rdi), %r12
callq 0x2200
movq %r12, %rdi
cmpq %r15, %r12
jne 0x2c93
movq %r14, %rdi
callq 0x31e4
leaq 0x98(%rbx), %rdi
callq 0x317a
leaq 0x80(%rbx), %r14
movq 0x80(%rbx), %rdi
cmpq %r14, %rdi
je 0x2cda
movq (%rdi), %r15
callq 0x2200
movq %r15, %rdi
cmpq %r14, %r15
jne 0x2cca
movq 0x60(%rbx), %rdi
leaq 0x70(%rbx), %rax
cmpq %rax, %rdi
je 0x2cec
callq 0x2200
leaq 0x30(%rbx), %rdi
callq 0x323c
movq %rbx, %rdi
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
jmp 0x3294
movq %rax, %r15
leaq 0x3a8(%rbx), %rdi
callq 0x313e
movq %r14, %rdi
callq 0x317a
leaq 0x80(%rbx), %rdi
callq 0x31a8
leaq 0x60(%rbx), %rdi
callq 0x2110
leaq 0x30(%rbx), %rdi
callq 0x31d0
movq %rbx, %rdi
callq 0x31da
movq %r15, %rdi
callq 0x2290
// File: /workspace/github_cpp_makefile_star2_O3/yiboyang[P]VirtualMemory/PageTable.cpp
// Function: PageTable::operator[](int)
int PageTable::operator[](const int pnum) {
	/*
	Get the number (index) of the frame in physical memory corresponding to given page number (pnum) in logical memory;
	this is done prior to every access to Memory. Page faults are resolved automatically.
	*/
	int fnum;
	pageFault = tlbMiss = false;
	if (tlb.contains(pnum)) // look in TLB first
		fnum = tlb[pnum];
	else { // TLB miss; look in page table
		tlbMiss = true;
		fnum = pt[pnum].first;

		if (fnum == -1) {
			// page fault!
			pageFault = true;
			numPageFaults++;
			// read the requested page from backing store into a free frame
			fnum = getFreeFrameNum();	// somehow find a free frame
			bs.read(pnum);		// read the page at pnum on backing store
			copy(bs.getBuff(), bs.getBuff() + FRAME_SIZE, Memory[fnum]);	// copy into the frame at fnum of physical memory
			pt[pnum].first = fnum;	// point the pnum enty to fnum in page table
		}

		tlb[pnum] = fnum;	// update TLB
	}


	if (pageFault) {
		// with either FIFO or LRU, if a page is newly brought into memory, its index is inserted at tail of queue
		q.push_back(pnum);
	}
	else {
		// in the case of no page fault, FIFO does nothing;
		// LRU will move the recently accessed page number to the tail of queue
		if (pageReplacementPolicy == "LRU") {
			q.remove(pnum);
			q.push_back(pnum);
		}
	}


	return fnum;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdi, %rbx
movl %esi, -0x2c(%rbp)
xorl %eax, %eax
movb %al, 0x3f8(%rdi)
movb %al, 0x3f0(%rdi)
leaq 0x3a8(%rdi), %r15
movq 0x3b8(%rdi), %rax
testq %rax, %rax
je 0x2dae
leaq 0x3b0(%rbx), %rdx
movq %rdx, %rcx
xorl %edi, %edi
cmpl %esi, 0x20(%rax)
setl %dil
cmovgeq %rax, %rcx
movq 0x10(%rax,%rdi,8), %rax
testq %rax, %rax
jne 0x2d89
cmpq %rdx, %rcx
je 0x2dae
cmpl %esi, 0x20(%rcx)
jle 0x2eb5
movb $0x1, 0x3f8(%rbx)
leaq -0x2c(%rbp), %rsi
movq %rbx, %rdi
callq 0x30d6
movl (%rax), %r14d
cmpl $-0x1, %r14d
jne 0x2e29
movb $0x1, 0x3f0(%rbx)
incl 0x3f4(%rbx)
movq %rbx, %rdi
callq 0x2ec6
movl %eax, %r14d
leaq 0x98(%rbx), %rdi
leaq -0x2c(%rbp), %r12
movl (%r12), %esi
callq 0x38a4
leaq 0x2a8(%rbx), %rsi
movslq %r14d, %r13
movq %r13, %rax
shlq $0x8, %rax
leaq 0x5412(%rip), %rdi      # 0x8220
addq %rax, %rdi
movl $0x100, %edx            # imm = 0x100
callq 0x2320
movq %rbx, %rdi
movq %r12, %rsi
callq 0x30d6
movl %r13d, (%rax)
movl -0x2c(%rbp), %esi
movq %r15, %rdi
callq 0x257c
movl %r14d, (%rax)
cmpb $0x1, 0x3f0(%rbx)
jne 0x2e56
leaq 0x80(%rbx), %r15
movl $0x18, %edi
callq 0x2220
movl -0x2c(%rbp), %ecx
jmp 0x2e8e
leaq 0x60(%rbx), %rdi
leaq 0x21d1(%rip), %rsi      # 0x5032
callq 0x20c0
testl %eax, %eax
jne 0x2ea3
leaq 0x80(%rbx), %r15
leaq -0x2c(%rbp), %r12
movq %r15, %rdi
movq %r12, %rsi
callq 0x266c
movl $0x18, %edi
callq 0x2220
movl (%r12), %ecx
movl %ecx, 0x10(%rax)
movq %rax, %rdi
movq %r15, %rsi
callq 0x2060
incq 0x90(%rbx)
movl %r14d, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %r15, %rdi
callq 0x257c
movl (%rax), %r14d
jmp 0x2e37
nop
// File: /workspace/github_cpp_makefile_star2_O3/yiboyang[P]VirtualMemory/PageTable.cpp
// Function: PageTable::getFreeFrameNum()
int PageTable::getFreeFrameNum() {
	/*
	Find a free frame and return its frame number
	*/
	int fnum;
	if (!fs.empty()) {
		fnum = *fs.begin();		// always get the free frame with the smallest frame number
		fs.erase(fnum);			// remove fnum from the set of free frames
	}
	else {	// need to replace a page, q is full (since we don't delete a page by itself, fs.size() == 64 - q.size())
		// either FIFO or LRU replaces the page at the front of the queue
		int pnum = q.front();	// victim page number
		fnum = pt[pnum].first;

		// if a dirty page, write its memory frame to backing store
		if (pt[pnum].second) {
			bs.write(pnum, fnum);
			setDirty(pnum, false);	// reset dirty bit
		}

		pt[pnum].first = -1;	// reset victim page's frame number
		q.pop_front();
	}
	return fnum;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %rbx
subq $0x18, %rsp
movq %rdi, %rbx
cmpq $0x0, 0x58(%rdi)
je 0x2f0d
movq 0x48(%rbx), %rax
addq $0x30, %rbx
movl 0x20(%rax), %eax
leaq -0x20(%rbp), %r14
movl %eax, (%r14)
movq %rbx, %rdi
movq %r14, %rsi
callq 0x3768
movq %rbx, %rdi
movq %rax, %rsi
callq 0x37ea
movl (%r14), %r14d
jmp 0x2f94
movq 0x80(%rbx), %rax
movl 0x10(%rax), %eax
leaq -0x1c(%rbp), %r15
movl %eax, (%r15)
movq %rbx, %rdi
movq %r15, %rsi
callq 0x30d6
movl (%rax), %r14d
movq %rbx, %rdi
movq %r15, %rsi
callq 0x30d6
cmpb $0x1, 0x4(%rax)
jne 0x2f64
leaq 0x98(%rbx), %rdi
movl -0x1c(%rbp), %esi
movl %r14d, %edx
callq 0x3954
movl -0x1c(%rbp), %eax
leaq -0x24(%rbp), %rsi
movl %eax, (%rsi)
movq %rbx, %rdi
callq 0x30d6
movb $0x0, 0x4(%rax)
leaq -0x1c(%rbp), %rsi
movq %rbx, %rdi
callq 0x30d6
movl $0xffffffff, (%rax)     # imm = 0xFFFFFFFF
movq 0x80(%rbx), %r15
decq 0x90(%rbx)
movq %r15, %rdi
callq 0x2330
movq %r15, %rdi
callq 0x2200
movl %r14d, %eax
addq $0x18, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O3/yiboyang[P]VirtualMemory/PageTable.cpp
// Function: operator<<(std::ostream&, PageTable const&)
ostream& operator<<(ostream &strm, const PageTable &PT) {
	for (auto const& kv : PT.pt) {
		if (kv.second.first != -1)
			strm << kv.first << ' ' << kv.second.first << endl;
	}
	return strm;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rsi, %r14
movq %rdi, %rbx
movq 0x18(%rsi), %r15
addq $0x8, %r14
cmpq %r14, %r15
je 0x3034
leaq -0x29(%rbp), %r12
cmpl $-0x1, 0x24(%r15)
je 0x3024
movl 0x20(%r15), %esi
movq %rbx, %rdi
callq 0x2370
movb $0x20, -0x29(%rbp)
movl $0x1, %edx
movq %rax, %rdi
movq %r12, %rsi
callq 0x2240
movl 0x24(%r15), %esi
movq %rax, %rdi
callq 0x2370
movq %rax, %r13
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r13, %rdi
movl $0xa, %esi
callq 0x2210
movsbl %al, %esi
movq %r13, %rdi
callq 0x2030
movq %rax, %rdi
callq 0x2190
movq %r15, %rdi
callq 0x2250
movq %rax, %r15
cmpq %r14, %rax
jne 0x2fc7
movq %rbx, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O3/yiboyang[P]VirtualMemory/./BackingStore.h
// Function: BackingStore::BackingStore(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>)
BackingStore(std::string name) {
		// open the file that simulates disk in rw mode
		store.open(name, std::ios::binary | std::ios::in | std::ios::out);	// c++11 allows istream.open string rather than char*
		if (!store)
			throw std::invalid_argument("Can't open backing store file!");
	}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movq %rsi, %r14
movq %rdi, %rbx
callq 0x2260
movq %rbx, %rdi
movq %r14, %rsi
movl $0x1c, %edx
callq 0x22c0
movq (%rbx), %rax
movq -0x18(%rax), %rax
testb $0x5, 0x20(%rbx,%rax)
jne 0x3084
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
movl $0x10, %edi
callq 0x2120
movq %rax, %r14
leaq 0x1f9e(%rip), %rsi      # 0x5036
movq %rax, %rdi
callq 0x23c0
movq 0x4f29(%rip), %rsi      # 0x7fd0
movq 0x4f12(%rip), %rdx      # 0x7fc0
movq %r14, %rdi
callq 0x2360
movq %rax, %r15
movq %r14, %rdi
callq 0x21c0
jmp 0x30c6
movq %rax, %r15
movq %rbx, %rdi
callq 0x2090
movq %r15, %rdi
callq 0x2380
// File: /workspace/github_cpp_makefile_star2_O3/yiboyang[P]VirtualMemory/BackingStore.cpp
// Function: BackingStore::read(int)
void BackingStore::read(int pnum) {
	assert(!store.eof());

	// seek to the page at pnum
	if (store.seekg(pnum * FRAME_SIZE, ios::beg))
		store.read((char *)buff, FRAME_SIZE);
	else
		throw runtime_error("Seek error");
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r14
pushq %rbx
movq (%rdi), %rax
movq -0x18(%rax), %rax
testb $0x2, 0x20(%rdi,%rax)
jne 0x38ef
movq %rdi, %rbx
shll $0x8, %esi
movslq %esi, %rsi
xorl %edx, %edx
callq 0x22b0
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
testb $0x5, 0x20(%rax,%rcx)
jne 0x390e
leaq 0x210(%rbx), %rsi
movl $0x100, %edx            # imm = 0x100
movq %rbx, %rdi
popq %rbx
popq %r14
popq %rbp
jmp 0x2270
leaq 0x178a(%rip), %rdi      # 0x5080
leaq 0x1790(%rip), %rsi      # 0x508d
leaq 0x179a(%rip), %rcx      # 0x509e
movl $0xd, %edx
callq 0x2180
movl $0x10, %edi
callq 0x2120
movq %rax, %rbx
leaq 0x1799(%rip), %rsi      # 0x50bb
movq %rax, %rdi
callq 0x20f0
movq 0x46bf(%rip), %rsi      # 0x7ff0
movq 0x4678(%rip), %rdx      # 0x7fb0
movq %rbx, %rdi
callq 0x2360
movq %rax, %r14
movq %rbx, %rdi
callq 0x21c0
movq %r14, %rdi
callq 0x2380
nop