// File: /workspace/github_cpp_makefile_star2_O2/ikatanic[P]lcskpp/main.cpp
// Function: main
int main(int argc, char** argv) {
  if (argc != 5) {
    printf(
      "Compute LCSk++ of two plain texts.\n\n"
      "Usage: ./main k input1 input2 output\n\n"
      "Example: ./main 4 test/tests/test.1.A test/tests/test.1.B out\n"
      "finds LCS4++ of files `test/tests/test.1.A` and `test/tests/test.1.B`\n"
      "and writes it to `out`\n"
    );
    return 0;
  };


  int k = stoi(argv[1]);
  ifstream infile1(argv[2]);
  string A;
  getline(infile1, A);
  
  ifstream infile2(argv[3]);
  string B;
  getline(infile2, B);

  printf("Sequence 1 length: %d\n", (int)A.size());
  printf("Sequence 2 length: %d\n", (int)B.size());
  printf("Computing LCSk++..\n");
  
  vector<pair<int, int>> recon;
  int length = lcskpp(A, B, k, &recon);

  printf("LCSk++ length: %d\n", length);
  
  auto r = freopen(argv[4], "w", stdout);
  for (auto& p: recon) {
    putchar(A[p.first]);
  }
  return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
subq $0x468, %rsp            # imm = 0x468
cmpl $0x5, %edi
jne 0x375f
movq %rsi, %rbx
movq 0x8(%rsi), %rsi
leaq 0x58(%rsp), %rdi
leaq 0x260(%rsp), %rdx
callq 0x1080
leaq 0x58(%rsp), %rdi
pushq $0xa
popq %rdx
xorl %esi, %esi
callq 0x3810
movl %eax, %ebp
leaq 0x58(%rsp), %rdi
callq 0x1090
movq 0x10(%rbx), %rsi
leaq 0x58(%rsp), %r14
pushq $0x8
popq %rdx
movq %r14, %rdi
callq 0x1190
leaq 0x28(%rsp), %rax
movq %rax, -0x10(%rax)
andq $0x0, -0x8(%rax)
movb $0x0, (%rax)
leaq 0x18(%rsp), %rsi
movq %r14, %rdi
callq 0x1050
movq 0x18(%rbx), %rsi
leaq 0x260(%rsp), %rdi
pushq $0x8
popq %rdx
callq 0x1190
leaq 0x48(%rsp), %rax
movq %rax, -0x10(%rax)
andq $0x0, -0x8(%rax)
movb $0x0, (%rax)
leaq 0x260(%rsp), %rdi
leaq 0x38(%rsp), %rsi
callq 0x1050
leaq 0x18(%rsp), %r14
movl 0x8(%r14), %esi
leaq 0xab3(%rip), %rdi       # 0x417e
xorl %eax, %eax
callq 0x1040
leaq 0x38(%rsp), %r15
movl 0x8(%r15), %esi
leaq 0xab3(%rip), %rdi       # 0x4195
xorl %eax, %eax
callq 0x1040
leaq 0xad6(%rip), %rdi       # 0x41c6
callq 0x1160
xorps %xmm0, %xmm0
movq %rsp, %rcx
movaps %xmm0, (%rcx)
andq $0x0, 0x10(%rcx)
movq %r14, %rdi
movq %r15, %rsi
movl %ebp, %edx
callq 0x20bf
leaq 0xa95(%rip), %rdi       # 0x41ac
movl %eax, %esi
xorl %eax, %eax
callq 0x1040
movq 0x20(%rbx), %rdi
movq 0x388d(%rip), %rax      # 0x6fb8
movq (%rax), %rdx
leaq 0xa8a(%rip), %rsi       # 0x41bf
callq 0x1120
movq (%rsp), %rbx
movq 0x8(%rsp), %r14
cmpq %r14, %rbx
je 0x376d
movslq (%rbx), %rax
movq 0x18(%rsp), %rcx
movsbl (%rcx,%rax), %edi
callq 0x1130
addq $0x8, %rbx
jmp 0x3743
leaq 0xa73(%rip), %rdi       # 0x41d9
callq 0x1160
jmp 0x37a0
movq %rsp, %rdi
callq 0x3596
leaq 0x38(%rsp), %rdi
callq 0x1090
leaq 0x260(%rsp), %rdi
callq 0x1060
leaq 0x18(%rsp), %rdi
callq 0x1090
leaq 0x58(%rsp), %rdi
callq 0x1060
xorl %eax, %eax
addq $0x468, %rsp            # imm = 0x468
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
jmp 0x37b2
movq %rax, %rbx
movq %rsp, %rdi
callq 0x3596
jmp 0x37c2
movq %rax, %rbx
leaq 0x38(%rsp), %rdi
callq 0x1090
leaq 0x260(%rsp), %rdi
callq 0x1060
jmp 0x37e0
jmp 0x37dd
movq %rax, %rbx
leaq 0x18(%rsp), %rdi
callq 0x1090
leaq 0x58(%rsp), %rdi
callq 0x1060
movq %rbx, %rdi
callq 0x1180
movq %rax, %rbx
leaq 0x58(%rsp), %rdi
callq 0x1090
jmp 0x37f4
movq %rax, %rbx
jmp 0x37f4