// File: mattdibi[P]Programmatore-JTAG-per-Xilinx/main.cpp
// Function: ExtractInstruction[abi:cxx11](std::basic_ifstream<char, std::char_traits<char>>&)
vector<string> ExtractInstruction(ifstream& is)
{
   vector<string> instruction;
   char ch;
   int n=0;

   while(is.good()&&!is.eof())
   {
      n=0;
      string s="";

      ch=is.get();

      if(ch==EOF)
            continue;
      else if(ch=='/') // se è un commento ignoriamo tutto
      {
            is.ignore(100, '\n');
            continue;
      }
      else
      {
            // raccolgo i caratteri della riga finchè non incontro un \n o raggiungo la massima lunghezza della istruzione permessa
            do
            {
                  n++;
                  s+=ch;
                  ch=is.get();
            }while(ch != '\n' && n < INSTR_LENGTH);

            // se raggiungo la massima lunghezza della istruzione inserisco un \n come carattere finale
            if(n >= INSTR_LENGTH)
            {
                  s+=ch;
                  s+='\n';
            }
            
            // carico nel vettore la stringa così costruita
            instruction.push_back(s);
      }
   }
   
   return instruction;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x80, %rsp
movq %rdi, -0x60(%rbp)
movq %rdi, %rax
movq %rax, -0x58(%rbp)
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movb $0x0, -0x11(%rbp)
callq 0x5560
movl $0x0, -0x18(%rbp)
movq -0x10(%rbp), %rdi
movq (%rdi), %rax
movq -0x18(%rax), %rax
addq %rax, %rdi
callq 0x3470
movb %al, -0x61(%rbp)
jmp 0x4ce6
movb -0x61(%rbp), %cl
xorl %eax, %eax
testb $0x1, %cl
movb %al, -0x62(%rbp)
jne 0x4cf5
jmp 0x4d15
movq -0x10(%rbp), %rdi
movq (%rdi), %rax
movq -0x18(%rax), %rax
addq %rax, %rdi
callq 0x34f0
movb %al, -0x63(%rbp)
jmp 0x4d0d
movb -0x63(%rbp), %al
xorb $-0x1, %al
movb %al, -0x62(%rbp)
movb -0x62(%rbp), %al
testb $0x1, %al
jne 0x4d21
jmp 0x4e9b
movl $0x0, -0x18(%rbp)
leaq -0x49(%rbp), %rdi
movq %rdi, -0x70(%rbp)
callq 0x34b0
movq -0x70(%rbp), %rdx
leaq 0x5323(%rip), %rsi      # 0xa063
leaq -0x48(%rbp), %rdi
callq 0x54b0
jmp 0x4d4b
leaq -0x49(%rbp), %rdi
callq 0x32e0
movq -0x10(%rbp), %rdi
callq 0x3330
movl %eax, -0x74(%rbp)
jmp 0x4d62
movl -0x74(%rbp), %eax
movb %al, -0x12(%rbp)
movsbl -0x12(%rbp), %eax
cmpl $-0x1, %eax
jne 0x4dc2
movl $0x2, -0x50(%rbp)
jmp 0x4e7f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x20(%rbp)
movl %eax, -0x24(%rbp)
jmp 0x4ec2
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x20(%rbp)
movl %eax, -0x24(%rbp)
leaq -0x49(%rbp), %rdi
callq 0x32e0
jmp 0x4ec2
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x20(%rbp)
movl %eax, -0x24(%rbp)
leaq -0x48(%rbp), %rdi
callq 0x3190
jmp 0x4ec2
movsbl -0x12(%rbp), %eax
cmpl $0x2f, %eax
jne 0x4dec
movq -0x10(%rbp), %rdi
movl $0x64, %esi
movl $0xa, %edx
callq 0x31b0
jmp 0x4de0
movl $0x2, -0x50(%rbp)
jmp 0x4e7f
jmp 0x4dee
movl -0x18(%rbp), %eax
incl %eax
movl %eax, -0x18(%rbp)
movsbl -0x12(%rbp), %esi
leaq -0x48(%rbp), %rdi
callq 0x31a0
jmp 0x4e05
movq -0x10(%rbp), %rdi
callq 0x3330
movl %eax, -0x78(%rbp)
jmp 0x4e13
movl -0x78(%rbp), %eax
movb %al, -0x12(%rbp)
movsbl -0x12(%rbp), %ecx
xorl %eax, %eax
cmpl $0xa, %ecx
movb %al, -0x79(%rbp)
je 0x4e34
cmpl $0xfa, -0x18(%rbp)
setl %al
movb %al, -0x79(%rbp)
movb -0x79(%rbp), %al
testb $0x1, %al
jne 0x4dee
cmpl $0xfa, -0x18(%rbp)
jl 0x4e65
movsbl -0x12(%rbp), %esi
leaq -0x48(%rbp), %rdi
callq 0x31a0
jmp 0x4e53
leaq -0x48(%rbp), %rdi
movl $0xa, %esi
callq 0x31a0
jmp 0x4e63
jmp 0x4e65
movq -0x60(%rbp), %rdi
leaq -0x48(%rbp), %rsi
callq 0x5780
jmp 0x4e74
jmp 0x4e76
jmp 0x4e78
movl $0x0, -0x50(%rbp)
leaq -0x48(%rbp), %rdi
callq 0x3190
movl -0x50(%rbp), %eax
testl %eax, %eax
je 0x4e96
jmp 0x4e91
jmp 0x4cce
jmp 0x4cce
movb $0x1, -0x11(%rbp)
movl $0x1, -0x50(%rbp)
testb $0x1, -0x11(%rbp)
jne 0x4eb5
movq -0x60(%rbp), %rdi
callq 0x55e0
movq -0x58(%rbp), %rax
addq $0x80, %rsp
popq %rbp
retq
movq -0x60(%rbp), %rdi
callq 0x55e0
movq -0x20(%rbp), %rdi
callq 0x34a0
nopw %cs:(%rax,%rax)