// File: /workspace/github_cpp_makefile_star2_O3/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 0x3a02
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 0x3a22
movq %rax, %r14
movslq %r14d, %rax
cmpq %r14, %rax
jne 0x3a2e
movl (%r12), %eax
cmpl $0x22, %eax
je 0x3a2e
testl %eax, %eax
jne 0x384c
movl 0xc(%rsp), %eax
movl %eax, (%r12)
leaq 0x78(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x385f
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 0x8a0(%rip), %rdi       # 0x41ba
xorl %eax, %eax
callq 0x1040
leaq 0x48(%rsp), %r12
movl 0x8(%r12), %esi
leaq 0x89f(%rip), %rdi       # 0x41d1
xorl %eax, %eax
callq 0x1040
leaq 0x8c2(%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 0x235a
leaq 0x87b(%rip), %rdi       # 0x41e8
movl %eax, %esi
xorl %eax, %eax
callq 0x1040
movq 0x20(%rbx), %rdi
movq 0x263f(%rip), %rax      # 0x5fc0
movq (%rax), %rdx
leaq 0x870(%rip), %rsi       # 0x41fb
callq 0x1110
movq 0x30(%rsp), %rbx
movq 0x38(%rsp), %r14
cmpq %r14, %rbx
je 0x39be
movslq (%rbx), %rax
movq 0x10(%rsp), %rcx
movsbl (%rcx,%rax), %edi
callq 0x1120
addq $0x8, %rbx
cmpq %r14, %rbx
jne 0x399f
movq 0x30(%rsp), %rbx
testq %rbx, %rbx
je 0x39cb
movq %rbx, %rdi
callq 0x10e0
movq 0x48(%rsp), %rdi
cmpq %rbp, %rdi
je 0x39da
callq 0x10e0
leaq 0x270(%rsp), %rdi
callq 0x1050
movq 0x10(%rsp), %rdi
cmpq %r13, %rdi
je 0x39f6
callq 0x10e0
leaq 0x68(%rsp), %rdi
callq 0x1050
jmp 0x3a0e
leaq 0x80c(%rip), %rdi       # 0x4215
callq 0x1160
xorl %eax, %eax
addq $0x478, %rsp            # imm = 0x478
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x7d4(%rip), %rdi       # 0x41fd
callq 0x10a0
leaq 0x7c8(%rip), %rdi       # 0x41fd
callq 0x1140
jmp 0x3a3c
movq %rax, %rbx
movq 0x30(%rsp), %rdi
testq %rdi, %rdi
je 0x3a5a
callq 0x10e0
jmp 0x3a5a
jmp 0x3a78
movq %rax, %rbx
jmp 0x3a94
movq %rax, %rbx
movq 0x48(%rsp), %rdi
cmpq %rbp, %rdi
je 0x3a69
callq 0x10e0
leaq 0x270(%rsp), %rdi
callq 0x1050
jmp 0x3a7b
movq %rax, %rbx
movq 0x10(%rsp), %rdi
cmpq %r13, %rdi
je 0x3a8a
callq 0x10e0
leaq 0x68(%rsp), %rdi
callq 0x1050
movq %rbx, %rdi
callq 0x1180
movq %rax, %rbx
cmpl $0x0, (%r12)
jne 0x3aae
movl 0xc(%rsp), %eax
movl %eax, (%r12)
leaq 0x78(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x3a94
callq 0x10e0
jmp 0x3a94