// File: /workspace/github_cpp_makefile_star2_O3/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
movb $0x1, %r14b
testq %rdx, %rdx
jle 0x82bb
movq %rcx, %rbx
movq %rsi, %r12
movq %rdi, %r15
addq %rsi, %rdx
leaq 0x58(%rdi), %rax
movq %rax, -0xa8(%rbp)
leaq 0x80(%rdi), %r8
leaq 0x40(%rdi), %rax
movq %rax, -0x98(%rbp)
leaq -0x48(%rbp), %r13
leaq 0x20(%rdi), %rax
movq %rax, -0xa0(%rbp)
movq %rdx, -0x68(%rbp)
movq %rdi, -0x30(%rbp)
movq %r8, -0x38(%rbp)
movq %rcx, -0x70(%rbp)
cmpl $0x2, 0x78(%r15)
jae 0x7ee9
movsbl (%r12), %esi
movq %r8, %rdi
callq 0x3320
movq -0x38(%rbp), %r8
movq -0x30(%rbp), %r15
movq -0x68(%rbp), %rdx
movq 0x88(%r15), %rax
cmpq $0x2, %rax
jb 0x82af
movq (%r8), %rcx
cmpb $0xd, -0x2(%rcx,%rax)
jne 0x82af
cmpb $0xa, -0x1(%rcx,%rax)
jne 0x82af
addq $-0x2, %rax
movq %rax, 0x88(%r15)
movb $0x0, (%rcx,%rax)
movl 0x78(%r15), %eax
cmpl $0x1, %eax
je 0x7f47
testl %eax, %eax
jne 0x8311
cmpq $0x0, 0x88(%r15)
je 0x8288
movq %r8, %rdi
movl $0x20, %esi
xorl %edx, %edx
movq %r8, %r14
callq 0x3430
cmpq $-0x1, %rax
je 0x82d0
movq %rax, %rbx
movq %rax, -0x60(%rbp)
incq %rbx
movq %r14, %rdi
movl $0x20, %esi
movq %rbx, %rdx
callq 0x3430
movq %rax, %r15
leaq -0x58(%rbp), %rdi
movq %r14, %rsi
movq %rdi, %r14
xorl %edx, %edx
movq -0x60(%rbp), %rcx
callq 0x33a0
movq -0x30(%rbp), %rdi
movq %r14, %rsi
callq 0x3400
movq -0x58(%rbp), %rdi
cmpq %r13, %rdi
je 0x7e11
movq -0x48(%rbp), %rsi
incq %rsi
callq 0x3380
movq %r15, %rcx
subq %rbx, %rcx
movq %r14, %rdi
movq -0x38(%rbp), %rsi
movq %rbx, %rdx
callq 0x33a0
movq -0xa0(%rbp), %rdi
movq %r14, %rsi
callq 0x3400
movq -0x58(%rbp), %rdi
cmpq %r13, %rdi
je 0x7e4a
movq -0x48(%rbp), %rsi
incq %rsi
callq 0x3380
incq %r15
movq %r14, %rdi
movq -0x38(%rbp), %rsi
movq %r15, %rdx
movq $-0x1, %rcx
callq 0x33a0
movl $0x7, %ecx
leaq -0x90(%rbp), %rbx
movq %rbx, %rdi
movq %r14, %rsi
xorl %edx, %edx
callq 0x33a0
movq %rbx, %rdi
leaq 0x3677(%rip), %rsi      # 0xb4fd
callq 0x3110
movl %eax, %ebx
movq -0x90(%rbp), %rdi
leaq -0x80(%rbp), %rax
cmpq %rax, %rdi
movb $0x1, %r14b
je 0x7eac
movq -0x80(%rbp), %rsi
incq %rsi
callq 0x3380
testl %ebx, %ebx
jne 0x7ebb
movq -0x30(%rbp), %rax
movl $0x1, 0x78(%rax)
movq -0x58(%rbp), %rdi
cmpq %r13, %rdi
je 0x7ed0
movq -0x48(%rbp), %rsi
incq %rsi
callq 0x3380
testl %ebx, %ebx
movq -0x70(%rbp), %rbx
movq -0x30(%rbp), %r15
movq -0x38(%rbp), %r8
je 0x8288
jmp 0x82d0
jne 0x82af
cmpl $0x0, 0x7c(%r15)
je 0x82d5
movsbl (%r12), %esi
movq -0xa8(%rbp), %rdi
callq 0x3320
decl 0x7c(%r15)
movq -0x68(%rbp), %rdx
movq -0x38(%rbp), %r8
jne 0x82af
cmpq $0x0, 0x10(%rbx)
je 0x82f4
movq %rbx, %rdi
callq *0x18(%rbx)
movq -0x30(%rbp), %r15
movq %r15, %rdi
callq 0x8686
movq -0x68(%rbp), %rdx
movq -0x38(%rbp), %r8
jmp 0x82af
movq 0x88(%r15), %rdx
testq %rdx, %rdx
je 0x7f8b
movq (%r8), %rsi
movzbl (%rsi), %eax
cmpl $0x20, %eax
je 0x7f67
cmpl $0x9, %eax
jne 0x81e6
movq 0x48(%r15), %rdi
cmpq %rdi, 0x40(%r15)
je 0x82d0
addq $-0x20, %rdi
callq 0x3130
movq -0x38(%rbp), %r8
movq -0x30(%rbp), %r15
jmp 0x8288
movq 0x40(%r15), %rbx
movq 0x48(%r15), %rax
movq %rax, -0x60(%rbp)
cmpq %rax, %rbx
je 0x81a2
movq %r13, -0x58(%rbp)
leaq -0x58(%rbp), %rdi
leaq 0x32ba(%rip), %rdx      # 0xb269
movq %rdx, %rsi
callq 0x3e98
movq 0x28(%rbx), %r15
testq %r15, %r15
je 0x8000
movq 0x20(%rbx), %r14
xorl %r13d, %r13d
movzbl (%r14,%r13), %eax
cmpl $0x20, %eax
je 0x7fd6
cmpl $0x9, %eax
jne 0x7fec
movq -0x50(%rbp), %rcx
testq %rcx, %rcx
je 0x7ff8
movq -0x58(%rbp), %rdx
movb $0x20, %al
cmpb $0x20, -0x1(%rdx,%rcx)
je 0x7ff8
movsbl %al, %esi
leaq -0x58(%rbp), %rdi
callq 0x3320
incq %r13
cmpq %r13, %r15
jne 0x7fc7
movq -0x50(%rbp), %rcx
testq %rcx, %rcx
leaq -0x48(%rbp), %r13
leaq -0x58(%rbp), %r14
je 0x805a
movq -0x58(%rbp), %rax
cmpb $0x20, -0x1(%rax,%rcx)
jne 0x805a
decq %rcx
leaq -0x90(%rbp), %r15
movq %r15, %rdi
movq %r14, %rsi
xorl %edx, %edx
callq 0x33a0
movq %r14, %rdi
movq %r15, %rsi
callq 0x3400
movq -0x90(%rbp), %rdi
leaq -0x80(%rbp), %rax
cmpq %rax, %rdi
je 0x805a
movq -0x80(%rbp), %rsi
incq %rsi
callq 0x3380
leaq 0x20(%rbx), %rdi
movq %r14, %rsi
callq 0x3220
movq -0x58(%rbp), %rdi
cmpq %r13, %rdi
je 0x807b
movq -0x48(%rbp), %rsi
incq %rsi
callq 0x3380
addq $0x40, %rbx
cmpq -0x60(%rbp), %rbx
jne 0x7fa0
movq -0x30(%rbp), %rax
movq 0x40(%rax), %r14
movq 0x48(%rax), %r15
cmpq %r15, %r14
je 0x81a2
movq %r13, -0x58(%rbp)
leaq -0x58(%rbp), %rdi
leaq 0x34cb(%rip), %rsi      # 0xb578
leaq 0x34d2(%rip), %rdx      # 0xb586
callq 0x3e98
movq 0x8(%r14), %rax
cmpq -0x50(%rbp), %rax
jne 0x8120
movq -0x58(%rbp), %rdi
testq %rax, %rax
je 0x8128
movq (%r14), %rcx
movl $0x1, %edx
xorl %esi, %esi
movzbl (%rcx,%rsi), %r8d
movzbl (%rdi,%rsi), %esi
leal -0x41(%r8), %r9d
movl %r8d, %r10d
orb $0x20, %r10b
cmpb $0x1a, %r9b
movzbl %r10b, %r9d
cmovael %r8d, %r9d
leal -0x41(%rsi), %r8d
movl %esi, %r10d
orb $0x20, %r10b
cmpb $0x1a, %r8b
movzbl %r10b, %r8d
cmovael %esi, %r8d
cmpb %r8b, %r9b
sete %bl
jne 0x812a
movl %edx, %esi
incl %edx
cmpq %rsi, %rax
ja 0x80d6
jmp 0x812a
movq -0x58(%rbp), %rdi
xorl %ebx, %ebx
jmp 0x812a
movb $0x1, %bl
cmpq %r13, %rdi
je 0x813b
movq -0x48(%rbp), %rsi
incq %rsi
callq 0x3380
testb %bl, %bl
je 0x8199
movq 0x20(%r14), %r13
callq 0x3070
movq %rax, %rbx
movl (%rax), %eax
movl %eax, -0x60(%rbp)
movl $0x0, (%rbx)
movq %r13, %rdi
leaq -0x58(%rbp), %rsi
movl $0xa, %edx
callq 0x3150
cmpq %r13, -0x58(%rbp)
je 0x82f9
movl (%rbx), %ecx
testl %ecx, %ecx
je 0x8189
cmpl $0x22, %ecx
movq -0x30(%rbp), %rcx
leaq -0x48(%rbp), %r13
jne 0x8196
jmp 0x8305
movl -0x60(%rbp), %ecx
movl %ecx, (%rbx)
movq -0x30(%rbp), %rcx
leaq -0x48(%rbp), %r13
movl %eax, 0x7c(%rcx)
addq $0x40, %r14
jmp 0x8095
movq -0x30(%rbp), %r15
movl $0x2, 0x78(%r15)
cmpl $0x0, 0x7c(%r15)
movb $0x1, %r14b
movq -0x70(%rbp), %rbx
movq -0x38(%rbp), %r8
jne 0x8288
cmpq $0x0, 0x10(%rbx)
je 0x82f4
movq %rbx, %rdi
callq *0x18(%rbx)
movq -0x30(%rbp), %r15
movq %r15, %rdi
callq 0x8686
jmp 0x8284
movq %r8, %rdi
movl $0x3a, %esi
xorl %edx, %edx
movq %r8, %r14
callq 0x3430
cmpq $-0x1, %rax
je 0x82d0
movq %rax, %rbx
leaq -0x58(%rbp), %rdi
movq %r14, %rsi
xorl %edx, %edx
movq %rax, %rcx
callq 0x33a0
incq %rbx
leaq -0x90(%rbp), %r15
movq %r15, %rdi
movq %r14, %rsi
movq %rbx, %rdx
movq $-0x1, %rcx
callq 0x33a0
movq -0x98(%rbp), %rdi
leaq -0x58(%rbp), %rsi
movq %r15, %rdx
callq 0x881c
movq -0x70(%rbp), %rbx
movb $0x1, %r14b
movq -0x90(%rbp), %rdi
leaq -0x80(%rbp), %rax
cmpq %rax, %rdi
je 0x826b
movq -0x80(%rbp), %rsi
incq %rsi
callq 0x3380
movq -0x58(%rbp), %rdi
cmpq %r13, %rdi
je 0x8280
movq -0x48(%rbp), %rsi
incq %rsi
callq 0x3380
movq -0x30(%rbp), %r15
movq -0x38(%rbp), %r8
movq 0x88(%r15), %rdx
movq %r8, %rdi
xorl %esi, %esi
leaq 0x2fce(%rip), %rcx      # 0xb269
xorl %r8d, %r8d
callq 0x34d0
movq -0x38(%rbp), %r8
movq -0x30(%rbp), %r15
movq -0x68(%rbp), %rdx
incq %r12
cmpq %rdx, %r12
jb 0x7d22
movl %r14d, %eax
addq $0x88, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
xorl %r14d, %r14d
jmp 0x82bb
leaq 0x32ab(%rip), %rdi      # 0xb587
leaq 0x2fec(%rip), %rsi      # 0xb2cf
leaq 0x322e(%rip), %rcx      # 0xb518
movl $0xe4, %edx
callq 0x3280
callq 0x3190
leaq 0x3299(%rip), %rdi      # 0xb599
callq 0x3250
leaq 0x328d(%rip), %rdi      # 0xb599
callq 0x3490
leaq 0x31ed(%rip), %rdi      # 0xb505
leaq 0x2fb0(%rip), %rsi      # 0xb2cf
leaq 0x31f2(%rip), %rcx      # 0xb518
movl $0xaf, %edx
callq 0x3280
movq %rax, %r14
movq -0x90(%rbp), %rdi
leaq -0x80(%rbp), %rax
cmpq %rax, %rdi
je 0x8356
movq -0x80(%rbp), %rsi
incq %rsi
callq 0x3380
jmp 0x8356
jmp 0x8353
movq %rax, %r14
movq -0x58(%rbp), %rdi
cmpq %r13, %rdi
jne 0x8389
jmp 0x8395
jmp 0x8379
movq %rax, %r14
cmpl $0x0, (%rbx)
jne 0x8395
movl -0x60(%rbp), %eax
movl %eax, (%rbx)
jmp 0x8395
movq %rax, %r14
jmp 0x8395
jmp 0x8379
movq %rax, %r14
movq -0x58(%rbp), %rdi
leaq -0x48(%rbp), %rax
cmpq %rax, %rdi
je 0x8395
movq -0x48(%rbp), %rsi
incq %rsi
callq 0x3380
movq %r14, %rdi
callq 0x3570
nop