// File: /workspace/github_cpp_makefile_star2_O1/m1c0l[P]http-client-server/HttpMessage.cpp
// Function: HttpMessage::decode(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>)
int HttpMessage::decode(string encoded) {
	stringstream ss;
	ss << encoded;
	string line;

	size_t start = 0, end = 0;
	bool firstLine = true;

	// header
	while ((end = encoded.find(CRLF, start)) != string::npos) {
		line = encoded.substr(start, end - start);
		start = end + sizeof(CRLF) - 1;

		if (line.size() == 0 && !firstLine) // end of header
			break;

		if (firstLine) {
			int decodeStatus = decodeFirstLine(line);
			if (decodeStatus) {
				return decodeStatus;
			}
		}
		else {
			int decodeStatus = decodeHeaderLine(line);
			if (decodeStatus) {
				return decodeStatus;
			}
		}

		firstLine = false;
	}

	return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x218, %rsp            # imm = 0x218
movq %rsi, %r13
movq %rdi, (%rsp)
leaq 0x90(%rsp), %rdi
callq 0x4250
leaq 0xa0(%rsp), %rdi
movq (%r13), %rsi
movq 0x8(%r13), %rdx
callq 0x4400
leaq 0x20(%rsp), %rax
movq %rax, -0x10(%rax)
movq $0x0, -0x8(%rax)
movb $0x0, (%rax)
leaq 0x45c3(%rip), %rsi      # 0x90fc
xorl %ebp, %ebp
movl $0x2, %ecx
movq %r13, %rdi
xorl %edx, %edx
callq 0x4530
cmpq $-0x1, %rax
je 0x4c90
movb $0x1, %bpl
xorl %r15d, %r15d
leaq 0x50(%rsp), %r14
movq %r13, %rsi
movq %r14, %rbx
movq %rax, 0x8(%rsp)
movq %rax, %rcx
subq %r15, %rcx
leaq 0x70(%rsp), %r14
movq %r14, %rdi
movq %r15, %rdx
callq 0x43a0
leaq 0x10(%rsp), %rdi
movq %r14, %rsi
callq 0x4420
movq 0x70(%rsp), %rdi
leaq 0x80(%rsp), %rax
cmpq %rax, %rdi
je 0x4baf
movq 0x80(%rsp), %rsi
incq %rsi
callq 0x4370
movq 0x18(%rsp), %rdx
testq %rdx, %rdx
setne %al
orb %bpl, %al
testb $0x1, %al
je 0x4c8e
movq %rbx, %r14
testb $0x1, %bpl
je 0x4c0c
leaq 0x60(%rsp), %rax
movq %rax, 0x50(%rsp)
movq 0x10(%rsp), %rsi
addq %rsi, %rdx
movq %r14, %rdi
callq 0x5100
movq (%rsp), %rdi
movq (%rdi), %rax
movq %r14, %rsi
callq *(%rax)
movl %eax, %ebp
movq 0x50(%rsp), %rdi
leaq 0x60(%rsp), %rax
cmpq %rax, %rdi
je 0x4c55
movq 0x60(%rsp), %rsi
jmp 0x4c4d
leaq 0x40(%rsp), %rax
movq %rax, 0x30(%rsp)
movq 0x10(%rsp), %rsi
addq %rsi, %rdx
leaq 0x30(%rsp), %r15
movq %r15, %rdi
callq 0x5100
movq (%rsp), %rdi
movq %r15, %rsi
callq 0x4882
movl %eax, %ebp
movq 0x30(%rsp), %rdi
leaq 0x40(%rsp), %rax
cmpq %rax, %rdi
je 0x4c55
movq 0x40(%rsp), %rsi
incq %rsi
callq 0x4370
testl %ebp, %ebp
cmovnel %ebp, %r12d
movl %r12d, %ebp
movq 0x8(%rsp), %r15
jne 0x4c90
addq $0x2, %r15
movl $0x2, %ecx
movq %r13, %rdi
leaq 0x4484(%rip), %rsi      # 0x90fc
movq %r15, %rdx
callq 0x4530
xorl %ebp, %ebp
cmpq $-0x1, %rax
jne 0x4b5f
jmp 0x4c90
xorl %ebp, %ebp
movq 0x10(%rsp), %rdi
leaq 0x20(%rsp), %rax
cmpq %rax, %rdi
je 0x4cac
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x4370
movq 0x82cd(%rip), %rsi      # 0xcf80
leaq 0x90(%rsp), %rdi
callq 0x4280
leaq 0x110(%rsp), %rdi
callq 0x4120
movl %ebp, %eax
addq $0x218, %rsp            # imm = 0x218
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
jmp 0x4d43
movq %rax, %rbx
movq 0x50(%rsp), %rdi
leaq 0x60(%rsp), %rax
cmpq %rax, %rdi
je 0x4d27
movq 0x60(%rsp), %rsi
jmp 0x4d18
jmp 0x4d24
movq %rax, %rbx
movq 0x30(%rsp), %rdi
leaq 0x40(%rsp), %rax
cmpq %rax, %rdi
je 0x4d27
movq 0x40(%rsp), %rsi
incq %rsi
callq 0x4370
jmp 0x4d27
jmp 0x4d24
movq %rax, %rbx
movq 0x10(%rsp), %rdi
leaq 0x20(%rsp), %rax
cmpq %rax, %rdi
je 0x4d43
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x4370
movq 0x8236(%rip), %rsi      # 0xcf80
leaq 0x90(%rsp), %rdi
callq 0x4280
leaq 0x110(%rsp), %rdi
callq 0x4120
movq %rbx, %rdi
callq 0x4550