// File: /workspace/github_cpp_makefile_star2_O1/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 0x3871(%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 0x57e7
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x4370
testl %ebp, %ebp
jne 0x5829
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 0x5829
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x4370
leaq 0x3807(%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 0x37e4(%rip), %rdx      # 0x9038
movq %r15, %rsi
callq 0x561a
cmpq $-0x1, %r14
je 0x58b1
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 0x58b1
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 0x5100
leaq 0x80(%rbx), %rdi
leaq 0xc0(%rsp), %rsi
callq 0x41c0
movq 0xc0(%rsp), %rdi
cmpq %r14, %rdi
je 0x5908
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 0x5100
leaq 0x60(%rbx), %rdi
leaq 0xa0(%rsp), %rsi
callq 0x41c0
movq 0xa0(%rsp), %rdi
cmpq %r14, %rdi
je 0x595b
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 0x5100
leaq 0x80(%rsp), %rsi
movq %rbx, %rdi
callq 0x480c
movq 0x80(%rsp), %rdi
cmpq %r14, %rdi
je 0x59ae
movq 0x90(%rsp), %rsi
incq %rsi
callq 0x4370
leaq 0x3684(%rip), %rsi      # 0x9039
leaq 0x40(%rsp), %rdi
callq 0x40e0
movl $0x1f5, %ebx            # imm = 0x1F5
testl %eax, %eax
leaq 0x50(%rsp), %r14
jne 0x5a04
leaq 0x3669(%rip), %rsi      # 0x903d
leaq 0x60(%rsp), %rdi
callq 0x40e0
testl %eax, %eax
je 0x59ff
leaq 0x365d(%rip), %rsi      # 0x9046
leaq 0x60(%rsp), %rdi
callq 0x40e0
testl %eax, %eax
movl $0x190, %ebx            # imm = 0x190
cmovel %eax, %ebx
jmp 0x5a04
movl $0x1f9, %ebx            # imm = 0x1F9
movq (%rsp), %rdi
cmpq %r13, %rdi
je 0x5a1a
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x4370
movq 0x60(%rsp), %rdi
cmpq %r12, %rdi
je 0x5a31
movq 0x70(%rsp), %rsi
incq %rsi
callq 0x4370
movq 0x20(%rsp), %rdi
leaq 0x30(%rsp), %rax
cmpq %rax, %rdi
je 0x5a4d
movq 0x30(%rsp), %rsi
incq %rsi
callq 0x4370
movq 0x40(%rsp), %rdi
cmpq %r14, %rdi
je 0x5a64
movq 0x50(%rsp), %rsi
incq %rsi
callq 0x4370
movq 0x7515(%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 0x5b17
jmp 0x5afc
movq %rax, %rbx
movq 0x80(%rsp), %rdi
cmpq %r14, %rdi
je 0x5aff
movq 0x90(%rsp), %rsi
jmp 0x5ae9
movq %rax, %rbx
movq 0xa0(%rsp), %rdi
cmpq %r14, %rdi
je 0x5aff
movq 0xb0(%rsp), %rsi
jmp 0x5ae9
movq %rax, %rbx
movq 0xc0(%rsp), %rdi
cmpq %r14, %rdi
je 0x5aff
movq 0xd0(%rsp), %rsi
incq %rsi
callq 0x4370
jmp 0x5aff
jmp 0x5b17
jmp 0x5b17
movq %rax, %rbx
jmp 0x5b69
movq %rax, %rbx
movq (%rsp), %rdi
cmpq %r13, %rdi
je 0x5b1a
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x4370
jmp 0x5b1a
movq %rax, %rbx
movq 0x60(%rsp), %rdi
cmpq %r12, %rdi
je 0x5b31
movq 0x70(%rsp), %rsi
incq %rsi
callq 0x4370
movq 0x20(%rsp), %rdi
leaq 0x30(%rsp), %rax
cmpq %rax, %rdi
je 0x5b4d
movq 0x30(%rsp), %rsi
incq %rsi
callq 0x4370
movq 0x40(%rsp), %rdi
leaq 0x50(%rsp), %rax
cmpq %rax, %rdi
je 0x5b69
movq 0x50(%rsp), %rsi
incq %rsi
callq 0x4370
movq 0x7410(%rip), %rsi      # 0xcf80
leaq 0x100(%rsp), %rdi
callq 0x4280
leaq 0x180(%rsp), %rdi
callq 0x4120
movq %rbx, %rdi
callq 0x4550