LLM4Binary/decompile-bench-makefile huggingface dataset:
// File: lorenatoscano[P]musify/src/playlist.cpp
// Function: Playlist::operator<<(Song*&)
void Playlist::operator<< (Song*& newSong) {
  if (newSong == nullptr) {
    return;
  } else {
    songs->insertEnd(*newSong);
  }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x80, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x68(%rbp)
movq -0x10(%rbp), %rax
cmpq $0x0, (%rax)
jne 0xa357
jmp 0xa3a8
movq -0x68(%rbp), %rax
movq 0x20(%rax), %rax
movq %rax, -0x78(%rbp)
movq -0x10(%rbp), %rax
movq (%rax), %rsi
leaq -0x50(%rbp), %rdi
movq %rdi, -0x70(%rbp)
callq 0x3bb0
movq -0x78(%rbp), %rdi
movq -0x70(%rbp), %rsi
callq 0x25f0
jmp 0xa386
leaq -0x50(%rbp), %rdi
callq 0xa9a0
jmp 0xa3a8
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
leaq -0x50(%rbp), %rdi
callq 0xa9a0
jmp 0xa3b1
addq $0x80, %rsp
popq %rbp
retq
movq -0x58(%rbp), %rdi
callq 0x21e0
nopw (%rax,%rax)
// File: lorenatoscano[P]musify/src/playlist.cpp
// Function: Playlist::moveSong(unsigned long, unsigned long)
void Playlist::moveSong(size_t start, size_t end) {
  if (start != end) {
    // Acessa o valor da música a ser movida
    node* target = songs->getNode(start);
    Song value = target->data;

    // Remove ela da posição atual
    songs->removePosition(start);

    // Insere ela na nova posição
    if (end < start) {
      songs->insertPosition(end, value);
    } else {
      songs->insertPosition(end + 1, value);
    } 

    // Cada vez que uma música for movida, playing recebe head
    playing = songs->getHead();
  }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x120, %rsp            # imm = 0x120
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0xf8(%rbp)
movq -0x10(%rbp), %rax
cmpq -0x18(%rbp), %rax
je 0xa68a
movq -0xf8(%rbp), %rax
movq 0x20(%rax), %rdi
movq -0x10(%rbp), %rsi
callq 0x3970
movq %rax, -0x20(%rbp)
movq -0x20(%rbp), %rsi
leaq -0x60(%rbp), %rdi
callq 0x3bb0
movq -0xf8(%rbp), %rax
movq 0x20(%rax), %rdi
movq -0x10(%rbp), %rsi
callq 0x33f0
jmp 0xa53b
movq -0x18(%rbp), %rax
cmpq -0x10(%rbp), %rax
jae 0xa5d3
movq -0xf8(%rbp), %rax
movq 0x20(%rax), %rax
movq %rax, -0x108(%rbp)
movq -0x18(%rbp), %rax
movq %rax, -0x100(%rbp)
leaq -0xb0(%rbp), %rdi
leaq -0x60(%rbp), %rsi
callq 0x3bb0
jmp 0xa578
movq -0x100(%rbp), %rsi
movq -0x108(%rbp), %rdi
leaq -0xb0(%rbp), %rdx
callq 0x3090
jmp 0xa594
leaq -0xb0(%rbp), %rdi
callq 0xa9a0
jmp 0xa649
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
jmp 0xa67f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
leaq -0xb0(%rbp), %rdi
callq 0xa9a0
jmp 0xa67f
movq -0xf8(%rbp), %rax
movq 0x20(%rax), %rax
movq %rax, -0x118(%rbp)
movq -0x18(%rbp), %rax
incq %rax
movq %rax, -0x110(%rbp)
leaq -0xf0(%rbp), %rdi
leaq -0x60(%rbp), %rsi
callq 0x3bb0
jmp 0xa605
movq -0x110(%rbp), %rsi
movq -0x118(%rbp), %rdi
leaq -0xf0(%rbp), %rdx
callq 0x3090
jmp 0xa621
leaq -0xf0(%rbp), %rdi
callq 0xa9a0
jmp 0xa649
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
leaq -0xf0(%rbp), %rdi
callq 0xa9a0
jmp 0xa67f
movq -0xf8(%rbp), %rax
movq 0x20(%rax), %rdi
callq 0x2ac0
movq %rax, -0x120(%rbp)
jmp 0xa662
movq -0xf8(%rbp), %rax
movq -0x120(%rbp), %rcx
movq %rcx, 0x28(%rax)
leaq -0x60(%rbp), %rdi
callq 0xa9a0
jmp 0xa68a
leaq -0x60(%rbp), %rdi
callq 0xa9a0
jmp 0xa693
addq $0x120, %rsp            # imm = 0x120
popq %rbp
retq
movq -0x68(%rbp), %rdi
callq 0x21e0
nopl (%rax)
// File: lorenatoscano[P]musify/src/playlist.cpp
// Function: Playlist::removeSong(Playlist&)
size_t Playlist::removeSong(Playlist& toRemove) {
  // Tratamento para garantir que a nova playlist não está vazia
  if (toRemove.getSongs()->getSize() < 1) {
    return 0;
  } else {
    size_t removed = 0;

    node* temp = toRemove.getSongs()->getHead();

    while (temp != nullptr) {
      // Obtém a posição da música na playlist atual
      size_t pos = getSongs()->getPosition(temp->data);

      // Remove da playlist atual
      if (pos > 0) {
        removeSong(pos);
        ++removed;
      }

      temp = temp->next;
    }
    
    return removed;
  }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xa0, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x88(%rbp)
movq -0x18(%rbp), %rdi
callq 0xa120
movq %rax, %rdi
callq 0x2b00
cmpq $0x1, %rax
jae 0xa6e2
movq $0x0, -0x8(%rbp)
jmp 0xa7b6
movq $0x0, -0x20(%rbp)
movq -0x18(%rbp), %rdi
callq 0xa120
movq %rax, %rdi
callq 0x2ac0
movq %rax, -0x28(%rbp)
cmpq $0x0, -0x28(%rbp)
je 0xa7ae
movq -0x88(%rbp), %rdi
callq 0xa120
movq %rax, -0xa0(%rbp)
movq -0x28(%rbp), %rsi
leaq -0x70(%rbp), %rdi
movq %rdi, -0x98(%rbp)
callq 0x3bb0
movq -0xa0(%rbp), %rdi
movq -0x98(%rbp), %rsi
callq 0x35b0
movq %rax, -0x90(%rbp)
jmp 0xa74d
leaq -0x70(%rbp), %rdi
callq 0xa9a0
movq -0x90(%rbp), %rax
movq %rax, -0x30(%rbp)
cmpq $0x0, -0x30(%rbp)
jbe 0xa79d
movq -0x88(%rbp), %rdi
movq -0x30(%rbp), %rsi
callq 0xa140
movq -0x20(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x20(%rbp)
jmp 0xa79d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x78(%rbp)
movl %eax, -0x7c(%rbp)
leaq -0x70(%rbp), %rdi
callq 0xa9a0
jmp 0xa7c3
movq -0x28(%rbp), %rax
movq 0x40(%rax), %rax
movq %rax, -0x28(%rbp)
jmp 0xa6ff
movq -0x20(%rbp), %rax
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0xa0, %rsp
popq %rbp
retq
movq -0x78(%rbp), %rdi
callq 0x21e0
nopl (%rax)
// File: lorenatoscano[P]musify/src/playlist.cpp
// Function: Playlist::playNext()
node* Playlist::playNext() {
  if (playing != nullptr) {
    // Guarda a música atual
    node* temp = playing;
    // Playing recebe a próxima música
    playing = playing->next;
    // Retorna a atual a ser tocada
    return temp;
  } 
  // Retorna nullptr caso não tenha mais nenhuma a tocar
  return nullptr;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
movq %rdi, -0x10(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x20(%rbp)
cmpq $0x0, 0x28(%rax)
je 0xa809
movq -0x20(%rbp), %rax
movq 0x28(%rax), %rcx
movq %rcx, -0x18(%rbp)
movq 0x28(%rax), %rcx
movq 0x40(%rcx), %rcx
movq %rcx, 0x28(%rax)
movq -0x18(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0xa811
movq $0x0, -0x8(%rbp)
movq -0x8(%rbp), %rax
popq %rbp
retq
nopw (%rax,%rax)
// File: lorenatoscano[P]musify/src/playlist.cpp
// Function: Playlist::displayAllSongs(node*)
void Playlist::displayAllSongs(node* current) {
  // Condição de parada
  if (current == nullptr) {
    count = 1;
    return;
  }
  // Imprime a música atual
  cout << count << " - " << current->data.getTitle() << " - " << current->data.getArtist() << endl;
  ++count;
  // Chamada recursiva
  displayAllSongs(current->next);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x90, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x68(%rbp)
cmpq $0x0, -0x10(%rbp)
jne 0xa853
movq -0x68(%rbp), %rax
movq $0x1, 0x30(%rax)
jmp 0xa923
movq -0x68(%rbp), %rax
movq 0x30(%rax), %rsi
movq 0x476e(%rip), %rdi      # 0xefd0
callq 0x2050
movq %rax, %rdi
leaq 0x7b4(%rip), %rsi       # 0xb025
callq 0x2120
movq %rax, -0x80(%rbp)
movq -0x10(%rbp), %rsi
leaq -0x30(%rbp), %rdi
movq %rdi, -0x78(%rbp)
callq 0xa9d0
movq -0x80(%rbp), %rdi
movq -0x78(%rbp), %rsi
callq 0x2100
movq %rax, -0x70(%rbp)
jmp 0xa89e
movq -0x70(%rbp), %rdi
leaq 0x77c(%rip), %rsi       # 0xb025
callq 0x2120
movq %rax, -0x88(%rbp)
jmp 0xa8b7
movq -0x10(%rbp), %rsi
leaq -0x60(%rbp), %rdi
callq 0xaa00
jmp 0xa8c6
movq -0x88(%rbp), %rdi
leaq -0x60(%rbp), %rsi
callq 0x2100
movq %rax, -0x90(%rbp)
jmp 0xa8df
movq -0x90(%rbp), %rdi
movq 0x46d3(%rip), %rsi      # 0xefc0
callq 0x2140
jmp 0xa8f4
leaq -0x60(%rbp), %rdi
callq 0x20a0
leaq -0x30(%rbp), %rdi
callq 0x20a0
movq -0x68(%rbp), %rdi
movq 0x30(%rdi), %rax
addq $0x1, %rax
movq %rax, 0x30(%rdi)
movq -0x10(%rbp), %rax
movq 0x40(%rax), %rsi
callq 0xa820
addq $0x90, %rsp
popq %rbp
retq
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
jmp 0xa94f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
leaq -0x60(%rbp), %rdi
callq 0x20a0
leaq -0x30(%rbp), %rdi
callq 0x20a0
movq -0x38(%rbp), %rdi
callq 0x21e0
nopw %cs:(%rax,%rax)
nopl (%rax,%rax)
// File: lorenatoscano[P]musify/src/utils.cpp
// Function: toLowercase(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>)
string toLowercase(string s) {
  string result = "";

  for (size_t i = 0; i < s.size(); i++) {
    result += tolower(s[i]);
  }
  
  return result;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x60, %rsp
movq %rsi, -0x50(%rbp)
movq %rdi, -0x40(%rbp)
movq %rdi, %rax
movq %rax, -0x48(%rbp)
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movb $0x0, -0x11(%rbp)
leaq -0x12(%rbp), %rdi
movq %rdi, -0x38(%rbp)
callq 0x21f0
movq -0x40(%rbp), %rdi
movq -0x38(%rbp), %rdx
leaq 0x569(%rip), %rsi       # 0xb028
callq 0x2180
jmp 0xaac6
leaq -0x12(%rbp), %rdi
callq 0x2150
movq $0x0, -0x30(%rbp)
movq -0x50(%rbp), %rdi
movq -0x30(%rbp), %rax
movq %rax, -0x58(%rbp)
callq 0x20d0
movq %rax, %rcx
movq -0x58(%rbp), %rax
cmpq %rcx, %rax
jae 0xab5f
movq -0x50(%rbp), %rdi
movq -0x30(%rbp), %rsi
callq 0x2200
movq %rax, -0x60(%rbp)
jmp 0xab07
movq -0x60(%rbp), %rax
movsbl (%rax), %edi
callq 0x21c0
movq -0x40(%rbp), %rdi
movsbl %al, %esi
callq 0x20b0
jmp 0xab21
jmp 0xab23
movq -0x30(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x30(%rbp)
jmp 0xaad7
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x20(%rbp)
movl %eax, -0x24(%rbp)
leaq -0x12(%rbp), %rdi
callq 0x2150
jmp 0xab7c
movq -0x40(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x20(%rbp)
movl %eax, -0x24(%rbp)
callq 0x20a0
jmp 0xab7c
movb $0x1, -0x11(%rbp)
testb $0x1, -0x11(%rbp)
jne 0xab72
movq -0x40(%rbp), %rdi
callq 0x20a0
movq -0x48(%rbp), %rax
addq $0x60, %rsp
popq %rbp
retq
movq -0x20(%rbp), %rdi
callq 0x21e0
// File: utkukaratas[P]xkeylayers/./config.hpp
// Function: key_add_key(TKey*, unsigned char)
TKey *key_add_key(TKey *keys, KeyCode key)
{
    TKey *rval = keys;

    if (keys == NULL)
    {
        keys = new TKey;
        rval = keys;
    }
    else
    {
        while (keys->next != NULL) keys = keys->next;
        keys = (keys->next = new TKey);
    }

    keys->key = key;
    keys->next = NULL;

    return rval;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movb %sil, %al
movq %rdi, -0x8(%rbp)
movb %al, -0x9(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x18(%rbp)
cmpq $0x0, -0x8(%rbp)
jne 0x2679
movl $0x10, %edi
callq 0x2190
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x18(%rbp)
jmp 0x26aa
jmp 0x267b
movq -0x8(%rbp), %rax
cmpq $0x0, 0x8(%rax)
je 0x2694
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x8(%rbp)
jmp 0x267b
movl $0x10, %edi
callq 0x2190
movq -0x8(%rbp), %rcx
movq %rax, 0x8(%rcx)
movq %rax, -0x8(%rbp)
movb -0x9(%rbp), %cl
movq -0x8(%rbp), %rax
movb %cl, (%rax)
movq -0x8(%rbp), %rax
movq $0x0, 0x8(%rax)
movq -0x18(%rbp), %rax
addq $0x20, %rsp
popq %rbp
retq
nopl (%rax)
// File: utkukaratas[P]xkeylayers/xkeylayers.cpp
// Function: debug(char const*, ...)
void debug(const char *fmt, ...) {
    if (app.debug) {
        va_list args;
        va_start(args, fmt);
        vfprintf(stdout, fmt, args);
        va_end(args);
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xd0, %rsp
testb %al, %al
je 0x2705
movaps %xmm0, -0xa0(%rbp)
movaps %xmm1, -0x90(%rbp)
movaps %xmm2, -0x80(%rbp)
movaps %xmm3, -0x70(%rbp)
movaps %xmm4, -0x60(%rbp)
movaps %xmm5, -0x50(%rbp)
movaps %xmm6, -0x40(%rbp)
movaps %xmm7, -0x30(%rbp)
movq %r9, -0xa8(%rbp)
movq %r8, -0xb0(%rbp)
movq %rcx, -0xb8(%rbp)
movq %rdx, -0xc0(%rbp)
movq %rsi, -0xc8(%rbp)
movq %rdi, -0x8(%rbp)
testb $0x1, 0x8b7d(%rip)      # 0xb2b0
je 0x2774
leaq -0x20(%rbp), %rax
leaq -0xd0(%rbp), %rcx
movq %rcx, 0x10(%rax)
leaq 0x10(%rbp), %rcx
movq %rcx, 0x8(%rax)
movl $0x30, 0x4(%rax)
movl $0x8, (%rax)
movq 0x8850(%rip), %rax      # 0xafb0
movq (%rax), %rdi
movq -0x8(%rbp), %rsi
leaq -0x20(%rbp), %rdx
callq 0x2250
leaq -0x20(%rbp), %rax
addq $0xd0, %rsp
popq %rbp
retq
nopl (%rax)
// File: utkukaratas[P]xkeylayers/xkeylayers.cpp
// Function: TApplication::trigger_key(TModifierKey*)
void TApplication::trigger_key(TModifierKey* mod)
{
    for (auto keycode : mod->fake_keys)
    {
        ::debug("Generating %s!\n", XKeysymToString(sym_from_code(keycode)));

        XTestFakeKeyEvent(_ctrl_conn, keycode, True, 0);
        generated = key_add_key(generated, keycode);
    }
    for (auto keycode : mod->fake_keys)
    {
        XTestFakeKeyEvent(_ctrl_conn, keycode, False, 0);
        generated = key_add_key(generated, keycode);
    }
    XFlush(_ctrl_conn);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x60, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x58(%rbp)
movq -0x10(%rbp), %rax
addq $0x10, %rax
movq %rax, -0x18(%rbp)
movq -0x18(%rbp), %rdi
callq 0x3db0
movq %rax, -0x20(%rbp)
movq -0x18(%rbp), %rdi
callq 0x3de0
movq %rax, -0x28(%rbp)
leaq -0x20(%rbp), %rdi
leaq -0x28(%rbp), %rsi
callq 0x3e10
testb $0x1, %al
jne 0x27d1
jmp 0x284b
leaq -0x20(%rbp), %rdi
callq 0x3e50
movb (%rax), %al
movb %al, -0x29(%rbp)
movzbl -0x29(%rbp), %edi
callq 0x3e70
movq %rax, %rdi
callq 0x2380
movq %rax, %rsi
leaq 0x482a(%rip), %rdi      # 0x7024
movb $0x0, %al
callq 0x26d0
movq -0x58(%rbp), %rax
movq 0x8(%rax), %rdi
movzbl -0x29(%rbp), %esi
movl $0x1, %edx
xorl %eax, %eax
movl %eax, %ecx
callq 0x2230
movq -0x58(%rbp), %rax
movq 0xd8(%rax), %rdi
movzbl -0x29(%rbp), %esi
callq 0x2640
movq %rax, %rcx
movq -0x58(%rbp), %rax
movq %rcx, 0xd8(%rax)
leaq -0x20(%rbp), %rdi
callq 0x3ea0
jmp 0x27be
movq -0x10(%rbp), %rax
addq $0x10, %rax
movq %rax, -0x38(%rbp)
movq -0x38(%rbp), %rdi
callq 0x3db0
movq %rax, -0x40(%rbp)
movq -0x38(%rbp), %rdi
callq 0x3de0
movq %rax, -0x48(%rbp)
leaq -0x40(%rbp), %rdi
leaq -0x48(%rbp), %rsi
callq 0x3e10
testb $0x1, %al
jne 0x2884
jmp 0x28d9
leaq -0x40(%rbp), %rdi
callq 0x3e50
movq %rax, %rcx
movq -0x58(%rbp), %rax
movb (%rcx), %cl
movb %cl, -0x49(%rbp)
movq 0x8(%rax), %rdi
movzbl -0x49(%rbp), %esi
xorl %edx, %edx
xorl %eax, %eax
movl %eax, %ecx
callq 0x2230
movq -0x58(%rbp), %rax
movq 0xd8(%rax), %rdi
movzbl -0x49(%rbp), %esi
callq 0x2640
movq %rax, %rcx
movq -0x58(%rbp), %rax
movq %rcx, 0xd8(%rax)
leaq -0x40(%rbp), %rdi
callq 0x3ea0
jmp 0x2871
movq -0x58(%rbp), %rax
movq 0x8(%rax), %rdi
callq 0x22c0
addq $0x60, %rsp
popq %rbp
retq
nopl (%rax)
// File: utkukaratas[P]xkeylayers/xkeylayers.cpp
// Function: TApplication::connect_x11()
void TApplication::connect_x11() {
    int dummy;
    _data_conn = XOpenDisplay(NULL);
    _ctrl_conn = XOpenDisplay(NULL);

    if (!_data_conn || !_ctrl_conn)
    {
        cerr << "Unable to connect to X11 display. Is $DISPLAY set?\n";
        exit(EXIT_FAILURE);
    }
    if (!XQueryExtension(_ctrl_conn,
                "XTEST", &dummy, &dummy, &dummy))
    {
        cerr << "Xtst extension missing\n";
        exit(EXIT_FAILURE);
    }
    if (!XRecordQueryVersion(_ctrl_conn, &dummy, &dummy))
    {
        cerr << "Failed to obtain xrecord version\n";
        exit(EXIT_FAILURE);
    }
    if (!XkbQueryExtension(_ctrl_conn, &dummy, &dummy,
            &dummy, &dummy, &dummy))
    {
        cerr << "Failed to obtain xkb version\n";
        exit(EXIT_FAILURE);
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x18(%rbp)
xorl %eax, %eax
movl %eax, %edi
callq 0x2260
movq %rax, %rcx
movq -0x18(%rbp), %rax
movq %rcx, (%rax)
xorl %eax, %eax
movl %eax, %edi
callq 0x2260
movq %rax, %rcx
movq -0x18(%rbp), %rax
movq %rcx, 0x8(%rax)
cmpq $0x0, (%rax)
je 0x293c
movq -0x18(%rbp), %rax
cmpq $0x0, 0x8(%rax)
jne 0x2959
movq 0x86ad(%rip), %rdi      # 0xaff0
leaq 0x46ea(%rip), %rsi      # 0x7034
callq 0x2180
movl $0x1, %edi
callq 0x2210
movq -0x18(%rbp), %rax
movq 0x8(%rax), %rdi
leaq 0x4700(%rip), %rsi      # 0x7068
leaq -0xc(%rbp), %r8
movq %r8, %rdx
movq %r8, %rcx
callq 0x2080
cmpl $0x0, %eax
jne 0x2999
movq 0x866d(%rip), %rdi      # 0xaff0
leaq 0x46e4(%rip), %rsi      # 0x706e
callq 0x2180
movl $0x1, %edi
callq 0x2210
movq -0x18(%rbp), %rax
movq 0x8(%rax), %rdi
leaq -0xc(%rbp), %rdx
movq %rdx, %rsi
callq 0x2350
cmpl $0x0, %eax
jne 0x29cf
movq 0x8637(%rip), %rdi      # 0xaff0
leaq 0x46c6(%rip), %rsi      # 0x7086
callq 0x2180
movl $0x1, %edi
callq 0x2210
movq -0x18(%rbp), %rax
movq 0x8(%rax), %rdi
leaq -0xc(%rbp), %r9
movq %r9, %rsi
movq %r9, %rdx
movq %r9, %rcx
movq %r9, %r8
callq 0x2160
cmpl $0x0, %eax
jne 0x2a0e
movq 0x85f8(%rip), %rdi      # 0xaff0
leaq 0x46a9(%rip), %rsi      # 0x70a8
callq 0x2180
movl $0x1, %edi
callq 0x2210
addq $0x20, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)
// File: utkukaratas[P]xkeylayers/xkeylayers.cpp
// Function: TApplication::hook_x11()
void TApplication::hook_x11() {
    XRecordRange *rec_range = XRecordAllocRange();
    rec_range->device_events.first = KeyPress;
    rec_range->device_events.last = ButtonRelease;
    XRecordClientSpec client_spec = XRecordAllClients;

    _record_ctx = XRecordCreateContext(_ctrl_conn,
            0, &client_spec, 1, &rec_range, 1);

    if (_record_ctx == 0)
    {
        cerr << "Failed to create xrecord context\n";
        exit(EXIT_FAILURE);
    }

    XSync(_ctrl_conn, False);

    if (!XRecordEnableContext(_data_conn,
                _record_ctx, intercept, (XPointer)&app))
    {
        cerr << "Failed to enable xrecord context\n";
        exit(EXIT_FAILURE);
    }

    if (!XRecordFreeContext(_ctrl_conn, _record_ctx))
    {
        cerr << "Failed to free xrecord context\n";
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x20(%rbp)
callq 0x23b0
movq %rax, %rcx
movq -0x20(%rbp), %rax
movq %rcx, -0x10(%rbp)
movq -0x10(%rbp), %rcx
movb $0x2, 0x12(%rcx)
movq -0x10(%rbp), %rcx
movb $0x5, 0x13(%rcx)
movq $0x3, -0x18(%rbp)
movq 0x8(%rax), %rdi
xorl %esi, %esi
leaq -0x18(%rbp), %rdx
movl $0x1, %r9d
leaq -0x10(%rbp), %r8
movl %r9d, %ecx
callq 0x2310
movq %rax, %rcx
movq -0x20(%rbp), %rax
movq %rcx, 0x10(%rax)
cmpq $0x0, 0x10(%rax)
jne 0x2aa7
movq 0x855f(%rip), %rdi      # 0xaff0
leaq 0x462e(%rip), %rsi      # 0x70c6
callq 0x2180
movl $0x1, %edi
callq 0x2210
movq -0x20(%rbp), %rax
movq 0x8(%rax), %rdi
xorl %esi, %esi
callq 0x23a0
movq -0x20(%rbp), %rax
movq (%rax), %rdi
movq 0x10(%rax), %rsi
leaq 0x68(%rip), %rdx        # 0x2b30
leaq 0x8741(%rip), %rcx      # 0xb210
callq 0x22d0
cmpl $0x0, %eax
jne 0x2af6
movq 0x8510(%rip), %rdi      # 0xaff0
leaq 0x4601(%rip), %rsi      # 0x70e8
callq 0x2180
movl $0x1, %edi
callq 0x2210
movq -0x20(%rbp), %rax
movq 0x8(%rax), %rdi
movq 0x10(%rax), %rsi
callq 0x2100
cmpl $0x0, %eax
jne 0x2b1f
movq 0x84dd(%rip), %rdi      # 0xaff0
leaq 0x45f0(%rip), %rsi      # 0x710a
callq 0x2180
addq $0x20, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)
// File: utkukaratas[P]xkeylayers/xkeylayers.cpp
// Function: is_any_mod_down()
bool is_any_mod_down() {
    return std::any_of(app.modifiers.begin(),
                       app.modifiers.end(),
                       [](TModifierKey* m){
        return m->is_down;
    });
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
leaq 0x8311(%rip), %rdi      # 0xb210
addq $0xa8, %rdi
callq 0x3f60
movq %rax, -0x8(%rbp)
leaq 0x82fa(%rip), %rdi      # 0xb210
addq $0xa8, %rdi
callq 0x3f90
movq %rax, -0x10(%rbp)
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
callq 0x2f40
andb $0x1, %al
addq $0x20, %rsp
popq %rbp
retq
nopl (%rax,%rax)
// File: utkukaratas[P]xkeylayers/xkeylayers.cpp
// Function: heuristic_test1(TModifierKey*)
bool heuristic_test1(TModifierKey* mod) {
    auto& lst = app.last_presses;
    bool last_3_keys_alpha =
            std::all_of(lst.rbegin() + 1, // the very last event was for the
                                        // modifier itself, so skip that.
                        lst.rbegin() + 4,
                        [](pair<KeySym, timeval> p){
                            KeySym k = p.first;
                            return ((k >= XK_A && k <= XK_Z) ||
                                    (k >= XK_a && k <= XK_z));
                        }
            );

    // take a look if the space was pressed very recently... (1 sec)
    timeval now;
    gettimeofday(&now, NULL);
    bool is_immediate = abs(diff_ms(now, lst[lst.size()-1].second)) < 1000;
    return last_3_keys_alpha && is_immediate;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x80, %rsp
movq %rdi, -0x8(%rbp)
leaq 0x827a(%rip), %rax      # 0xb210
addq $0xc0, %rax
movq %rax, -0x10(%rbp)
leaq -0x28(%rbp), %rdi
leaq 0x8265(%rip), %rsi      # 0xb210
addq $0xc0, %rsi
callq 0x4040
leaq -0x20(%rbp), %rdi
leaq -0x28(%rbp), %rsi
movl $0x1, %edx
callq 0x4090
leaq -0x38(%rbp), %rdi
leaq 0x823c(%rip), %rsi      # 0xb210
addq $0xc0, %rsi
callq 0x4040
leaq -0x30(%rbp), %rdi
leaq -0x38(%rbp), %rsi
movl $0x4, %edx
callq 0x4090
leaq -0x20(%rbp), %rdi
leaq -0x30(%rbp), %rsi
callq 0x30b0
andb $0x1, %al
movb %al, -0x11(%rbp)
leaq -0x50(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x22e0
movq -0x50(%rbp), %rax
movq %rax, -0x68(%rbp)
movq -0x48(%rbp), %rax
movq %rax, -0x60(%rbp)
leaq 0x81e8(%rip), %rdi      # 0xb210
addq $0xc0, %rdi
callq 0x4100
movq %rax, %rsi
subq $0x1, %rsi
leaq 0x81ce(%rip), %rdi      # 0xb210
addq $0xc0, %rdi
callq 0x40e0
movq 0x8(%rax), %rcx
movq %rcx, -0x78(%rbp)
movq 0x10(%rax), %rax
movq %rax, -0x70(%rbp)
movq -0x68(%rbp), %rdi
movq -0x60(%rbp), %rsi
movq -0x78(%rbp), %rdx
movq -0x70(%rbp), %rcx
callq 0x3110
movl %eax, %ecx
negl %ecx
cmovnsl %ecx, %eax
cmpl $0x3e8, %eax            # imm = 0x3E8
setl %al
andb $0x1, %al
movb %al, -0x51(%rbp)
xorl %eax, %eax
testb $0x1, -0x11(%rbp)
movb %al, -0x79(%rbp)
je 0x3098
movb -0x51(%rbp), %al
movb %al, -0x79(%rbp)
movb -0x79(%rbp), %al
andb $0x1, %al
addq $0x80, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)
// File: utkukaratas[P]xkeylayers/xkeylayers.cpp
// Function: sig_handler(void*)
void* sig_handler(void *user_data)
{
    TApplication *self = (TApplication*)user_data;
    int sig;

    debug("sig_handler running...\n");

    sigwait(&self->_sigset, &sig);

    debug("Caught signal %d!\n", sig);

    if (!XRecordDisableContext(self->_ctrl_conn, self->_record_ctx))
    {
        fprintf(stderr, "Failed to disable xrecord context\n");
        exit(EXIT_FAILURE);
    }

    XSync(self->_ctrl_conn, False);

    debug("sig_handler exiting...\n");

    return NULL;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x10(%rbp)
leaq 0x401e(%rip), %rdi      # 0x7189
movb $0x0, %al
callq 0x26d0
movq -0x10(%rbp), %rdi
addq $0x20, %rdi
leaq -0x14(%rbp), %rsi
callq 0x2090
movl -0x14(%rbp), %esi
leaq 0x4014(%rip), %rdi      # 0x71a1
movb $0x0, %al
callq 0x26d0
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rdi
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rsi
callq 0x2320
cmpl $0x0, %eax
jne 0x31d0
movq 0x7e1b(%rip), %rax      # 0xafd0
movq (%rax), %rdi
leaq 0x3ff5(%rip), %rsi      # 0x71b4
movb $0x0, %al
callq 0x2280
movl $0x1, %edi
callq 0x2210
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rdi
xorl %esi, %esi
callq 0x23a0
leaq 0x3ff1(%rip), %rdi      # 0x71d7
movb $0x0, %al
callq 0x26d0
xorl %eax, %eax
addq $0x20, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)
// File: DavieV[P]virtual-usb-printer/usbip.cc
// Function: set_op_rep_device(_USB_DEVICE_DESCRIPTOR const&, _USB_CONFIGURATION_DESCRIPTOR const&, _OP_REP_DEVICE*)
void set_op_rep_device(const USB_DEVICE_DESCRIPTOR& dev_dsc,
                       const USB_CONFIGURATION_DESCRIPTOR& config,
                       OP_REP_DEVICE* device) {
  // Set constants.
  memset(device->usbPath, 0, 256);
  strcpy(device->usbPath, kUsbPath);
  memset(device->busID, 0, 32);
  strcpy(device->busID, kBusId);

  device->busnum=htonl(1);
  device->devnum=htonl(2);
  device->speed=htonl(2);

  // Set values using |device|.
  device->idVendor = htons(dev_dsc.idVendor);
  device->idProduct = htons(dev_dsc.idProduct);
  device->bcdDevice = htons(dev_dsc.bcdDevice);
  device->bDeviceClass = dev_dsc.bDeviceClass;
  device->bDeviceSubClass = dev_dsc.bDeviceSubClass;
  device->bDeviceProtocol = dev_dsc.bDeviceProtocol;
  device->bNumConfigurations = dev_dsc.bNumConfigurations;

  // Set values using |config|.
  device->bConfigurationValue = config.bConfigurationValue;
  device->bNumInterfaces = config.bNumInterfaces;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq -0x18(%rbp), %rdi
xorl %esi, %esi
movl $0x100, %edx            # imm = 0x100
callq 0x2130
movq -0x18(%rbp), %rdi
leaq 0x6b91(%rip), %rsi      # 0x9010
callq 0x2180
movq -0x18(%rbp), %rdi
addq $0x100, %rdi            # imm = 0x100
xorl %esi, %esi
movl $0x20, %edx
callq 0x2130
movq -0x18(%rbp), %rdi
addq $0x100, %rdi            # imm = 0x100
leaq 0x6b91(%rip), %rsi      # 0x903e
callq 0x2180
movl $0x1, %edi
callq 0x2150
movl %eax, %ecx
movq -0x18(%rbp), %rax
movl %ecx, 0x120(%rax)
movl $0x2, %edi
callq 0x2150
movl %eax, %ecx
movq -0x18(%rbp), %rax
movl %ecx, 0x124(%rax)
movl $0x2, %edi
callq 0x2150
movl %eax, %ecx
movq -0x18(%rbp), %rax
movl %ecx, 0x128(%rax)
movq -0x8(%rbp), %rax
movzwl 0x8(%rax), %edi
callq 0x2060
movw %ax, %cx
movq -0x18(%rbp), %rax
movw %cx, 0x12c(%rax)
movq -0x8(%rbp), %rax
movzwl 0xa(%rax), %edi
callq 0x2060
movw %ax, %cx
movq -0x18(%rbp), %rax
movw %cx, 0x12e(%rax)
movq -0x8(%rbp), %rax
movzwl 0xc(%rax), %edi
callq 0x2060
movw %ax, %cx
movq -0x18(%rbp), %rax
movw %cx, 0x130(%rax)
movq -0x8(%rbp), %rax
movb 0x4(%rax), %cl
movq -0x18(%rbp), %rax
movb %cl, 0x132(%rax)
movq -0x8(%rbp), %rax
movb 0x5(%rax), %cl
movq -0x18(%rbp), %rax
movb %cl, 0x133(%rax)
movq -0x8(%rbp), %rax
movb 0x6(%rax), %cl
movq -0x18(%rbp), %rax
movb %cl, 0x134(%rax)
movq -0x8(%rbp), %rax
movb 0x11(%rax), %cl
movq -0x18(%rbp), %rax
movb %cl, 0x136(%rax)
movq -0x10(%rbp), %rax
movb 0x5(%rax), %cl
movq -0x18(%rbp), %rax
movb %cl, 0x135(%rax)
movq -0x10(%rbp), %rax
movb 0x4(%rax), %cl
movq -0x18(%rbp), %rax
movb %cl, 0x137(%rax)
addq $0x20, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)
// File: DavieV[P]virtual-usb-printer/usbip.cc
// Function: set_op_rep_devlist_interfaces(std::vector<_USB_INTERFACE_DESCRIPTOR, std::allocator<_USB_INTERFACE_DESCRIPTOR>> const&, _OP_REP_DEVLIST_INTERFACE**)
void set_op_rep_devlist_interfaces(
    const std::vector<USB_INTERFACE_DESCRIPTOR>& interfaces,
    OP_REP_DEVLIST_INTERFACE **rep_interfaces) {
  // TODO(daviev): Change this to use a smart pointer at some point.
  *rep_interfaces = (OP_REP_DEVLIST_INTERFACE *)malloc(
      interfaces.size() * sizeof(OP_REP_DEVLIST_INTERFACE));
  for (size_t i = 0; i < interfaces.size(); ++i) {
    const auto& interface = interfaces[i];
    (*rep_interfaces)[i].bInterfaceClass = interface.bInterfaceClass;
    (*rep_interfaces)[i].bInterfaceSubClass = interface.bInterfaceSubClass;
    (*rep_interfaces)[i].bInterfaceProtocol = interface.bInterfaceProtocol;
    (*rep_interfaces)[i].padding = 0;
  }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x8(%rbp), %rdi
callq 0x2f40
movq %rax, %rdi
shlq $0x2, %rdi
callq 0x2220
movq %rax, %rcx
movq -0x10(%rbp), %rax
movq %rcx, (%rax)
movq $0x0, -0x18(%rbp)
movq -0x18(%rbp), %rax
movq %rax, -0x28(%rbp)
movq -0x8(%rbp), %rdi
callq 0x2f40
movq %rax, %rcx
movq -0x28(%rbp), %rax
cmpq %rcx, %rax
jae 0x2687
movq -0x8(%rbp), %rdi
movq -0x18(%rbp), %rsi
callq 0x2f70
movq %rax, -0x20(%rbp)
movq -0x20(%rbp), %rax
movb 0x5(%rax), %dl
movq -0x10(%rbp), %rax
movq (%rax), %rax
movq -0x18(%rbp), %rcx
movb %dl, (%rax,%rcx,4)
movq -0x20(%rbp), %rax
movb 0x6(%rax), %dl
movq -0x10(%rbp), %rax
movq (%rax), %rax
movq -0x18(%rbp), %rcx
movb %dl, 0x1(%rax,%rcx,4)
movq -0x20(%rbp), %rax
movb 0x7(%rax), %dl
movq -0x10(%rbp), %rax
movq (%rax), %rax
movq -0x18(%rbp), %rcx
movb %dl, 0x2(%rax,%rcx,4)
movq -0x10(%rbp), %rax
movq (%rax), %rax
movq -0x18(%rbp), %rcx
movb $0x0, 0x3(%rax,%rcx,4)
movq -0x18(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x18(%rbp)
jmp 0x25f7
addq $0x30, %rsp
popq %rbp
retq
nopl (%rax)
// File: DavieV[P]virtual-usb-printer/usbip.cc
// Function: handle_device_list(UsbPrinter const&, int)
void handle_device_list(const UsbPrinter& printer, int sockfd) {
  OP_REP_DEVLIST list;
  printf("list devices\n");

  create_op_rep_devlist(printer.device_descriptor(),
                        printer.configuration_descriptor(),
                        printer.interfaces(), &list);

  ssize_t sent = send(sockfd, &list.header, sizeof(list.header), 0);
  if (sent != sizeof(OP_REP_DEVLIST_HEADER)) {
    printf("send error : %s \n", strerror(errno));
    goto cleanup;
  }

  sent = send(sockfd, &list.device, sizeof(list.device), 0);
  if (sent != sizeof(list.device)) {
    printf("send error : %s \n", strerror(errno));
    goto cleanup;
  }

  sent = send(sockfd, list.interfaces,
              sizeof(*list.interfaces) * list.device.bNumInterfaces, 0);
  if (sent != sizeof(*list.interfaces) * list.device.bNumInterfaces) {
    printf("send error : %s \n", strerror(errno));
    goto cleanup;
  }

cleanup:
  free(list.interfaces);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x1b0, %rsp            # imm = 0x1B0
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
leaq 0x6909(%rip), %rdi      # 0x9042
xorl %eax, %eax
callq 0x2050
movq -0x8(%rbp), %rsi
leaq -0x16a(%rbp), %rdi
callq 0x2f90
movq -0x8(%rbp), %rdi
callq 0x2fc0
movb %dl, -0x180(%rbp)
movq %rax, -0x188(%rbp)
movq -0x188(%rbp), %rax
movq %rax, -0x173(%rbp)
movb -0x180(%rbp), %al
movb %al, -0x16b(%rbp)
movq -0x8(%rbp), %rsi
leaq -0x1a0(%rbp), %rdi
callq 0x3000
leaq -0x16a(%rbp), %rdi
leaq -0x173(%rbp), %rsi
leaq -0x1a0(%rbp), %rdx
leaq -0x158(%rbp), %rcx
callq 0x2690
leaq -0x1a0(%rbp), %rdi
callq 0x3030
movl -0xc(%rbp), %edi
leaq -0x158(%rbp), %rsi
movl $0xc, %edx
xorl %ecx, %ecx
callq 0x2110
movq %rax, -0x1a8(%rbp)
cmpq $0xc, -0x1a8(%rbp)
je 0x2806
callq 0x2040
movl (%rax), %edi
callq 0x20d0
movq %rax, %rsi
leaq 0x6856(%rip), %rdi      # 0x9050
movb $0x0, %al
callq 0x2050
jmp 0x28a7
movl -0xc(%rbp), %edi
leaq -0x158(%rbp), %rsi
addq $0xc, %rsi
movl $0x138, %edx            # imm = 0x138
xorl %ecx, %ecx
callq 0x2110
movq %rax, -0x1a8(%rbp)
cmpq $0x138, -0x1a8(%rbp) # imm = 0x138
je 0x2853
callq 0x2040
movl (%rax), %edi
callq 0x20d0
movq %rax, %rsi
leaq 0x6806(%rip), %rdi      # 0x9050
movb $0x0, %al
callq 0x2050
jmp 0x28a7
movl -0xc(%rbp), %edi
movq -0x14(%rbp), %rsi
movzbl -0x15(%rbp), %eax
movl %eax, %edx
shlq $0x2, %rdx
xorl %ecx, %ecx
callq 0x2110
movq %rax, -0x1a8(%rbp)
movq -0x1a8(%rbp), %rax
movzbl -0x15(%rbp), %ecx
shlq $0x2, %rcx
cmpq %rcx, %rax
je 0x28a5
callq 0x2040
movl (%rax), %edi
callq 0x20d0
movq %rax, %rsi
leaq 0x67b4(%rip), %rdi      # 0x9050
movb $0x0, %al
callq 0x2050
jmp 0x28a7
jmp 0x28a7
movq -0x14(%rbp), %rdi
callq 0x21e0
addq $0x1b0, %rsp            # imm = 0x1B0
popq %rbp
retq
nopl (%rax)
// File: DavieV[P]virtual-usb-printer/usbip.cc
// Function: handle_attach(UsbPrinter const&, int)
int handle_attach(const UsbPrinter& printer, int sockfd) {
  char busid[32];
  OP_REP_IMPORT rep;
  printf("attach device\n");
  ssize_t received = recv(sockfd, busid, 32, 0);
  if (received != 32) {
    printf("receive error : %s \n", strerror(errno));
    return 1;
  }
  create_op_rep_import(printer.device_descriptor(),
                       printer.configuration_descriptor(), &rep);
  ssize_t sent = send(sockfd, &rep, sizeof(rep), 0);
  if (sent != sizeof(rep)) {
    printf("send error : %s \n", strerror(errno));
    return 1;
  }
  return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x1c0, %rsp            # imm = 0x1C0
movq %rdi, -0x10(%rbp)
movl %esi, -0x14(%rbp)
leaq 0x6729(%rip), %rdi      # 0x9062
movb $0x0, %al
callq 0x2050
movl -0x14(%rbp), %edi
leaq -0x40(%rbp), %rsi
movl $0x20, %edx
xorl %ecx, %ecx
callq 0x20c0
movq %rax, -0x188(%rbp)
cmpq $0x20, -0x188(%rbp)
je 0x298d
callq 0x2040
movl (%rax), %edi
callq 0x20d0
movq %rax, %rsi
leaq 0x66f7(%rip), %rdi      # 0x9071
movb $0x0, %al
callq 0x2050
movl $0x1, -0x4(%rbp)
jmp 0x2a3e
movq -0x10(%rbp), %rsi
leaq -0x19a(%rbp), %rdi
callq 0x2f90
movq -0x10(%rbp), %rdi
callq 0x2fc0
movb %dl, -0x1b0(%rbp)
movq %rax, -0x1b8(%rbp)
movq -0x1b8(%rbp), %rax
movq %rax, -0x1a3(%rbp)
movb -0x1b0(%rbp), %al
movb %al, -0x19b(%rbp)
leaq -0x19a(%rbp), %rdi
leaq -0x1a3(%rbp), %rsi
leaq -0x180(%rbp), %rdx
callq 0x28c0
movl -0x14(%rbp), %edi
leaq -0x180(%rbp), %rsi
movl $0x140, %edx            # imm = 0x140
xorl %ecx, %ecx
callq 0x2110
movq %rax, -0x1c0(%rbp)
cmpq $0x140, -0x1c0(%rbp) # imm = 0x140
je 0x2a37
callq 0x2040
movl (%rax), %edi
callq 0x20d0
movq %rax, %rsi
leaq 0x6629(%rip), %rdi      # 0x9050
movb $0x0, %al
callq 0x2050
movl $0x1, -0x4(%rbp)
jmp 0x2a3e
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x1c0, %rsp            # imm = 0x1C0
popq %rbp
retq
nopw (%rax,%rax)
// File: DavieV[P]virtual-usb-printer/usbip.cc
// Function: pack_usbip(int*, unsigned long)
void pack_usbip(int *data, size_t msg_size) {
  int size = msg_size / 4;
  for (int i = 0; i < size; i++) {
    data[i] = htonl(data[i]);
  }
  // Put |setup| into network byte order. Since |setup| is a 64-bit integer we
  // have to swap the final 2 int entries since they are both a part of |setup|.
  swap(&data[size - 1], &data[size - 2]);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x10(%rbp), %rax
shrq $0x2, %rax
movl %eax, -0x14(%rbp)
movl $0x0, -0x18(%rbp)
movl -0x18(%rbp), %eax
cmpl -0x14(%rbp), %eax
jge 0x2ad2
movq -0x8(%rbp), %rax
movslq -0x18(%rbp), %rcx
movl (%rax,%rcx,4), %edi
callq 0x2150
movl %eax, %edx
movq -0x8(%rbp), %rax
movslq -0x18(%rbp), %rcx
movl %edx, (%rax,%rcx,4)
movl -0x18(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x18(%rbp)
jmp 0x2aa2
movq -0x8(%rbp), %rdi
movl -0x14(%rbp), %eax
subl $0x1, %eax
cltq
shlq $0x2, %rax
addq %rax, %rdi
movq -0x8(%rbp), %rsi
movl -0x14(%rbp), %eax
subl $0x2, %eax
cltq
shlq $0x2, %rax
addq %rax, %rsi
callq 0x2a50
addq $0x20, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)
// File: DavieV[P]virtual-usb-printer/usbip.cc
// Function: unpack_usbip(int*, unsigned long)
void unpack_usbip(int *data, size_t msg_size) {
  int size = msg_size / 4;
  for (int i = 0; i < size; i++) {
    data[i] = ntohl(data[i]);
  }
  // Put |setup| into host byte order. Since |setup| is a 64-bit integer we
  // have to swap the final 2 int entries since they are both a part of |setup|.
  swap(&data[size - 1], &data[size - 2]);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x10(%rbp), %rax
shrq $0x2, %rax
movl %eax, -0x14(%rbp)
movl $0x0, -0x18(%rbp)
movl -0x18(%rbp), %eax
cmpl -0x14(%rbp), %eax
jge 0x2b62
movq -0x8(%rbp), %rax
movslq -0x18(%rbp), %rcx
movl (%rax,%rcx,4), %edi
callq 0x2200
movl %eax, %edx
movq -0x8(%rbp), %rax
movslq -0x18(%rbp), %rcx
movl %edx, (%rax,%rcx,4)
movl -0x18(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x18(%rbp)
jmp 0x2b32
movq -0x8(%rbp), %rdi
movl -0x14(%rbp), %eax
subl $0x1, %eax
cltq
shlq $0x2, %rax
addq %rax, %rdi
movq -0x8(%rbp), %rsi
movl -0x14(%rbp), %eax
subl $0x2, %eax
cltq
shlq $0x2, %rax
addq %rax, %rsi
callq 0x2a50
addq $0x20, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)
// File: DavieV[P]virtual-usb-printer/usbip.cc
// Function: print_usbip_cmd_submit(_USBIP_CMD_SUBMIT const&)
void print_usbip_cmd_submit(const USBIP_CMD_SUBMIT& command) {
  printf("usbip cmd %u\n", command.command);
  printf("usbip seqnum %u\n", command.seqnum);
  printf("usbip devid %u\n", command.devid);
  printf("usbip direction %u\n", command.direction);
  printf("usbip ep %u\n", command.ep);
  printf("usbip flags %u\n", command.transfer_flags);
  printf("usbip number of packets %u\n", command.number_of_packets);
  printf("usbip interval %u\n", command.interval);
  printf("usbip setup %llu\n", command.setup);
  printf("usbip buffer length  %u\n", command.transfer_buffer_length);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x10, %rsp
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rax
movl (%rax), %esi
leaq 0x64cd(%rip), %rdi      # 0x9086
movb $0x0, %al
callq 0x2050
movq -0x8(%rbp), %rax
movl 0x4(%rax), %esi
leaq 0x64c6(%rip), %rdi      # 0x9094
movb $0x0, %al
callq 0x2050
movq -0x8(%rbp), %rax
movl 0x8(%rax), %esi
leaq 0x64c2(%rip), %rdi      # 0x90a5
movb $0x0, %al
callq 0x2050
movq -0x8(%rbp), %rax
movl 0xc(%rax), %esi
leaq 0x64bd(%rip), %rdi      # 0x90b5
movb $0x0, %al
callq 0x2050
movq -0x8(%rbp), %rax
movl 0x10(%rax), %esi
leaq 0x64bc(%rip), %rdi      # 0x90c9
movb $0x0, %al
callq 0x2050
movq -0x8(%rbp), %rax
movl 0x14(%rax), %esi
leaq 0x64b4(%rip), %rdi      # 0x90d6
movb $0x0, %al
callq 0x2050
movq -0x8(%rbp), %rax
movl 0x20(%rax), %esi
leaq 0x64af(%rip), %rdi      # 0x90e6
movb $0x0, %al
callq 0x2050
movq -0x8(%rbp), %rax
movl 0x24(%rax), %esi
leaq 0x64b6(%rip), %rdi      # 0x9102
movb $0x0, %al
callq 0x2050
movq -0x8(%rbp), %rax
movq 0x28(%rax), %rsi
leaq 0x64b3(%rip), %rdi      # 0x9115
movb $0x0, %al
callq 0x2050
movq -0x8(%rbp), %rax
movl 0x18(%rax), %esi
leaq 0x64b0(%rip), %rdi      # 0x9127
movb $0x0, %al
callq 0x2050
addq $0x10, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)
// File: DavieV[P]virtual-usb-printer/usbip.cc
// Function: print_standard_device_request(_StandardDeviceRequest const&)
void print_standard_device_request(const StandardDeviceRequest& request) {
  printf("  UC Request Type %u\n", request.bmRequestType);
  printf("  UC Request %u\n", request.bRequest);
  printf("  UC Value  %u[%u]\n", request.wValue1, request.wValue0);
  printf("  UC Index  %u-%u\n", request.wIndex1, request.wIndex0);
  printf("  UC Length %u\n", request.wLength);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x10, %rsp
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rax
movzbl (%rax), %esi
leaq 0x6496(%rip), %rdi      # 0x9140
movb $0x0, %al
callq 0x2050
movq -0x8(%rbp), %rax
movzbl 0x1(%rax), %esi
leaq 0x6496(%rip), %rdi      # 0x9156
movb $0x0, %al
callq 0x2050
movq -0x8(%rbp), %rax
movzbl 0x3(%rax), %esi
movq -0x8(%rbp), %rax
movzbl 0x2(%rax), %edx
leaq 0x6489(%rip), %rdi      # 0x9167
movb $0x0, %al
callq 0x2050
movq -0x8(%rbp), %rax
movzbl 0x5(%rax), %esi
movq -0x8(%rbp), %rax
movzbl 0x4(%rax), %edx
leaq 0x647f(%rip), %rdi      # 0x917b
movb $0x0, %al
callq 0x2050
movq -0x8(%rbp), %rax
movzwl 0x6(%rax), %esi
leaq 0x647c(%rip), %rdi      # 0x918e
movb $0x0, %al
callq 0x2050
addq $0x10, %rsp
popq %rbp
retq
nop
// File: DavieV[P]virtual-usb-printer/usbip.cc
// Function: create_usbip_ret_submit(_USBIP_CMD_SUBMIT const*)
USBIP_RET_SUBMIT create_usbip_ret_submit(const USBIP_CMD_SUBMIT *command) {
  USBIP_RET_SUBMIT usb_req;
  memset(&usb_req, 0, sizeof(usb_req));
  usb_req.seqnum = command->seqnum;
  usb_req.devid = command->devid;
  usb_req.direction = command->direction;
  usb_req.ep = command->ep;
  usb_req.setup = command->setup;
  return usb_req;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movq %rdi, -0x18(%rbp)
movq %rdi, %rax
movq %rax, -0x10(%rbp)
movq %rsi, -0x8(%rbp)
xorl %esi, %esi
movl $0x30, %edx
callq 0x2130
movq -0x18(%rbp), %rdi
movq -0x10(%rbp), %rax
movq -0x8(%rbp), %rcx
movl 0x4(%rcx), %ecx
movl %ecx, 0x4(%rdi)
movq -0x8(%rbp), %rcx
movl 0x8(%rcx), %ecx
movl %ecx, 0x8(%rdi)
movq -0x8(%rbp), %rcx
movl 0xc(%rcx), %ecx
movl %ecx, 0xc(%rdi)
movq -0x8(%rbp), %rcx
movl 0x10(%rcx), %ecx
movl %ecx, 0x10(%rdi)
movq -0x8(%rbp), %rcx
movq 0x28(%rcx), %rcx
movq %rcx, 0x28(%rdi)
addq $0x20, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)
// File: DavieV[P]virtual-usb-printer/usbip.cc
// Function: CreateUsbipRetSubmit(_USBIP_CMD_SUBMIT const&)
USBIP_RET_SUBMIT CreateUsbipRetSubmit(const USBIP_CMD_SUBMIT& request) {
  USBIP_RET_SUBMIT response;
  memset(&response, 0, sizeof(response));
  response.command = COMMAND_USBIP_RET_SUBMIT;
  response.seqnum = request.seqnum;
  response.devid = request.devid;
  response.direction = request.direction;
  response.ep = request.ep;
  return response;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movq %rdi, -0x18(%rbp)
movq %rdi, %rax
movq %rax, -0x10(%rbp)
movq %rsi, -0x8(%rbp)
xorl %esi, %esi
movl $0x30, %edx
callq 0x2130
movq -0x18(%rbp), %rdi
movq -0x10(%rbp), %rax
movl $0x3, (%rdi)
movq -0x8(%rbp), %rcx
movl 0x4(%rcx), %ecx
movl %ecx, 0x4(%rdi)
movq -0x8(%rbp), %rcx
movl 0x8(%rcx), %ecx
movl %ecx, 0x8(%rdi)
movq -0x8(%rbp), %rcx
movl 0xc(%rcx), %ecx
movl %ecx, 0xc(%rdi)
movq -0x8(%rbp), %rcx
movl 0x10(%rcx), %ecx
movl %ecx, 0x10(%rdi)
addq $0x20, %rsp
popq %rbp
retq
nop
// File: DavieV[P]virtual-usb-printer/usbip.cc
// Function: SendUsbRequest(int, _USBIP_CMD_SUBMIT const&, char const*, unsigned int, unsigned int)
void SendUsbRequest(int sockfd, const USBIP_CMD_SUBMIT& usb_request,
                    const char* data, unsigned int data_size,
                    unsigned int status) {
  USBIP_RET_SUBMIT response = CreateUsbipRetSubmit(usb_request);
  response.status = status;
  response.actual_length = data_size;
  response.start_frame = 0;
  // TODO(daviev): Figure out what this means.
  response.number_of_packets = 0;
  response.error_count = 0;

  if (data_size > 0) {
    printf("Sending buffer: \n");
    for (int i = 0; i < data_size; ++i) {
      printf("%u ", data[i]);
    }
    printf("\n");
  }

  size_t response_size = sizeof(response);
  pack_usbip((int*)&response, response_size);

  if (send(sockfd, (char*)&response, response_size, 0) != response_size) {
    printf("send error : %s \n", strerror(errno));
    exit(-1);
  }

  // Skip sending data if there isn't any.
  if (data_size == 0) {
    return;
  }

  if (send(sockfd, data, data_size, 0) != data_size) {
    printf("send error : %s \n", strerror(errno));
    exit(-1);
  }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x60, %rsp
movl %edi, -0x4(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movl %ecx, -0x1c(%rbp)
movl %r8d, -0x20(%rbp)
movq -0x10(%rbp), %rsi
leaq -0x50(%rbp), %rdi
callq 0x2d90
movl -0x20(%rbp), %eax
movl %eax, -0x3c(%rbp)
movl -0x1c(%rbp), %eax
movl %eax, -0x38(%rbp)
movl $0x0, -0x34(%rbp)
movl $0x0, -0x30(%rbp)
movl $0x0, -0x2c(%rbp)
cmpl $0x0, -0x1c(%rbp)
jbe 0x2e8e
leaq 0x6359(%rip), %rdi      # 0x919e
movb $0x0, %al
callq 0x2050
movl $0x0, -0x54(%rbp)
movl -0x54(%rbp), %eax
cmpl -0x1c(%rbp), %eax
jae 0x2e80
movq -0x18(%rbp), %rax
movslq -0x54(%rbp), %rcx
movsbl (%rax,%rcx), %esi
leaq 0x6342(%rip), %rdi      # 0x91b0
movb $0x0, %al
callq 0x2050
movl -0x54(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x54(%rbp)
jmp 0x2e53
leaq 0x6327(%rip), %rdi      # 0x91ae
movb $0x0, %al
callq 0x2050
movq $0x30, -0x60(%rbp)
movq -0x60(%rbp), %rsi
leaq -0x50(%rbp), %rdi
callq 0x2a80
movl -0x4(%rbp), %edi
movq -0x60(%rbp), %rdx
leaq -0x50(%rbp), %rsi
xorl %ecx, %ecx
callq 0x2110
cmpq -0x60(%rbp), %rax
je 0x2ee2
callq 0x2040
movl (%rax), %edi
callq 0x20d0
movq %rax, %rsi
leaq 0x617f(%rip), %rdi      # 0x9050
movb $0x0, %al
callq 0x2050
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
callq 0x21f0
cmpl $0x0, -0x1c(%rbp)
jne 0x2eea
jmp 0x2f2c
movl -0x4(%rbp), %edi
movq -0x18(%rbp), %rsi
movl -0x1c(%rbp), %eax
movl %eax, %edx
xorl %ecx, %ecx
callq 0x2110
movl -0x1c(%rbp), %ecx
cmpq %rcx, %rax
je 0x2f2c
callq 0x2040
movl (%rax), %edi
callq 0x20d0
movq %rax, %rsi
leaq 0x6135(%rip), %rdi      # 0x9050
movb $0x0, %al
callq 0x2050
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
callq 0x21f0
addq $0x60, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)
nopl (%rax)
// File: DavieV[P]virtual-usb-printer/usb_printer.cc
// Function: UsbPrinter::HandleUsbRequest(int, _USBIP_CMD_SUBMIT const&)
void UsbPrinter::HandleUsbRequest(int sockfd,
                                  const USBIP_CMD_SUBMIT& usb_request) {
  // Endpoint 0 is used for USB control requests.
  if (usb_request.ep == 0) {
    printf("# control requests\n");
    HandleUsbControl(sockfd, usb_request);
  } else {
    printf("# data requests\n");
  }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movq %rdx, -0x18(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x20(%rbp)
movq -0x18(%rbp), %rax
cmpl $0x0, 0x10(%rax)
jne 0x3aa5
leaq 0x5770(%rip), %rdi      # 0x91fc
movb $0x0, %al
callq 0x2050
movq -0x20(%rbp), %rdi
movl -0xc(%rbp), %esi
movq -0x18(%rbp), %rdx
callq 0x3ac0
jmp 0x3ab3
leaq 0x5764(%rip), %rdi      # 0x9210
movb $0x0, %al
callq 0x2050
addq $0x20, %rsp
popq %rbp
retq
nopl (%rax)
// File: DavieV[P]virtual-usb-printer/usb_printer.cc
// Function: UsbPrinter::HandleUsbControl(int, _USBIP_CMD_SUBMIT const&)
void UsbPrinter::HandleUsbControl(int sockfd,
                                  const USBIP_CMD_SUBMIT& usb_request) {
  StandardDeviceRequest control_request =
      CreateStandardDeviceRequest(usb_request.setup);
  print_standard_device_request(control_request);
  int request_type = GetControlType(control_request.bmRequestType);
  switch (request_type) {
    case STANDARD_TYPE:
      HandleStandardControl(sockfd, usb_request, control_request);
      break;
    case CLASS_TYPE:
      HandlePrinterControl(sockfd, usb_request, control_request);
      break;
    case VENDOR_TYPE:
    case RESERVED_TYPE:
    default:
      printf("Unable to handle request of type %d\n", request_type);
      break;
  }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movq %rdx, -0x18(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x30(%rbp)
movq -0x18(%rbp), %rax
movq 0x28(%rax), %rdi
callq 0x3b70
movq %rax, -0x20(%rbp)
leaq -0x20(%rbp), %rdi
callq 0x2c90
movzbl -0x20(%rbp), %edi
callq 0x3c20
movl %eax, -0x24(%rbp)
movl -0x24(%rbp), %eax
movl %eax, -0x28(%rbp)
testl %eax, %eax
je 0x3b24
jmp 0x3b0d
movl -0x28(%rbp), %eax
subl $0x1, %eax
je 0x3b3a
jmp 0x3b17
movl -0x28(%rbp), %eax
addl $-0x2, %eax
subl $0x2, %eax
jb 0x3b50
jmp 0x3b52
movq -0x30(%rbp), %rdi
movl -0xc(%rbp), %esi
movq -0x18(%rbp), %rdx
leaq -0x20(%rbp), %rcx
callq 0x3c40
jmp 0x3b63
movq -0x30(%rbp), %rdi
movl -0xc(%rbp), %esi
movq -0x18(%rbp), %rdx
leaq -0x20(%rbp), %rcx
callq 0x3cf0
jmp 0x3b63
jmp 0x3b52
movl -0x24(%rbp), %esi
leaq 0x56c5(%rip), %rdi      # 0x9221
movb $0x0, %al
callq 0x2050
addq $0x30, %rsp
popq %rbp
retq
nopl (%rax)
// File: DavieV[P]virtual-usb-printer/usb_printer.cc
// Function: (anonymous namespace)::CreateStandardDeviceRequest(long long)
StandardDeviceRequest CreateStandardDeviceRequest(long long setup) {
  StandardDeviceRequest request;
  request.bmRequestType = (setup & 0xFF00000000000000) >> 56;
  request.bRequest = (setup & 0x00FF000000000000) >> 48;
  request.wValue0 = (setup & 0x0000FF0000000000) >> 40;
  request.wValue1 = (setup & 0x000000FF00000000) >> 32;
  request.wIndex0 = (setup & 0x00000000FF000000) >> 24;
  request.wIndex1 = (setup & 0x0000000000FF0000) >> 16;
  request.wLength = ntohs(setup & 0x000000000000FFFF);
  return request;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x10, %rsp
movq %rdi, -0x10(%rbp)
movabsq $-0x100000000000000, %rax # imm = 0xFF00000000000000
andq -0x10(%rbp), %rax
shrq $0x38, %rax
movb %al, -0x8(%rbp)
movabsq $0xff000000000000, %rax # imm = 0xFF000000000000
andq -0x10(%rbp), %rax
sarq $0x30, %rax
movb %al, -0x7(%rbp)
movabsq $0xff0000000000, %rax   # imm = 0xFF0000000000
andq -0x10(%rbp), %rax
sarq $0x28, %rax
movb %al, -0x6(%rbp)
movabsq $0xff00000000, %rax     # imm = 0xFF00000000
andq -0x10(%rbp), %rax
sarq $0x20, %rax
movb %al, -0x5(%rbp)
movabsq $0xff000000, %rax       # imm = 0xFF000000
andq -0x10(%rbp), %rax
sarq $0x18, %rax
movb %al, -0x4(%rbp)
movq -0x10(%rbp), %rax
andq $0xff0000, %rax         # imm = 0xFF0000
sarq $0x10, %rax
movb %al, -0x3(%rbp)
movq -0x10(%rbp), %rax
andq $0xffff, %rax           # imm = 0xFFFF
movzwl %ax, %edi
callq 0x22a0
movw %ax, -0x2(%rbp)
movq -0x8(%rbp), %rax
addq $0x10, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)