// File: /workspace/github_cpp_makefile_star2_O3/trisolaris233[P]httpc/src/request_parser.hpp
// Function: httpc::RequestParser::ResultType httpc::RequestParser::ParseRequest<char>(httpc::Request&, char)
ResultType ParseRequest(
                Request& request_, CharT chr) {
            // there is a problem with the original parsing function
            // the case is that when request line is like this "GET HTTP/1.1"
            // is also available on many broswers, but error will occurs on
            // the original one.
            switch(parse_enum_) {
                case kStart:
                    if (!is_char(chr) || is_ctl(chr) || is_tspecial(chr)) {
                        return kBad;
                    } else {
                        request_.method.push_back(chr);
                        parse_enum_ = kHTTPMethod;
                        return kIndeterminate;
                    }

                case kHTTPMethod:
                    if (chr == ' ') {
                        parse_enum_ = kURI;
                        return kIndeterminate;
                    } else if (!is_char(chr) || is_ctl(chr) || is_tspecial(chr)) {
                        return kBad;
                    } else {
                        request_.method.push_back(chr);
                        return kIndeterminate;
                    }

                case kURI:
                    if (chr == ' ') {
                        parse_enum_ = kH;
                        return kIndeterminate;
                    } else if (is_ctl(chr)) {
                        return kBad;
                    } else {
                        request_.uri.Append(chr);
                        return kIndeterminate;
                    }

                case kH:
                    if (chr == 'H') {
                        parse_enum_ = kT1;
                        return kIndeterminate;
                    } else {
                        return kBad;
                    }

                case kT1:
                    if (chr == 'T') {
                        parse_enum_ = kT2;
                        return kIndeterminate;
                    } else {
                        return kBad;
                    }
                    
                case kT2:
                    if (chr == 'T') {
                        parse_enum_ = kP;
                        return kIndeterminate;
                    } else {
                        return kBad;
                    }

                case kP:
                    if (chr == 'P') {
                        parse_enum_ = kSlash;
                        return kIndeterminate;
                    } else {
                        return kBad;
                    }

                case kSlash:
                    if (chr == '/') {
                        parse_enum_ = kMajorVersion;
                        return kIndeterminate;
                    } else {
                        return kBad;
                    }

                case kMajorVersion:
                    if (chr == '.') {
                        power_ = 1;
                        parse_enum_ = kMinorVersion;
                        return kIndeterminate;
                    } else if (std::isdigit(chr)) {
                        request_.http_major_version += power_ * static_cast<int>(chr - 0x30);
                        return kIndeterminate;
                    } else {
                        return kBad;
                    }

                case kMinorVersion:
                    if (chr == '\r') {
                        parse_enum_ = kFirstLF;
                        return kIndeterminate;
                    } else if (std::isdigit(chr)) {
                        request_.http_minor_version += power_ * static_cast<int>(chr - 0x30);
                        return kIndeterminate;
                    } else {
                        return kBad;
                    }

                case kFirstLF:
                    if (chr == '\n') {
                        parse_enum_ = kHeaderLineStart;
                        return kIndeterminate;
                    } else {
                        return kBad;
                    }

                case kHeaderLineStart:
                    if (chr == '\r') {
                        parse_enum_ = kExceptingNewLineEnding;
                        return kIndeterminate;
                    } else if (!request_.headers.empty() && (chr == ' ' || chr == '\t')) {
                        parse_enum_ = kHeaderLws;
                        return kIndeterminate;
                    } else if (!is_char(chr) || is_ctl(chr) || is_tspecial(chr)) {
                        return kBad;
                    } else {
                        request_.headers.push_back(Header());
                        request_.headers.back().field.push_back(chr);
                        parse_enum_ = kHeaderName;
                        return kIndeterminate;
                    }

                case kHeaderLws:
                    if (chr == '\r') {
                        parse_enum_ = kExceptingNormalNewLine;
                        return kIndeterminate;
                    } else if (chr == ' ' || chr == '\t') {
                        return kIndeterminate;
                    } else if (is_ctl(chr)) {
                        return kBad;
                    } else {
                        parse_enum_ = kHeaderValue;
                        request_.headers.back().value.push_back(chr);
                        return kIndeterminate;;
                    }

                case kHeaderName:
                    if (chr == ':') {
                        parse_enum_ = kSpaceBeforeHeaderValue;
                        return kIndeterminate;
                    } else if (!is_char(chr) || is_ctl(chr) || is_tspecial(chr)) {
                        return kBad;
                    } else {
                        request_.headers.back().field.push_back(chr);
                        return kIndeterminate;
                    }

                case kSpaceBeforeHeaderValue:
                    if (chr == ' ') {
                        parse_enum_ = kHeaderValue;
                        return kIndeterminate;
                    } else {
                        return kBad;
                    }

                case kHeaderValue:
                    if (chr == '\r') {
                        parse_enum_ = kExceptingNormalNewLine;
                        return kIndeterminate;
                    } else if (is_ctl(chr)) {
                        return kBad;
                    } else {
                        request_.headers.back().value.push_back(chr);
                        return kIndeterminate;
                    }

                case kExceptingNormalNewLine:
                    if (chr == '\n') {
                        parse_enum_ = kHeaderLineStart;
                        return kIndeterminate;
                    } else {
                        return kBad;
                    }

                case kExceptingNewLineEnding:
                    return chr == '\n' ? kGood : kBad;
                    
                
                default:
                    return kBad;
            }
        }

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x40, %rsp
movl 0x20(%rdi), %eax
movl $0x1, %ebx
cmpq $0x12, %rax
ja 0x176fc
movq %rsi, %r14
movq %rdi, %r15
leaq 0xcc50(%rip), %rcx      # 0x2407c
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
cmpb $0xa, %dl
jne 0x176fc
movl $0xc, 0x20(%r15)
jmp 0x176f7
cmpb $0x3a, %dl
jne 0x1760c
movl $0x10, 0x20(%r15)
jmp 0x176f7
cmpb $0x54, %dl
jne 0x176fc
movl $0x5, 0x20(%r15)
jmp 0x176f7
cmpb $0xd, %dl
jne 0x1764d
movl $0x12, 0x20(%r15)
jmp 0x176f7
cmpb $0x20, %dl
jne 0x1767c
movl $0x2, 0x20(%r15)
jmp 0x176f7
cmpb $0x54, %dl
jne 0x176fc
movl $0x6, 0x20(%r15)
jmp 0x176f7
cmpb $0x48, %dl
jne 0x176fc
movl $0x4, 0x20(%r15)
jmp 0x176f7
movsbl %dl, %r12d
movl %r12d, %edi
callq 0x227bd
testb %al, %al
je 0x176fc
movl %r12d, %edi
callq 0x227cc
testb %al, %al
jne 0x176fc
movl %r12d, %edi
callq 0x227e0
testb %al, %al
jne 0x176fc
movq %r14, %rdi
movl %r12d, %esi
callq 0x8480
movl $0x1, 0x20(%r15)
jmp 0x176f7
cmpb $0x20, %dl
jne 0x176a6
movl $0x3, 0x20(%r15)
jmp 0x176f7
cmpb $0x50, %dl
jne 0x176fc
movl $0x7, 0x20(%r15)
jmp 0x176f7
cmpb $0x2f, %dl
jne 0x176fc
movl $0x8, 0x20(%r15)
jmp 0x176f7
cmpb $0xd, %dl
je 0x175a8
movsbl %dl, %r15d
movl %r15d, %edi
callq 0x227cc
testb %al, %al
jne 0x176fc
movq 0xa0(%r14), %rdi
addq $-0x20, %rdi
jmp 0x176bd
movsbl %dl, %r12d
cmpl $0x9, %r12d
je 0x176f7
cmpl $0x20, %r12d
je 0x176f7
cmpl $0xd, %r12d
jne 0x17795
movl $0x11, 0x20(%r15)
jmp 0x176f7
cmpb $0xd, %dl
jne 0x176c7
movl $0xb, 0x20(%r15)
jmp 0x176f7
cmpb $0x2e, %dl
jne 0x176e0
movl $0x1, 0x28(%r15)
movl $0xa, 0x20(%r15)
jmp 0x176f7
xorl %ebx, %ebx
cmpb $0xa, %dl
setne %bl
jmp 0x176fc
cmpb $0x20, %dl
jne 0x176fc
movl $0xe, 0x20(%r15)
jmp 0x176f7
movsbl %dl, %r15d
movl %r15d, %edi
callq 0x227bd
testb %al, %al
je 0x176fc
movl %r15d, %edi
callq 0x227cc
testb %al, %al
jne 0x176fc
movl %r15d, %edi
callq 0x227e0
testb %al, %al
jne 0x176fc
movq 0xa0(%r14), %rdi
addq $-0x40, %rdi
jmp 0x176bd
movq 0x98(%r14), %rax
cmpq 0xa0(%r14), %rax
je 0x1770b
movsbl %dl, %eax
cmpl $0x20, %eax
je 0x17672
cmpl $0x9, %eax
jne 0x1770b
movl $0xf, 0x20(%r15)
jmp 0x176f7
movsbl %dl, %r15d
movl %r15d, %edi
callq 0x227bd
testb %al, %al
je 0x176fc
movl %r15d, %edi
callq 0x227cc
testb %al, %al
jne 0x176fc
movl %r15d, %edi
callq 0x227e0
testb %al, %al
je 0x176ba
jmp 0x176fc
movsbl %dl, %r15d
movl %r15d, %edi
callq 0x227cc
testb %al, %al
jne 0x176fc
addq $0x20, %r14
movq %r14, %rdi
movl %r15d, %esi
callq 0x8480
jmp 0x176f7
movsbl %dl, %eax
addl $-0x30, %eax
cmpl $0x9, %eax
ja 0x176fc
imull 0x28(%r15), %eax
addl %eax, 0x94(%r14)
jmp 0x176f7
movsbl %dl, %eax
addl $-0x30, %eax
cmpl $0x9, %eax
ja 0x176fc
imull 0x28(%r15), %eax
addl %eax, 0x90(%r14)
movl $0x2, %ebx
movl %ebx, %eax
addq $0x40, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
movsbl %dl, %r12d
movl %r12d, %edi
callq 0x227bd
testb %al, %al
je 0x176fc
movl %r12d, %edi
callq 0x227cc
testb %al, %al
jne 0x176fc
movl %r12d, %edi
callq 0x227e0
testb %al, %al
jne 0x176fc
leaq 0x98(%r14), %rdi
leaq -0x50(%rbp), %rax
xorps %xmm0, %xmm0
movups %xmm0, 0x10(%rax)
movups %xmm0, 0x20(%rax)
movups %xmm0, (%rax)
movq %rax, -0x10(%rax)
movq $0x0, -0x8(%rax)
leaq -0x30(%rbp), %rax
movq %rax, -0x10(%rax)
movb $0x0, (%rax)
leaq -0x60(%rbp), %rsi
callq 0xb61a
leaq -0x60(%rbp), %rdi
callq 0xb4e8
movq 0xa0(%r14), %rdi
addq $-0x40, %rdi
movl %r12d, %esi
callq 0x8480
movl $0xd, 0x20(%r15)
jmp 0x176f7
movl %r12d, %edi
callq 0x227cc
testb %al, %al
jne 0x176fc
movl $0xe, 0x20(%r15)
movq 0xa0(%r14), %rdi
addq $-0x20, %rdi
movl %r12d, %esi
jmp 0x176c0
movq %rax, %rbx
leaq -0x60(%rbp), %rdi
callq 0xb4e8
movq %rbx, %rdi
callq 0x8830