// File: trisolaris233[P]httpc/src/request_parser.hpp
// Function: httpc::RequestParser::ResultType httpc::RequestParser::ParseBody<char*>(httpc::Request&, char*, char*)
ResultType ParseBody(
            Request& request_, InputIterator begin, InputIterator end
        ) {
            // debug().dg(std::string(begin, end)).lf();
            bool flag = false;
            for (auto itr = begin; itr != end; ++itr) {
                if (*itr != '\r' && *itr != '\n') {
                    std::cout << *itr;
                } else if (*itr == '\r') {
                    std::cout << "\\r";
                    flag = true;
                } else {
                    if (flag) {
                        flag = false;
                    }
                    std::cout << "\\n" << std::endl;
                }
            }

            auto itr = request_.FindHeader("Content-Type");
            if (itr != request_.HeaderCEnd()) {
                auto pos = itr->value.find_first_of(';');
                std::string content_type(std::move(itr->value.substr(0, pos)));
                
                if (content_type == "multipart/form-data") {
                    if (pos != std::string::npos) {
                        std::string boundary(
                            std::move(
                                itr->value.substr(
                                    itr->value.find_first_of('=', pos + 1) + 1
                                )
                            )
                        );
                        std::string str(begin, end), tmp;
                        // bool flag = false;
                        bool start_flag = false;
                        bool flag = false;
                        auto metadata_line = 0;
                        std::vector<std::string> metadatas;
                        // std::string content;
                        // debug().dg("boundary => ").dg(boundary).lf();
                        std::string start_boundary("--" + boundary),
                                    end_boundary("--" + boundary + "--\r");

                        for (; begin != end; ++begin) {
                            if (*begin == '\r' && !start_flag) {
                                flag = true;
                                continue;
                            }
                            if (*begin == '\n') {
                                flag = false;
                                if (tmp == start_boundary) {
                                    tmp.clear();
                                    metadata_line = 0;
                                    metadatas.clear();
                                    start_flag = true;
                                    continue;
                                } else if (tmp == end_boundary) {
                                    tmp.clear();
                                    metadata_line = 0;
                                    metadatas.clear();
                                    start_flag = false;
                                    continue;
                                } else {
                                    if (start_flag) {
                                        if (metadata_line < 2) {
                                            metadatas.emplace_back(tmp);
                                            metadata_line++;
                                        } else if (metadata_line == 2) {
                                            std::string str(metadatas[0]), token_to_find("filename=");
                                            auto pos_token = str.find(token_to_find);
                                            if (pos_token == std::string::npos 
                                                || pos_token + token_to_find.length() >= str.length()) {
                                                request_.file_recv_successfully_flag_ = false;
                                                request_.file_recv_complete_flag_ = true;
                                                return kBad;
                                            }
                                            std::string filename_with_quote_flag(
                                                std::move(
                                                    str.substr(pos_token + token_to_find.length() + 1)
                                                )
                                            );
                                            request_.files_.emplace_back(
                                                std::string(
                                                    filename_with_quote_flag.substr(
                                                        1, 
                                                        filename_with_quote_flag.find_first_of(2, '"') 
                                                    )
                                                )
                                            );
                                            // flag = true;
                                            // std::string content_type(std::move(metadatas[1].find()))
                                            auto content_type_pos = metadatas[1].find_first_of(':');
                                            if (content_type_pos == std::string::npos
                                                || content_type_pos + 1 >= metadatas[1].length()) {
                                                request_.file_recv_successfully_flag_ = false;
                                                request_.file_recv_complete_flag_ = true;
                                                return kBad;
                                            }
                                            std::string content_type_tmp(std::move(metadatas[1].substr(content_type_pos + 2)));
                                            request_.files_.back().SetType(std::move(content_type_tmp.substr(1, content_type_tmp.length() - 1)));
                                            metadata_line++;
                                            // start_flag = false;
                                        } else {
                                            tmp.push_back(*begin);
                                            request_.files_.back().AppendContent(tmp);
                                        }
                                    }
                                    tmp.clear();
                                }
                            } else {
                                // debug().dg(static_cast<int>(*begin)).lf();
                                tmp.push_back(*begin);
                            }
                        }
                    } else {
                        request_.file_recv_successfully_flag_ = false;
                        request_.file_recv_complete_flag_ = true;
                        return kBad;
                    }
                }
            }
            request_.file_recv_successfully_flag_ = 
            request_.file_recv_complete_flag_ = true;
            return kGood;
        }

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x350, %rsp            # imm = 0x350
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq %rcx, -0x28(%rbp)
movb $0x0, -0x29(%rbp)
movq -0x20(%rbp), %rax
movq %rax, -0x38(%rbp)
movq -0x38(%rbp), %rax
cmpq -0x28(%rbp), %rax
je 0x42ab8
movq -0x38(%rbp), %rax
movsbl (%rax), %eax
cmpl $0xd, %eax
je 0x42a52
movq -0x38(%rbp), %rax
movsbl (%rax), %eax
cmpl $0xa, %eax
je 0x42a52
movq -0x38(%rbp), %rax
movq 0x47540(%rip), %rdi     # 0x89f88
movsbl (%rax), %esi
callq 0xa7f0
jmp 0x42aa5
movq -0x38(%rbp), %rax
movsbl (%rax), %eax
cmpl $0xd, %eax
jne 0x42a77
movq 0x47523(%rip), %rdi     # 0x89f88
leaq 0x17576(%rip), %rsi     # 0x59fe2
callq 0xa6a0
movb $0x1, -0x29(%rbp)
jmp 0x42aa3
testb $0x1, -0x29(%rbp)
je 0x42a81
movb $0x0, -0x29(%rbp)
movq 0x47500(%rip), %rdi     # 0x89f88
leaq 0x17556(%rip), %rsi     # 0x59fe5
callq 0xa6a0
movq %rax, %rdi
movq 0x47472(%rip), %rsi     # 0x89f10
callq 0xa720
jmp 0x42aa5
jmp 0x42aa7
movq -0x38(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x38(%rbp)
jmp 0x42a17
movq -0x18(%rbp), %rdi
leaq 0x16c8e(%rip), %rsi     # 0x59751
callq 0x313c0
movq %rax, -0x40(%rbp)
movq -0x18(%rbp), %rdi
callq 0x30d50
movq %rax, -0x48(%rbp)
leaq -0x40(%rbp), %rdi
leaq -0x48(%rbp), %rsi
callq 0x14d60
testb $0x1, %al
jne 0x42aef
jmp 0x43492
leaq -0x40(%rbp), %rdi
callq 0x31450
movq %rax, %rdi
addq $0x20, %rdi
movl $0x3b, %esi
xorl %eax, %eax
movl %eax, %edx
callq 0xa480
movq %rax, -0x50(%rbp)
leaq -0x40(%rbp), %rdi
callq 0x31450
movq %rax, %rsi
addq $0x20, %rsi
movq -0x50(%rbp), %rcx
leaq -0x90(%rbp), %rdi
xorl %eax, %eax
movl %eax, %edx
callq 0xa700
leaq -0x70(%rbp), %rdi
leaq -0x90(%rbp), %rsi
callq 0xa400
leaq -0x90(%rbp), %rdi
callq 0xa450
leaq -0x70(%rbp), %rdi
leaq 0x1748c(%rip), %rsi     # 0x59fe8
callq 0x13b80
testb $0x1, %al
jne 0x42b6a
jmp 0x43464
cmpq $-0x1, -0x50(%rbp)
je 0x43439
leaq -0x40(%rbp), %rdi
movq %rdi, -0x2d8(%rbp)
callq 0x31450
movq -0x2d8(%rbp), %rdi
addq $0x20, %rax
movq %rax, -0x2d0(%rbp)
callq 0x31450
movq %rax, %rdi
addq $0x20, %rdi
movq -0x50(%rbp), %rdx
incq %rdx
movl $0x3d, %esi
callq 0xa480
movq -0x2d0(%rbp), %rsi
movq %rax, %rdx
incq %rdx
leaq -0xd0(%rbp), %rdi
movq $-0x1, %rcx
callq 0xa700
jmp 0x42bd6
leaq -0xb0(%rbp), %rdi
leaq -0xd0(%rbp), %rsi
movq %rsi, -0x2f8(%rbp)
callq 0xa400
movq -0x2f8(%rbp), %rdi
callq 0xa450
movq -0x20(%rbp), %rax
movq %rax, -0x2f0(%rbp)
movq -0x28(%rbp), %rax
movq %rax, -0x2e8(%rbp)
leaq -0x101(%rbp), %rdi
movq %rdi, -0x2e0(%rbp)
callq 0xab40
movq -0x2f0(%rbp), %rsi
movq -0x2e8(%rbp), %rdx
movq -0x2e0(%rbp), %rcx
leaq -0x100(%rbp), %rdi
callq 0x31550
jmp 0x42c48
leaq -0x101(%rbp), %rdi
callq 0xa740
leaq -0x128(%rbp), %rdi
callq 0xa990
movb $0x0, -0x129(%rbp)
movb $0x0, -0x12a(%rbp)
movl $0x0, -0x130(%rbp)
leaq -0x148(%rbp), %rdi
callq 0x43c90
leaq 0x17371(%rip), %rsi     # 0x59ffc
leaq -0x168(%rbp), %rdi
leaq -0xb0(%rbp), %rdx
callq 0x43cb0
jmp 0x42ca0
leaq 0x17355(%rip), %rsi     # 0x59ffc
leaq -0x1a8(%rbp), %rdi
leaq -0xb0(%rbp), %rdx
callq 0x43cb0
jmp 0x42cbc
leaq 0x1733c(%rip), %rdx     # 0x59fff
leaq -0x188(%rbp), %rdi
leaq -0x1a8(%rbp), %rsi
callq 0x43dc0
jmp 0x42cd8
leaq -0x1a8(%rbp), %rdi
callq 0xa450
movq -0x20(%rbp), %rax
cmpq -0x28(%rbp), %rax
je 0x4338b
movq -0x20(%rbp), %rax
movsbl (%rax), %eax
cmpl $0xd, %eax
jne 0x42da6
testb $0x1, -0x129(%rbp)
jne 0x42da6
movb $0x1, -0x12a(%rbp)
jmp 0x4337a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xd8(%rbp)
movl %eax, -0xdc(%rbp)
jmp 0x43487
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xd8(%rbp)
movl %eax, -0xdc(%rbp)
leaq -0x101(%rbp), %rdi
callq 0xa740
jmp 0x4342b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xd8(%rbp)
movl %eax, -0xdc(%rbp)
jmp 0x43407
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xd8(%rbp)
movl %eax, -0xdc(%rbp)
jmp 0x433fb
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xd8(%rbp)
movl %eax, -0xdc(%rbp)
leaq -0x1a8(%rbp), %rdi
callq 0xa450
jmp 0x433fb
movq -0x20(%rbp), %rax
movsbl (%rax), %eax
cmpl $0xa, %eax
jne 0x43361
movb $0x0, -0x12a(%rbp)
leaq -0x128(%rbp), %rdi
leaq -0x168(%rbp), %rsi
callq 0x12ee0
testb $0x1, %al
jne 0x42dd6
jmp 0x42e04
leaq -0x128(%rbp), %rdi
callq 0xa900
movl $0x0, -0x130(%rbp)
leaq -0x148(%rbp), %rdi
callq 0x43e10
movb $0x1, -0x129(%rbp)
jmp 0x4337a
leaq -0x128(%rbp), %rdi
leaq -0x188(%rbp), %rsi
callq 0x12ee0
testb $0x1, %al
jne 0x42e1d
jmp 0x42e4b
leaq -0x128(%rbp), %rdi
callq 0xa900
movl $0x0, -0x130(%rbp)
leaq -0x148(%rbp), %rdi
callq 0x43e10
movb $0x0, -0x129(%rbp)
jmp 0x4337a
testb $0x1, -0x129(%rbp)
je 0x43351
cmpl $0x2, -0x130(%rbp)
jge 0x42ea1
leaq -0x148(%rbp), %rdi
leaq -0x128(%rbp), %rsi
callq 0x43e30
jmp 0x42e76
movl -0x130(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x130(%rbp)
jmp 0x4334f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xd8(%rbp)
movl %eax, -0xdc(%rbp)
jmp 0x433ef
cmpl $0x2, -0x130(%rbp)
jne 0x43315
xorl %eax, %eax
movl %eax, %esi
leaq -0x148(%rbp), %rdi
callq 0x43eb0
movq %rax, %rsi
leaq -0x1c8(%rbp), %rdi
callq 0xa2c0
jmp 0x42ecf
leaq -0x1e9(%rbp), %rdi
movq %rdi, -0x300(%rbp)
callq 0xab40
movq -0x300(%rbp), %rdx
leaq 0x17113(%rip), %rsi     # 0x5a003
leaq -0x1e8(%rbp), %rdi
callq 0xf9c0
jmp 0x42efe
leaq -0x1e9(%rbp), %rdi
callq 0xa740
leaq -0x1c8(%rbp), %rdi
leaq -0x1e8(%rbp), %rsi
xorl %eax, %eax
movl %eax, %edx
callq 0xac90
movq %rax, -0x1f8(%rbp)
cmpq $-0x1, -0x1f8(%rbp)
je 0x42f7b
movq -0x1f8(%rbp), %rax
movq %rax, -0x310(%rbp)
leaq -0x1e8(%rbp), %rdi
callq 0xaa10
movq %rax, %rcx
movq -0x310(%rbp), %rax
addq %rcx, %rax
movq %rax, -0x308(%rbp)
leaq -0x1c8(%rbp), %rdi
callq 0xaa10
movq %rax, %rcx
movq -0x308(%rbp), %rax
cmpq %rcx, %rax
jb 0x42fca
movq -0x18(%rbp), %rax
movb $0x0, 0x122(%rax)
movq -0x18(%rbp), %rax
movb $0x1, 0x121(%rax)
movl $0x1, -0x4(%rbp)
movl $0x1, -0x1fc(%rbp)
jmp 0x43281
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xd8(%rbp)
movl %eax, -0xdc(%rbp)
leaq -0x1e9(%rbp), %rdi
callq 0xa740
jmp 0x43304
movq -0x1f8(%rbp), %rax
movq %rax, -0x318(%rbp)
leaq -0x1e8(%rbp), %rdi
callq 0xaa10
movq %rax, %rcx
movq -0x318(%rbp), %rax
leaq 0x1(%rax,%rcx), %rdx
leaq -0x240(%rbp), %rdi
leaq -0x1c8(%rbp), %rsi
movq $-0x1, %rcx
callq 0xa700
jmp 0x4300f
leaq -0x220(%rbp), %rdi
movq %rdi, -0x320(%rbp)
leaq -0x240(%rbp), %rsi
movq %rsi, -0x330(%rbp)
callq 0xa400
movq -0x330(%rbp), %rdi
callq 0xa450
movq -0x320(%rbp), %rdi
movq -0x18(%rbp), %rax
addq $0xd0, %rax
movq %rax, -0x328(%rbp)
movl $0x2, %esi
movl $0x22, %edx
callq 0xa480
movq -0x320(%rbp), %rsi
movq %rax, %rcx
leaq -0x260(%rbp), %rdi
movl $0x1, %edx
callq 0xa700
jmp 0x43080
movq -0x328(%rbp), %rdi
leaq -0x260(%rbp), %rsi
callq 0x43ed0
jmp 0x43095
leaq -0x260(%rbp), %rdi
callq 0xa450
leaq -0x148(%rbp), %rdi
movl $0x1, %esi
callq 0x43eb0
movq %rax, %rdi
movl $0x3a, %esi
xorl %eax, %eax
movl %eax, %edx
callq 0xa480
movq %rax, -0x268(%rbp)
cmpq $-0x1, -0x268(%rbp)
je 0x4310e
movq -0x268(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x338(%rbp)
leaq -0x148(%rbp), %rdi
movl $0x1, %esi
callq 0x43eb0
movq %rax, %rdi
callq 0xaa10
movq %rax, %rcx
movq -0x338(%rbp), %rax
cmpq %rcx, %rax
jb 0x4318b
movq -0x18(%rbp), %rax
movb $0x0, 0x122(%rax)
movq -0x18(%rbp), %rax
movb $0x1, 0x121(%rax)
movl $0x1, -0x4(%rbp)
movl $0x1, -0x1fc(%rbp)
jmp 0x43275
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xd8(%rbp)
movl %eax, -0xdc(%rbp)
jmp 0x432f8
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xd8(%rbp)
movl %eax, -0xdc(%rbp)
jmp 0x432ec
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xd8(%rbp)
movl %eax, -0xdc(%rbp)
leaq -0x260(%rbp), %rdi
callq 0xa450
jmp 0x432ec
leaq -0x148(%rbp), %rdi
movl $0x1, %esi
callq 0x43eb0
movq %rax, %rsi
movq -0x268(%rbp), %rdx
addq $0x2, %rdx
leaq -0x2a8(%rbp), %rdi
movq $-0x1, %rcx
callq 0xa700
jmp 0x431bf
leaq -0x288(%rbp), %rdi
movq %rdi, -0x340(%rbp)
leaq -0x2a8(%rbp), %rsi
movq %rsi, -0x350(%rbp)
callq 0xa400
movq -0x350(%rbp), %rdi
callq 0xa450
movq -0x18(%rbp), %rdi
addq $0xd0, %rdi
callq 0x43f50
movq -0x340(%rbp), %rdi
movq %rax, -0x348(%rbp)
callq 0xaa10
movq -0x340(%rbp), %rsi
movq %rax, %rcx
decq %rcx
leaq -0x2c8(%rbp), %rdi
movl $0x1, %edx
callq 0xa700
jmp 0x4322f
movq -0x348(%rbp), %rdi
leaq -0x2c8(%rbp), %rsi
callq 0x43f90
jmp 0x43244
leaq -0x2c8(%rbp), %rdi
callq 0xa450
movl -0x130(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x130(%rbp)
leaq -0x288(%rbp), %rdi
callq 0xa450
movl $0x0, -0x1fc(%rbp)
leaq -0x220(%rbp), %rdi
callq 0xa450
leaq -0x1e8(%rbp), %rdi
callq 0xa450
leaq -0x1c8(%rbp), %rdi
callq 0xa450
movl -0x1fc(%rbp), %eax
testl %eax, %eax
jne 0x43395
jmp 0x432a9
jmp 0x4334d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xd8(%rbp)
movl %eax, -0xdc(%rbp)
jmp 0x432e0
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xd8(%rbp)
movl %eax, -0xdc(%rbp)
leaq -0x2c8(%rbp), %rdi
callq 0xa450
leaq -0x288(%rbp), %rdi
callq 0xa450
leaq -0x220(%rbp), %rdi
callq 0xa450
leaq -0x1e8(%rbp), %rdi
callq 0xa450
leaq -0x1c8(%rbp), %rdi
callq 0xa450
jmp 0x433ef
movq -0x20(%rbp), %rax
movsbl (%rax), %esi
leaq -0x128(%rbp), %rdi
callq 0xa5d0
jmp 0x4332a
movq -0x18(%rbp), %rdi
addq $0xd0, %rdi
callq 0x43f50
movq %rax, %rdi
leaq -0x128(%rbp), %rsi
callq 0x43fc0
jmp 0x4334b
jmp 0x4334d
jmp 0x4334f
jmp 0x43351
leaq -0x128(%rbp), %rdi
callq 0xa900
jmp 0x4335f
jmp 0x43378
movq -0x20(%rbp), %rax
movsbl (%rax), %esi
leaq -0x128(%rbp), %rdi
callq 0xa5d0
jmp 0x43376
jmp 0x43378
jmp 0x4337a
movq -0x20(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x20(%rbp)
jmp 0x42ce4
movl $0x0, -0x1fc(%rbp)
leaq -0x188(%rbp), %rdi
callq 0xa450
leaq -0x168(%rbp), %rdi
callq 0xa450
leaq -0x148(%rbp), %rdi
callq 0x43ff0
leaq -0x128(%rbp), %rdi
callq 0xa450
leaq -0x100(%rbp), %rdi
callq 0xa450
leaq -0xb0(%rbp), %rdi
callq 0xa450
movl -0x1fc(%rbp), %eax
testl %eax, %eax
jne 0x4346e
jmp 0x433ed
jmp 0x43462
leaq -0x188(%rbp), %rdi
callq 0xa450
leaq -0x168(%rbp), %rdi
callq 0xa450
leaq -0x148(%rbp), %rdi
callq 0x43ff0
leaq -0x128(%rbp), %rdi
callq 0xa450
leaq -0x100(%rbp), %rdi
callq 0xa450
leaq -0xb0(%rbp), %rdi
callq 0xa450
jmp 0x43487
movq -0x18(%rbp), %rax
movb $0x0, 0x122(%rax)
movq -0x18(%rbp), %rax
movb $0x1, 0x121(%rax)
movl $0x1, -0x4(%rbp)
movl $0x1, -0x1fc(%rbp)
jmp 0x4346e
jmp 0x43464
movl $0x0, -0x1fc(%rbp)
leaq -0x70(%rbp), %rdi
callq 0xa450
movl -0x1fc(%rbp), %eax
testl %eax, %eax
je 0x43485
jmp 0x43483
jmp 0x434af
jmp 0x43492
leaq -0x70(%rbp), %rdi
callq 0xa450
jmp 0x434bb
movq -0x18(%rbp), %rax
movb $0x1, 0x121(%rax)
movq -0x18(%rbp), %rax
movb $0x1, 0x122(%rax)
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x350, %rsp            # imm = 0x350
popq %rbp
retq
movq -0xd8(%rbp), %rdi
callq 0xab10
nopw (%rax,%rax)