// File: /workspace/github_cpp_makefile_star2_O3/tylerkaraszewski[P]Argyle/HttpRequest.cpp
// Function: HttpRequest::parse(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&)
size_t HttpRequest::parse(const string& buffer)
{
  size_t headerEnd = buffer.find("\r\n\r\n");
  if (headerEnd == buffer.npos)
  {
    return 0;
  }

  // Ok, now we parse this.
  size_t startOffset = 0;
  size_t endOffset = 0;

  // Special handling for the first line.
  endOffset = buffer.find_first_of(SPACES);
  if (endOffset == buffer.npos)
  {
    m_httpError = 400;
    return headerEnd + 4;
  }
  m_method = buffer.substr(startOffset, endOffset);
  startOffset = buffer.find_first_not_of(SPACES, endOffset);
  if (startOffset == buffer.npos)
  {
    m_httpError = 400;
    return headerEnd + 4;
  }
  endOffset = buffer.find_first_of(SPACES, startOffset);
  if (endOffset == buffer.npos)
  {
    m_httpError = 400;
    return headerEnd + 4;
  }
  m_path = buffer.substr(startOffset, endOffset - startOffset);
  startOffset = buffer.find_first_not_of(SPACES, endOffset);
  if (startOffset == buffer.npos)
  {
    m_httpError = 400;
    return headerEnd + 4;
  }
  endOffset = buffer.find_first_of(NEWLINES, startOffset);
  if (endOffset == buffer.npos)
  {
    m_httpError = 400;
    return headerEnd + 4;
  }
  m_httpVersion = buffer.substr(startOffset, endOffset - startOffset);

  size_t pathOffset = m_path.find_first_of("#");
  if (pathOffset != m_path.npos)
  {
    m_path = m_path.substr(0, pathOffset);
  }
  pathOffset = m_path.find_first_of("?");
  if (pathOffset != m_path.npos)
  {
    m_queryString = m_path.substr(pathOffset);
    m_path = m_path.substr(0, pathOffset);
  }

  // Now we loop across all the headers we've got.
  startOffset = buffer.find_first_not_of(NEWLINES, endOffset);
  while (endOffset < headerEnd)
  {
    endOffset = buffer.find_first_of(SEPARATOR, startOffset);
    if (endOffset == buffer.npos)
    {
      break;
    }
    string headerName = buffer.substr(startOffset, endOffset - startOffset);
    headerName = headerName.substr(0, headerName.find_last_not_of(SPACES) + 1);
    startOffset = buffer.find_first_not_of(SPACES, endOffset + 1);
    if (startOffset == buffer.npos)
    {
      break;
    }
    endOffset = buffer.find_first_of(NEWLINES, startOffset);
    if (endOffset == buffer.npos)
    {
      break;
    }
    string value = buffer.substr(startOffset, endOffset - startOffset);
    startOffset = buffer.find_first_not_of(NEWLINES, endOffset);
    while ((buffer.find_first_of(SPACES) == startOffset) && (startOffset < headerEnd))
    {
      endOffset = buffer.find_first_of(NEWLINES, startOffset);
      if (endOffset == buffer.npos)
      {
        break;
      }
      value += buffer.substr(startOffset, endOffset - startOffset);
      startOffset = buffer.find_first_not_of(NEWLINES, endOffset);
      if (startOffset == buffer.npos)
      {
        break;
      }
    }

    toLower(headerName);
    if (headerName == "user-agent")
    {
      m_userAgent = value;
    }
    else if (headerName == "if-modified-since")
    {
      m_ifModifiedSince = Utils::parseHttpDate(value);
    }
    m_headers.insert(pair<string, string>(headerName, value));
  }

  // Set our keep-alive flag.
  HeaderMap::const_iterator it = m_headers.find("connection");
  {
    string c = it->second;
    toLower(c);
    if (c.find("keep-alive") != c.npos)
    {
      m_keepAlive = true;
    }
  }

  // Now we need to parse the request body.
  it = m_headers.find("content-length");
  if (it != m_headers.end())
  {
    const string& l = it->second;
    m_contentLength = strtoll(l.c_str(), NULL, 10);
  }

  // '4' is the \r\n\r\n following the headers.
  unsigned long long totalSize = headerEnd + 4 + m_contentLength;
  if (buffer.size() >= totalSize)
  {
    m_body = buffer.substr(headerEnd + 4, m_contentLength);
  }
  else
  {
    totalSize = 0;
  }

  return totalSize;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xa8, %rsp
movq %rsi, %r15
movq %rdi, %r14
leaq 0x55f0(%rip), %rsi      # 0xc232
xorl %ebx, %ebx
movl $0x4, %ecx
movq %r15, %rdi
xorl %edx, %edx
callq 0x3500
cmpq $-0x1, %rax
je 0x73d3
movq %rax, %rbp
movq 0x96a1(%rip), %rsi      # 0x10308
movq 0x96a2(%rip), %rcx      # 0x10310
movq %r15, %rdi
xorl %edx, %edx
callq 0x3420
cmpq $-0x1, %rax
je 0x73c1
movq %rax, %rbx
leaq 0x8(%rsp), %r12
movq %r12, %rdi
movq %r15, %rsi
xorl %edx, %edx
movq %rax, %rcx
callq 0x32b0
leaq 0x10(%r14), %rdi
movq %r12, %rsi
callq 0x3360
movq (%r12), %rdi
leaq 0x18(%rsp), %rax
cmpq %rax, %rdi
je 0x6cc1
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x3290
movq 0x9640(%rip), %rsi      # 0x10308
movq 0x9641(%rip), %rcx      # 0x10310
movq %r15, %rdi
movq %rbx, %rdx
callq 0x34e0
cmpq $-0x1, %rax
je 0x73c1
movq %rax, %rbx
movq 0x961a(%rip), %rsi      # 0x10308
movq 0x961b(%rip), %rcx      # 0x10310
movq %r15, %rdi
movq %rax, %rdx
callq 0x3420
cmpq $-0x1, %rax
je 0x73c1
movq %rax, %r12
movq %rax, %rcx
subq %rbx, %rcx
leaq 0x8(%rsp), %r13
movq %r13, %rdi
movq %r15, %rsi
movq %rbx, %rdx
callq 0x32b0
movq %r14, %rbx
addq $0x30, %r14
movq %r14, %rdi
movq %r13, %rsi
callq 0x3360
movq (%r13), %rdi
leaq 0x18(%rsp), %rax
cmpq %rax, %rdi
je 0x6d53
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x3290
movq 0x95ae(%rip), %rsi      # 0x10308
movq 0x95af(%rip), %rcx      # 0x10310
movq %r15, %rdi
movq %r12, %rdx
callq 0x34e0
cmpq $-0x1, %rax
je 0x73e8
movq %rax, %r13
movq 0x95a8(%rip), %rsi      # 0x10328
movq 0x95a9(%rip), %rcx      # 0x10330
movq %r15, %rdi
movq %rax, %rdx
callq 0x3420
cmpq $-0x1, %rax
je 0x73e8
movq %rax, %r12
movq %rbp, 0x50(%rsp)
movq %rax, %rcx
subq %r13, %rcx
leaq 0x8(%rsp), %rbp
movq %rbp, %rdi
movq %r15, %rsi
movq %r13, %rdx
callq 0x32b0
movq %rbx, 0x48(%rsp)
leaq 0x50(%rbx), %rdi
movq %rbp, %rsi
callq 0x3360
movq (%rbp), %rdi
leaq 0x18(%rsp), %rax
cmpq %rax, %rdi
je 0x6de9
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x3290
leaq 0x5447(%rip), %rsi      # 0xc237
movl $0x1, %ecx
movq %r14, %rdi
xorl %edx, %edx
callq 0x3420
cmpq $-0x1, %rax
movq 0x50(%rsp), %rbp
je 0x6e45
leaq 0x8(%rsp), %r13
movq %r13, %rdi
movq %r14, %rsi
xorl %edx, %edx
movq %rax, %rcx
callq 0x32b0
movq %r14, %rdi
movq %r13, %rsi
callq 0x3360
movq (%r13), %rdi
leaq 0x18(%rsp), %rax
cmpq %rax, %rdi
je 0x6e45
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x3290
leaq 0x53ed(%rip), %rsi      # 0xc239
movl $0x1, %ecx
movq %r14, %rdi
xorl %edx, %edx
callq 0x3420
cmpq $-0x1, %rax
je 0x6ef1
movq %rax, %r13
leaq 0x8(%rsp), %rbp
movq %rbp, %rdi
movq %r14, %rsi
movq %rax, %rdx
movq $-0x1, %rcx
callq 0x32b0
movq 0x48(%rsp), %rax
leaq 0xc0(%rax), %rdi
movq %rbp, %rsi
callq 0x3360
movq (%rbp), %rdi
leaq 0x18(%rsp), %rax
cmpq %rax, %rdi
je 0x6eb1
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x3290
leaq 0x8(%rsp), %rbp
movq %rbp, %rdi
movq %r14, %rsi
xorl %edx, %edx
movq %r13, %rcx
callq 0x32b0
movq %r14, %rdi
movq %rbp, %rsi
callq 0x3360
movq (%rbp), %rdi
leaq 0x18(%rsp), %rax
cmpq %rax, %rdi
je 0x6eec
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x3290
movq 0x50(%rsp), %rbp
movq 0x9430(%rip), %rsi      # 0x10328
movq 0x9431(%rip), %rcx      # 0x10330
movq %r15, %rdi
movq %r12, %rdx
callq 0x34e0
movq %rax, %rbx
movq 0x48(%rsp), %rcx
leaq 0xe8(%rcx), %rax
movq %rax, 0xa0(%rsp)
leaq 0x70(%rcx), %rax
movq %rax, 0x58(%rsp)
cmpq %rbp, %r12
jae 0x728e
movq 0x940e(%rip), %rsi      # 0x10348
movq 0x940f(%rip), %rcx      # 0x10350
movq %r15, %rdi
movq %rbx, %rdx
callq 0x3420
cmpq $-0x1, %rax
je 0x728e
movq %rax, %r12
movq %rax, %rcx
subq %rbx, %rcx
leaq 0x80(%rsp), %rdi
movq %r15, %rsi
movq %rbx, %rdx
movq %rdi, %rbx
callq 0x32b0
movq 0x938c(%rip), %rsi      # 0x10308
movq 0x938d(%rip), %rcx      # 0x10310
movq %rbx, %rdi
movq $-0x1, %rdx
callq 0x34a0
leaq 0x1(%rax), %rcx
leaq 0x8(%rsp), %r14
movq %r14, %rdi
movq %rbx, %rsi
xorl %edx, %edx
callq 0x32b0
leaq 0x18(%rsp), %r13
movq %rbx, %rdi
movq %r14, %rsi
callq 0x3360
movq 0x8(%rsp), %rdi
cmpq %r13, %rdi
je 0x6fcf
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x3290
leaq 0x1(%r12), %rdx
movq 0x932d(%rip), %rsi      # 0x10308
movq 0x932e(%rip), %rcx      # 0x10310
movq %r15, %rdi
callq 0x34e0
cmpq $-0x1, %rax
je 0x7128
movq %rax, %rbx
movq 0x932a(%rip), %rsi      # 0x10328
movq 0x932b(%rip), %rcx      # 0x10330
movq %r15, %rdi
movq %rax, %rdx
callq 0x3420
cmpq $-0x1, %rax
je 0x7131
movq %rax, %r12
movq %rax, %rcx
subq %rbx, %rcx
leaq 0x60(%rsp), %rdi
movq %r15, %rsi
movq %rbx, %rdx
callq 0x32b0
movq 0x92ee(%rip), %rsi      # 0x10328
movq 0x92ef(%rip), %rcx      # 0x10330
movq %r15, %rdi
movq %r12, %rdx
callq 0x34e0
movq %rax, %rbx
movq 0x92b2(%rip), %rsi      # 0x10308
movq 0x92b3(%rip), %rcx      # 0x10310
movq %r15, %rdi
xorl %edx, %edx
callq 0x3420
cmpq %rbp, %rbx
leaq 0x8(%rsp), %r14
jae 0x7150
cmpq %rbx, %rax
jne 0x7150
movq 0x92a3(%rip), %rsi      # 0x10328
movq 0x92a4(%rip), %rcx      # 0x10330
movq %r15, %rdi
movq %rbx, %rdx
callq 0x3420
cmpq $-0x1, %rax
je 0x7140
movq %rax, %r12
movq %rax, %rcx
subq %rbx, %rcx
movq %r14, %rdi
movq %r15, %rsi
movq %rbx, %rdx
callq 0x32b0
movq 0x8(%rsp), %rsi
movq 0x10(%rsp), %rdx
leaq 0x60(%rsp), %rdi
callq 0x30f0
movq 0x8(%rsp), %rdi
cmpq %r13, %rdi
je 0x70e3
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x3290
movq 0x923e(%rip), %rsi      # 0x10328
movq 0x923f(%rip), %rcx      # 0x10330
movq %r15, %rdi
movq %r12, %rdx
callq 0x34e0
cmpq $-0x1, %rax
je 0x7149
movq %rax, %rbx
movq 0x91fc(%rip), %rsi      # 0x10308
movq 0x91fd(%rip), %rcx      # 0x10310
movq %r15, %rdi
xorl %edx, %edx
callq 0x3420
cmpq %rbp, %rbx
jb 0x7075
jmp 0x7150
movq $-0x1, %rbx
jmp 0x7138
movq $-0x1, %r12
xorl %r13d, %r13d
jmp 0x7260
movq $-0x1, %r12
jmp 0x7150
movq $-0x1, %rbx
movq 0x88(%rsp), %r13
testq %r13, %r13
je 0x7180
movq 0x80(%rsp), %rbp
xorl %r14d, %r14d
movsbl (%rbp,%r14), %edi
callq 0x33d0
movb %al, (%rbp,%r14)
incq %r14
cmpq %r14, %r13
jne 0x7168
leaq 0x80(%rsp), %r14
movq %r14, %rdi
leaq 0x50a9(%rip), %rsi      # 0xc23b
callq 0x30d0
testl %eax, %eax
je 0x71cb
movq %r14, %rdi
leaq 0x4fc8(%rip), %rsi      # 0xc16d
callq 0x30d0
testl %eax, %eax
leaq 0x18(%rsp), %r13
jne 0x71e2
leaq 0x60(%rsp), %rdi
callq 0xad20
movq 0x48(%rsp), %rcx
movq %rax, 0x108(%rcx)
jmp 0x71e2
movq 0xa0(%rsp), %rdi
leaq 0x60(%rsp), %rsi
callq 0x3190
leaq 0x18(%rsp), %r13
leaq 0x8(%rsp), %r14
movq %r14, %rdi
leaq 0x80(%rsp), %rsi
leaq 0x60(%rsp), %rdx
callq 0x7640
movq 0x58(%rsp), %rdi
movq %r14, %rsi
callq 0x7770
movq 0x50(%rsp), %rbp
movq 0x28(%rsp), %rdi
leaq 0x38(%rsp), %rax
cmpq %rax, %rdi
je 0x722a
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x3290
movq 0x8(%rsp), %rdi
cmpq %r13, %rdi
je 0x7241
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x3290
movq 0x60(%rsp), %rdi
leaq 0x70(%rsp), %rax
cmpq %rax, %rdi
je 0x725d
movq 0x70(%rsp), %rsi
incq %rsi
callq 0x3290
movb $0x1, %r13b
movq 0x80(%rsp), %rdi
leaq 0x90(%rsp), %rax
cmpq %rax, %rdi
je 0x7285
movq 0x90(%rsp), %rsi
incq %rsi
callq 0x3290
testb %r13b, %r13b
jne 0x6f2a
leaq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %r13
movq %r13, (%rdi)
leaq 0x4fa4(%rip), %rsi      # 0xc246
leaq 0x4fa7(%rip), %rdx      # 0xc250
callq 0x513a
leaq 0x8(%rsp), %rsi
movq 0x58(%rsp), %rdi
callq 0x792e
movq %rax, %rbx
movq 0x8(%rsp), %rdi
cmpq %r13, %rdi
je 0x72d7
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x3290
leaq 0x8(%rsp), %r12
movq %r13, (%r12)
movq 0x40(%rbx), %rsi
movq 0x48(%rbx), %rdx
addq %rsi, %rdx
movq %r12, %rdi
callq 0x76da
movq 0x8(%r12), %rbx
testq %rbx, %rbx
je 0x731b
movq 0x8(%rsp), %r12
xorl %r13d, %r13d
movsbl (%r12,%r13), %edi
callq 0x33d0
movb %al, (%r12,%r13)
incq %r13
cmpq %r13, %rbx
jne 0x7305
leaq 0x4f2f(%rip), %rsi      # 0xc251
leaq 0x8(%rsp), %rdi
movl $0xa, %ecx
xorl %edx, %edx
callq 0x3500
cmpq $-0x1, %rax
movq 0x48(%rsp), %r14
je 0x7343
movb $0x1, 0x8(%r14)
movq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %r13
cmpq %r13, %rdi
je 0x735f
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x3290
leaq 0x8(%rsp), %rdi
movq %r13, (%rdi)
leaq 0x4eee(%rip), %rsi      # 0xc25c
leaq 0x4ef5(%rip), %rdx      # 0xc26a
callq 0x513a
leaq 0x8(%rsp), %rsi
movq 0x58(%rsp), %rdi
callq 0x792e
movq %rax, %rbx
movq 0x8(%rsp), %rdi
cmpq %r13, %rdi
je 0x73a3
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x3290
leaq 0x78(%r14), %rax
cmpq %rax, %rbx
je 0x73f4
movq 0x40(%rbx), %rdi
xorl %esi, %esi
movl $0xa, %edx
callq 0x3080
movq %rax, (%r14)
jmp 0x73f7
movl $0x190, 0xe0(%r14) # imm = 0x190
addq $0x4, %rbp
movq %rbp, %rbx
movq %rbx, %rax
addq $0xa8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl $0x190, 0xe0(%rbx)      # imm = 0x190
jmp 0x73cc
movq (%r14), %rax
leaq (%rax,%rbp), %rbx
addq $0x4, %rbx
cmpq %rbx, 0x8(%r15)
jae 0x7409
xorl %ebx, %ebx
jmp 0x73d3
addq $0x4, %rbp
leaq 0x8(%rsp), %r12
movq %r12, %rdi
movq %r15, %rsi
movq %rbp, %rdx
movq %rax, %rcx
callq 0x32b0
addq $0xa0, %r14
movq %r14, %rdi
movq %r12, %rsi
callq 0x3360
movq (%r12), %rdi
cmpq %r13, %rdi
je 0x73d3
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x3290
jmp 0x73d3
jmp 0x7451
jmp 0x7469
movq %rax, %rbx
movq 0x8(%rsp), %rdi
cmpq %r13, %rdi
je 0x74e8
movq 0x18(%rsp), %rsi
jmp 0x74e0
movq %rax, %rbx
jmp 0x74e8
jmp 0x7488
jmp 0x7488
jmp 0x7483
movq %rax, %rbx
leaq 0x8(%rsp), %rdi
callq 0x76a4
jmp 0x74a7
movq %rax, %rbx
jmp 0x74c3
movq %rax, %rbx
jmp 0x74a7
movq %rax, %rbx
movq 0x8(%rsp), %rdi
cmpq %r13, %rdi
je 0x74a7
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x3290
movq 0x60(%rsp), %rdi
leaq 0x70(%rsp), %rax
cmpq %rax, %rdi
je 0x74c3
movq 0x70(%rsp), %rsi
incq %rsi
callq 0x3290
movq 0x80(%rsp), %rdi
leaq 0x90(%rsp), %rax
cmpq %rax, %rdi
je 0x74e8
movq 0x90(%rsp), %rsi
incq %rsi
callq 0x3290
movq %rbx, %rdi
callq 0x3520