// File: /workspace/github_cpp_makefile_star2_O3/m1c0l[P]http-client-server/web-client.cpp
// Function: main
int main(int argc, char **argv) {
	if (argc < 2) {
		cerr << "usage: " << argv[0] << " [URL] [URL] ..." << '\n';
		return 1;
	}

	Url *url = new Url[argc];
	thread *t = new thread[argc];
	HttpRequest **req = new HttpRequest*[argc];
	sockaddr_in *serverAddr = new sockaddr_in[argc];

	// send a request for each url
	for (int i = 1; i < argc; i++) {

		url[i] = parseUrl(argv[i]);
		serverAddr[i] = getServerAddr(url[i].host, url[i].port);

		// set up HTTP request
		req[i] = new HttpRequest();
		req[i]->setMethod("GET");
		req[i]->setUrl(url[i].path);
		req[i]->setVersion("HTTP/1.0");
		req[i]->setHeader("Host", url[i].host);

		// send the request and retrieve the file
		t[i] = thread(processRequest, (sockaddr*)&serverAddr[i], req[i],
			url[i].path);
	}

	// join threads
	for (int i = 1; i < argc; i++) {
		t[i].join();
	}

	return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x1b8, %rsp            # imm = 0x1B8
movq %rsi, %r14
cmpl $0x1, %edi
jg 0x88ef
movq 0x9740(%rip), %rbx      # 0x11ff0
leaq 0x384f(%rip), %rsi      # 0xc106
movl $0x7, %edx
movq %rbx, %rdi
callq 0x5390
movq (%r14), %r14
testq %r14, %r14
je 0x8e5a
movq %r14, %rdi
callq 0x5120
movq 0x9711(%rip), %rdi      # 0x11ff0
movq %r14, %rsi
movq %rax, %rdx
callq 0x5390
jmp 0x8e71
movq %r14, %r15
movl %edi, %r12d
movq %r12, %rax
shlq $0x5, %rax
leaq (%rax,%rax,2), %rbx
leaq (%rax,%rax,2), %rdi
addq $0x8, %rdi
callq 0x5030
movq %r12, (%rax)
movq %rax, (%rsp)
addq $0x38, %rax
xorl %ecx, %ecx
leaq -0x20(%rax), %rdx
movq %rdx, -0x30(%rax)
movq %rcx, -0x28(%rax)
movb %cl, -0x20(%rax)
movq %rax, -0x10(%rax)
movq %rcx, -0x8(%rax)
movb %cl, (%rax)
leaq 0x20(%rax), %rdx
movq %rdx, 0x10(%rax)
movq %rcx, 0x18(%rax)
movb %cl, 0x20(%rax)
addq $0x60, %rax
addq $-0x60, %rbx
jne 0x891a
leaq (,%r12,8), %rbx
leaq 0x8(,%r12,8), %rdi
callq 0x5030
movq %r12, (%rax)
movq %rax, 0x8(%rsp)
leaq 0x8(%rax), %rdi
xorl %esi, %esi
movq %rbx, %rdx
callq 0x5190
movq %rbx, %rdi
callq 0x5030
movq %rax, %rbx
movq %r12, %rdi
shlq $0x4, %rdi
callq 0x5030
addq $0x8, %rbx
movq %rbx, 0x10(%rsp)
addq $0x10, %rax
addq $0x68, (%rsp)
leaq 0x8d39(%rip), %rcx      # 0x116e0
addq $0x10, %rcx
movq %rcx, 0x98(%rsp)
movq %r12, 0x80(%rsp)
leaq -0x8(,%r12,8), %rcx
movq %rcx, 0x88(%rsp)
leaq 0xb8(%rsp), %rbx
movq %rax, 0xa0(%rsp)
movq %rax, %r14
xorl %r13d, %r13d
movq %r15, %rax
movq %r15, 0x90(%rsp)
movq %r14, 0xb0(%rsp)
movq 0x8(%rax,%r13), %rsi
movq %rbx, %rdi
leaq 0x18(%rsp), %rdx
callq 0x8fca
leaq 0x158(%rsp), %rbp
movq %rbp, %rdi
movq %rbx, %rsi
callq 0x760c
leaq 0x148(%rsp), %r12
movq (%rsp), %rbx
movq %rbx, %rdi
movq %rbp, %rsi
callq 0x53c0
leaq 0x20(%rbx), %rdi
leaq 0x178(%rsp), %rsi
callq 0x53c0
leaq 0x40(%rbx), %rdi
movq %rdi, 0xa8(%rsp)
leaq 0x198(%rsp), %rsi
callq 0x53c0
movq 0x198(%rsp), %rdi
leaq 0x1a8(%rsp), %rax
cmpq %rax, %rdi
je 0x8a7f
movq 0x1a8(%rsp), %rsi
incq %rsi
callq 0x5320
movq 0x178(%rsp), %rdi
leaq 0x188(%rsp), %rax
cmpq %rax, %rdi
je 0x8aa4
movq 0x188(%rsp), %rsi
incq %rsi
callq 0x5320
movq 0x158(%rsp), %rdi
leaq 0x168(%rsp), %rax
cmpq %rax, %rdi
je 0x8ac9
movq 0x168(%rsp), %rsi
incq %rsi
callq 0x5320
movq 0xb8(%rsp), %rdi
leaq 0xc8(%rsp), %rax
cmpq %rax, %rdi
je 0x8aee
movq 0xc8(%rsp), %rsi
incq %rsi
callq 0x5320
leaq 0x70(%rsp), %rax
movq %rax, 0x60(%rsp)
movq (%rsp), %r14
movq (%r14), %rsi
movq 0x8(%r14), %rdx
addq %rsi, %rdx
leaq 0x60(%rsp), %rbx
movq %rbx, %rdi
callq 0x61d2
movq %r12, 0x138(%rsp)
movq 0x20(%r14), %rsi
movq 0x28(%r14), %rdx
addq %rsi, %rdx
leaq 0x138(%rsp), %rbp
movq %rbp, %rdi
callq 0x61d2
movq %rbx, %rdi
movq %rbp, %rsi
callq 0x7978
movq 0xa0(%rsp), %rcx
movq %rax, (%rcx,%r13,2)
movq $0x0, 0x8(%rcx,%r13,2)
movq 0x138(%rsp), %rdi
cmpq %r12, %rdi
je 0x8b73
movq 0x148(%rsp), %rsi
incq %rsi
callq 0x5320
movq 0x60(%rsp), %rdi
leaq 0x70(%rsp), %rax
cmpq %rax, %rdi
leaq 0x128(%rsp), %r12
je 0x8b97
movq 0x70(%rsp), %rsi
incq %rsi
callq 0x5320
movl $0xa0, %edi
callq 0x5300
movq %rax, %rbp
leaq 0x10(%rax), %rdi
movl $0x90, %edx
xorl %esi, %esi
callq 0x5190
leaq 0x18(%rbp), %rax
movq %rax, 0x8(%rbp)
xorl %ecx, %ecx
movb %cl, 0x18(%rbp)
leaq 0x58(%rbp), %rax
movq %rax, 0x28(%rbp)
movq $0x1, 0x30(%rbp)
xorps %xmm0, %xmm0
movups %xmm0, 0x38(%rbp)
movl $0x3f800000, 0x48(%rbp) # imm = 0x3F800000
movups %xmm0, 0x50(%rbp)
movq 0x98(%rsp), %rax
movq %rax, (%rbp)
leaq 0x70(%rbp), %rax
movq %rax, 0x60(%rbp)
movb %cl, 0x70(%rbp)
leaq 0x90(%rbp), %rax
movq %rax, 0x80(%rbp)
movb %cl, 0x90(%rbp)
movq 0x10(%rsp), %rax
movq %rbp, (%rax,%r13)
movq %r12, 0x118(%rsp)
leaq 0x118(%rsp), %rbx
movq %rbx, %rdi
leaq 0x3408(%rip), %rsi      # 0xc039
leaq 0x3404(%rip), %rdx      # 0xc03c
callq 0x66e8
movq %rbp, %rdi
movq %rbx, %rsi
callq 0x6780
leaq 0x20(%rsp), %r15
movq 0x118(%rsp), %rdi
cmpq %r12, %rdi
je 0x8c6a
movq 0x128(%rsp), %rsi
incq %rsi
callq 0x5320
movq 0x10(%rsp), %rax
leaq (%rax,%r13), %rbp
movq (%rbp), %r12
leaq 0x108(%rsp), %rbx
movq %rbx, 0xf8(%rsp)
movq (%rsp), %rax
movq 0x40(%rax), %rsi
movq 0x48(%rax), %rdx
addq %rsi, %rdx
leaq 0xf8(%rsp), %r14
movq %r14, %rdi
callq 0x61d2
movq %r12, %rdi
movq %r14, %rsi
callq 0x67b4
movq 0xf8(%rsp), %rdi
cmpq %rbx, %rdi
je 0x8cce
movq 0x108(%rsp), %rsi
incq %rsi
callq 0x5320
movq (%rbp), %r12
leaq 0xe8(%rsp), %rbx
movq %rbx, 0xd8(%rsp)
leaq 0xd8(%rsp), %r14
movq %r14, %rdi
leaq 0x3352(%rip), %rsi      # 0xc046
leaq 0x3353(%rip), %rdx      # 0xc04e
callq 0x66e8
movq %r12, %rdi
movq %r14, %rsi
callq 0x58fc
movq 0xd8(%rsp), %rdi
cmpq %rbx, %rdi
je 0x8d28
movq 0xe8(%rsp), %rsi
incq %rsi
callq 0x5320
movq (%rbp), %r12
leaq 0x50(%rsp), %rax
movq %rax, 0x40(%rsp)
leaq 0x40(%rsp), %r14
movq %r14, %rdi
leaq 0x33ad(%rip), %rsi      # 0xc0f2
leaq 0x33aa(%rip), %rdx      # 0xc0f6
callq 0x66e8
leaq 0x30(%rsp), %rax
movq %rax, 0x20(%rsp)
movq (%rsp), %rax
movq (%rax), %rsi
movq 0x8(%rax), %rdx
addq %rsi, %rdx
movq %r15, %rdi
callq 0x61d2
leaq 0xb8(%rsp), %rbx
movq %r12, %rdi
movq %r14, %rsi
movq %r15, %rdx
callq 0x592a
movq 0x20(%rsp), %rdi
leaq 0x30(%rsp), %rax
cmpq %rax, %rdi
je 0x8da3
movq 0x30(%rsp), %rsi
incq %rsi
callq 0x5320
movq 0x40(%rsp), %rdi
leaq 0x50(%rsp), %rax
cmpq %rax, %rdi
je 0x8dbf
movq 0x50(%rsp), %rsi
incq %rsi
callq 0x5320
movq 0xb0(%rsp), %r14
movq %r14, 0x18(%rsp)
leaq 0x158(%rsp), %rdi
leaq -0x12d1(%rip), %rsi     # 0x7b0a
leaq 0x18(%rsp), %rdx
movq %rbp, %rcx
movq 0xa8(%rsp), %r8
callq 0x9600
movq 0x8(%rsp), %rcx
cmpq $0x0, 0x10(%rcx,%r13)
jne 0x8ebb
movq 0x158(%rsp), %rax
movq %rax, 0x10(%rcx,%r13)
addq $0x8, %r13
addq $0x10, %r14
addq $0x60, (%rsp)
cmpq %r13, 0x88(%rsp)
movq 0x90(%rsp), %rax
jne 0x89ec
movq 0x8(%rsp), %r14
addq $0x10, %r14
movq 0x80(%rsp), %rbx
decq %rbx
movq %r14, %rdi
callq 0x55b8
addq $0x8, %r14
decq %rbx
jne 0x8e45
xorl %eax, %eax
jmp 0x8ea9
movq (%rbx), %rax
movq -0x18(%rax), %rax
leaq (%rbx,%rax), %rdi
movl 0x20(%rbx,%rax), %esi
orl $0x1, %esi
callq 0x5500
movq 0x9178(%rip), %rbx      # 0x11ff0
leaq 0x328f(%rip), %rsi      # 0xc10e
movl $0x10, %edx
movq %rbx, %rdi
callq 0x5390
leaq 0x158(%rsp), %rsi
movb $0xa, (%rsi)
movl $0x1, %edx
movq %rbx, %rdi
callq 0x5390
movl $0x1, %eax
addq $0x1b8, %rsp            # imm = 0x1B8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x50a0
movq %rax, %r14
jmp 0x8fc1
movq %rax, %r14
movq 0xb8(%rsp), %rdi
leaq 0xc8(%rsp), %rax
cmpq %rax, %rdi
je 0x8fc1
movq 0xc8(%rsp), %rsi
jmp 0x8fb9
movq %rax, %r14
jmp 0x8f16
movq %rax, %r14
movq 0x138(%rsp), %rdi
cmpq %r12, %rdi
je 0x8f16
movq 0x148(%rsp), %rsi
incq %rsi
callq 0x5320
movq 0x60(%rsp), %rdi
leaq 0x70(%rsp), %rax
cmpq %rax, %rdi
je 0x8fc1
movq 0x70(%rsp), %rsi
jmp 0x8fb9
movq %rax, %r14
movq 0x118(%rsp), %rdi
cmpq %r12, %rdi
je 0x8fc1
movq 0x128(%rsp), %rsi
jmp 0x8fb9
movq %rax, %r14
movq 0xf8(%rsp), %rdi
cmpq %rbx, %rdi
je 0x8fc1
movq 0x108(%rsp), %rsi
jmp 0x8fb9
movq %rax, %r14
movq 0xd8(%rsp), %rdi
cmpq %rbx, %rdi
je 0x8fc1
movq 0xe8(%rsp), %rsi
jmp 0x8fb9
movq %rax, %r14
jmp 0x8fa5
movq %rax, %r14
movq 0x20(%rsp), %rdi
leaq 0x30(%rsp), %rax
cmpq %rax, %rdi
je 0x8fa5
movq 0x30(%rsp), %rsi
incq %rsi
callq 0x5320
movq 0x40(%rsp), %rdi
leaq 0x50(%rsp), %rax
cmpq %rax, %rdi
je 0x8fc1
movq 0x50(%rsp), %rsi
incq %rsi
callq 0x5320
movq %r14, %rdi
callq 0x5540
nop