// File: AlgoLab[P]bwt-lcp-parallel/bwt_lcp.cpp
// Function: compute_partial_BWT(unsigned char, unsigned int, 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>>>> const&, 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>>>> const&)
void compute_partial_BWT(
    const strlen_t k, const strnum_t m,
    const fnames_t& S_tpl,
    const fnames_t& B_tpl
) {
  const fnames_t N_tpl[] = {
    template_generator("supportfile-N0_%d.tmp", 0, ALPHSIZE),
    template_generator("supportfile-N1_%d.tmp", 0, ALPHSIZE),
  };
  { // B0 (and N0)
    copy_file(S_tpl[0], B_tpl[0]);
    multi_strnum_writer_t N0(N_tpl[0]);
    for (strnum_t i = 0; i < m; ++i) {
      N0.write(0, i);
    }
  }
  { // B1...Bk
    for (strlen_t l = 1; l <= k; ++l) {
      {
        enc_fasta_reader_t Bl1(B_tpl[l-1]);
        multi_strnum_reader_t Nl1(N_tpl[(l + 1) % 2]);
        multi_strnum_writer_t Nl(N_tpl[l % 2]);
        for (strnum_t i = 0; i < m; ++i) {
          Nl.write(Bl1.read(), Nl1.read());
        }
      }
      {
        enc_fasta_rnd_reader_t Sl(S_tpl[l], m);
        multi_strnum_reader_t Nl(N_tpl[l % 2]);
        enc_fasta_writer_t Bl(B_tpl[l]);
        for (strnum_t i = 0; i < m; ++i) {
          const strnum_t Nli = Nl.read();
          const enc_nucl_t SlNli = Sl.read(Nli);
          Bl.write(SlNli);
        }
      }
    }
  }
  // Cleaning
  remove_files(N_tpl[0]);
  remove_files(N_tpl[1]);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x280, %rsp            # imm = 0x280
movb %dil, %al
movb %al, -0x1(%rbp)
movl %esi, -0x8(%rbp)
movq %rdx, -0x10(%rbp)
movq %rcx, -0x18(%rbp)
movb $0x1, -0xb2(%rbp)
leaq -0x50(%rbp), %rax
movq %rax, -0x58(%rbp)
leaq -0x79(%rbp), %rdi
movq %rdi, -0x200(%rbp)
callq 0x3490
movq -0x200(%rbp), %rdx
leaq 0x156bf(%rip), %rsi     # 0x19018
leaq -0x78(%rbp), %rdi
callq 0x7fd0
jmp 0x3964
leaq -0x50(%rbp), %rdi
leaq -0x78(%rbp), %rsi
xorl %edx, %edx
movl $0x6, %ecx
callq 0x3650
jmp 0x397a
leaq -0x38(%rbp), %rax
movq %rax, -0x210(%rbp)
movq %rax, -0x58(%rbp)
leaq -0xb1(%rbp), %rdi
movq %rdi, -0x208(%rbp)
callq 0x3490
movq -0x208(%rbp), %rdx
leaq 0x15684(%rip), %rsi     # 0x1902e
leaq -0xb0(%rbp), %rdi
callq 0x7fd0
jmp 0x39b8
movq -0x210(%rbp), %rdi
leaq -0xb0(%rbp), %rsi
xorl %edx, %edx
movl $0x6, %ecx
callq 0x3650
jmp 0x39d4
movb $0x0, -0xb2(%rbp)
leaq -0xb0(%rbp), %rdi
callq 0x3170
leaq -0xb1(%rbp), %rdi
callq 0x3300
leaq -0x78(%rbp), %rdi
callq 0x3170
leaq -0x79(%rbp), %rdi
callq 0x3300
movq -0x10(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
movq %rsi, -0x220(%rbp)
callq 0x8080
movq -0x220(%rbp), %rsi
movq %rax, -0x218(%rbp)
movq -0x18(%rbp), %rdi
callq 0x8080
movq -0x218(%rbp), %rdi
movq %rax, %rsi
callq 0x3710
jmp 0x3a41
leaq 0x155fc(%rip), %rdx     # 0x19044
leaq -0xf0(%rbp), %rdi
leaq -0x50(%rbp), %rsi
callq 0x80a0
jmp 0x3a5a
movl $0x0, -0xf4(%rbp)
movl -0xf4(%rbp), %eax
cmpl -0x8(%rbp), %eax
jae 0x3ba2
movl -0xf4(%rbp), %edx
leaq -0xf0(%rbp), %rdi
xorl %esi, %esi
callq 0x8120
jmp 0x3a89
jmp 0x3a8b
movl -0xf4(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xf4(%rbp)
jmp 0x3a64
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x88(%rbp)
movl %eax, -0x8c(%rbp)
jmp 0x3b0b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x88(%rbp)
movl %eax, -0x8c(%rbp)
jmp 0x3b02
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x88(%rbp)
movl %eax, -0x8c(%rbp)
jmp 0x3af6
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x88(%rbp)
movl %eax, -0x8c(%rbp)
leaq -0xb0(%rbp), %rdi
callq 0x3170
leaq -0xb1(%rbp), %rdi
callq 0x3300
leaq -0x78(%rbp), %rdi
callq 0x3170
leaq -0x79(%rbp), %rdi
callq 0x3300
testb $0x1, -0xb2(%rbp)
jne 0x3b1f
jmp 0x3b63
movq -0x58(%rbp), %rax
leaq -0x50(%rbp), %rcx
cmpq %rax, %rcx
movq %rax, -0x228(%rbp)
je 0x3b61
movq -0x228(%rbp), %rdi
addq $-0x18, %rdi
movq %rdi, -0x230(%rbp)
callq 0x7e90
movq -0x230(%rbp), %rax
leaq -0x50(%rbp), %rcx
cmpq %rcx, %rax
movq %rax, -0x228(%rbp)
jne 0x3b33
jmp 0x3b63
jmp 0x3fa1
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x88(%rbp)
movl %eax, -0x8c(%rbp)
jmp 0x3f58
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x88(%rbp)
movl %eax, -0x8c(%rbp)
leaq -0xf0(%rbp), %rdi
callq 0x8160
jmp 0x3f58
leaq -0xf0(%rbp), %rdi
callq 0x8160
movb $0x1, -0xf5(%rbp)
movzbl -0xf5(%rbp), %eax
movzbl -0x1(%rbp), %ecx
cmpl %ecx, %eax
jg 0x3ef2
movq -0x18(%rbp), %rdi
movzbl -0xf5(%rbp), %eax
movl %eax, %esi
decq %rsi
callq 0x8080
movq %rax, %rsi
leaq 0x15460(%rip), %rdx     # 0x19047
leaq -0x110(%rbp), %rdi
callq 0x8190
jmp 0x3bf5
movzbl -0xf5(%rbp), %eax
incl %eax
andl $0x1, %eax
leaq (%rax,%rax,2), %rax
leaq -0x50(%rbp,%rax,8), %rsi
leaq 0x15436(%rip), %rdx     # 0x19047
leaq -0x148(%rbp), %rdi
callq 0x8220
jmp 0x3c1f
movzbl -0xf5(%rbp), %eax
andl $0x1, %eax
leaq (%rax,%rax,2), %rax
leaq -0x50(%rbp,%rax,8), %rsi
leaq 0x1540b(%rip), %rdx     # 0x19044
leaq -0x180(%rbp), %rdi
callq 0x80a0
jmp 0x3c47
movl $0x0, -0x184(%rbp)
movl -0x184(%rbp), %eax
cmpl -0x8(%rbp), %eax
jae 0x3d15
leaq -0x110(%rbp), %rdi
callq 0x8300
movb %al, -0x231(%rbp)
jmp 0x3c74
movb -0x231(%rbp), %al
movzbl %al, %eax
movl %eax, -0x23c(%rbp)
leaq -0x148(%rbp), %rdi
callq 0x8330
movl %eax, -0x238(%rbp)
jmp 0x3c97
movl -0x238(%rbp), %edx
movl -0x23c(%rbp), %esi
leaq -0x180(%rbp), %rdi
callq 0x8120
jmp 0x3cb1
jmp 0x3cb3
movl -0x184(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x184(%rbp)
jmp 0x3c51
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x88(%rbp)
movl %eax, -0x8c(%rbp)
jmp 0x3e48
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x88(%rbp)
movl %eax, -0x8c(%rbp)
jmp 0x3e3c
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x88(%rbp)
movl %eax, -0x8c(%rbp)
leaq -0x180(%rbp), %rdi
callq 0x8160
jmp 0x3e3c
leaq -0x180(%rbp), %rdi
callq 0x8160
leaq -0x148(%rbp), %rdi
callq 0x8360
leaq -0x110(%rbp), %rdi
callq 0x8390
movq -0x10(%rbp), %rdi
movzbl -0xf5(%rbp), %eax
movl %eax, %esi
callq 0x8080
movq %rax, %rsi
movl -0x8(%rbp), %eax
movl %eax, %edx
leaq -0x1a0(%rbp), %rdi
callq 0x83b0
jmp 0x3d61
movzbl -0xf5(%rbp), %eax
andl $0x1, %eax
leaq (%rax,%rax,2), %rax
leaq -0x50(%rbp,%rax,8), %rsi
leaq 0x152cc(%rip), %rdx     # 0x19047
leaq -0x1d8(%rbp), %rdi
callq 0x8220
jmp 0x3d89
movq -0x18(%rbp), %rdi
movzbl -0xf5(%rbp), %eax
movl %eax, %esi
callq 0x8080
movq %rax, %rsi
leaq 0x1529f(%rip), %rdx     # 0x19044
leaq -0x1e8(%rbp), %rdi
callq 0x8470
jmp 0x3db3
movl $0x0, -0x1ec(%rbp)
movl -0x1ec(%rbp), %eax
cmpl -0x8(%rbp), %eax
jae 0x3ea1
leaq -0x1d8(%rbp), %rdi
callq 0x8330
movl %eax, -0x240(%rbp)
jmp 0x3de0
movl -0x240(%rbp), %eax
movl %eax, -0x1f0(%rbp)
movl -0x1f0(%rbp), %eax
movl %eax, %esi
leaq -0x1a0(%rbp), %rdi
callq 0x84b0
movb %al, -0x241(%rbp)
jmp 0x3e08
movb -0x241(%rbp), %al
movb %al, -0x1f1(%rbp)
leaq -0x1e8(%rbp), %rdi
leaq -0x1f1(%rbp), %rsi
callq 0x8500
jmp 0x3e29
jmp 0x3e2b
movl -0x1ec(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1ec(%rbp)
jmp 0x3dbd
leaq -0x148(%rbp), %rdi
callq 0x8360
leaq -0x110(%rbp), %rdi
callq 0x8390
jmp 0x3f58
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x88(%rbp)
movl %eax, -0x8c(%rbp)
jmp 0x3ee4
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x88(%rbp)
movl %eax, -0x8c(%rbp)
jmp 0x3ed8
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x88(%rbp)
movl %eax, -0x8c(%rbp)
leaq -0x1e8(%rbp), %rdi
callq 0x8570
jmp 0x3ed8
leaq -0x1e8(%rbp), %rdi
callq 0x8570
leaq -0x1d8(%rbp), %rdi
callq 0x8360
leaq -0x1a0(%rbp), %rdi
callq 0x85e0
movb -0xf5(%rbp), %al
addb $0x1, %al
movb %al, -0xf5(%rbp)
jmp 0x3bb5
leaq -0x1d8(%rbp), %rdi
callq 0x8360
leaq -0x1a0(%rbp), %rdi
callq 0x85e0
jmp 0x3f58
leaq -0x50(%rbp), %rdi
callq 0x3860
leaq -0x50(%rbp), %rdi
addq $0x18, %rdi
callq 0x3860
leaq -0x50(%rbp), %rax
movq %rax, -0x258(%rbp)
addq $0x30, %rax
movq %rax, -0x250(%rbp)
movq -0x250(%rbp), %rdi
addq $-0x18, %rdi
movq %rdi, -0x260(%rbp)
callq 0x7e90
movq -0x258(%rbp), %rcx
movq -0x260(%rbp), %rax
cmpq %rcx, %rax
movq %rax, -0x250(%rbp)
jne 0x3f1e
addq $0x280, %rsp            # imm = 0x280
popq %rbp
retq
leaq -0x50(%rbp), %rax
movq %rax, -0x270(%rbp)
addq $0x30, %rax
movq %rax, -0x268(%rbp)
movq -0x268(%rbp), %rdi
addq $-0x18, %rdi
movq %rdi, -0x278(%rbp)
callq 0x7e90
movq -0x270(%rbp), %rcx
movq -0x278(%rbp), %rax
cmpq %rcx, %rax
movq %rax, -0x268(%rbp)
jne 0x3f6e
jmp 0x3fa1
movq -0x88(%rbp), %rdi
callq 0x3480
nopl (%rax)