// File: /workspace/github_cpp_makefile_star2_O1/ixchow[P]http-tweak/./http.hpp
// Function: http::incoming_request::parse_bytes(char const*, long, std::function<void ()> const&)
bool parse_bytes(char const *begin, ssize_t count, std::function< void() > const &on_finish) {
		for (char const *c = begin; c < begin + count; ++c) {
			if (mode == RequestLine || mode == HeaderLine) {
				line += *c;
				//once line is complete, parse it:
				if (line.size() >= 2 && line[line.size() - 2] == '\r' && line[line.size()-1] == '\n') {
					line.erase(line.size()-2); //trim CRLF

					if (mode == RequestLine) {
						if (line.size() != 0) { //ignore empty lines before request
							//parse "method SP url SP version"
							std::string::size_type i1 = line.find(' ');
							if (i1 == std::string::npos) return false;
							std::string::size_type i2 = line.find(' ', i1+1);
							if (i1 == std::string::npos) return false;
							method = line.substr(0, i1);
							url = line.substr(i1+1, i2-(i1+1));
							std::string version = line.substr(i2+1);
							if (version.substr(0,7) != "HTTP/1.") return false; //unsupported http version

							mode = HeaderLine; //next lines are headers
						}
					} else { assert(mode == HeaderLine);
						if (line.size() == 0) {
							//empty line separates headers from body

							//clean up headers by trimming whitespace as per the spec:
							for (auto &nf : headers) {
								std::string value = "";
								//replace runs of ' '/'\t' with single ' ' (and ignore first such run):
								for (auto const &c : nf.second) {
									if (c == ' ' || c == '\t') {
										if (!value.empty() && value[value.size()-1] != ' ') {
											value += ' ';
										}
									} else {
										value += c;
									}
								}
								if (!value.empty() && value[value.size()-1] == ' ') value = value.substr(0, value.size()-1);
								nf.second = value;
							}

							//set body_remains based on size of body passed in content header:
							for (auto const &nf : headers) {
								if (case_insensitive_equals(nf.first, "Content-Length")) {
									body_remains = std::stoul(nf.second);
								}
							}

							mode = Body;
							if (body_remains == 0) {
								on_finish();
								reset();
							}
						} else {
							//parse "name: [space] value" or "[space] continuation-value"
							if (line[0] == ' ' || line[0] == '\t') {
								//[space] continuation-value
								if (headers.empty()) {
									return false; //nothing to continue
								}
								headers.back().second += line;
							} else {
								auto i = line.find(':');
								if (i == std::string::npos) {
									return false; //no ':' to split field name and value
								}
								headers.emplace_back(line.substr(0, i), line.substr(i+1));
							}
						}
					}
					line = ""; //clear line, now that it's parsed
				}
			} else if (mode == Body) {
				assert(body_remains != 0);
				body += *c;
				--body_remains;
				if (body_remains == 0) {
					on_finish();
					reset();
				}
			}
		}
		return true;
	}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x88, %rsp
