// File: /workspace/github_cpp_makefile_star2_O1/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, %rbp
cmpl $0x1, %edi
jg 0x892b
movq 0x9705(%rip), %rbx      # 0x11ff0
leaq 0x3814(%rip), %rsi      # 0xc106
movl $0x7, %edx
movq %rbx, %rdi
callq 0x5390
movq (%rbp), %r14
testq %r14, %r14
je 0x8ea1
movq %r14, %rdi
callq 0x5120
movq 0x96d5(%rip), %rdi      # 0x11ff0
movq %r14, %rsi
movq %rax, %rdx
callq 0x5390
jmp 0x8eb8
movl %edi, 0xc(%rsp)
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 0x8957
leaq (,%r12,8), %rbx
leaq 0x8(,%r12,8), %rdi
callq 0x5030
movq %r12, (%rax)
movq %rax, 0x10(%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, 0x18(%rsp)
addq $0x10, %rax
addq $0x68, (%rsp)
leaq -0x8(,%r12,8), %rcx
movq %rcx, 0x68(%rsp)
leaq 0x8c97(%rip), %rcx      # 0x11688
addq $0x10, %rcx
movq %rcx, 0x78(%rsp)
leaq 0x98(%rsp), %r12
leaq 0x20(%rsp), %r13
leaq 0xb8(%rsp), %r15
movq %rax, 0x80(%rsp)
movq %rax, %r14
xorl %ebx, %ebx
movq %rbp, 0x70(%rsp)
movq %r14, 0x90(%rsp)
movq 0x8(%rbp,%rbx), %rsi
movq %r12, %rdi
movq %r13, %rdx
callq 0x9012
leaq 0x158(%rsp), %r13
movq %r13, %rdi
movq %r12, %rsi
callq 0x7638
leaq 0x148(%rsp), %r12
movq (%rsp), %r14
movq %r14, %rdi
movq %r13, %rsi
callq 0x53c0
leaq 0x20(%r14), %rdi
leaq 0x178(%rsp), %rsi
callq 0x53c0
leaq 0x40(%r14), %rdi
movq %rdi, 0x88(%rsp)
leaq 0x198(%rsp), %rsi
callq 0x53c0
movq 0x198(%rsp), %rdi
leaq 0x1a8(%rsp), %rax
cmpq %rax, %rdi
je 0x8ab2
movq 0x1a8(%rsp), %rsi
incq %rsi
callq 0x5320
movq 0x178(%rsp), %rdi
leaq 0x188(%rsp), %rax
cmpq %rax, %rdi
leaq 0x48(%rsp), %r13
je 0x8adc
movq 0x188(%rsp), %rsi
incq %rsi
callq 0x5320
movq 0x158(%rsp), %rdi
leaq 0x168(%rsp), %rax
cmpq %rax, %rdi
je 0x8b01
movq 0x168(%rsp), %rsi
incq %rsi
callq 0x5320
movq 0x98(%rsp), %rdi
leaq 0xa8(%rsp), %rax
cmpq %rax, %rdi
je 0x8b26
movq 0xa8(%rsp), %rsi
incq %rsi
callq 0x5320
leaq 0x58(%rsp), %rax
movq %rax, 0x48(%rsp)
movq (%rsp), %r14
movq (%r14), %rsi
movq 0x8(%r14), %rdx
addq %rsi, %rdx
movq %r13, %rdi
callq 0x6200
movq %r12, 0x138(%rsp)
movq 0x20(%r14), %rsi
movq 0x28(%r14), %rdx
addq %rsi, %rdx
movq %r13, %r14
leaq 0x138(%rsp), %r13
movq %r13, %rdi
callq 0x6200
movq %r14, %rdi
movq %r13, %rsi
callq 0x79a4
movq 0x80(%rsp), %rcx
movq %rax, (%rcx,%rbx,2)
movq $0x0, 0x8(%rcx,%rbx,2)
movq 0x138(%rsp), %rdi
cmpq %r12, %rdi
je 0x8ba9
movq 0x148(%rsp), %rsi
incq %rsi
callq 0x5320
movq 0x48(%rsp), %rdi
leaq 0x58(%rsp), %rax
cmpq %rax, %rdi
leaq 0x128(%rsp), %r12
je 0x8bcd
movq 0x58(%rsp), %rsi
incq %rsi
callq 0x5320
movl $0xa0, %edi
callq 0x5300
movq %rax, %rbp
movl $0xa0, %edx
movq %rax, %rdi
xorl %esi, %esi
callq 0x5190
leaq 0x18(%rbp), %rax
movq %rax, 0x8(%rbp)
xorl %ecx, %ecx
movq %rcx, 0x10(%rbp)
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 0x78(%rsp), %rax
movq %rax, (%rbp)
leaq 0x70(%rbp), %rax
movq %rax, 0x60(%rbp)
movq %rcx, 0x68(%rbp)
movb %cl, 0x70(%rbp)
leaq 0x90(%rbp), %rax
movq %rax, 0x80(%rbp)
movq %rcx, 0x88(%rbp)
movb %cl, 0x90(%rbp)
movq 0x18(%rsp), %rax
movq %rbp, (%rax,%rbx)
movq %r12, 0x118(%rsp)
leaq 0x118(%rsp), %r13
movq %r13, %rdi
leaq 0x33c7(%rip), %rsi      # 0xc039
leaq 0x33c3(%rip), %rdx      # 0xc03c
callq 0x671a
movq %rbp, %rdi
movq %r13, %rsi
callq 0x67ac
movq 0x118(%rsp), %rdi
cmpq %r12, %rdi
je 0x8ca6
movq 0x128(%rsp), %rsi
incq %rsi
callq 0x5320
movq 0x18(%rsp), %rax
leaq (%rax,%rbx), %rbp
movq (%rbp), %r12
leaq 0x108(%rsp), %r13
movq %r13, 0xf8(%rsp)
movq (%rsp), %rax
movq 0x40(%rax), %rsi
movq 0x48(%rax), %rdx
addq %rsi, %rdx
leaq 0xf8(%rsp), %r14
movq %r14, %rdi
callq 0x6200
movq %r12, %rdi
movq %r14, %rsi
callq 0x67e0
movq 0xf8(%rsp), %rdi
cmpq %r13, %rdi
je 0x8d0a
movq 0x108(%rsp), %rsi
incq %rsi
callq 0x5320
movq (%rbp), %r12
leaq 0xe8(%rsp), %r13
movq %r13, 0xd8(%rsp)
leaq 0xd8(%rsp), %r14
movq %r14, %rdi
leaq 0x3316(%rip), %rsi      # 0xc046
leaq 0x3317(%rip), %rdx      # 0xc04e
callq 0x671a
movq %r12, %rdi
movq %r14, %rsi
callq 0x590c
movq 0xd8(%rsp), %rdi
cmpq %r13, %rdi
je 0x8d64
movq 0xe8(%rsp), %rsi
incq %rsi
callq 0x5320
movq (%rbp), %r12
leaq 0x38(%rsp), %rax
movq %rax, 0x28(%rsp)
leaq 0x28(%rsp), %r14
movq %r14, %rdi
leaq 0x3371(%rip), %rsi      # 0xc0f2
leaq 0x336e(%rip), %rdx      # 0xc0f6
callq 0x671a
leaq 0xc8(%rsp), %r13
movq %r13, 0xb8(%rsp)
movq (%rsp), %rax
movq (%rax), %rsi
movq 0x8(%rax), %rdx
addq %rsi, %rdx
movq %r15, %rdi
callq 0x6200
movq %r12, %rdi
movq %r14, %rsi
movq %r15, %rdx
callq 0x593a
movq 0xb8(%rsp), %rdi
cmpq %r13, %rdi
je 0x8dde
movq 0xc8(%rsp), %rsi
incq %rsi
callq 0x5320
movq 0x28(%rsp), %rdi
leaq 0x38(%rsp), %rax
cmpq %rax, %rdi
leaq 0x98(%rsp), %r12
leaq 0x20(%rsp), %r13
je 0x8e07
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x5320
movq 0x90(%rsp), %r14
movq %r14, 0x20(%rsp)
leaq 0x158(%rsp), %rdi
leaq -0x12ed(%rip), %rsi     # 0x7b36
movq %r13, %rdx
movq %rbp, %rcx
movq 0x88(%rsp), %r8
callq 0x968e
movq 0x10(%rsp), %rcx
cmpq $0x0, 0x10(%rcx,%rbx)
jne 0x8f02
movq 0x158(%rsp), %rax
movq %rax, 0x10(%rcx,%rbx)
addq $0x8, %rbx
addq $0x10, %r14
addq $0x60, (%rsp)
cmpq %rbx, 0x68(%rsp)
movq 0x70(%rsp), %rbp
jne 0x8a21
movl 0xc(%rsp), %eax
cmpl $0x3, %eax
movl $0x2, %ebx
cmovgel %eax, %ebx
movq 0x10(%rsp), %r14
addq $0x10, %r14
decq %rbx
movq %r14, %rdi
callq 0x55b8
addq $0x8, %r14
decq %rbx
jne 0x8e8c
xorl %eax, %eax
jmp 0x8ef0
movq (%rbx), %rax
movq -0x18(%rax), %rax
leaq (%rbx,%rax), %rdi
movl 0x20(%rbx,%rax), %esi
orl $0x1, %esi
callq 0x5500
movq 0x9131(%rip), %rbx      # 0x11ff0
leaq 0x3248(%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, %rbx
jmp 0x9009
movq %rax, %rbx
movq 0x98(%rsp), %rdi
leaq 0xa8(%rsp), %rax
cmpq %rax, %rdi
je 0x9009
movq 0xa8(%rsp), %rsi
jmp 0x9001
movq %rax, %rbx
jmp 0x8f5d
movq %rax, %rbx
movq 0x138(%rsp), %rdi
cmpq %r12, %rdi
je 0x8f5d
movq 0x148(%rsp), %rsi
incq %rsi
callq 0x5320
movq 0x48(%rsp), %rdi
leaq 0x58(%rsp), %rax
cmpq %rax, %rdi
je 0x9009
movq 0x58(%rsp), %rsi
jmp 0x9001
movq %rax, %rbx
movq 0x118(%rsp), %rdi
cmpq %r12, %rdi
je 0x9009
movq 0x128(%rsp), %rsi
jmp 0x9001
movq %rax, %rbx
movq 0xf8(%rsp), %rdi
cmpq %r13, %rdi
je 0x9009
movq 0x108(%rsp), %rsi
jmp 0x9001
movq %rax, %rbx
movq 0xd8(%rsp), %rdi
cmpq %r13, %rdi
je 0x9009
movq 0xe8(%rsp), %rsi
jmp 0x9001
movq %rax, %rbx
jmp 0x8fed
movq %rax, %rbx
movq 0xb8(%rsp), %rdi
cmpq %r13, %rdi
je 0x8fed
movq 0xc8(%rsp), %rsi
incq %rsi
callq 0x5320
movq 0x28(%rsp), %rdi
leaq 0x38(%rsp), %rax
cmpq %rax, %rdi
je 0x9009
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x5320
movq %rbx, %rdi
callq 0x5540
nop