// File: /workspace/github_cpp_makefile_star2_O1/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 0x41028c
leaq 0x23fbe0(%rip), %rax    # 0x647ce0
movq %rax, 0x8(%rsp)
movq (%r15), %rax
movq %r15, %rdi
xorl %esi, %esi
callq *0x20(%rax)
movb $0x1, %r12b
movl $0x1, %ebp
xorl %ebx, %ebx
movq (%r15), %rax
movq %r15, %rdi
movq %rbp, %rsi
callq *0x20(%rax)
movq %r15, %rdi
callq 0x40b7d2
cmpb $0xd, %al
je 0x40814a
movq (%r15), %rax
movq %r15, %rdi
callq *0x38(%rax)
leaq 0x1(%rbp), %rdx
xorl %ecx, %ecx
cmpq %rax, %rdx
jne 0x408423
movq %rbp, %r13
subq %rbx, %r13
jne 0x40815f
xorl %r12d, %r12d
movl $0x2, %ecx
jmp 0x408423
leaq 0x1(%r13), %rdi
callq 0x50c8f0
testq %rax, %rax
je 0x4082f8
movq %rax, %r14
movq (%r15), %rax
movq %r15, %rdi
movq %rbx, %rsi
callq *0x20(%rax)
movq %r15, %rdi
movq %r14, %rsi
movq %r13, %rdx
xorl %ecx, %ecx
callq 0x40b790
movq %r14, %rax
subq %rbx, %rax
movb $0x0, (%rax,%rbp)
leaq 0x198(%rsp), %rdi
movq %r14, %rsi
callq 0x4107fc
leaq 0x430(%rsp), %rbx
movq %rbx, %rdi
leaq 0x1c61e9(%rip), %rsi    # 0x5ce3a5
callq 0x4107fc
leaq 0x3d8(%rsp), %r12
movq %r12, %rdi
leaq 0x1ce6b5(%rip), %rsi    # 0x5d6888
callq 0x4107fc
leaq 0x198(%rsp), %rdi
movq %rbx, %rsi
movq %r12, %rdx
callq 0x410f5c
movq 0x410(%rsp), %rdi
leaq 0x420(%rsp), %rax
cmpq %rax, %rdi
je 0x408210
movq 0x420(%rsp), %rsi
incq %rsi
callq 0x426f20
leaq 0x3d8(%rsp), %rdi
callq 0x410354
movq 0x468(%rsp), %rdi
leaq 0x478(%rsp), %rax
cmpq %rax, %rdi
je 0x408242
movq 0x478(%rsp), %rsi
incq %rsi
callq 0x426f20
movq %rbx, %rdi
callq 0x410354
leaq 0x328(%rsp), %rdi
leaq 0x198(%rsp), %rsi
callq 0x410a3a
leaq 0x40(%rsp), %rdi
leaq 0x328(%rsp), %rsi
callq 0x408db0
movq 0x360(%rsp), %rdi
leaq 0x370(%rsp), %rax
cmpq %rax, %rdi
je 0x408296
movq 0x370(%rsp), %rsi
incq %rsi
callq 0x426f20
leaq 0x328(%rsp), %rdi
callq 0x410354
movq %r14, %rdi
callq 0x50cc30
movq (%r15), %rax
movq %r15, %rdi
callq *0x38(%rax)
leaq 0x2(%rbp), %rbx
cmpq %rax, %rbx
setl %r12b
movq 0x1d0(%rsp), %rdi
leaq 0x1e0(%rsp), %rax
cmpq %rax, %rdi
je 0x4082e4
movq 0x1e0(%rsp), %rsi
incq %rsi
callq 0x426f20
leaq 0x198(%rsp), %rdi
callq 0x410354
xorl %ecx, %ecx
jmp 0x408423
movl $0x7, %edx
movq $0x653b20, %rdi         # imm = 0x653B20
leaq 0x1c5e48(%rip), %rsi    # 0x5ce153
callq 0x490a00
movq (%rsp), %rsi
movq (%rsi), %rax
leaq 0x198(%rsp), %rdi
callq *0x8(%rax)
leaq 0x1d0(%rsp), %rdi
leaq 0x1c6055(%rip), %rsi    # 0x5ce386
callq 0x4a25e0
leaq 0x68(%rsp), %rsi
movq %rsi, 0x58(%rsp)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
je 0x40835e
movq %rdx, 0x58(%rsp)
movq (%rcx), %rdx
movq %rdx, 0x68(%rsp)
jmp 0x408364
movups (%rcx), %xmm0
movups %xmm0, (%rsi)
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 0x490a00
movq %rax, %r14
movl $0x4, %edx
movq %rax, %rdi
leaq 0x1c5d07(%rip), %rsi    # 0x5ce0ab
callq 0x490a00
movq (%r14), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x471b50
movsbl %al, %esi
movq %r14, %rdi
callq 0x490500
movq %rax, %rdi
callq 0x48fad0
movq 0x58(%rsp), %rdi
leaq 0x68(%rsp), %rax
cmpq %rax, %rdi
je 0x4083ec
movq 0x68(%rsp), %rsi
incq %rsi
callq 0x426f20
movq 0x1d0(%rsp), %rdi
leaq 0x1e0(%rsp), %rax
cmpq %rax, %rdi
je 0x408411
movq 0x1e0(%rsp), %rsi
incq %rsi
callq 0x426f20
leaq 0x198(%rsp), %rdi
callq 0x410354
movl $0x1, %ecx
testb $0x1, %cl
jne 0x408af7
incq %rbp
testb $0x1, %r12b
jne 0x40811a
movq $0x653c40, %rdi         # imm = 0x653C40
leaq 0x1c5c4a(%rip), %rsi    # 0x5ce091
movl $0x4, %edx
callq 0x490a00
movq $0x653c40, %rdi         # imm = 0x653C40
leaq 0x1ea9c3(%rip), %rsi    # 0x5f2e22
xorl %edx, %edx
callq 0x490a00
movq $0x653c40, %rbx         # imm = 0x653C40
leaq 0x1c5c37(%rip), %rsi    # 0x5ce0ab
movl $0x4, %edx
movq %rbx, %rdi
callq 0x490a00
movq (%rbx), %rax
addq -0x18(%rax), %rbx
movq %rbx, %rdi
movl $0xa, %esi
callq 0x471b50
movsbl %al, %esi
movq $0x653c40, %rdi         # imm = 0x653C40
callq 0x490500
movq %rax, %rdi
callq 0x48fad0
movq 0x48(%rsp), %rax
subq 0x40(%rsp), %rax
testq %rax, %rax
jle 0x4085a5
movabsq $0x2e8ba2e8ba2e8ba3, %rcx # imm = 0x2E8BA2E8BA2E8BA3
mulq %rcx
shrq $0x4, %rdx
cmpq $0x2, %rdx
movl $0x1, %r13d
cmovgeq %rdx, %r13
xorl %ebx, %ebx
movq $0x653c40, %r14         # imm = 0x653C40
leaq 0x198(%rsp), %r12
leaq 0x1c5bb5(%rip), %rbp    # 0x5ce0ab
movl $0x4, %edx
movq %r14, %rdi
leaq 0x1c5b8c(%rip), %rsi    # 0x5ce091
callq 0x490a00
movq %r12, %rdi
leaq 0x8(%rsp), %rsi
movq %rbx, %rdx
callq 0x408cc4
movq 0x1d0(%rsp), %rsi
movq 0x1d8(%rsp), %rdx
movq %r14, %rdi
callq 0x490a00
movq %rax, %r15
movl $0x4, %edx
movq %rax, %rdi
movq %rbp, %rsi
callq 0x490a00
movq (%r15), %rax
movq -0x18(%rax), %rdi
addq %r15, %rdi
movl $0xa, %esi
callq 0x471b50
movsbl %al, %esi
movq %r15, %rdi
callq 0x490500
movq %rax, %rdi
callq 0x48fad0
movq 0x1d0(%rsp), %rdi
leaq 0x1e0(%rsp), %rax
cmpq %rax, %rdi
je 0x408591
movq 0x1e0(%rsp), %rsi
incq %rsi
callq 0x426f20
movq %r12, %rdi
callq 0x410354
incq %rbx
cmpq %rbx, %r13
jne 0x4084f6
movq $0x653c40, %rdi         # imm = 0x653C40
leaq 0x1c5ade(%rip), %rsi    # 0x5ce091
movl $0x4, %edx
callq 0x490a00
movq $0x653c40, %rdi         # imm = 0x653C40
leaq 0x1ea857(%rip), %rsi    # 0x5f2e22
xorl %edx, %edx
callq 0x490a00
movq $0x653c40, %rbx         # imm = 0x653C40
leaq 0x1c5acb(%rip), %rsi    # 0x5ce0ab
movl $0x4, %edx
movq %rbx, %rdi
callq 0x490a00
movq (%rbx), %rax
addq -0x18(%rax), %rbx
movq %rbx, %rdi
movl $0xa, %esi
callq 0x471b50
movsbl %al, %esi
movq $0x653c40, %rdi         # imm = 0x653C40
callq 0x490500
movq %rax, %rdi
callq 0x48fad0
leaq 0x198(%rsp), %rdi
leaq 0x8(%rsp), %rsi
xorl %edx, %edx
callq 0x408cc4
leaq 0x1c68d3(%rip), %rsi    # 0x5cef06
leaq 0x380(%rsp), %rdi
callq 0x4107fc
leaq 0x198(%rsp), %rdi
leaq 0x380(%rsp), %rsi
callq 0x410fbc
movq %rax, %rbx
leaq 0x3c8(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x408679
movq 0x3c8(%rsp), %rsi
incq %rsi
callq 0x426f20
leaq 0x380(%rsp), %rdi
callq 0x410354
movq 0x1d0(%rsp), %rdi
leaq 0x1e0(%rsp), %rax
cmpq %rax, %rdi
je 0x4086ab
movq 0x1e0(%rsp), %rsi
incq %rsi
callq 0x426f20
leaq 0x198(%rsp), %rdi
callq 0x410354
movq %rbx, %r15
addq $0x38, %r15
movq 0x40(%rbx), %rax
subq 0x38(%rbx), %rax
cmpq $0xaf, %rax
jg 0x40873c
movq $0x653b20, %rdi         # imm = 0x653B20
leaq 0x1c5a76(%rip), %rsi    # 0x5ce153
movl $0x7, %edx
callq 0x490a00
movq (%rsp), %rsi
movq (%rsi), %rax
leaq 0x198(%rsp), %rdi
callq *0x8(%rax)
leaq 0x1d0(%rsp), %rdi
leaq 0x1c5c9f(%rip), %rsi    # 0x5ce3a7
callq 0x4a25e0
leaq 0x68(%rsp), %rsi
movq %rsi, 0x58(%rsp)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
je 0x4089e8
movq %rdx, 0x58(%rsp)
movq (%rcx), %rdx
movq %rdx, 0x68(%rsp)
jmp 0x4089ee
leaq 0x58(%rsp), %rdi
callq 0x41028c
leaq 0x23f843(%rip), %r12    # 0x647f90
leaq 0x90(%rsp), %r14
movq %r12, -0x38(%r14)
movq %r14, %rdi
callq 0x4107d2
leaq 0xe8(%rsp), %r13
movq %r13, %rdi
callq 0x4107d2
leaq 0x140(%rsp), %rdi
callq 0x4107d2
movq 0x38(%rbx), %rsi
movq 0x40(%rbx), %rdx
subq %rsi, %rdx
je 0x408b1d
movq %r14, %rdi
callq 0x410b12
movq 0x38(%rbx), %rsi
movq 0x40(%rbx), %rdx
subq %rsi, %rdx
sarq $0x3, %rdx
movabsq $0x2e8ba2e8ba2e8ba3, %rax # imm = 0x2E8BA2E8BA2E8BA3
imulq %rax, %rdx
cmpq $0x2, %rdx
jb 0x408b33
addq $0x58, %rsi
movq %r13, %rdi
callq 0x410b12
movq 0x38(%rbx), %rsi
movq 0x40(%rbx), %rax
subq %rsi, %rax
cmpq $0xb1, %rax
jl 0x408814
movq 0x40(%rbx), %rdx
subq %rsi, %rdx
sarq $0x3, %rdx
movabsq $0x2e8ba2e8ba2e8ba3, %rax # imm = 0x2E8BA2E8BA2E8BA3
imulq %rax, %rdx
cmpq $0x2, %rdx
jbe 0x408b3a
addq $0xb0, %rsi
leaq 0x140(%rsp), %rdi
callq 0x410b12
movq %rbx, %rdi
callq 0x410354
movq %r15, %rdi
callq 0x405150
movl $0x50, %esi
movq %rbx, %rdi
callq 0x426f20
leaq 0x488(%rsp), %rdi
leaq 0x58(%rsp), %rsi
callq 0x41045a
leaq 0x4c0(%rsp), %r15
movq %r12, -0x38(%r15)
movq %r15, %rdi
movq %r14, %rsi
callq 0x410a3a
leaq 0x518(%rsp), %rbp
movq %rbp, %rdi
movq %r13, %rsi
callq 0x410a3a
leaq 0x570(%rsp), %rbx
movq %rbx, %rdi
leaq 0x140(%rsp), %rsi
callq 0x410a3a
movq $0x652870, %rsi         # imm = 0x652870
leaq 0x198(%rsp), %rdi
leaq 0x488(%rsp), %rcx
movq (%rsp), %rdx
callq 0x408fcc
leaq 0x5b8(%rsp), %rax
movq %r12, -0x130(%rax)
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x4088cd
movq 0x5b8(%rsp), %rsi
incq %rsi
callq 0x426f20
movq %rbx, %rdi
callq 0x410354
leaq 0x560(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x4088f6
movq 0x560(%rsp), %rsi
incq %rsi
callq 0x426f20
movq %rbp, %rdi
callq 0x410354
leaq 0x508(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x40891f
movq 0x508(%rsp), %rsi
incq %rsi
callq 0x426f20
movq %r15, %rdi
callq 0x410354
leaq 0x488(%rsp), %rdi
callq 0x410354
leaq 0x198(%rsp), %rsi
movq (%rsp), %rdi
callq 0x40e18e
leaq 0x198(%rsp), %rdi
callq 0x40904a
leaq 0x188(%rsp), %rax
movq %r12, -0x130(%rax)
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x40897a
movq 0x188(%rsp), %rsi
incq %rsi
callq 0x426f20
leaq 0x140(%rsp), %rdi
callq 0x410354
leaq 0x130(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x4089a8
movq 0x130(%rsp), %rsi
incq %rsi
callq 0x426f20
movq %r13, %rdi
callq 0x410354
leaq 0xd8(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x4089d1
movq 0xd8(%rsp), %rsi
incq %rsi
callq 0x426f20
movq %r14, %rdi
callq 0x410354
leaq 0x58(%rsp), %rdi
callq 0x410354
jmp 0x408af7
movups (%rcx), %xmm0
movups %xmm0, (%rsi)
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 0x490a00
movq %rax, %r14
leaq 0x1c5685(%rip), %rsi    # 0x5ce0ab
movl $0x4, %edx
movq %rax, %rdi
callq 0x490a00
movq (%r14), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x471b50
movsbl %al, %esi
movq %r14, %rdi
callq 0x490500
movq %rax, %rdi
callq 0x48fad0
movq 0x58(%rsp), %rdi
leaq 0x68(%rsp), %rax
cmpq %rax, %rdi
je 0x408a76
movq 0x68(%rsp), %rsi
incq %rsi
callq 0x426f20
movq 0x1d0(%rsp), %rdi
leaq 0x1e0(%rsp), %rax
cmpq %rax, %rdi
je 0x408a9b
movq 0x1e0(%rsp), %rsi
incq %rsi
callq 0x426f20
leaq 0x198(%rsp), %rdi
callq 0x410354
movq $0x652c08, %rsi         # imm = 0x652C08
leaq 0x198(%rsp), %rdi
callq 0x4168dc
leaq 0x198(%rsp), %rsi
movq (%rsp), %rdi
callq 0x40e18e
movq %rbx, %rdi
callq 0x410354
movq %r15, %rdi
callq 0x405150
movl $0x50, %esi
movq %rbx, %rdi
callq 0x426f20
leaq 0x198(%rsp), %rdi
callq 0x4169fc
leaq 0x8(%rsp), %rdi
callq 0x410354
leaq 0x40(%rsp), %rdi
callq 0x405150
addq $0x5c8, %rsp            # imm = 0x5C8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
sarq $0x3, %rdx
movabsq $0x2e8ba2e8ba2e8ba3, %rax # imm = 0x2E8BA2E8BA2E8BA3
imulq %rax, %rdx
xorl %esi, %esi
jmp 0x408b3f
movl $0x1, %esi
jmp 0x408b3f
movl $0x2, %esi
leaq 0x1c5882(%rip), %rdi    # 0x5ce3c8
xorl %eax, %eax
callq 0x471660
movq %rax, %rbx
leaq 0x198(%rsp), %rdi
callq 0x40904a
jmp 0x408c20
movq %rax, %rbx
leaq 0x488(%rsp), %rdi
callq 0x408d12
jmp 0x408c20
movq %rax, %rbx
movq %rbp, %rdi
callq 0x40512a
jmp 0x408b87
movq %rax, %rbx
movq %r15, %rdi
callq 0x40512a
jmp 0x408b94
movq %rax, %rbx
leaq 0x488(%rsp), %rdi
callq 0x410354
jmp 0x408c20
movq %rax, %rbx
leaq 0x198(%rsp), %rdi
callq 0x4169fc
jmp 0x408ca7
jmp 0x408c1d
jmp 0x408c92
movq %rax, %rbx
movq %r13, %rdi
callq 0x40512a
jmp 0x408bcf
movq %rax, %rbx
movq %r14, %rdi
callq 0x40512a
jmp 0x408be1
jmp 0x408c97
movq %rax, %rbx
leaq 0x58(%rsp), %rdi
callq 0x410354
jmp 0x408ca7
jmp 0x408c92
jmp 0x408c92
jmp 0x408c92
movq %rax, %rbx
leaq 0x380(%rsp), %rdi
jmp 0x408c5c
jmp 0x408c97
jmp 0x408c92
jmp 0x408c92
movq %rax, %rbx
jmp 0x408cb1
movq %rax, %rbx
leaq 0x58(%rsp), %rdi
callq 0x408d12
jmp 0x408ca7
jmp 0x408c6d
jmp 0x408c97
jmp 0x408c92
movq %rax, %rbx
leaq 0x328(%rsp), %rdi
jmp 0x408c5c
movq %rax, %rbx
leaq 0x3d8(%rsp), %rdi
callq 0x40512a
jmp 0x408c54
movq %rax, %rbx
leaq 0x430(%rsp), %rdi
callq 0x40512a
jmp 0x408c9a
jmp 0x408c92
jmp 0x408c92
jmp 0x408c92
jmp 0x408c92
jmp 0x408c92
movq %rax, %rbx
movq 0x58(%rsp), %rdi
leaq 0x68(%rsp), %rax
cmpq %rax, %rdi
je 0x408c9a
movq 0x68(%rsp), %rsi
incq %rsi
callq 0x426f20
jmp 0x408c9a
jmp 0x408c97
jmp 0x408c92
movq %rax, %rbx
jmp 0x408ca7
movq %rax, %rbx
leaq 0x198(%rsp), %rdi
callq 0x40512a
leaq 0x8(%rsp), %rdi
callq 0x410354
leaq 0x40(%rsp), %rdi
callq 0x405150
movq %rbx, %rdi
callq 0x4d11b0
nop