// File: BelfordZ[P]SimpleFileServer/FrameSet.cpp
// Function: FrameSet::FrameSet(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&, bool)
FrameSet::FrameSet(const std::string& line, bool ravageFrames) {
   //make SYNC frame
   Frame syncFrm(SYNC, to_string(line.length()) );
   frames.push_back(syncFrm);
	
   // create vector of frames
   bool goodFrame;
   for (int i=0; i< line.length(); i+=62){
      //create a data frame class for data
      Frame* f = NULL;

      int badFrame = rand() % 5;

      if((badFrame == 3 || badFrame == 4) && ravageFrames) {
	 goodFrame = false;
	 std::cout << "Flipping bit!" << std::endl;
      } else {
	 goodFrame = true;
      }
      
      if(line.length() < 62) {
	 f = new Frame(DATA, line, goodFrame);
      } else {
	 f = new Frame (DATA, line.substr(i, 62), goodFrame);
      }	

      frames.push_back(*f);
      //int x;std::cin>>x;

   }

   
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x110, %rsp            # imm = 0x110
movb %dl, %al
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
andb $0x1, %al
movb %al, -0x11(%rbp)
movq -0x8(%rbp), %rdi
movq %rdi, -0xe8(%rbp)
movq %rdi, %rax
movq %rax, -0xf0(%rbp)
callq 0x8d00
movl $0x2, -0x64(%rbp)
movq -0x10(%rbp), %rdi
callq 0x3430
movq -0xe8(%rbp), %rsi
movl %eax, %edx
leaq -0x88(%rbp), %rdi
callq 0x8b20
jmp 0x881b
leaq -0x60(%rbp), %rdi
leaq -0x64(%rbp), %rsi
leaq -0x88(%rbp), %rdx
movl $0x1, %ecx
callq 0x7c40
jmp 0x8836
leaq -0x88(%rbp), %rdi
callq 0x3548
movq -0xf0(%rbp), %rdi
leaq -0x60(%rbp), %rsi
callq 0x8d20
jmp 0x8854
movl $0x0, -0x9c(%rbp)
movslq -0x9c(%rbp), %rax
movq %rax, -0xf8(%rbp)
movq -0x10(%rbp), %rdi
callq 0x3430
movq %rax, %rcx
movq -0xf8(%rbp), %rax
cmpq %rcx, %rax
jae 0x8ae8
movq $0x0, -0xa8(%rbp)
callq 0x30d0
movl $0x5, %ecx
cltd
idivl %ecx
movl %edx, -0xac(%rbp)
cmpl $0x3, -0xac(%rbp)
je 0x88bc
cmpl $0x4, -0xac(%rbp)
jne 0x8951
testb $0x1, -0x11(%rbp)
je 0x8951
movb $0x0, -0x95(%rbp)
movq 0x7704(%rip), %rdi      # 0xffd8
leaq 0x29ad(%rip), %rsi      # 0xb288
callq 0x32c0
movq %rax, -0x100(%rbp)
jmp 0x88e9
movq -0x100(%rbp), %rdi
movq 0x76c9(%rip), %rsi      # 0xffc0
callq 0x3310
jmp 0x88fe
jmp 0x8958
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x90(%rbp)
movl %eax, -0x94(%rbp)
jmp 0x8b03
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x90(%rbp)
movl %eax, -0x94(%rbp)
leaq -0x88(%rbp), %rdi
callq 0x3548
jmp 0x8b03
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x90(%rbp)
movl %eax, -0x94(%rbp)
jmp 0x8afa
movb $0x1, -0x95(%rbp)
movq -0x10(%rbp), %rdi
callq 0x3430
cmpq $0x3e, %rax
jae 0x89e2
movl $0x48, %edi
callq 0x32d0
movq %rax, -0x108(%rbp)
jmp 0x897a
movq -0x108(%rbp), %rdi
movl $0x4, -0xb0(%rbp)
movq -0x10(%rbp), %rdx
movzbl -0x95(%rbp), %ecx
andl $0x1, %ecx
leaq -0xb0(%rbp), %rsi
callq 0x7c40
jmp 0x89a7
movq -0x108(%rbp), %rax
movq %rax, -0xa8(%rbp)
jmp 0x8abd
movq -0x108(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x90(%rbp)
movl %eax, -0x94(%rbp)
movl $0x48, %esi
callq 0x32e0
jmp 0x8afa
movl $0x48, %edi
callq 0x32d0
movq %rax, -0x110(%rbp)
jmp 0x89f5
movb $0x1, -0xd9(%rbp)
movl $0x4, -0xb4(%rbp)
movq -0x10(%rbp), %rsi
movslq -0x9c(%rbp), %rdx
leaq -0xd8(%rbp), %rdi
movl $0x3e, %ecx
callq 0x3300
jmp 0x8a24
movq -0x110(%rbp), %rdi
movzbl -0x95(%rbp), %ecx
andl $0x1, %ecx
leaq -0xb4(%rbp), %rsi
leaq -0xd8(%rbp), %rdx
callq 0x7c40
jmp 0x8a4a
movq -0x110(%rbp), %rax
movb $0x0, -0xd9(%rbp)
movq %rax, -0xa8(%rbp)
leaq -0xd8(%rbp), %rdi
callq 0x3548
jmp 0x8abd
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x90(%rbp)
movl %eax, -0x94(%rbp)
jmp 0x8a9f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x90(%rbp)
movl %eax, -0x94(%rbp)
leaq -0xd8(%rbp), %rdi
callq 0x3548
testb $0x1, -0xd9(%rbp)
jne 0x8aaa
jmp 0x8abb
movq -0x110(%rbp), %rdi
movl $0x48, %esi
callq 0x32e0
jmp 0x8afa
movq -0xf0(%rbp), %rdi
movq -0xa8(%rbp), %rsi
callq 0x8d20
jmp 0x8ad2
jmp 0x8ad4
movl -0x9c(%rbp), %eax
addl $0x3e, %eax
movl %eax, -0x9c(%rbp)
jmp 0x885e
leaq -0x60(%rbp), %rdi
callq 0x5190
addq $0x110, %rsp            # imm = 0x110
popq %rbp
retq
leaq -0x60(%rbp), %rdi
callq 0x5190
movq -0xe8(%rbp), %rdi
callq 0x5b90
movq -0x90(%rbp), %rdi
callq 0x3490
nopl (%rax,%rax)