testq %rdx, %rdx
setle %r13b
jle 0x8383
movq %rsi, %r15
movq %rdi, %r11
movq %rcx, -0x88(%rbp)
addq %rsi, %rdx
movq %rdx, -0xb0(%rbp)
leaq 0x58(%rdi), %rax
movq %rax, -0xa8(%rbp)
leaq 0x80(%rdi), %rax
movq %rax, -0x58(%rbp)
leaq 0x40(%rdi), %rax
movq %rax, -0x98(%rbp)
leaq -0x40(%rbp), %r12
leaq 0x20(%rdi), %rax
movq %rax, -0xa0(%rbp)
leaq -0x80(%rbp), %rbx
movq %rdi, -0x30(%rbp)
cmpl $0x2, 0x78(%r11)
jae 0x7f78
movsbl (%r15), %esi
movq -0x58(%rbp), %rdi
callq 0x3320
movq -0x30(%rbp), %r11
movq 0x88(%r11), %rax
cmpq $0x2, %rax
jb 0x836f
movq -0x58(%rbp), %rcx
movq (%rcx), %rcx
cmpb $0xd, -0x2(%rcx,%rax)
jne 0x836f
cmpb $0xa, -0x1(%rcx,%rax)
jne 0x836f
addq $-0x2, %rax
movq %rax, 0x88(%r11)
movb $0x0, (%rcx,%rax)
movl 0x78(%r11), %eax
cmpl $0x1, %eax
je 0x7fd2
testl %eax, %eax
jne 0x83d8
cmpq $0x0, 0x88(%r11)
je 0x834f
movq -0x58(%rbp), %rbx
movq %rbx, %rdi
movl $0x20, %esi
xorl %edx, %edx
callq 0x3430
cmpq $-0x1, %rax
je 0x8383
movq %rax, %r14
movq %rax, -0x90(%rbp)
incq %r14
movq %rbx, %rdi
movl $0x20, %esi
movq %r14, %rdx
callq 0x3430
movq %rax, -0x60(%rbp)
leaq -0x50(%rbp), %rdi
movq %rbx, %rsi
xorl %edx, %edx
movq -0x90(%rbp), %rcx
callq 0x33a0
movq -0x30(%rbp), %rdi
leaq -0x50(%rbp), %rsi
callq 0x3400
movq -0x50(%rbp), %rdi
cmpq %r12, %rdi
je 0x7ea3
movq -0x40(%rbp), %rsi
incq %rsi
callq 0x3380
movq -0x60(%rbp), %rcx
subq %r14, %rcx
leaq -0x50(%rbp), %rbx
movq %rbx, %rdi
movq -0x58(%rbp), %rsi
movq %r14, %rdx
callq 0x33a0
movq -0xa0(%rbp), %rdi
movq %rbx, %rsi
callq 0x3400
movq -0x50(%rbp), %rdi
cmpq %r12, %rdi
je 0x7ee1
movq -0x40(%rbp), %rsi
incq %rsi
callq 0x3380
movq -0x60(%rbp), %rdx
incq %rdx
leaq -0x50(%rbp), %r14
movq %r14, %rdi
movq -0x58(%rbp), %rsi
movq $-0x1, %rcx
callq 0x33a0
movl $0x7, %ecx
leaq -0x80(%rbp), %rbx
movq %rbx, %rdi
movq %r14, %rsi
xorl %edx, %edx
callq 0x33a0
movq %rbx, %rdi
leaq 0x3605(%rip), %rsi      # 0xb524
callq 0x3110
movl %eax, %r14d
movq -0x80(%rbp), %rdi
leaq -0x70(%rbp), %rax
cmpq %rax, %rdi
je 0x7f40
movq -0x70(%rbp), %rsi
incq %rsi
callq 0x3380
testl %r14d, %r14d
movq -0x30(%rbp), %r11
jne 0x7f51
movl $0x1, 0x78(%r11)
movq -0x50(%rbp), %rdi
cmpq %r12, %rdi
je 0x7f6a
movq -0x40(%rbp), %rsi
incq %rsi
callq 0x3380
movq -0x30(%rbp), %r11
testl %r14d, %r14d
je 0x834f
jmp 0x8383
jne 0x836f
cmpl $0x0, 0x7c(%r11)
je 0x839c
movq %r11, %r14
movsbl (%r15), %esi
movq -0xa8(%rbp), %rdi
callq 0x3320
decl 0x7c(%r14)
movq %r14, %r11
jne 0x836f
movq -0x88(%rbp), %rdi
cmpq $0x0, 0x10(%rdi)
je 0x83c7
callq *0x18(%rdi)
movq -0x30(%rbp), %r14
movq %r14, %rdi
callq 0x876a
movq %r14, %r11
jmp 0x836f
movq 0x88(%r11), %rdx
testq %rdx, %rdx
je 0x8012
movq -0x58(%rbp), %rdi
movq (%rdi), %rsi
movzbl (%rsi), %eax
cmpl $0x20, %eax
je 0x7ff6
cmpl $0x9, %eax
jne 0x82be
movq 0x48(%r11), %rdi
cmpq %rdi, 0x40(%r11)
je 0x8383
addq $-0x20, %rdi
callq 0x3130
jmp 0x834b
movq 0x40(%r11), %rbx
movq 0x48(%r11), %rax
movq %rax, -0x60(%rbp)
cmpq %rax, %rbx
leaq -0x50(%rbp), %r13
je 0x810d
movq %r12, -0x50(%rbp)
movq %r13, %rdi
leaq 0x3230(%rip), %rdx      # 0xb269
movq %rdx, %rsi
callq 0x3eaa
movq 0x28(%rbx), %r13
testq %r13, %r13
je 0x808a
movq 0x20(%rbx), %r12
xorl %r14d, %r14d
movzbl (%r12,%r14), %eax
cmpl $0x20, %eax
je 0x8060
cmpl $0x9, %eax
jne 0x8076
movq -0x48(%rbp), %rcx
testq %rcx, %rcx
je 0x8082
movq -0x50(%rbp), %rdx
movb $0x20, %al
cmpb $0x20, -0x1(%rdx,%rcx)
je 0x8082
movsbl %al, %esi
leaq -0x50(%rbp), %rdi
callq 0x3320
incq %r14
cmpq %r14, %r13
jne 0x8051
movq -0x48(%rbp), %rcx
testq %rcx, %rcx
leaq -0x40(%rbp), %r12
leaq -0x50(%rbp), %r13
je 0x80de
movq -0x50(%rbp), %rax
cmpb $0x20, -0x1(%rax,%rcx)
jne 0x80de
decq %rcx
leaq -0x80(%rbp), %r14
movq %r14, %rdi
movq %r13, %rsi
xorl %edx, %edx
callq 0x33a0
movq %r13, %rdi
movq %r14, %rsi
callq 0x3400
movq -0x80(%rbp), %rdi
leaq -0x70(%rbp), %rax
cmpq %rax, %rdi
je 0x80de
movq -0x70(%rbp), %rsi
incq %rsi
callq 0x3380
leaq 0x20(%rbx), %rdi
movq %r13, %rsi
callq 0x3220
movq -0x50(%rbp), %rdi
cmpq %r12, %rdi
je 0x80ff
movq -0x40(%rbp), %rsi
incq %rsi
callq 0x3380
addq $0x40, %rbx
cmpq -0x60(%rbp), %rbx
jne 0x802b
movq -0x30(%rbp), %r11
movq 0x40(%r11), %rbx
movq 0x48(%r11), %rax
movq %rax, -0x60(%rbp)
cmpq %rax, %rbx
je 0x827e
movq %r12, -0x50(%rbp)
movq %r13, %rdi
leaq 0x346b(%rip), %rsi      # 0xb59f
leaq 0x3472(%rip), %rdx      # 0xb5ad
callq 0x3eaa
movq 0x8(%rbx), %rax
cmpq -0x48(%rbp), %rax
jne 0x81ed
testq %rax, %rax
sete %r14b
movq -0x30(%rbp), %r11
je 0x81f9
movq (%rbx), %rcx
movq -0x50(%rbp), %rdx
movzbl (%rcx), %esi
movzbl (%rdx), %edi
leal -0x41(%rsi), %r8d
movl %esi, %r9d
orb $0x20, %r9b
cmpb $0x1a, %r8b
movzbl %r9b, %r8d
cmovael %esi, %r8d
leal -0x41(%rdi), %esi
movl %edi, %r9d
orb $0x20, %r9b
cmpb $0x1a, %sil
movzbl %r9b, %esi
cmovael %edi, %esi
cmpb %sil, %r8b
jne 0x81f6
movl $0x1, %esi
movl %esi, %esi
cmpq %rsi, %rax
setbe %r14b
jbe 0x81f9
movzbl (%rcx,%rsi), %edi
movzbl (%rdx,%rsi), %r8d
leal -0x41(%rdi), %r9d
movl %edi, %r10d
orb $0x20, %r10b
cmpb $0x1a, %r9b
movzbl %r10b, %r9d
cmovael %edi, %r9d
leal -0x41(%r8), %edi
movl %r8d, %r10d
orb $0x20, %r10b
cmpb $0x1a, %dil
movzbl %r10b, %edi
cmovael %r8d, %edi
incl %esi
cmpb %dil, %r9b
je 0x81a2
jmp 0x81f9
xorl %r14d, %r14d
movq -0x30(%rbp), %r11
jmp 0x81f9
xorl %r14d, %r14d
movq -0x50(%rbp), %rdi
cmpq %r12, %rdi
je 0x8212
movq -0x40(%rbp), %rsi
incq %rsi
callq 0x3380
movq -0x30(%rbp), %r11
testb %r14b, %r14b
je 0x8270
movq 0x20(%rbx), %r14
callq 0x3070
movq %r13, %rsi
movq %rax, %r13
movl (%rax), %r12d
movl $0x0, (%rax)
movq %r14, %rdi
movl $0xa, %edx
callq 0x3150
cmpq %r14, -0x50(%rbp)
je 0x83bb
movl (%r13), %ecx
testl %ecx, %ecx
je 0x825c
cmpl $0x22, %ecx
movq -0x30(%rbp), %r11
jne 0x8264
jmp 0x83cc
movl %r12d, (%r13)
movq -0x30(%rbp), %r11
movl %eax, 0x7c(%r11)
leaq -0x40(%rbp), %r12
leaq -0x50(%rbp), %r13
addq $0x40, %rbx
cmpq -0x60(%rbp), %rbx
jne 0x8126
movl $0x2, 0x78(%r11)
cmpl $0x0, 0x7c(%r11)
leaq -0x80(%rbp), %rbx
jne 0x834f
movq -0x88(%rbp), %rdi
cmpq $0x0, 0x10(%rdi)
je 0x83c7
callq *0x18(%rdi)
movq -0x30(%rbp), %r14
movq %r14, %rdi
callq 0x876a
movq %r14, %r11
jmp 0x834f
movl $0x3a, %esi
xorl %edx, %edx
callq 0x3430
cmpq $-0x1, %rax
je 0x8383
movq %rax, %r14
leaq -0x50(%rbp), %rdi
movq %rbx, %r13
movq -0x58(%rbp), %rbx
movq %rbx, %rsi
xorl %edx, %edx
movq %rax, %rcx
callq 0x33a0
incq %r14
movq %r13, %rdi
movq %rbx, %rsi
movq %r14, %rdx
movq $-0x1, %rcx
callq 0x33a0
movq -0x98(%rbp), %rdi
leaq -0x50(%rbp), %rsi
movq %r13, %rdx
callq 0x8920
movq %r13, %rbx
movq -0x80(%rbp), %rdi
leaq -0x70(%rbp), %rax
cmpq %rax, %rdi
je 0x8336
movq -0x70(%rbp), %rsi
incq %rsi
callq 0x3380
movq -0x50(%rbp), %rdi
cmpq %r12, %rdi
je 0x834b
movq -0x40(%rbp), %rsi
incq %rsi
callq 0x3380
movq -0x30(%rbp), %r11
movq 0x88(%r11), %rdx
movq -0x58(%rbp), %rdi
xorl %esi, %esi
leaq 0x2f06(%rip), %rcx      # 0xb269
xorl %r8d, %r8d
callq 0x34d0
movq -0x30(%rbp), %r11
incq %r15
cmpq -0xb0(%rbp), %r15
setae %r13b
jb 0x7db2
andb $0x1, %r13b
movl %r13d, %eax
addq $0x88, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x320b(%rip), %rdi      # 0xb5ae
leaq 0x2f25(%rip), %rsi      # 0xb2cf
leaq 0x318e(%rip), %rcx      # 0xb53f
movl $0xe4, %edx
callq 0x3280
leaq 0x31fe(%rip), %rdi      # 0xb5c0
callq 0x3250
callq 0x3190
leaq 0x31ed(%rip), %rdi      # 0xb5c0
callq 0x3490
leaq 0x314d(%rip), %rdi      # 0xb52c
leaq 0x2ee9(%rip), %rsi      # 0xb2cf
leaq 0x3152(%rip), %rcx      # 0xb53f
movl $0xaf, %edx
callq 0x3280
movq %rax, %rbx
movq -0x80(%rbp), %rdi
leaq -0x70(%rbp), %rax
cmpq %rax, %rdi
je 0x8441
movq -0x70(%rbp), %rsi
incq %rsi
callq 0x3380
jmp 0x8441
jmp 0x843e
movq %rax, %rbx
movq -0x50(%rbp), %rdi
cmpq %r12, %rdi
jne 0x844e
jmp 0x845a
jmp 0x843e
movq %rax, %rbx
cmpl $0x0, (%r13)
jne 0x845a
movl %r12d, (%r13)
jmp 0x845a
jmp 0x843e
movq %rax, %rbx
jmp 0x845a
movq %rax, %rbx
movq -0x50(%rbp), %rdi
leaq -0x40(%rbp), %rax
cmpq %rax, %rdi
je 0x845a
movq -0x40(%rbp), %rsi
incq %rsi
callq 0x3380
movq %rbx, %rdi
callq 0x3570