// File: /workspace/github_cpp_makefile_star2_O3/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 %r13
pushq %r12
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
movq 0x8(%r14), %rdx
callq 0x4400
leaq 0x50(%rsp), %rcx
movq %rcx, -0x10(%rcx)
xorl %eax, %eax
movq %rax, -0x8(%rcx)
movb %al, (%rcx)
leaq 0x30(%rsp), %rcx
movq %rcx, -0x10(%rcx)
movq %rax, -0x8(%rcx)
movb %al, (%rcx)
leaq 0x70(%rsp), %r12
movq %r12, -0x10(%r12)
movq %rax, -0x8(%r12)
movb %al, (%r12)
leaq 0x100(%rsp), %rdi
leaq 0x40(%rsp), %rsi
callq 0x4440
leaq 0x20(%rsp), %rsi
movq %rax, %rdi
callq 0x4440
leaq 0x60(%rsp), %rsi
movq %rax, %rdi
callq 0x4440
movq %rsp, %rdi
leaq 0x20(%rsp), %rsi
movl $0x7, %ecx
xorl %edx, %edx
callq 0x43a0
leaq 0x389d(%rip), %rsi      # 0x9031
movq %rsp, %r14
movq %r14, %rdi
callq 0x40e0
movl %eax, %ebp
movq (%r14), %rdi
leaq 0x10(%rsp), %r13
cmpq %r13, %rdi
je 0x57bb
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x4370
testl %ebp, %ebp
jne 0x57fd
movq %rsp, %rdi
leaq 0x20(%rsp), %rsi
movl $0x7, %edx
movq $-0x1, %rcx
callq 0x43a0
leaq 0x20(%rsp), %rdi
movq %rsp, %r14
movq %r14, %rsi
callq 0x4420
movq (%r14), %rdi
cmpq %r13, %rdi
je 0x57fd
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x4370
leaq 0x3833(%rip), %r15      # 0x9037
leaq 0x20(%rsp), %rdi
movl $0x1, %ecx
movq %r15, %rsi
xorl %edx, %edx
callq 0x44c0
movq %rax, %r14
movq %rsp, %rdi
movq %r13, (%rdi)
leaq 0x3810(%rip), %rdx      # 0x9038
movq %r15, %rsi
callq 0x55e8
cmpq $-0x1, %r14
je 0x5885
leaq 0xe0(%rsp), %rdi
leaq 0x20(%rsp), %rsi
movq %r14, %rdx
movq $-0x1, %rcx
callq 0x43a0
movq %rsp, %rdi
leaq 0xe0(%rsp), %r14
movq %r14, %rsi
callq 0x4420
movq (%r14), %rdi
leaq 0xf0(%rsp), %rax
cmpq %rax, %rdi
je 0x5885
movq 0xf0(%rsp), %rsi
incq %rsi
callq 0x4370
leaq 0xd0(%rsp), %r14
movq %r14, -0x10(%r14)
movq 0x40(%rsp), %rsi
movq 0x48(%rsp), %rdx
addq %rsi, %rdx
leaq 0xc0(%rsp), %rdi
callq 0x50d2
leaq 0x80(%rbx), %rdi
leaq 0xc0(%rsp), %rsi
callq 0x41c0
movq 0xc0(%rsp), %rdi
cmpq %r14, %rdi
je 0x58dc
movq 0xd0(%rsp), %rsi
incq %rsi
callq 0x4370
leaq 0xb0(%rsp), %r14
movq %r14, -0x10(%r14)
movq (%rsp), %rsi
movq 0x8(%rsp), %rdx
addq %rsi, %rdx
leaq 0xa0(%rsp), %rdi
callq 0x50d2
leaq 0x60(%rbx), %rdi
leaq 0xa0(%rsp), %rsi
callq 0x41c0
movq 0xa0(%rsp), %rdi
cmpq %r14, %rdi
je 0x592f
movq 0xb0(%rsp), %rsi
incq %rsi
callq 0x4370
leaq 0x90(%rsp), %r14
movq %r14, -0x10(%r14)
movq 0x60(%rsp), %rsi
movq 0x68(%rsp), %rdx
addq %rsi, %rdx
leaq 0x80(%rsp), %rdi
callq 0x50d2
leaq 0x80(%rsp), %rsi
movq %rbx, %rdi
callq 0x47fc
movq 0x80(%rsp), %rdi
cmpq %r14, %rdi
je 0x5982
movq 0x90(%rsp), %rsi
incq %rsi
callq 0x4370
leaq 0x36b0(%rip), %rsi      # 0x9039
leaq 0x40(%rsp), %rdi
callq 0x40e0
movl $0x1f5, %ebx            # imm = 0x1F5
testl %eax, %eax
leaq 0x50(%rsp), %r14
jne 0x59d8
leaq 0x3695(%rip), %rsi      # 0x903d
leaq 0x60(%rsp), %rdi
callq 0x40e0
testl %eax, %eax
je 0x59d3
leaq 0x3689(%rip), %rsi      # 0x9046
leaq 0x60(%rsp), %rdi
callq 0x40e0
testl %eax, %eax
movl $0x190, %ebx            # imm = 0x190
cmovel %eax, %ebx
jmp 0x59d8
movl $0x1f9, %ebx            # imm = 0x1F9
movq (%rsp), %rdi
cmpq %r13, %rdi
je 0x59ee
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x4370
movq 0x60(%rsp), %rdi
cmpq %r12, %rdi
je 0x5a05
movq 0x70(%rsp), %rsi
incq %rsi
callq 0x4370
movq 0x20(%rsp), %rdi
leaq 0x30(%rsp), %rax
cmpq %rax, %rdi
je 0x5a21
movq 0x30(%rsp), %rsi
incq %rsi
callq 0x4370
movq 0x40(%rsp), %rdi
cmpq %r14, %rdi
je 0x5a38
movq 0x50(%rsp), %rsi
incq %rsi
callq 0x4370
movq 0x7541(%rip), %rsi      # 0xcf80
leaq 0x100(%rsp), %rdi
callq 0x4280
leaq 0x180(%rsp), %rdi
callq 0x4120
movl %ebx, %eax
addq $0x288, %rsp            # imm = 0x288
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x5aeb
jmp 0x5ad0
movq %rax, %rbx
movq 0x80(%rsp), %rdi
cmpq %r14, %rdi
je 0x5ad3
movq 0x90(%rsp), %rsi
jmp 0x5abd
movq %rax, %rbx
movq 0xa0(%rsp), %rdi
cmpq %r14, %rdi
je 0x5ad3
movq 0xb0(%rsp), %rsi
jmp 0x5abd
movq %rax, %rbx
movq 0xc0(%rsp), %rdi
cmpq %r14, %rdi
je 0x5ad3
movq 0xd0(%rsp), %rsi
incq %rsi
callq 0x4370
jmp 0x5ad3
jmp 0x5aeb
jmp 0x5aeb
movq %rax, %rbx
jmp 0x5b3d
movq %rax, %rbx
movq (%rsp), %rdi
cmpq %r13, %rdi
je 0x5aee
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x4370
jmp 0x5aee
movq %rax, %rbx
movq 0x60(%rsp), %rdi
cmpq %r12, %rdi
je 0x5b05
movq 0x70(%rsp), %rsi
incq %rsi
callq 0x4370
movq 0x20(%rsp), %rdi
leaq 0x30(%rsp), %rax
cmpq %rax, %rdi
je 0x5b21
movq 0x30(%rsp), %rsi
incq %rsi
callq 0x4370
movq 0x40(%rsp), %rdi
leaq 0x50(%rsp), %rax
cmpq %rax, %rdi
je 0x5b3d
movq 0x50(%rsp), %rsi
incq %rsi
callq 0x4370
movq 0x743c(%rip), %rsi      # 0xcf80
leaq 0x100(%rsp), %rdi
callq 0x4280
leaq 0x180(%rsp), %rdi
callq 0x4120
movq %rbx, %rdi
callq 0x4550