// File: /workspace/github_cpp_makefile_star2_O2/m1c0l[P]http-client-server/HttpRequest.cpp
// Function: HttpRequest::decodeFirstLine(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>)
int HttpRequest::decodeFirstLine(string line) {
	stringstream ss;
	ss << line;
	string method, url, version;
	ss >> method >> url >> version;

	
	
	if (url.substr(0,7) == "http://"){
	  url = url.substr(7);
	}
	//size_t colonPos = url.find_first_of(":");
	size_t slashPos = url.find_first_of("/");
	/*
	string hostName = url;
	if (colonPos != string::npos) {
	  hostname = url.substr(0,colPos);
	}
	else if (slashPos != string::npos) {
	  hostname = url.substr(0,slashPos);
	}

	string port = "80";
	if (colonPos != string::npos && slashPos != string::npos) {
	  port = url.substr(colonPos + 1, slashPos - colonPos - 1);
	}
	else if (colonPos != string::npos) {
	  port = url.substr(colonPos + 1);
	}
	*/
	string filename = "/";
	if (slashPos != string::npos) {
	  filename = url.substr(slashPos);
	}
	setMethod(method);
	setUrl(filename);
	setVersion(version);
	if (method != "GET") {
		// only GET supported
		return 501;
	}        
	if (version == "HTTP/1.1") {

		// this HTTP version not implemented yet
		return 505;
	}
	else if (version != "HTTP/1.0") {
		// bad version string
	  return 400;}

	return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
subq $0x288, %rsp            # imm = 0x288
movq %rsi, %r14
movq %rdi, %rbx
leaq 0x100(%rsp), %rdi
callq 0x4250
leaq 0x110(%rsp), %rdi
movq %r14, %rsi
callq 0x42f0
leaq 0x70(%rsp), %rax
movq %rax, -0x10(%rax)
andq $0x0, -0x8(%rax)
xorl %ecx, %ecx
leaq 0x30(%rsp), %rdx
movq %rdx, -0x10(%rdx)
andq $0x0, -0x8(%rdx)
movb %cl, (%rax)
movb %cl, (%rdx)
leaq 0x50(%rsp), %rax
movq %rax, -0x10(%rax)
andq $0x0, -0x8(%rax)
movb %cl, (%rax)
leaq 0x100(%rsp), %rdi
leaq 0x60(%rsp), %rsi
callq 0x4430
leaq 0x20(%rsp), %rsi
movq %rax, %rdi
callq 0x4430
leaq 0x40(%rsp), %rsi
movq %rax, %rdi
callq 0x4430
movq %rsp, %rdi
leaq 0x20(%rsp), %rsi
pushq $0x7
popq %rcx
xorl %edx, %edx
callq 0x43a0
leaq 0x3ce2(%rip), %rsi      # 0x9031
movq %rsp, %r14
movq %r14, %rdi
callq 0x56b7
movl %eax, %ebp
movq %r14, %rdi
callq 0x4170
testb %bpl, %bpl
je 0x5394
movq %rsp, %rdi
leaq 0x20(%rsp), %rsi
pushq $0x7
popq %rdx
pushq $-0x1
popq %rcx
callq 0x43a0
leaq 0x20(%rsp), %rdi
movq %rsp, %r14
movq %r14, %rsi
callq 0x4410
movq %r14, %rdi
callq 0x4170
leaq 0x3c9c(%rip), %r15      # 0x9037
leaq 0x20(%rsp), %rdi
movq %r15, %rsi
xorl %edx, %edx
callq 0x41d0
movq %rax, %r14
movq %rsp, %rdi
leaq 0xe0(%rsp), %rdx
movq %r15, %rsi
callq 0x4bfa
cmpq $-0x1, %r14
je 0x53f9
leaq 0xe0(%rsp), %rdi
leaq 0x20(%rsp), %rsi
pushq $-0x1
popq %rcx
movq %r14, %rdx
callq 0x43a0
movq %rsp, %rdi
leaq 0xe0(%rsp), %r14
movq %r14, %rsi
callq 0x4410
movq %r14, %rdi
callq 0x4170
leaq 0xc0(%rsp), %rdi
leaq 0x60(%rsp), %rsi
callq 0x4480
leaq 0x80(%rbx), %rdi
leaq 0xc0(%rsp), %rsi
callq 0x41e0
leaq 0xc0(%rsp), %rdi
callq 0x4170
leaq 0xa0(%rsp), %rdi
movq %rsp, %rsi
callq 0x4480
leaq 0x60(%rbx), %rdi
leaq 0xa0(%rsp), %rsi
callq 0x41e0
leaq 0xa0(%rsp), %rdi
callq 0x4170
leaq 0x80(%rsp), %rdi
leaq 0x40(%rsp), %rsi
callq 0x4480
leaq 0x80(%rsp), %rsi
movq %rbx, %rdi
callq 0x472c
leaq 0x80(%rsp), %rdi
callq 0x4170
leaq 0x3ba9(%rip), %rsi      # 0x9039
leaq 0x60(%rsp), %rdi
callq 0x56c4
movl $0x1f5, %ebx            # imm = 0x1F5
testb %al, %al
jne 0x54da
leaq 0x3b93(%rip), %rsi      # 0x903d
leaq 0x40(%rsp), %rdi
callq 0x56b7
movl $0x1f9, %ebx            # imm = 0x1F9
testb %al, %al
jne 0x54da
leaq 0x3b82(%rip), %rsi      # 0x9046
leaq 0x40(%rsp), %rdi
callq 0x56c4
xorl %ecx, %ecx
testb %al, %al
movl $0x190, %ebx            # imm = 0x190
cmovel %ecx, %ebx
movq %rsp, %rdi
callq 0x4170
leaq 0x40(%rsp), %rdi
callq 0x4170
leaq 0x20(%rsp), %rdi
callq 0x4170
leaq 0x60(%rsp), %rdi
callq 0x4170
leaq 0x100(%rsp), %rdi
callq 0x4280
movl %ebx, %eax
addq $0x288, %rsp            # imm = 0x288
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
jmp 0x5563
jmp 0x5556
movq %rax, %rbx
leaq 0x80(%rsp), %rdi
jmp 0x5546
movq %rax, %rbx
leaq 0xa0(%rsp), %rdi
jmp 0x5546
movq %rax, %rbx
leaq 0xc0(%rsp), %rdi
callq 0x4170
jmp 0x5559
jmp 0x5563
jmp 0x5563
movq %rax, %rbx
jmp 0x5584
movq %rax, %rbx
movq %rsp, %rdi
callq 0x4170
jmp 0x5566
movq %rax, %rbx
leaq 0x40(%rsp), %rdi
callq 0x4170
leaq 0x20(%rsp), %rdi
callq 0x4170
leaq 0x60(%rsp), %rdi
callq 0x4170
leaq 0x100(%rsp), %rdi
callq 0x4280
movq %rbx, %rdi
callq 0x4540
nop