// File: /workspace/github_cpp_makefile_star2_O1/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 0x17aea
movq %rsi, %r14
movq %rdi, %r15
leaq 0xc862(%rip), %rcx      # 0x2407c
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
cmpb $0xa, %dl
jne 0x17aea
movl $0xc, 0x20(%r15)
jmp 0x17ae5
cmpb $0x3a, %dl
jne 0x179fa
movl $0x10, 0x20(%r15)
jmp 0x17ae5
cmpb $0x54, %dl
jne 0x17aea
movl $0x5, 0x20(%r15)
jmp 0x17ae5
cmpb $0xd, %dl
jne 0x17a3b
movl $0x12, 0x20(%r15)
jmp 0x17ae5
cmpb $0x20, %dl
jne 0x17a6a
movl $0x2, 0x20(%r15)
jmp 0x17ae5
cmpb $0x54, %dl
jne 0x17aea
movl $0x6, 0x20(%r15)
jmp 0x17ae5
cmpb $0x48, %dl
jne 0x17aea
movl $0x4, 0x20(%r15)
jmp 0x17ae5
movsbl %dl, %r12d
movl %r12d, %edi
callq 0x22eb1
testb %al, %al
je 0x17aea
movl %r12d, %edi
callq 0x22ec0
testb %al, %al
jne 0x17aea
movl %r12d, %edi
callq 0x22ed4
testb %al, %al
jne 0x17aea
movq %r14, %rdi
movl %r12d, %esi
callq 0x8480
movl $0x1, 0x20(%r15)
jmp 0x17ae5
cmpb $0x20, %dl
jne 0x17a94
movl $0x3, 0x20(%r15)
jmp 0x17ae5
cmpb $0x50, %dl
jne 0x17aea
movl $0x7, 0x20(%r15)
jmp 0x17ae5
cmpb $0x2f, %dl
jne 0x17aea
movl $0x8, 0x20(%r15)
jmp 0x17ae5
cmpb $0xd, %dl
je 0x17996
movsbl %dl, %r15d
movl %r15d, %edi
callq 0x22ec0
testb %al, %al
jne 0x17aea
movq 0xa0(%r14), %rdi
addq $-0x20, %rdi
jmp 0x17aab
movsbl %dl, %r12d
cmpl $0x9, %r12d
je 0x17ae5
cmpl $0x20, %r12d
je 0x17ae5
cmpl $0xd, %r12d
jne 0x17b8b
movl $0x11, 0x20(%r15)
jmp 0x17ae5
cmpb $0xd, %dl
jne 0x17ab5
movl $0xb, 0x20(%r15)
jmp 0x17ae5
cmpb $0x2e, %dl
jne 0x17ace
movl $0x1, 0x28(%r15)
movl $0xa, 0x20(%r15)
jmp 0x17ae5
xorl %ebx, %ebx
cmpb $0xa, %dl
setne %bl
jmp 0x17aea
cmpb $0x20, %dl
jne 0x17aea
movl $0xe, 0x20(%r15)
jmp 0x17ae5
movsbl %dl, %r15d
movl %r15d, %edi
callq 0x22eb1
testb %al, %al
je 0x17aea
movl %r15d, %edi
callq 0x22ec0
testb %al, %al
jne 0x17aea
movl %r15d, %edi
callq 0x22ed4
testb %al, %al
jne 0x17aea
movq 0xa0(%r14), %rdi
addq $-0x40, %rdi
jmp 0x17aab
movq 0x98(%r14), %rax
cmpq 0xa0(%r14), %rax
je 0x17af9
movsbl %dl, %eax
cmpl $0x20, %eax
je 0x17a60
cmpl $0x9, %eax
jne 0x17af9
movl $0xf, 0x20(%r15)
jmp 0x17ae5
movsbl %dl, %r15d
movl %r15d, %edi
callq 0x22eb1
testb %al, %al
je 0x17aea
movl %r15d, %edi
callq 0x22ec0
testb %al, %al
jne 0x17aea
movl %r15d, %edi
callq 0x22ed4
testb %al, %al
je 0x17aa8
jmp 0x17aea
movsbl %dl, %r15d
movl %r15d, %edi
callq 0x22ec0
testb %al, %al
jne 0x17aea
addq $0x20, %r14
movq %r14, %rdi
movl %r15d, %esi
callq 0x8480
jmp 0x17ae5
movsbl %dl, %eax
addl $-0x30, %eax
cmpl $0x9, %eax
ja 0x17aea
imull 0x28(%r15), %eax
addl %eax, 0x94(%r14)
jmp 0x17ae5
movsbl %dl, %eax
addl $-0x30, %eax
cmpl $0x9, %eax
ja 0x17aea
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 0x22eb1
testb %al, %al
je 0x17aea
movl %r12d, %edi
callq 0x22ec0
testb %al, %al
jne 0x17aea
movl %r12d, %edi
callq 0x22ed4
testb %al, %al
jne 0x17aea
leaq 0x98(%r14), %rdi
xorps %xmm0, %xmm0
leaq -0x30(%rbp), %rax
movaps %xmm0, -0x30(%rax)
movaps %xmm0, -0x20(%rax)
movaps %xmm0, -0x10(%rax)
movaps %xmm0, (%rax)
leaq -0x50(%rbp), %rcx
movq %rcx, -0x10(%rcx)
xorl %edx, %edx
movq %rdx, -0x8(%rcx)
movb %dl, (%rcx)
movq %rax, 0x10(%rcx)
movq %rdx, 0x18(%rcx)
movb %dl, 0x20(%rcx)
leaq -0x60(%rbp), %rsi
callq 0xb6b8
leaq -0x60(%rbp), %rdi
callq 0xb586
movq 0xa0(%r14), %rdi
addq $-0x40, %rdi
movl %r12d, %esi
callq 0x8480
movl $0xd, 0x20(%r15)
jmp 0x17ae5
movl %r12d, %edi
callq 0x22ec0
testb %al, %al
jne 0x17aea
movl $0xe, 0x20(%r15)
movq 0xa0(%r14), %rdi
addq $-0x20, %rdi
movl %r12d, %esi
jmp 0x17aae
movq %rax, %rbx
leaq -0x60(%rbp), %rdi
callq 0xb586
movq %rbx, %rdi
callq 0x8830