// File: /workspace/github_cpp_makefile_star2_O3/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 $0x208, %rsp            # imm = 0x208
movq %rsi, %rbx
movq %rdi, %r14
leaq 0x80(%rsp), %rdi
callq 0x4250
leaq 0x90(%rsp), %rdi
movq (%rbx), %rsi
movq 0x8(%rbx), %rdx
callq 0x4400
leaq 0x10(%rsp), %rax
movq %rax, -0x10(%rax)
movq $0x0, -0x8(%rax)
movb $0x0, (%rax)
leaq 0x45d5(%rip), %rsi      # 0x90fc
xorl %ebp, %ebp
movl $0x2, %ecx
movq %rbx, %rdi
xorl %edx, %edx
callq 0x4530
cmpq $-0x1, %rax
je 0x4c64
movq %rax, %r13
movb $0x1, %bpl
xorl %r15d, %r15d
leaq 0x60(%rsp), %r12
movq %r13, %rcx
subq %r15, %rcx
movq %r12, %rdi
movq %rbx, %rsi
movq %r15, %rdx
callq 0x43a0
movq %rsp, %rdi
movq %r12, %rsi
callq 0x4420
movq 0x60(%rsp), %rdi
leaq 0x70(%rsp), %rax
cmpq %rax, %rdi
leaq 0x40(%rsp), %r15
je 0x4b90
movq 0x70(%rsp), %rsi
incq %rsi
callq 0x4370
movq 0x8(%rsp), %rdx
testq %rdx, %rdx
setne %al
orb %bpl, %al
testb $0x1, %al
je 0x4c62
testb $0x1, %bpl
je 0x4be8
leaq 0x50(%rsp), %rax
movq %rax, 0x40(%rsp)
movq (%rsp), %rsi
addq %rsi, %rdx
movq %r15, %rdi
callq 0x50d2
movq (%r14), %rax
movq %r14, %rdi
movq %r15, %rsi
callq *(%rax)
movl %eax, %ebp
movq 0x40(%rsp), %rdi
leaq 0x50(%rsp), %rax
cmpq %rax, %rdi
je 0x4c2f
movq 0x50(%rsp), %rsi
jmp 0x4c27
leaq 0x30(%rsp), %rax
movq %rax, 0x20(%rsp)
movq (%rsp), %rsi
addq %rsi, %rdx
leaq 0x20(%rsp), %r15
movq %r15, %rdi
callq 0x50d2
movq %r14, %rdi
movq %r15, %rsi
callq 0x4872
movl %eax, %ebp
movq 0x20(%rsp), %rdi
leaq 0x30(%rsp), %rax
cmpq %rax, %rdi
je 0x4c2f
movq 0x30(%rsp), %rsi
incq %rsi
callq 0x4370
testl %ebp, %ebp
jne 0x4c64
movq %r13, %r15
addq $0x2, %r15
movl $0x2, %ecx
movq %rbx, %rdi
leaq 0x44b3(%rip), %rsi      # 0x90fc
movq %r15, %rdx
callq 0x4530
movq %rax, %r13
xorl %ebp, %ebp
cmpq $-0x1, %rax
jne 0x4b50
jmp 0x4c64
xorl %ebp, %ebp
movq (%rsp), %rdi
leaq 0x10(%rsp), %rax
cmpq %rax, %rdi
je 0x4c7f
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x4370
movq 0x82fa(%rip), %rsi      # 0xcf80
leaq 0x80(%rsp), %rdi
callq 0x4280
leaq 0x100(%rsp), %rdi
callq 0x4120
movl %ebp, %eax
addq $0x208, %rsp            # imm = 0x208
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
jmp 0x4d15
movq %rax, %rbx
movq 0x40(%rsp), %rdi
leaq 0x50(%rsp), %rax
cmpq %rax, %rdi
je 0x4cfa
movq 0x50(%rsp), %rsi
jmp 0x4ceb
jmp 0x4cf7
movq %rax, %rbx
movq 0x20(%rsp), %rdi
leaq 0x30(%rsp), %rax
cmpq %rax, %rdi
je 0x4cfa
movq 0x30(%rsp), %rsi
incq %rsi
callq 0x4370
jmp 0x4cfa
jmp 0x4cf7
movq %rax, %rbx
movq (%rsp), %rdi
leaq 0x10(%rsp), %rax
cmpq %rax, %rdi
je 0x4d15
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x4370
movq 0x8264(%rip), %rsi      # 0xcf80
leaq 0x80(%rsp), %rdi
callq 0x4280
leaq 0x100(%rsp), %rdi
callq 0x4120
movq %rbx, %rdi
callq 0x4550