// File: mattdibi[P]Programmatore-JTAG-per-Xilinx/main.cpp
// Function: ExtractBitstream(std::vector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>>>, long)
vector<string> ExtractBitstream(vector<string> instructionsFile, long int currentIndex)
{
      vector<string> stream;
      string tmp, tmp2;
      int i = 0, k = 0;

      // Prima riga: ignoro tutto ciò che viene prima delle parentesi
      while(instructionsFile[currentIndex][i] != '(')
      {
            i++;
      }

      i++;

      // Arrivato alla parentesi prendo tutto
      while(instructionsFile[currentIndex][i] != '\n' && instructionsFile[currentIndex][i] != '\r')
      {
            tmp += instructionsFile[currentIndex][i];
            i++;
      }

      stream.push_back(tmp);

      currentIndex++;

      // Immetto righe finchè l'ultimo carattere di una riga è ')' si noti che così viene caricata anche l'SMASK
      while(instructionsFile[currentIndex][instructionsFile[currentIndex].size() - 4] != ')')
      {
            stream.push_back(instructionsFile[currentIndex]);
            currentIndex++;
      }

      // Immetto ultima riga fino al carattere di ')'
      while(instructionsFile[currentIndex][k] != ')')
      {
            tmp2 += instructionsFile[currentIndex][k];
            k++;
      }

      stream.push_back(tmp2);

      return stream;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xe0, %rsp
movq %rsi, -0x90(%rbp)
movq %rdi, -0x88(%rbp)
movq %rdi, %rax
movq %rax, -0x80(%rbp)
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movb $0x0, -0x19(%rbp)
callq 0x5560
leaq -0x40(%rbp), %rdi
callq 0x33a0
leaq -0x60(%rbp), %rdi
callq 0x33a0
movl $0x0, -0x64(%rbp)
movl $0x0, -0x68(%rbp)
movq -0x90(%rbp), %rdi
movq -0x18(%rbp), %rsi
callq 0x5660
movq %rax, %rdi
movslq -0x64(%rbp), %rsi
callq 0x3540
movq %rax, -0x98(%rbp)
jmp 0x50ca
movq -0x98(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x28, %eax
je 0x5113
movl -0x64(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x64(%rbp)
jmp 0x50a5
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x70(%rbp)
movl %eax, -0x74(%rbp)
leaq -0x60(%rbp), %rdi
callq 0x3190
leaq -0x40(%rbp), %rdi
callq 0x3190
movq -0x88(%rbp), %rdi
callq 0x55e0
jmp 0x5353
movl -0x64(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x64(%rbp)
movq -0x90(%rbp), %rdi
movq -0x18(%rbp), %rsi
callq 0x5660
movq %rax, %rdi
movslq -0x64(%rbp), %rsi
callq 0x3540
movq %rax, -0xa0(%rbp)
jmp 0x5141
movq -0xa0(%rbp), %rax
movsbl (%rax), %ecx
xorl %eax, %eax
cmpl $0xa, %ecx
movb %al, -0xa1(%rbp)
je 0x5193
movq -0x90(%rbp), %rdi
movq -0x18(%rbp), %rsi
callq 0x5660
movq %rax, %rdi
movslq -0x64(%rbp), %rsi
callq 0x3540
movq %rax, -0xb0(%rbp)
jmp 0x517d
movq -0xb0(%rbp), %rax
movsbl (%rax), %eax
cmpl $0xd, %eax
setne %al
movb %al, -0xa1(%rbp)
movb -0xa1(%rbp), %al
testb $0x1, %al
jne 0x519f
jmp 0x51e7
movq -0x90(%rbp), %rdi
movq -0x18(%rbp), %rsi
callq 0x5660
movq %rax, %rdi
movslq -0x64(%rbp), %rsi
callq 0x3540
movq %rax, -0xb8(%rbp)
jmp 0x51c4
movq -0xb8(%rbp), %rax
movsbl (%rax), %esi
leaq -0x40(%rbp), %rdi
callq 0x31a0
jmp 0x51d9
movl -0x64(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x64(%rbp)
jmp 0x511c
movq -0x88(%rbp), %rdi
leaq -0x40(%rbp), %rsi
callq 0x5780
jmp 0x51f9
movq -0x18(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x18(%rbp)
movq -0x90(%rbp), %rdi
movq -0x18(%rbp), %rsi
callq 0x5660
movq -0x90(%rbp), %rdi
movq %rax, -0xc8(%rbp)
movq -0x18(%rbp), %rsi
callq 0x5660
movq %rax, %rdi
callq 0x31d0
movq -0xc8(%rbp), %rdi
movq %rax, %rsi
addq $-0x4, %rsi
callq 0x3540
movq %rax, -0xc0(%rbp)
jmp 0x5250
movq -0xc0(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x29, %eax
je 0x5291
movq -0x90(%rbp), %rdi
movq -0x18(%rbp), %rsi
callq 0x5660
movq -0x88(%rbp), %rdi
movq %rax, %rsi
callq 0x5780
jmp 0x5280
movq -0x18(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x18(%rbp)
jmp 0x5205
jmp 0x5293
movq -0x90(%rbp), %rdi
movq -0x18(%rbp), %rsi
callq 0x5660
movq %rax, %rdi
movslq -0x68(%rbp), %rsi
callq 0x3540
movq %rax, -0xd0(%rbp)
jmp 0x52b8
movq -0xd0(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x29, %eax
je 0x530c
movq -0x90(%rbp), %rdi
movq -0x18(%rbp), %rsi
callq 0x5660
movq %rax, %rdi
movslq -0x68(%rbp), %rsi
callq 0x3540
movq %rax, -0xd8(%rbp)
jmp 0x52ec
movq -0xd8(%rbp), %rax
movsbl (%rax), %esi
leaq -0x60(%rbp), %rdi
callq 0x31a0
jmp 0x5301
movl -0x68(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x68(%rbp)
jmp 0x5293
movq -0x88(%rbp), %rdi
leaq -0x60(%rbp), %rsi
callq 0x5780
jmp 0x531e
movb $0x1, -0x19(%rbp)
leaq -0x60(%rbp), %rdi
callq 0x3190
leaq -0x40(%rbp), %rdi
callq 0x3190
testb $0x1, -0x19(%rbp)
jne 0x5346
movq -0x88(%rbp), %rdi
callq 0x55e0
movq -0x80(%rbp), %rax
addq $0xe0, %rsp
popq %rbp
retq
movq -0x70(%rbp), %rdi
callq 0x34a0
nopl (%rax)