// File: /workspace/github_cpp_makefile_star2_O2/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
movq %rcx, -0x68(%rbp)
movq %rdx, %r12
movq %rsi, %r14
addq %rsi, %r12
leaq 0x58(%rdi), %rax
movq %rax, -0x88(%rbp)
leaq 0x80(%rdi), %rax
movq %rax, -0x38(%rbp)
leaq 0x40(%rdi), %rax
movq %rax, -0x78(%rbp)
movq %rdi, -0x30(%rbp)
leaq 0x20(%rdi), %rax
movq %rax, -0x80(%rbp)
leaq -0x58(%rbp), %r13
cmpq %r12, %r14
jae 0x7086
movq -0x30(%rbp), %r15
cmpl $0x2, 0x78(%r15)
jae 0x6dfb
movsbl (%r14), %esi
movq -0x38(%rbp), %rdi
callq 0x3310
movq 0x88(%r15), %rsi
cmpq $0x2, %rsi
jb 0x7075
movq -0x38(%rbp), %rax
movq (%rax), %rax
cmpb $0xd, -0x2(%rax,%rsi)
jne 0x7075
cmpb $0xa, -0x1(%rax,%rsi)
jne 0x7075
addq $-0x2, %rsi
movq -0x38(%rbp), %rdi
pushq $-0x1
popq %rdx
callq 0x30c0
movq -0x30(%rbp), %rcx
movl 0x78(%rcx), %eax
cmpl $0x1, %eax
je 0x6e41
testl %eax, %eax
jne 0x70bd
movq -0x30(%rbp), %rax
cmpq $0x0, 0x88(%rax)
je 0x7065
movq -0x38(%rbp), %rdi
pushq $0x20
popq %rsi
xorl %edx, %edx
callq 0x3410
cmpq $-0x1, %rax
je 0x7086
movq %rax, %r15
movq %rax, %rdx
incq %rdx
movq %rdx, -0x60(%rbp)
movq -0x38(%rbp), %r13
movq %r13, %rdi
pushq $0x20
popq %rsi
callq 0x3410
movq %rax, %rbx
leaq -0x58(%rbp), %rdi
movq %r13, %rsi
xorl %edx, %edx
movq %r15, %rcx
callq 0x3390
movq -0x30(%rbp), %rdi
leaq -0x58(%rbp), %rsi
callq 0x33d0
leaq -0x58(%rbp), %rdi
callq 0x31c0
movq %rbx, %rcx
movq -0x60(%rbp), %rdx
subq %rdx, %rcx
leaq -0x58(%rbp), %rdi
movq %r13, %rsi
callq 0x3390
movq -0x80(%rbp), %rdi
leaq -0x58(%rbp), %rsi
callq 0x33d0
leaq -0x58(%rbp), %rdi
callq 0x31c0
incq %rbx
leaq -0x58(%rbp), %rdi
movq %r13, %rsi
leaq -0x58(%rbp), %r13
movq %rbx, %rdx
pushq $-0x1
popq %rcx
callq 0x3390
leaq -0xb0(%rbp), %rbx
movq %rbx, %rdi
movq %r13, %rsi
xorl %edx, %edx
pushq $0x7
popq %rcx
callq 0x3390
movq %rbx, %rdi
leaq 0x3723(%rip), %rsi      # 0xa4f5
callq 0x757a
movl %eax, %r15d
movq %rbx, %rdi
callq 0x31c0
testb %r15b, %r15b
jne 0x707d
movq -0x30(%rbp), %rax
movl $0x1, 0x78(%rax)
jmp 0x705d
jne 0x7075
movq -0x30(%rbp), %r15
cmpl $0x0, 0x7c(%r15)
je 0x709e
movsbl (%r14), %esi
movq -0x88(%rbp), %rdi
callq 0x3310
decl 0x7c(%r15)
jne 0x7075
movq -0x68(%rbp), %rdi
callq 0x7612
movq -0x30(%rbp), %rdi
callq 0x7626
jmp 0x7075
cmpq $0x0, 0x88(%rcx)
je 0x6e87
movq -0x38(%rbp), %rax
movq (%rax), %rax
movzbl (%rax), %eax
cmpl $0x20, %eax
je 0x6e63
cmpl $0x9, %eax
jne 0x6ffc
movq -0x30(%rbp), %rax
movq 0x48(%rax), %rdi
cmpq %rdi, 0x40(%rax)
je 0x7086
addq $-0x20, %rdi
movq -0x38(%rbp), %rsi
callq 0x35a0
jmp 0x7065
movq 0x40(%rcx), %rbx
movq 0x48(%rcx), %rax
movq %rax, -0x90(%rbp)
movq %r14, -0x70(%rbp)
leaq -0xb0(%rbp), %r15
cmpq -0x90(%rbp), %rbx
je 0x6f74
movq %r12, %r13
leaq -0x58(%rbp), %rdi
leaq 0x33a5(%rip), %rsi      # 0xa261
movq %r15, %rdx
callq 0x3ac4
leaq 0x20(%rbx), %rax
movq %rax, -0x60(%rbp)
movq 0x20(%rbx), %r12
movq 0x28(%rbx), %r15
xorl %r14d, %r14d
cmpq %r14, %r15
je 0x6f12
movzbl (%r12,%r14), %eax
cmpl $0x20, %eax
je 0x6eeb
cmpl $0x9, %eax
jne 0x6f01
movq -0x50(%rbp), %rcx
testq %rcx, %rcx
je 0x6f0d
movq -0x58(%rbp), %rdx
movb $0x20, %al
cmpb $0x20, -0x1(%rdx,%rcx)
je 0x6f0d
movsbl %al, %esi
leaq -0x58(%rbp), %rdi
callq 0x3310
incq %r14
jmp 0x6ed7
movq -0x50(%rbp), %rcx
testq %rcx, %rcx
movq %r13, %r12
leaq -0x58(%rbp), %r14
leaq -0xb0(%rbp), %r15
je 0x6f57
movq -0x58(%rbp), %rax
cmpb $0x20, -0x1(%rax,%rcx)
jne 0x6f57
decq %rcx
movq %r15, %rdi
movq %r14, %rsi
xorl %edx, %edx
callq 0x3390
movq %r14, %rdi
movq %r15, %rsi
callq 0x33d0
movq %r15, %rdi
callq 0x31c0
movq -0x60(%rbp), %rdi
movq %r14, %rsi
callq 0x3210
movq %r14, %rdi
callq 0x31c0
addq $0x40, %rbx
jmp 0x6ea1
movq -0x30(%rbp), %rax
movq 0x40(%rax), %r15
movq 0x48(%rax), %r14
leaq -0x58(%rbp), %r13
cmpq %r14, %r15
je 0x6fd3
movq %r13, %rdi
leaq 0x35dd(%rip), %rsi      # 0xa570
leaq -0xb0(%rbp), %rdx
callq 0x3ac4
movq %r15, %rdi
movq %r13, %rsi
callq 0x7587
movl %eax, %ebx
movq %r13, %rdi
callq 0x31c0
testb %bl, %bl
je 0x6fcd
leaq 0x20(%r15), %rdi
xorl %esi, %esi
pushq $0xa
popq %rdx
callq 0x75f1
movq -0x30(%rbp), %rcx
movl %eax, 0x7c(%rcx)
addq $0x40, %r15
jmp 0x6f84
movq -0x30(%rbp), %rax
movl $0x2, 0x78(%rax)
cmpl $0x0, 0x7c(%rax)
movq -0x70(%rbp), %r14
jne 0x7065
movq -0x68(%rbp), %rdi
callq 0x7612
movq -0x30(%rbp), %rdi
callq 0x7626
jmp 0x7065
movq -0x38(%rbp), %rdi
pushq $0x3a
popq %rsi
xorl %edx, %edx
callq 0x3410
cmpq $-0x1, %rax
je 0x7086
movq %rax, %r15
movq %r13, %rdi
movq -0x38(%rbp), %rbx
movq %rbx, %rsi
xorl %edx, %edx
movq %rax, %rcx
callq 0x3390
incq %r15
leaq -0xb0(%rbp), %rdi
movq %rbx, %rsi
movq %r15, %rdx
pushq $-0x1
popq %rcx
callq 0x3390
movq -0x78(%rbp), %rdi
movq %r13, %rsi
leaq -0xb0(%rbp), %rbx
movq %rbx, %rdx
callq 0x7674
movq %rbx, %rdi
callq 0x31c0
movq %r13, %rdi
callq 0x31c0
movq -0x38(%rbp), %rdi
leaq 0x31f1(%rip), %rsi      # 0xa261
callq 0x3590
incq %r14
jmp 0x6c81
leaq -0x58(%rbp), %rdi
callq 0x31c0
cmpq %r12, %r14
setae %al
addq $0x88, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x34da(%rip), %rdi      # 0xa57f
leaq 0x321b(%rip), %rsi      # 0xa2c7
leaq 0x345d(%rip), %rcx      # 0xa510
movl $0xe4, %edx
callq 0x3270
leaq 0x3439(%rip), %rdi      # 0xa4fd
leaq 0x31fc(%rip), %rsi      # 0xa2c7
leaq 0x343e(%rip), %rcx      # 0xa510
movl $0xaf, %edx
callq 0x3270
jmp 0x70e0
jmp 0x70fc
movq %rax, %rbx
leaq -0xb0(%rbp), %rdi
callq 0x31c0
jmp 0x70ff
jmp 0x70fc
jmp 0x70fc
jmp 0x70fc
movq %rax, %rbx
jmp 0x7108
movq %rax, %rbx
leaq -0x58(%rbp), %rdi
callq 0x31c0
movq %rbx, %rdi
callq 0x3540