// File: /workspace/github_cpp_makefile_star2_O1/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 %r13
pushq %r12
pushq %rbx
subq $0x478, %rsp            # imm = 0x478
cmpl $0x5, %edi
jne 0x39e2
movq %rsi, %rbx
movq 0x8(%rsi), %rsi
leaq 0x68(%rsp), %r15
leaq 0x10(%rsp), %rdx
movq %r15, %rdi
callq 0x1070
movq 0x68(%rsp), %r13
callq 0x1030
movq %rax, %r12
movl (%rax), %eax
movl %eax, 0xc(%rsp)
movl $0x0, (%r12)
leaq 0x270(%rsp), %rbp
movq %r13, %rdi
movq %rbp, %rsi
movl $0xa, %edx
callq 0x1130
cmpq %r13, (%rbp)
je 0x3a48
movq %rax, %r14
movslq %r14d, %rax
cmpq %r14, %rax
jne 0x3a54
movl (%r12), %eax
cmpl $0x22, %eax
je 0x3a54
testl %eax, %eax
jne 0x3878
movl 0xc(%rsp), %eax
movl %eax, (%r12)
leaq 0x78(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x388b
callq 0x10e0
movq 0x10(%rbx), %rsi
movq %r15, %rdi
movl $0x8, %edx
callq 0x1190
leaq 0x20(%rsp), %r13
movq %r13, -0x10(%r13)
movq $0x0, -0x8(%r13)
movb $0x0, (%r13)
movq 0x68(%rsp), %rax
addq -0x18(%rax), %r15
movq %r15, %rdi
movl $0xa, %esi
callq 0x10f0
movsbl %al, %edx
leaq 0x68(%rsp), %rdi
leaq 0x10(%rsp), %rsi
callq 0x11a0
movq 0x18(%rbx), %rsi
leaq 0x270(%rsp), %r15
movq %r15, %rdi
movl $0x8, %edx
callq 0x1190
leaq 0x58(%rsp), %rbp
movq %rbp, -0x10(%rbp)
movq $0x0, -0x8(%rbp)
movb $0x0, (%rbp)
movq 0x270(%rsp), %rax
addq -0x18(%rax), %r15
movq %r15, %rdi
movl $0xa, %esi
callq 0x10f0
movsbl %al, %edx
leaq 0x270(%rsp), %rdi
leaq 0x48(%rsp), %rsi
callq 0x11a0
leaq 0x10(%rsp), %r15
movl 0x8(%r15), %esi
leaq 0x874(%rip), %rdi       # 0x41ba
xorl %eax, %eax
callq 0x1040
leaq 0x48(%rsp), %r12
movl 0x8(%r12), %esi
leaq 0x873(%rip), %rdi       # 0x41d1
xorl %eax, %eax
callq 0x1040
leaq 0x896(%rip), %rdi       # 0x4202
callq 0x1160
xorps %xmm0, %xmm0
leaq 0x30(%rsp), %rcx
movaps %xmm0, (%rcx)
movq $0x0, 0x10(%rcx)
movq %r15, %rdi
movq %r12, %rsi
movl %r14d, %edx
callq 0x2376
leaq 0x84f(%rip), %rdi       # 0x41e8
movl %eax, %esi
xorl %eax, %eax
callq 0x1040
movq 0x20(%rbx), %rdi
movq 0x2613(%rip), %rax      # 0x5fc0
movq (%rax), %rdx
leaq 0x844(%rip), %rsi       # 0x41fb
callq 0x1110
movq 0x30(%rsp), %rbx
movq 0x38(%rsp), %r14
cmpq %r14, %rbx
je 0x39f0
movslq (%rbx), %rax
movq 0x10(%rsp), %rcx
movsbl (%rcx,%rax), %edi
callq 0x1120
addq $0x8, %rbx
jmp 0x39c6
leaq 0x82c(%rip), %rdi       # 0x4215
callq 0x1160
jmp 0x3a34
movq 0x30(%rsp), %rdi
testq %rdi, %rdi
je 0x39ff
callq 0x10e0
movq 0x48(%rsp), %rdi
cmpq %rbp, %rdi
je 0x3a0e
callq 0x10e0
leaq 0x270(%rsp), %rdi
callq 0x1050
movq 0x10(%rsp), %rdi
cmpq %r13, %rdi
je 0x3a2a
callq 0x10e0
leaq 0x68(%rsp), %rdi
callq 0x1050
xorl %eax, %eax
addq $0x478, %rsp            # imm = 0x478
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x7ae(%rip), %rdi       # 0x41fd
callq 0x10a0
leaq 0x7a2(%rip), %rdi       # 0x41fd
callq 0x1140
jmp 0x3a62
movq %rax, %rbx
movq 0x30(%rsp), %rdi
testq %rdi, %rdi
je 0x3a80
callq 0x10e0
jmp 0x3a80
jmp 0x3a9e
movq %rax, %rbx
jmp 0x3aba
movq %rax, %rbx
movq 0x48(%rsp), %rdi
cmpq %rbp, %rdi
je 0x3a8f
callq 0x10e0
leaq 0x270(%rsp), %rdi
callq 0x1050
jmp 0x3aa1
movq %rax, %rbx
movq 0x10(%rsp), %rdi
cmpq %r13, %rdi
je 0x3ab0
callq 0x10e0
leaq 0x68(%rsp), %rdi
callq 0x1050
movq %rbx, %rdi
callq 0x1180
movq %rax, %rbx
cmpl $0x0, (%r12)
jne 0x3ad4
movl 0xc(%rsp), %eax
movl %eax, (%r12)
leaq 0x78(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x3aba
callq 0x10e0
jmp 0x3aba