// File: mbourand[P]webserv/srcs/Headers/Header.cpp
// Function: Header::parse(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>)
size_t Header::parse(std::string content)
{
	size_t len = 0;
	size_t result = content.find("\r\n") + 2;

	while (content.find_first_not_of(" \t\v\f", result) != result)
		result = content.find("\r\n", result) + 2;
	_value = content.substr(1, result - 2);
	if (_value.find_first_not_of(" \t\v\f\r\n") > _value.find("\r\n") || _value.empty())
		throw std::invalid_argument("Bad line folding");
	_value.erase(_value.find_last_not_of(" \t\v\f\r\n") + 1);
	while ((len = _value.find("\r\n", len)) != std::string::npos)
		_value.erase(len, _value.find_first_not_of(" \t\v\f\r\n", len) - len);
	return (result);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x90, %rsp
movq %rsi, -0x68(%rbp)
movq %rdi, %rax
movq -0x68(%rbp), %rdi
movq %rdi, -0x60(%rbp)
movq %rax, -0x8(%rbp)
movq %rdi, -0x10(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x58(%rbp)
movq $0x0, -0x18(%rbp)
leaq 0x61f87(%rip), %rsi     # 0x6dcb0
xorl %eax, %eax
movl %eax, %edx
callq 0x9c60
addq $0x2, %rax
movq %rax, -0x20(%rbp)
movq -0x60(%rbp), %rdi
movq -0x20(%rbp), %rdx
leaq 0x5e44b(%rip), %rsi     # 0x6a194
callq 0x93f0
cmpq -0x20(%rbp), %rax
je 0xbd72
movq -0x60(%rbp), %rdi
movq -0x20(%rbp), %rdx
leaq 0x61f4d(%rip), %rsi     # 0x6dcb0
callq 0x9c60
addq $0x2, %rax
movq %rax, -0x20(%rbp)
jmp 0xbd3a
movq -0x60(%rbp), %rsi
movq -0x20(%rbp), %rcx
subq $0x2, %rcx
leaq -0x40(%rbp), %rdi
movl $0x1, %edx
callq 0x96b0
movq -0x58(%rbp), %rdi
addq $0x8, %rdi
leaq -0x40(%rbp), %rsi
callq 0x97e0
leaq -0x40(%rbp), %rdi
callq 0x9c98
movq -0x58(%rbp), %rdi
addq $0x8, %rdi
leaq 0x5e3e4(%rip), %rsi     # 0x6a199
xorl %eax, %eax
movl %eax, %edx
callq 0x93f0
movq -0x58(%rbp), %rdi
movq %rax, -0x70(%rbp)
addq $0x8, %rdi
leaq 0x61edf(%rip), %rsi     # 0x6dcb0
xorl %eax, %eax
movl %eax, %edx
callq 0x9c60
movq %rax, %rcx
movq -0x70(%rbp), %rax
cmpq %rcx, %rax
ja 0xbdf9
movq -0x58(%rbp), %rdi
addq $0x8, %rdi
callq 0x9a50
testb $0x1, %al
jne 0xbdf9
jmp 0xbe4c
movl $0x10, %edi
callq 0x9340
movq %rax, %rdi
movq %rdi, %rax
movq %rax, -0x78(%rbp)
leaq 0x5e38c(%rip), %rsi     # 0x6a1a0
callq 0x9be0
jmp 0xbe1b
movq -0x78(%rbp), %rdi
movq 0x831a2(%rip), %rsi     # 0x8efc8
movq 0x8318b(%rip), %rdx     # 0x8efb8
callq 0x9aa0
movq -0x78(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
callq 0x94c0
jmp 0xbf05
movq -0x58(%rbp), %rdi
movq %rdi, %rax
addq $0x8, %rax
movq %rax, -0x80(%rbp)
addq $0x8, %rdi
leaq 0x5e333(%rip), %rsi     # 0x6a199
movq $-0x1, %rdx
callq 0x9b50
movq -0x80(%rbp), %rdi
movq %rax, %rsi
addq $0x1, %rsi
movq $-0x1, %rdx
callq 0x9180
movq -0x58(%rbp), %rdi
addq $0x8, %rdi
movq -0x18(%rbp), %rdx
leaq 0x61e14(%rip), %rsi     # 0x6dcb0
callq 0x9c60
movq %rax, -0x18(%rbp)
cmpq $-0x1, %rax
je 0xbef8
movq -0x58(%rbp), %rdi
movq %rdi, %rax
addq $0x8, %rax
movq %rax, -0x90(%rbp)
movq -0x18(%rbp), %rax
movq %rax, -0x88(%rbp)
addq $0x8, %rdi
movq -0x18(%rbp), %rdx
leaq 0x5e2c2(%rip), %rsi     # 0x6a199
callq 0x93f0
movq -0x90(%rbp), %rdi
movq -0x88(%rbp), %rsi
movq %rax, %rdx
subq -0x18(%rbp), %rdx
callq 0x9180
jmp 0xbe89
movq -0x20(%rbp), %rax
addq $0x90, %rsp
popq %rbp
retq
movq -0x48(%rbp), %rdi
callq 0x9af0
nop