// File: /workspace/github_cpp_makefile_star2_O3/enbock[P]Warp10Server/warp10server/src/Network/WebConnection.cpp
// Function: Warp10::Network::WebConnection::decodeBuffer(u::ByteArray*)
void WebConnection::decodeBuffer(ByteArray* buffer)
{
	Vector<String> header;
	buffer->position(0);
	int64 startPosition = 0, position = 0;
	bool continueRead = true;
	// read header
	while (continueRead) {
		position++;
		buffer->position(position);
		char byte = buffer->readByte();
		if (byte == 0x0D || position + 1 == buffer->length()) {
			int64 length = position - startPosition ;
			if (length == 0) {
				// end of header
				continueRead = false;
				continue;
			}
			char* line = (char*)malloc(length + 1);
			if (!line) {
				error(
					className() + "::decodeBuffer: Out of memory."
				);
				return;
			}
			buffer->position(startPosition);
			buffer->readBytes(line, length, 0);
			line[length] = 0x00; // end byte
			String headerLine = String(line);
			headerLine.replace("\r", "_");
			header.push(headerLine);
			free(line);
			startPosition = position + 2;
			continueRead = startPosition < buffer->length();
		}
	}

#ifndef NDEBUG
	trace("");
	for(int64 i = 0, l = header.length(); i < l; i++) trace(header[i]);
	trace("");
#endif

	Vector<String>* commandParts = ((String)header[0]).explode(" ");

	if (commandParts->length() < 2) {
		error(className() + "::decodeBuffer: Invalid request.");
		
		u::Network::Event close(u::Network::Event::CLOSE);
		dispatchEvent(&close);
		delete commandParts;
		return;
	}
	
	WebRequest request;
	request.method = commandParts->at(0);
	request.resource = commandParts->at(1);
	if(commandParts->length() > 2)
		request.protocol = commandParts->at(2);
	delete commandParts;

	WebEvent requestEvent(WebEvent::REQUEST, this, request);
	dispatchEvent(&requestEvent);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x5c8, %rsp            # imm = 0x5C8
movq %rsi, %r15
movq %rdi, (%rsp)
leaq 0x40(%rsp), %rax
xorps %xmm0, %xmm0
movups %xmm0, (%rax)
movq $0x0, 0x10(%rax)
leaq 0x8(%rsp), %rdi
callq 0x41026c
leaq 0x23fc14(%rip), %rax    # 0x647ce0
movq %rax, 0x8(%rsp)
movq (%r15), %rax
movq %r15, %rdi
xorl %esi, %esi
callq *0x20(%rax)
xorl %ebx, %ebx
xorl %r14d, %r14d
movq %rbx, %r13
addq $0x3, %r14
movq %r14, %rcx
movq %rcx, %rbx
leaq -0x2(%rcx), %r14
movq (%r15), %rax
movq %r15, %rdi
movq %r14, %rsi
callq *0x20(%rax)
movq %r15, %rdi
callq 0x40b768
cmpb $0xd, %al
je 0x408120
movq (%r15), %rax
movq %r15, %rdi
callq *0x38(%rax)
leaq 0x1(%rbx), %rcx
leaq -0x1(%rbx), %rdx
cmpq %rax, %rdx
jne 0x4080eb
movq %rbx, %rbp
subq %r13, %rbp
cmpq $0x2, %rbp
je 0x4082c8
movq %r13, %rdi
notq %rdi
addq %rbx, %rdi
callq 0x50c800
testq %rax, %rax
je 0x40884f
movq %rax, %r12
movq (%r15), %rax
movq %r15, %rdi
movq %r13, %rsi
callq *0x20(%rax)
addq $-0x2, %rbp
movq %r15, %rdi
movq %r12, %rsi
movq %rbp, %rdx
xorl %ecx, %ecx
callq 0x40b726
movq %r12, %rax
subq %r13, %rax
movb $0x0, -0x2(%rax,%rbx)
leaq 0x198(%rsp), %r13
movq %r13, %rdi
movq %r12, %rsi
callq 0x4107ee
leaq 0x380(%rsp), %rdi
leaq 0x1c620e(%rip), %rsi    # 0x5ce3a5
callq 0x4107ee
leaq 0x430(%rsp), %rbp
movq %rbp, %rdi
leaq 0x1ce6da(%rip), %rsi    # 0x5d6888
callq 0x4107ee
movq %r13, %rdi
leaq 0x380(%rsp), %rsi
movq %rbp, %rdx
callq 0x410f4e
movq 0x468(%rsp), %rdi
leaq 0x478(%rsp), %rax
cmpq %rax, %rdi
je 0x4081eb
movq 0x478(%rsp), %rsi
incq %rsi
callq 0x426e30
leaq 0x430(%rsp), %rdi
callq 0x410332
movq 0x3b8(%rsp), %rdi
leaq 0x3c8(%rsp), %rax
cmpq %rax, %rdi
je 0x40821d
movq 0x3c8(%rsp), %rsi
incq %rsi
callq 0x426e30
leaq 0x380(%rsp), %rdi
callq 0x410332
leaq 0x328(%rsp), %rdi
movq %r13, %rsi
callq 0x410a2c
leaq 0x40(%rsp), %rdi
leaq 0x328(%rsp), %rsi
callq 0x408d40
movq 0x360(%rsp), %rdi
leaq 0x370(%rsp), %rax
cmpq %rax, %rdi
je 0x408271
movq 0x370(%rsp), %rsi
incq %rsi
callq 0x426e30
leaq 0x328(%rsp), %rdi
callq 0x410332
movq %r12, %rdi
callq 0x50cb40
movq (%r15), %rax
movq %r15, %rdi
callq *0x38(%rax)
movq %rax, %r12
movq 0x1d0(%rsp), %rdi
leaq 0x1e0(%rsp), %rax
cmpq %rax, %rdi
je 0x4082b7
movq 0x1e0(%rsp), %rsi
incq %rsi
callq 0x426e30
movq %r13, %rdi
callq 0x410332
cmpq %r12, %rbx
jl 0x4080e1
movq $0x653c40, %rdi         # imm = 0x653C40
leaq 0x1c5dbb(%rip), %rsi    # 0x5ce091
movl $0x4, %edx
callq 0x490910
movq $0x653c40, %rdi         # imm = 0x653C40
leaq 0x1eab34(%rip), %rsi    # 0x5f2e22
xorl %edx, %edx
callq 0x490910
movq $0x653c40, %rbx         # imm = 0x653C40
leaq 0x1c5da8(%rip), %rsi    # 0x5ce0ab
movl $0x4, %edx
movq %rbx, %rdi
callq 0x490910
movq (%rbx), %rax
addq -0x18(%rax), %rbx
movq %rbx, %rdi
movl $0xa, %esi
callq 0x471a60
movsbl %al, %esi
movq $0x653c40, %rdi         # imm = 0x653C40
callq 0x490410
movq %rax, %rdi
callq 0x48f9e0
movq 0x48(%rsp), %rax
subq 0x40(%rsp), %rax
testq %rax, %rax
jle 0x408433
movabsq $0x2e8ba2e8ba2e8ba3, %rcx # imm = 0x2E8BA2E8BA2E8BA3
mulq %rcx
movq %rdx, %rbx
shrq $0x4, %rbx
cmpq $0x1, %rbx
adcq $0x0, %rbx
xorl %r14d, %r14d
movq $0x653c40, %r15         # imm = 0x653C40
leaq 0x198(%rsp), %r13
leaq 0x1c5d28(%rip), %r12    # 0x5ce0ab
movl $0x4, %edx
movq %r15, %rdi
leaq 0x1c5cff(%rip), %rsi    # 0x5ce091
callq 0x490910
movq %r13, %rdi
leaq 0x8(%rsp), %rsi
movq %r14, %rdx
callq 0x408c54
movq 0x1d0(%rsp), %rsi
movq 0x1d8(%rsp), %rdx
movq %r15, %rdi
callq 0x490910
movq %rax, %rbp
movl $0x4, %edx
movq %rax, %rdi
movq %r12, %rsi
callq 0x490910
movq (%rbp), %rax
movq -0x18(%rax), %rdi
addq %rbp, %rdi
movl $0xa, %esi
callq 0x471a60
movsbl %al, %esi
movq %rbp, %rdi
callq 0x490410
movq %rax, %rdi
callq 0x48f9e0
movq 0x1d0(%rsp), %rdi
leaq 0x1e0(%rsp), %rax
cmpq %rax, %rdi
je 0x40841f
movq 0x1e0(%rsp), %rsi
incq %rsi
callq 0x426e30
movq %r13, %rdi
callq 0x410332
incq %r14
cmpq %r14, %rbx
jne 0x408383
movq $0x653c40, %rdi         # imm = 0x653C40
leaq 0x1c5c50(%rip), %rsi    # 0x5ce091
movl $0x4, %edx
callq 0x490910
movq $0x653c40, %rdi         # imm = 0x653C40
leaq 0x1ea9c9(%rip), %rsi    # 0x5f2e22
xorl %edx, %edx
callq 0x490910
movq $0x653c40, %rbx         # imm = 0x653C40
leaq 0x1c5c3d(%rip), %rsi    # 0x5ce0ab
movl $0x4, %edx
movq %rbx, %rdi
callq 0x490910
movq (%rbx), %rax
addq -0x18(%rax), %rbx
movq %rbx, %rdi
movl $0xa, %esi
callq 0x471a60
movsbl %al, %esi
movq $0x653c40, %rdi         # imm = 0x653C40
callq 0x490410
movq %rax, %rdi
callq 0x48f9e0
leaq 0x198(%rsp), %rdi
leaq 0x8(%rsp), %rsi
xorl %edx, %edx
callq 0x408c54
leaq 0x1c6a45(%rip), %rsi    # 0x5cef06
leaq 0x3d8(%rsp), %rdi
callq 0x4107ee
leaq 0x198(%rsp), %rdi
leaq 0x3d8(%rsp), %rsi
callq 0x410fae
leaq 0x68(%rsp), %r12
movq %rax, %r15
leaq 0x420(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x40850c
movq 0x420(%rsp), %rsi
incq %rsi
callq 0x426e30
leaq 0x3d8(%rsp), %rdi
callq 0x410332
movq 0x1d0(%rsp), %rdi
leaq 0x1e0(%rsp), %rax
cmpq %rax, %rdi
je 0x40853e
movq 0x1e0(%rsp), %rsi
incq %rsi
callq 0x426e30
leaq 0x198(%rsp), %rdi
callq 0x410332
movq %r15, %r13
addq $0x38, %r13
movq 0x40(%r15), %rax
subq 0x38(%r15), %rax
cmpq $0xaf, %rax
jg 0x4085ca
movq $0x653b20, %rdi         # imm = 0x653B20
leaq 0x1c5be3(%rip), %rsi    # 0x5ce153
movl $0x7, %edx
callq 0x490910
movq (%rsp), %rsi
movq (%rsi), %rax
leaq 0x198(%rsp), %rdi
callq *0x8(%rax)
leaq 0x1d0(%rsp), %rdi
leaq 0x1c5e0c(%rip), %rsi    # 0x5ce3a7
callq 0x4a24f0
movq %r12, 0x58(%rsp)
movq (%rax), %rsi
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rsi
je 0x4088bc
movq %rsi, 0x58(%rsp)
movq (%rcx), %rdx
movq %rdx, 0x68(%rsp)
jmp 0x4088c7
leaq 0x58(%rsp), %rdi
callq 0x41026c
leaq 0x23f9b5(%rip), %rbp    # 0x647f90
leaq 0x90(%rsp), %r12
movq %rbp, -0x38(%r12)
movq %r12, %rdi
callq 0x4107c4
leaq 0xe8(%rsp), %r14
movq %r14, %rdi
callq 0x4107c4
leaq 0x140(%rsp), %rdi
callq 0x4107c4
movq 0x38(%r15), %rsi
cmpq %rsi, 0x40(%r15)
je 0x408aa8
movq %r12, %rdi
callq 0x410b04
movq 0x38(%r15), %rsi
movq 0x40(%r15), %rdx
subq %rsi, %rdx
sarq $0x3, %rdx
movabsq $0x2e8ba2e8ba2e8ba3, %rax # imm = 0x2E8BA2E8BA2E8BA3
imulq %rax, %rdx
cmpq $0x1, %rdx
jbe 0x408aae
addq $0x58, %rsi
movq %r14, %rdi
callq 0x410b04
movq 0x38(%r15), %rsi
movq 0x40(%r15), %rax
subq %rsi, %rax
cmpq $0xb1, %rax
jl 0x40867d
addq $0xb0, %rsi
leaq 0x140(%rsp), %rdi
callq 0x410b04
movq %r15, %rdi
callq 0x410332
movq %r13, %rdi
callq 0x405152
movl $0x50, %esi
movq %r15, %rdi
callq 0x426e30
leaq 0x488(%rsp), %rdi
leaq 0x58(%rsp), %rsi
callq 0x41044e
leaq 0x4c0(%rsp), %r15
movq %rbp, -0x38(%r15)
movq %r15, %rdi
movq %r12, %rsi
callq 0x410a2c
leaq 0x518(%rsp), %r13
movq %r13, %rdi
movq %r14, %rbx
movq %r14, %rsi
callq 0x410a2c
leaq 0x570(%rsp), %r14
movq %r14, %rdi
leaq 0x140(%rsp), %rsi
callq 0x410a2c
movq $0x652870, %rsi         # imm = 0x652870
leaq 0x198(%rsp), %rdi
leaq 0x488(%rsp), %rcx
movq (%rsp), %rdx
callq 0x408f6c
leaq 0x5b8(%rsp), %rax
movq %rbp, -0x130(%rax)
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x408739
movq 0x5b8(%rsp), %rsi
incq %rsi
callq 0x426e30
movq %r14, %rdi
callq 0x410332
leaq 0x560(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x408762
movq 0x560(%rsp), %rsi
incq %rsi
callq 0x426e30
movq %r13, %rdi
callq 0x410332
leaq 0x508(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x40878b
movq 0x508(%rsp), %rsi
incq %rsi
callq 0x426e30
movq %r15, %rdi
callq 0x410332
leaq 0x488(%rsp), %rdi
callq 0x410332
leaq 0x198(%rsp), %rsi
movq (%rsp), %rdi
callq 0x40e11a
leaq 0x198(%rsp), %rdi
callq 0x408fea
leaq 0x188(%rsp), %rax
movq %rbp, -0x130(%rax)
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x4087e6
movq 0x188(%rsp), %rsi
incq %rsi
callq 0x426e30
leaq 0x140(%rsp), %rdi
callq 0x410332
leaq 0x130(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x408814
movq 0x130(%rsp), %rsi
incq %rsi
callq 0x426e30
movq %rbx, %rdi
callq 0x410332
leaq 0xd8(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x40883d
movq 0xd8(%rsp), %rsi
incq %rsi
callq 0x426e30
movq %r12, %rdi
callq 0x410332
leaq 0x58(%rsp), %rdi
jmp 0x408a7d
movq $0x653b20, %rdi         # imm = 0x653B20
leaq 0x1c58f6(%rip), %rsi    # 0x5ce153
movl $0x7, %edx
callq 0x490910
movq (%rsp), %rsi
movq (%rsi), %rax
leaq 0x198(%rsp), %rdi
callq *0x8(%rax)
leaq 0x68(%rsp), %r15
leaq 0x1c5b01(%rip), %rsi    # 0x5ce386
leaq 0x1d0(%rsp), %rdi
callq 0x4a24f0
movq %r15, 0x58(%rsp)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
je 0x4089c6
movq %rdx, 0x58(%rsp)
movq (%rcx), %rdx
movq %rdx, 0x68(%rsp)
jmp 0x4089cd
movups (%rcx), %xmm0
movups %xmm0, (%r12)
movq %r12, %rsi
movq 0x8(%rax), %rdx
movq %rdx, 0x60(%rsp)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
movq $0x653b20, %rdi         # imm = 0x653B20
callq 0x490910
movq %rax, %rbx
leaq 0x1c57b6(%rip), %rsi    # 0x5ce0ab
movl $0x4, %edx
movq %rax, %rdi
callq 0x490910
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x471a60
movsbl %al, %esi
movq %rbx, %rdi
callq 0x490410
movq %rax, %rdi
callq 0x48f9e0
movq 0x58(%rsp), %rdi
cmpq %r12, %rdi
je 0x408940
movq 0x68(%rsp), %rsi
incq %rsi
callq 0x426e30
movq 0x1d0(%rsp), %rdi
leaq 0x1e0(%rsp), %rax
cmpq %rax, %rdi
je 0x408965
movq 0x1e0(%rsp), %rsi
incq %rsi
callq 0x426e30
leaq 0x198(%rsp), %rdi
callq 0x410332
movq $0x652c08, %rsi         # imm = 0x652C08
leaq 0x198(%rsp), %rdi
callq 0x416860
leaq 0x198(%rsp), %rsi
movq (%rsp), %rdi
callq 0x40e11a
movq %r15, %rdi
callq 0x410332
movq %r13, %rdi
callq 0x405152
movl $0x50, %esi
movq %r15, %rdi
callq 0x426e30
leaq 0x198(%rsp), %rdi
callq 0x41697a
jmp 0x408a82
movups (%rcx), %xmm0
movups %xmm0, (%r15)
movq 0x8(%rax), %rdx
movq %rdx, 0x60(%rsp)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
movq 0x58(%rsp), %rsi
movq 0x60(%rsp), %rdx
movq $0x653b20, %rdi         # imm = 0x653B20
callq 0x490910
movq %rax, %rbx
leaq 0x1c56a6(%rip), %rsi    # 0x5ce0ab
movl $0x4, %edx
movq %rax, %rdi
callq 0x490910
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x471a60
movsbl %al, %esi
movq %rbx, %rdi
callq 0x490410
movq %rax, %rdi
callq 0x48f9e0
movq 0x58(%rsp), %rdi
cmpq %r15, %rdi
je 0x408a50
movq 0x68(%rsp), %rsi
incq %rsi
callq 0x426e30
movq 0x1d0(%rsp), %rdi
leaq 0x1e0(%rsp), %rax
cmpq %rax, %rdi
je 0x408a75
movq 0x1e0(%rsp), %rsi
incq %rsi
callq 0x426e30
leaq 0x198(%rsp), %rdi
callq 0x410332
leaq 0x8(%rsp), %rdi
callq 0x410332
leaq 0x40(%rsp), %rdi
callq 0x405152
addq $0x5c8, %rsp            # imm = 0x5C8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
xorl %esi, %esi
xorl %edx, %edx
jmp 0x408ab3
movl $0x1, %esi
leaq 0x1c590e(%rip), %rdi    # 0x5ce3c8
xorl %eax, %eax
callq 0x471570
jmp 0x408c20
jmp 0x408c34
jmp 0x408c34
movq %rax, %r14
leaq 0x198(%rsp), %rdi
callq 0x408fea
jmp 0x408bac
movq %rax, %r14
leaq 0x488(%rsp), %rdi
callq 0x408ca2
jmp 0x408bac
movq %rax, %r14
movq %r13, %rdi
callq 0x40512c
jmp 0x408b0a
movq %rax, %r14
movq %r15, %rdi
callq 0x40512c
jmp 0x408b17
movq %rax, %r14
leaq 0x488(%rsp), %rdi
callq 0x410332
jmp 0x408bac
movq %rax, %r14
leaq 0x198(%rsp), %rdi
callq 0x41697a
jmp 0x408c37
jmp 0x408ba9
jmp 0x408c34
movq %r14, %rdi
movq %rax, %r14
callq 0x40512c
jmp 0x408b55
movq %rax, %r14
movq %r12, %rdi
callq 0x40512c
jmp 0x408b67
jmp 0x408c20
movq %rax, %r14
leaq 0x58(%rsp), %rdi
callq 0x410332
jmp 0x408c37
jmp 0x408c34
jmp 0x408c34
jmp 0x408c34
movq %rax, %r14
leaq 0x3d8(%rsp), %rdi
jmp 0x408c0f
jmp 0x408c20
jmp 0x408c34
jmp 0x408c34
movq %rax, %r14
jmp 0x408c41
movq %rax, %r14
leaq 0x58(%rsp), %rdi
callq 0x408ca2
jmp 0x408c37
movq %rax, %r14
movq 0x58(%rsp), %rdi
cmpq %r15, %rdi
jne 0x408bd4
jmp 0x408c23
movq %rax, %r14
movq 0x58(%rsp), %rdi
cmpq %r12, %rdi
je 0x408c23
movq 0x68(%rsp), %rsi
incq %rsi
callq 0x426e30
jmp 0x408c23
jmp 0x408c34
movq %rax, %r14
leaq 0x328(%rsp), %rdi
jmp 0x408c0f
movq %rax, %r14
leaq 0x430(%rsp), %rdi
callq 0x40512c
jmp 0x408c07
movq %rax, %r14
leaq 0x380(%rsp), %rdi
callq 0x40512c
jmp 0x408c23
jmp 0x408c34
jmp 0x408c34
jmp 0x408c34
jmp 0x408c34
jmp 0x408c20
movq %rax, %r14
leaq 0x198(%rsp), %rdi
callq 0x40512c
jmp 0x408c37
jmp 0x408c34
movq %rax, %r14
leaq 0x8(%rsp), %rdi
callq 0x410332
leaq 0x40(%rsp), %rdi
callq 0x405152
movq %r14, %rdi
callq 0x4d10c0
nop