// File: VanAndelInstitute[P]intent/src/seq_tools.cpp
// Function: format_barcode(ParsedBarcode, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, int)
FastqRead format_barcode(ParsedBarcode bc, 
                         std::string id, 
                         std::string direction,
                         int format) {
  FastqRead read;
  int length = bc.barcode1.length();
  if(format == FORMAT_V2) {
      read.read = bc.barcode2 + 
                  bc.barcode1.substr(length - 8) + 
                  bc.barcode2.substr(4,4) + bc.UMI;
      read.quality = bc.barcode2_quality + 
                     bc.barcode1_quality.substr(length - 8) +
                     bc.barcode2_quality.substr(4,4) + bc.UMI_quality;
      read.direction = direction;
      read.id = id;
  } else if(format == FORMAT_V3) {
      read.read = bc.barcode2 + 
                  bc.barcode1.substr(length - 8) + 
                  bc.barcode2.substr(2,6) + bc.UMI;
      read.quality = bc.barcode2_quality + 
                     bc.barcode1_quality.substr(length - 8) +
                     bc.barcode2_quality.substr(2,6) + bc.UMI_quality;
      read.direction = direction;
      read.id = id;
  } else if(format == FORMAT_EXTENDED) {
      std::string cb1 = bc.barcode1;
      std::string cb1_q = bc.barcode1_quality;
      if(cb1.length() < 12) {
              cb1.insert(cb1.begin(), 12 - cb1.length(), 'G');
              cb1_q.insert(cb1_q.begin(), 12 - cb1_q.length(), 'A');
      }
      read.read = cb1 + 
                  bc.barcode2 + 
                  bc.barcode2 +
                  bc.UMI;
      read.quality =cb1_q + 
                  bc.barcode2_quality + 
                  bc.barcode2_quality +
                  bc.UMI_quality;
      read.direction = direction;
      read.id = id;
  } else {
    std::cout << "Bad barcode format specified\n\n";
    exit(0);
  }
  return(read);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x490, %rsp            # imm = 0x490
movq %rcx, -0x418(%rbp)
movq %rdx, -0x410(%rbp)
movq %rsi, -0x3f8(%rbp)
movq %rdi, -0x408(%rbp)
movq %rdi, %rax
movq %rax, -0x400(%rbp)
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movl %r8d, -0x24(%rbp)
movb $0x0, -0x25(%rbp)
callq 0x6c7b0
movq -0x3f8(%rbp), %rdi
addq $0x8, %rdi
callq 0x8850
movl %eax, -0x2c(%rbp)
cmpl $0x0, -0x24(%rbp)
jne 0x6bbb3
movq -0x3f8(%rbp), %rsi
movq %rsi, %rax
addq $0x48, %rax
movq %rax, -0x420(%rbp)
addq $0x8, %rsi
movl -0x2c(%rbp), %eax
addl $-0x8, %eax
movslq %eax, %rdx
leaq -0xb0(%rbp), %rdi
movq $-0x1, %rcx
callq 0x8590
jmp 0x6b892
movq -0x420(%rbp), %rsi
leaq -0x90(%rbp), %rdi
leaq -0xb0(%rbp), %rdx
callq 0x6c920
jmp 0x6b8ae
movq -0x3f8(%rbp), %rsi
addq $0x48, %rsi
leaq -0xe0(%rbp), %rdi
movl $0x4, %ecx
movq %rcx, %rdx
callq 0x8590
jmp 0x6b8cf
leaq -0x70(%rbp), %rdi
leaq -0x90(%rbp), %rsi
leaq -0xe0(%rbp), %rdx
callq 0x38990
jmp 0x6b8e8
movq -0x3f8(%rbp), %rdx
addq $0x88, %rdx
leaq -0x50(%rbp), %rdi
leaq -0x70(%rbp), %rsi
callq 0x38850
jmp 0x6b905
movq -0x408(%rbp), %rdi
addq $0x20, %rdi
leaq -0x50(%rbp), %rsi
movq %rsi, -0x430(%rbp)
callq 0x86c0
movq -0x430(%rbp), %rdi
callq 0x8a98
leaq -0x70(%rbp), %rdi
callq 0x8a98
leaq -0xe0(%rbp), %rdi
callq 0x8a98
leaq -0x90(%rbp), %rdi
callq 0x8a98
leaq -0xb0(%rbp), %rdi
callq 0x8a98
movq -0x3f8(%rbp), %rsi
movq %rsi, %rax
addq $0x68, %rax
movq %rax, -0x428(%rbp)
addq $0x28, %rsi
movl -0x2c(%rbp), %eax
addl $-0x8, %eax
movslq %eax, %rdx
leaq -0x160(%rbp), %rdi
movq $-0x1, %rcx
callq 0x8590
jmp 0x6b990
movq -0x428(%rbp), %rsi
leaq -0x140(%rbp), %rdi
leaq -0x160(%rbp), %rdx
callq 0x6c920
jmp 0x6b9ac
movq -0x3f8(%rbp), %rsi
addq $0x68, %rsi
leaq -0x180(%rbp), %rdi
movl $0x4, %ecx
movq %rcx, %rdx
callq 0x8590
jmp 0x6b9cd
leaq -0x120(%rbp), %rdi
leaq -0x140(%rbp), %rsi
leaq -0x180(%rbp), %rdx
callq 0x38990
jmp 0x6b9e9
movq -0x3f8(%rbp), %rdx
addq $0xa8, %rdx
leaq -0x100(%rbp), %rdi
leaq -0x120(%rbp), %rsi
callq 0x38850
jmp 0x6ba0c
movq -0x408(%rbp), %rdi
addq $0x60, %rdi
leaq -0x100(%rbp), %rsi
movq %rsi, -0x438(%rbp)
callq 0x86c0
movq -0x438(%rbp), %rdi
callq 0x8a98
leaq -0x120(%rbp), %rdi
callq 0x8a98
leaq -0x180(%rbp), %rdi
callq 0x8a98
leaq -0x140(%rbp), %rdi
callq 0x8a98
leaq -0x160(%rbp), %rdi
callq 0x8a98
movq -0x408(%rbp), %rdi
movq -0x418(%rbp), %rsi
addq $0x40, %rdi
callq 0x8070
jmp 0x6ba7f
movq -0x410(%rbp), %rsi
movq -0x408(%rbp), %rdi
callq 0x8070
jmp 0x6ba94
jmp 0x6c2c3
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xb8(%rbp)
movl %eax, -0xbc(%rbp)
jmp 0x6c2e9
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xb8(%rbp)
movl %eax, -0xbc(%rbp)
jmp 0x6bb1f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xb8(%rbp)
movl %eax, -0xbc(%rbp)
jmp 0x6bb13
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xb8(%rbp)
movl %eax, -0xbc(%rbp)
jmp 0x6bb07
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xb8(%rbp)
movl %eax, -0xbc(%rbp)
leaq -0x70(%rbp), %rdi
callq 0x8a98
leaq -0xe0(%rbp), %rdi
callq 0x8a98
leaq -0x90(%rbp), %rdi
callq 0x8a98
leaq -0xb0(%rbp), %rdi
callq 0x8a98
jmp 0x6c2e9
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xb8(%rbp)
movl %eax, -0xbc(%rbp)
jmp 0x6bba2
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xb8(%rbp)
movl %eax, -0xbc(%rbp)
jmp 0x6bb96
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xb8(%rbp)
movl %eax, -0xbc(%rbp)
jmp 0x6bb8a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xb8(%rbp)
movl %eax, -0xbc(%rbp)
leaq -0x120(%rbp), %rdi
callq 0x8a98
leaq -0x180(%rbp), %rdi
callq 0x8a98
leaq -0x140(%rbp), %rdi
callq 0x8a98
leaq -0x160(%rbp), %rdi
callq 0x8a98
jmp 0x6c2e9
cmpl $0x1, -0x24(%rbp)
jne 0x6bf14
movq -0x3f8(%rbp), %rsi
movq %rsi, %rax
addq $0x48, %rax
movq %rax, -0x440(%rbp)
addq $0x8, %rsi
movl -0x2c(%rbp), %eax
addl $-0x8, %eax
movslq %eax, %rdx
leaq -0x200(%rbp), %rdi
movq $-0x1, %rcx
callq 0x8590
jmp 0x6bbf4
movq -0x440(%rbp), %rsi
leaq -0x1e0(%rbp), %rdi
leaq -0x200(%rbp), %rdx
callq 0x6c920
jmp 0x6bc10
movq -0x3f8(%rbp), %rsi
addq $0x48, %rsi
leaq -0x220(%rbp), %rdi
movl $0x2, %edx
movl $0x6, %ecx
callq 0x8590
jmp 0x6bc33
leaq -0x1c0(%rbp), %rdi
leaq -0x1e0(%rbp), %rsi
leaq -0x220(%rbp), %rdx
callq 0x38990
jmp 0x6bc4f
movq -0x3f8(%rbp), %rdx
addq $0x88, %rdx
leaq -0x1a0(%rbp), %rdi
leaq -0x1c0(%rbp), %rsi
callq 0x38850
jmp 0x6bc72
movq -0x408(%rbp), %rdi
addq $0x20, %rdi
leaq -0x1a0(%rbp), %rsi
movq %rsi, -0x450(%rbp)
callq 0x86c0
movq -0x450(%rbp), %rdi
callq 0x8a98
leaq -0x1c0(%rbp), %rdi
callq 0x8a98
leaq -0x220(%rbp), %rdi
callq 0x8a98
leaq -0x1e0(%rbp), %rdi
callq 0x8a98
leaq -0x200(%rbp), %rdi
callq 0x8a98
movq -0x3f8(%rbp), %rsi
movq %rsi, %rax
addq $0x68, %rax
movq %rax, -0x448(%rbp)
addq $0x28, %rsi
movl -0x2c(%rbp), %eax
addl $-0x8, %eax
movslq %eax, %rdx
leaq -0x2a0(%rbp), %rdi
movq $-0x1, %rcx
callq 0x8590
jmp 0x6bd03
movq -0x448(%rbp), %rsi
leaq -0x280(%rbp), %rdi
leaq -0x2a0(%rbp), %rdx
callq 0x6c920
jmp 0x6bd1f
movq -0x3f8(%rbp), %rsi
addq $0x68, %rsi
leaq -0x2c0(%rbp), %rdi
movl $0x2, %edx
movl $0x6, %ecx
callq 0x8590
jmp 0x6bd42
leaq -0x260(%rbp), %rdi
leaq -0x280(%rbp), %rsi
leaq -0x2c0(%rbp), %rdx
callq 0x38990
jmp 0x6bd5e
movq -0x3f8(%rbp), %rdx
addq $0xa8, %rdx
leaq -0x240(%rbp), %rdi
leaq -0x260(%rbp), %rsi
callq 0x38850
jmp 0x6bd81
movq -0x408(%rbp), %rdi
addq $0x60, %rdi
leaq -0x240(%rbp), %rsi
movq %rsi, -0x458(%rbp)
callq 0x86c0
movq -0x458(%rbp), %rdi
callq 0x8a98
leaq -0x260(%rbp), %rdi
callq 0x8a98
leaq -0x2c0(%rbp), %rdi
callq 0x8a98
leaq -0x280(%rbp), %rdi
callq 0x8a98
leaq -0x2a0(%rbp), %rdi
callq 0x8a98
movq -0x408(%rbp), %rdi
movq -0x418(%rbp), %rsi
addq $0x40, %rdi
callq 0x8070
jmp 0x6bdf4
movq -0x410(%rbp), %rsi
movq -0x408(%rbp), %rdi
callq 0x8070
jmp 0x6be09
jmp 0x6c2c1
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xb8(%rbp)
movl %eax, -0xbc(%rbp)
jmp 0x6be80
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xb8(%rbp)
movl %eax, -0xbc(%rbp)
jmp 0x6be74
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xb8(%rbp)
movl %eax, -0xbc(%rbp)
jmp 0x6be68
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xb8(%rbp)
movl %eax, -0xbc(%rbp)
leaq -0x1c0(%rbp), %rdi
callq 0x8a98
leaq -0x220(%rbp), %rdi
callq 0x8a98
leaq -0x1e0(%rbp), %rdi
callq 0x8a98
leaq -0x200(%rbp), %rdi
callq 0x8a98
jmp 0x6c2e9
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xb8(%rbp)
movl %eax, -0xbc(%rbp)
jmp 0x6bf03
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xb8(%rbp)
movl %eax, -0xbc(%rbp)
jmp 0x6bef7
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xb8(%rbp)
movl %eax, -0xbc(%rbp)
jmp 0x6beeb
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xb8(%rbp)
movl %eax, -0xbc(%rbp)
leaq -0x260(%rbp), %rdi
callq 0x8a98
leaq -0x2c0(%rbp), %rdi
callq 0x8a98
leaq -0x280(%rbp), %rdi
callq 0x8a98
leaq -0x2a0(%rbp), %rdi
callq 0x8a98
jmp 0x6c2e9
cmpl $0x2, -0x24(%rbp)
jne 0x6c2a3
movq -0x3f8(%rbp), %rsi
addq $0x8, %rsi
leaq -0x2e0(%rbp), %rdi
callq 0x8280
jmp 0x6bf37
movq -0x3f8(%rbp), %rsi
addq $0x28, %rsi
leaq -0x300(%rbp), %rdi
callq 0x8280
jmp 0x6bf50
leaq -0x2e0(%rbp), %rdi
callq 0x8850
cmpq $0xc, %rax
jae 0x6c076
leaq -0x2e0(%rbp), %rdi
movq %rdi, -0x468(%rbp)
callq 0x84c0
movq %rax, -0x310(%rbp)
leaq -0x308(%rbp), %rdi
leaq -0x310(%rbp), %rsi
callq 0x6c380
movq -0x468(%rbp), %rdi
callq 0x8850
movq -0x468(%rbp), %rdi
movl $0xc, %edx
subq %rax, %rdx
movq -0x308(%rbp), %rsi
movl $0x47, %ecx
callq 0x86e0
movq %rax, -0x460(%rbp)
jmp 0x6bfc8
movq -0x460(%rbp), %rax
movq %rax, -0x318(%rbp)
leaq -0x300(%rbp), %rdi
movq %rdi, -0x478(%rbp)
callq 0x84c0
movq %rax, -0x328(%rbp)
leaq -0x320(%rbp), %rdi
leaq -0x328(%rbp), %rsi
callq 0x6c380
movq -0x478(%rbp), %rdi
callq 0x8850
movq -0x478(%rbp), %rdi
movl $0xc, %edx
subq %rax, %rdx
movq -0x320(%rbp), %rsi
movl $0x41, %ecx
callq 0x86e0
movq %rax, -0x470(%rbp)
jmp 0x6c038
movq -0x470(%rbp), %rax
movq %rax, -0x330(%rbp)
jmp 0x6c076
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xb8(%rbp)
movl %eax, -0xbc(%rbp)
jmp 0x6c295
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xb8(%rbp)
movl %eax, -0xbc(%rbp)
jmp 0x6c289
movq -0x3f8(%rbp), %rdx
addq $0x48, %rdx
leaq -0x390(%rbp), %rdi
leaq -0x2e0(%rbp), %rsi
callq 0x6c970
jmp 0x6c096
movq -0x3f8(%rbp), %rdx
addq $0x48, %rdx
leaq -0x370(%rbp), %rdi
leaq -0x390(%rbp), %rsi
callq 0x38850
jmp 0x6c0b6
movq -0x3f8(%rbp), %rdx
addq $0x88, %rdx
leaq -0x350(%rbp), %rdi
leaq -0x370(%rbp), %rsi
callq 0x38850
jmp 0x6c0d9
movq -0x408(%rbp), %rdi
addq $0x20, %rdi
leaq -0x350(%rbp), %rsi
movq %rsi, -0x480(%rbp)
callq 0x86c0
movq -0x480(%rbp), %rdi
callq 0x8a98
leaq -0x370(%rbp), %rdi
callq 0x8a98
leaq -0x390(%rbp), %rdi
callq 0x8a98
movq -0x3f8(%rbp), %rdx
addq $0x68, %rdx
leaq -0x3f0(%rbp), %rdi
leaq -0x300(%rbp), %rsi
callq 0x6c970
jmp 0x6c13b
movq -0x3f8(%rbp), %rdx
addq $0x68, %rdx
leaq -0x3d0(%rbp), %rdi
leaq -0x3f0(%rbp), %rsi
callq 0x38850
jmp 0x6c15b
movq -0x3f8(%rbp), %rdx
addq $0xa8, %rdx
leaq -0x3b0(%rbp), %rdi
leaq -0x3d0(%rbp), %rsi
callq 0x38850
jmp 0x6c17e
movq -0x408(%rbp), %rdi
addq $0x60, %rdi
leaq -0x3b0(%rbp), %rsi
movq %rsi, -0x488(%rbp)
callq 0x86c0
movq -0x488(%rbp), %rdi
callq 0x8a98
leaq -0x3d0(%rbp), %rdi
callq 0x8a98
leaq -0x3f0(%rbp), %rdi
callq 0x8a98
movq -0x408(%rbp), %rdi
movq -0x418(%rbp), %rsi
addq $0x40, %rdi
callq 0x8070
jmp 0x6c1d9
movq -0x410(%rbp), %rsi
movq -0x408(%rbp), %rdi
callq 0x8070
jmp 0x6c1ee
leaq -0x300(%rbp), %rdi
callq 0x8a98
leaq -0x2e0(%rbp), %rdi
callq 0x8a98
jmp 0x6c2bf
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xb8(%rbp)
movl %eax, -0xbc(%rbp)
jmp 0x6c23d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xb8(%rbp)
movl %eax, -0xbc(%rbp)
leaq -0x370(%rbp), %rdi
callq 0x8a98
leaq -0x390(%rbp), %rdi
callq 0x8a98
jmp 0x6c289
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xb8(%rbp)
movl %eax, -0xbc(%rbp)
jmp 0x6c27d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xb8(%rbp)
movl %eax, -0xbc(%rbp)
leaq -0x3d0(%rbp), %rdi
callq 0x8a98
leaq -0x3f0(%rbp), %rdi
callq 0x8a98
leaq -0x300(%rbp), %rdi
callq 0x8a98
leaq -0x2e0(%rbp), %rdi
callq 0x8a98
jmp 0x6c2e9
movq 0x21d0e(%rip), %rdi     # 0x8dfb8
leaq 0x44d3(%rip), %rsi      # 0x70784
callq 0x8540
jmp 0x6c2b8
xorl %edi, %edi
callq 0x86b0
jmp 0x6c2c1
jmp 0x6c2c3
movb $0x1, -0x25(%rbp)
testb $0x1, -0x25(%rbp)
jne 0x6c2d9
movq -0x408(%rbp), %rdi
callq 0x36ad0
movq -0x400(%rbp), %rax
addq $0x490, %rsp            # imm = 0x490
popq %rbp
retq
movq -0x408(%rbp), %rdi
callq 0x36ad0
movq -0xb8(%rbp), %rdi
callq 0x8970
nopw %cs:(%rax,%rax)
nopl (%rax,%rax)