// File: AsherGlick[P]CommentHeader/source/main.cpp
// Function: wrap(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, unsigned int)
vector<string> wrap(string text, unsigned int width) {
  vector<string> lines;
  int lastSplit = 0;
  // Split on newlines
  for (unsigned int i = 0; i < text.size(); i++) {
    if (text[i] == '\n') {
      lines.push_back(text.substr(lastSplit, i-lastSplit));
      lastSplit = i + 1;
    }
  }
  if (text.substr(lastSplit, text.size() - lastSplit) != "") {
    lines.push_back(text.substr(lastSplit, text.size() - lastSplit));
  }

  // Split lines that are too long
  vector<string> wrappedLines;
  for (unsigned int i = 0; i < lines.size(); i++) {
    while (lines[i].size() > width) {
      int splitIndex = width;
      // Find the last space to prevent splitting mid-word
      for (int j = width-1; j >= 0; j--) {
        if (lines[i][j] == ' ') {
          splitIndex = j;
          break;
        }
      }

      wrappedLines.push_back(lines[i].substr(0, splitIndex));
      lines[i] = lines[i].substr(splitIndex + 1, lines.size() - splitIndex);
    }
    wrappedLines.push_back(lines[i]);
  }

  // Return the lines
  return wrappedLines;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x160, %rsp            # imm = 0x160
movq %rsi, -0x110(%rbp)
movq %rdi, -0x108(%rbp)
movq %rdi, %rax
movq %rax, -0x100(%rbp)
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl %edx, -0x14(%rbp)
leaq -0x30(%rbp), %rdi
callq 0xc650
movl $0x0, -0x34(%rbp)
movl $0x0, -0x38(%rbp)
movq -0x110(%rbp), %rdi
movl -0x38(%rbp), %eax
movq %rax, -0x118(%rbp)
callq 0x31e0
movq %rax, %rcx
movq -0x118(%rbp), %rax
cmpq %rcx, %rax
jae 0x12ca4
movq -0x110(%rbp), %rdi
movl -0x38(%rbp), %eax
movl %eax, %esi
callq 0x34c0
movq %rax, -0x120(%rbp)
jmp 0x12c18
movq -0x120(%rbp), %rax
movsbl (%rax), %eax
cmpl $0xa, %eax
jne 0x12c94
movq -0x110(%rbp), %rsi
movslq -0x34(%rbp), %rdx
movl %edx, %ecx
movl -0x38(%rbp), %eax
subl %ecx, %eax
movl %eax, %ecx
leaq -0x68(%rbp), %rdi
callq 0x32c0
jmp 0x12c46
leaq -0x30(%rbp), %rdi
leaq -0x68(%rbp), %rsi
callq 0x138f0
jmp 0x12c55
leaq -0x68(%rbp), %rdi
callq 0x31a0
movl -0x38(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
jmp 0x12c94
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
jmp 0x1301a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
leaq -0x68(%rbp), %rdi
callq 0x31a0
jmp 0x1301a
jmp 0x12c96
movl -0x38(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x38(%rbp)
jmp 0x12bd5
movq -0x110(%rbp), %rdi
movslq -0x34(%rbp), %rax
movq %rax, -0x128(%rbp)
callq 0x31e0
movq -0x110(%rbp), %rsi
movq -0x128(%rbp), %rdx
movq %rax, %rcx
movslq -0x34(%rbp), %rax
subq %rax, %rcx
leaq -0x88(%rbp), %rdi
callq 0x32c0
jmp 0x12ce1
leaq 0x5f11(%rip), %rsi      # 0x18bf9
leaq -0x88(%rbp), %rdi
callq 0x13e90
movb %al, -0x129(%rbp)
jmp 0x12cfc
leaq -0x88(%rbp), %rdi
callq 0x31a0
movb -0x129(%rbp), %al
testb $0x1, %al
jne 0x12d17
jmp 0x12dae
movq -0x110(%rbp), %rdi
movslq -0x34(%rbp), %rax
movq %rax, -0x138(%rbp)
callq 0x31e0
movq -0x110(%rbp), %rsi
movq -0x138(%rbp), %rdx
movq %rax, %rcx
movslq -0x34(%rbp), %rax
subq %rax, %rcx
leaq -0xa8(%rbp), %rdi
callq 0x32c0
jmp 0x12d54
leaq -0x30(%rbp), %rdi
leaq -0xa8(%rbp), %rsi
callq 0x138f0
jmp 0x12d66
leaq -0xa8(%rbp), %rdi
callq 0x31a0
jmp 0x12dae
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
leaq -0x88(%rbp), %rdi
callq 0x31a0
jmp 0x1301a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
leaq -0xa8(%rbp), %rdi
callq 0x31a0
jmp 0x1301a
movq -0x108(%rbp), %rdi
movb $0x0, -0xa9(%rbp)
callq 0xc650
movl $0x0, -0xb0(%rbp)
movl -0xb0(%rbp), %eax
movq %rax, -0x140(%rbp)
leaq -0x30(%rbp), %rdi
callq 0xd0e0
movq %rax, %rcx
movq -0x140(%rbp), %rax
cmpq %rcx, %rax
jae 0x12fd9
jmp 0x12df6
movl -0xb0(%rbp), %eax
movl %eax, %esi
leaq -0x30(%rbp), %rdi
callq 0x13920
movq %rax, %rdi
callq 0x31e0
movl -0x14(%rbp), %ecx
cmpq %rcx, %rax
jbe 0x12fa1
movl -0x14(%rbp), %eax
movl %eax, -0xb4(%rbp)
movl -0x14(%rbp), %eax
subl $0x1, %eax
movl %eax, -0xb8(%rbp)
cmpl $0x0, -0xb8(%rbp)
jl 0x12ea3
movl -0xb0(%rbp), %eax
movl %eax, %esi
leaq -0x30(%rbp), %rdi
callq 0x13920
movq %rax, %rdi
movslq -0xb8(%rbp), %rsi
callq 0x34c0
movq %rax, -0x148(%rbp)
jmp 0x12e62
movq -0x148(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x20, %eax
jne 0x12e90
movl -0xb8(%rbp), %eax
movl %eax, -0xb4(%rbp)
jmp 0x12ea3
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
jmp 0x1300e
jmp 0x12e92
movl -0xb8(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0xb8(%rbp)
jmp 0x12e30
movl -0xb0(%rbp), %eax
movl %eax, %esi
leaq -0x30(%rbp), %rdi
callq 0x13920
movq %rax, %rsi
movslq -0xb4(%rbp), %rcx
xorl %eax, %eax
movl %eax, %edx
leaq -0xd8(%rbp), %rdi
callq 0x32c0
jmp 0x12ed0
movq -0x108(%rbp), %rdi
leaq -0xd8(%rbp), %rsi
callq 0x138f0
jmp 0x12ee5
leaq -0xd8(%rbp), %rdi
callq 0x31a0
movl -0xb0(%rbp), %eax
movl %eax, %esi
leaq -0x30(%rbp), %rdi
movq %rdi, -0x160(%rbp)
callq 0x13920
movq -0x160(%rbp), %rdi
movq %rax, -0x158(%rbp)
movl -0xb4(%rbp), %eax
incl %eax
cltq
movq %rax, -0x150(%rbp)
callq 0xd0e0
movq -0x158(%rbp), %rsi
movq -0x150(%rbp), %rdx
movq %rax, %rcx
movslq -0xb4(%rbp), %rax
subq %rax, %rcx
leaq -0xf8(%rbp), %rdi
callq 0x32c0
jmp 0x12f56
movl -0xb0(%rbp), %eax
movl %eax, %esi
leaq -0x30(%rbp), %rdi
callq 0x13920
movq %rax, %rdi
leaq -0xf8(%rbp), %rsi
callq 0x3350
leaq -0xf8(%rbp), %rdi
callq 0x31a0
jmp 0x12df6
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
leaq -0xd8(%rbp), %rdi
callq 0x31a0
jmp 0x1300e
movl -0xb0(%rbp), %eax
movl %eax, %esi
leaq -0x30(%rbp), %rdi
callq 0x13920
movq -0x108(%rbp), %rdi
movq %rax, %rsi
callq 0x13ec0
jmp 0x12fc3
jmp 0x12fc5
movl -0xb0(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xb0(%rbp)
jmp 0x12dcb
movb $0x1, -0xa9(%rbp)
testb $0x1, -0xa9(%rbp)
jne 0x12ff5
movq -0x108(%rbp), %rdi
callq 0xcae0
leaq -0x30(%rbp), %rdi
callq 0xcae0
movq -0x100(%rbp), %rax
addq $0x160, %rsp            # imm = 0x160
popq %rbp
retq
movq -0x108(%rbp), %rdi
callq 0xcae0
leaq -0x30(%rbp), %rdi
callq 0xcae0
movq -0x40(%rbp), %rdi
callq 0x3460
nopl (%rax)