// File: /workspace/github_cpp_makefile_star2_O2/maxgodfrey2004[P]gss/src/fileutils.cc
// Function: gss::fileutils::Match(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>)
void Match(std::string filename, std::string pattern) {
  CheckAccessible(filename.c_str());
  std::ifstream infile(filename);
  std::string line;
  std::vector<int> occurrences;
  int pattern_length = static_cast<int>(pattern.length());
  int line_idx;
  int line_length;

  while (std::getline(infile, line)) {
    if (line == "") {
      continue;
    }
    occurrences = kmp::FindMatches(line, pattern);
    if (!occurrences.empty()) {
      line_idx = 0;
      line_length = static_cast<int>(line.length());
      for (int occ_idx : occurrences) {
        for (; line_idx < occ_idx; ++line_idx) {
          std::cout << line[line_idx];
        }
        std::cout << color::RED;
        for (; line_idx < occ_idx + pattern_length; ++line_idx) {
          std::cout << line[line_idx];
        }
        std::cout << color::RESET;
      }
      for (; line_idx < line_length; ++line_idx) {
        std::cout << line[line_idx];
      }
      std::cout << std::endl;
    }
  }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x2a8, %rsp            # imm = 0x2A8
movq %rsi, %r14
movq %rdi, %rbx
movq (%rdi), %rdi
callq 0x2a50
leaq 0xa0(%rsp), %r13
pushq $0x8
popq %rdx
movq %r13, %rdi
movq %rbx, %rsi
callq 0x21a0
leaq 0x10(%rsp), %rax
movq %rax, -0x10(%rax)
andq $0x0, -0x8(%rax)
movb $0x0, (%rax)
xorps %xmm0, %xmm0
leaq 0x20(%rsp), %rax
movaps %xmm0, (%rax)
andq $0x0, 0x10(%rax)
movq %r14, 0x38(%rsp)
movl 0x8(%r14), %r15d
movq 0x3752(%rip), %r14      # 0x5fd0
movq %r13, %rdi
movq %rsp, %rsi
callq 0x2030
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
testb $0x5, 0x20(%rax,%rcx)
jne 0x29cd
movq %rsp, %rdi
leaq 0x17f7(%rip), %rsi      # 0x409c
callq 0x2aad
testb %al, %al
jne 0x287e
leaq 0x68(%rsp), %rbx
movq %rbx, %rdi
movq %rsp, %rsi
callq 0x2180
leaq 0x48(%rsp), %r12
movq %r12, %rdi
movq 0x38(%rsp), %rsi
callq 0x2180
leaq 0x88(%rsp), %rbp
movq %rbp, %rdi
movq %rbx, %rsi
movq %r12, %rdx
callq 0x2bbf
leaq 0x20(%rsp), %rdi
movq %rbp, %rsi
callq 0x2afa
movq %rbp, %rdi
callq 0x2ac6
movq %r12, %rdi
callq 0x21e8
movq %rbx, %rdi
callq 0x21e8
movq 0x20(%rsp), %rbx
movq 0x28(%rsp), %r12
cmpq %r12, %rbx
je 0x287e
xorl %r13d, %r13d
movq 0x8(%rsp), %rax
movq %rax, 0x40(%rsp)
cmpq %r12, %rbx
je 0x2996
movslq %r13d, %r13
movslq (%rbx), %rbp
cmpq %rbp, %r13
jge 0x2951
movq (%rsp), %rax
movsbl (%rax,%r13), %esi
movq %r14, %rdi
callq 0x2160
incq %r13
jmp 0x2936
movq %r14, %rdi
leaq 0x37dd(%rip), %rsi      # 0x6138
callq 0x2110
addl %r15d, %ebp
movslq %ebp, %rbp
cmpq %rbp, %r13
jge 0x2981
movq (%rsp), %rax
movsbl (%rax,%r13), %esi
movq %r14, %rdi
callq 0x2160
incq %r13
jmp 0x2966
movq %r14, %rdi
leaq 0x378d(%rip), %rsi      # 0x6118
callq 0x2110
addq $0x4, %rbx
jmp 0x292b
movslq %r13d, %rbx
movslq 0x40(%rsp), %r12
leaq 0xa0(%rsp), %r13
cmpq %r12, %rbx
jge 0x29c0
movq (%rsp), %rax
movsbl (%rax,%rbx), %esi
movq %r14, %rdi
callq 0x2160
incq %rbx
jmp 0x29a6
movq %r14, %rdi
callq 0x20b0
jmp 0x287e
leaq 0x20(%rsp), %rdi
callq 0x2ac6
movq %rsp, %rdi
callq 0x21e8
leaq 0xa0(%rsp), %rdi
callq 0x2040
addq $0x2a8, %rsp            # imm = 0x2A8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x2a26
movq %rax, %rbx
leaq 0x48(%rsp), %rdi
callq 0x21e8
jmp 0x2a12
movq %rax, %rbx
leaq 0x68(%rsp), %rdi
callq 0x21e8
jmp 0x2a29
jmp 0x2a26
jmp 0x2a26
jmp 0x2a26
jmp 0x2a26
movq %rax, %rbx
leaq 0x20(%rsp), %rdi
callq 0x2ac6
movq %rsp, %rdi
callq 0x21e8
leaq 0xa0(%rsp), %rdi
callq 0x2040
movq %rbx, %rdi
callq 0x21c0