// File: /workspace/github_c_makefile_star2_O3/Tarsnap[P]kivaloo/liball/../libcperciva/http/http.c
// Function: http_request2
void *
http_request2(struct sock_addr * const * addrs, struct http_request * request,
    size_t maxrlen, int (* callback)(void *, struct http_response *),
    void * cookie, char * sslhost)
{
	struct http_cookie * H;
	char * s;
	size_t i;

	/* Bake a cookie. */
	if ((H = malloc(sizeof(struct http_cookie))) == NULL)
		goto err0;
	H->sas = addrs;
	H->s = -1;
	H->ssl = NULL;
	H->connect_cookie = NULL;
	H->W = NULL;
	H->R = NULL;
	H->callback = callback;
	H->cookie = cookie;
	H->sslhost = sslhost;
	H->hepos = 0;
	H->res_head = NULL;
	H->res_bodylen_max = maxrlen;
	H->res_bodylen_alloc = 0;
	H->res.status = 0;
	H->res.nheaders = 0;
	H->res.headers = NULL;
	H->res.bodylen = 0;
	H->res.body = NULL;

	/*
	 * Record whether this is a HEAD request; this matters when it comes
	 * to figuring out whether the response should have a body attached.
	 */
	if (strcmp(request->method, "HEAD") == 0)
		H->req_ishead = 1;
	else
		H->req_ishead = 0;

	/* Compute length of header. */
	H->req_headlen = strlen(request->method) + strlen(" ") +
	    strlen(request->path) + strlen(" HTTP/1.1\r\n");
	for (i = 0; i < request->nheaders; i++) {
		/* "header: value\r\n". */
		H->req_headlen += strlen(request->headers[i].header) +
		    strlen(request->headers[i].value) + 4;
	}
	H->req_headlen += 2;			/* Blank line. */

	/* Allocate space for header plus NUL byte (so we can use stpcpy). */
	if ((s = (char *)(H->req_head = malloc(H->req_headlen + 1))) == NULL)
		goto err1;

	/* Construct request line. */
	s = stpcpy(s, request->method);
	s = stpcpy(s, " ");
	s = stpcpy(s, request->path);
	s = stpcpy(s, " HTTP/1.1\r\n");

	/* Append header lines. */
	for (i = 0; i < request->nheaders; i++) {
		s = stpcpy(s, request->headers[i].header);
		s = stpcpy(s, ": ");
		s = stpcpy(s, request->headers[i].value);
		s = stpcpy(s, "\r\n");
	}

	/* Append final blank line. */
	s = stpcpy(s, "\r\n");

	/* Sanity-check: We should have the right size of request header. */
	assert((uint8_t *)s == &H->req_head[H->req_headlen]);

	/* Record the request body parameters. */
	H->req_bodylen = request->bodylen;
	H->req_body = request->body;

	/* Connect to the target host. */
	if ((H->connect_cookie = network_connect(H->sas,
	    callback_connected, H)) == NULL)
		goto err2;

	/* Success! */
	return (H);

err2:
	free(H->req_head);
err1:
	free(H);
err0:
	/* Failure! */
	return (NULL);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %r9, %r13
movq %r8, %rbp
movq %rcx, %r14
movq %rdx, (%rsp)
movq %rsi, %r15
movq %rdi, %r12
movl $0xd0, %edi
callq 0x34c0
testq %rax, %rax
je 0x8cd7
movq %rax, %rbx
movq %r12, 0x10(%rsp)
movq %r12, (%rax)
movl $0xffffffff, 0x8(%rax)  # imm = 0xFFFFFFFF
xorps %xmm0, %xmm0
movups %xmm0, 0x10(%rax)
movups %xmm0, 0x20(%rax)
movq %r14, 0x60(%rax)
movq %rbp, 0x68(%rax)
movq %r13, 0x58(%rax)
xorl %eax, %eax
movq %rax, 0x70(%rbx)
movq %rax, 0x80(%rbx)
movq (%rsp), %rcx
movq %rcx, 0x98(%rbx)
movq %rax, 0xa0(%rbx)
movl $0x0, 0xa8(%rbx)
movups %xmm0, 0xb0(%rbx)
movups %xmm0, 0xc0(%rbx)
movq (%r15), %r14
leaq 0x90fd(%rip), %rsi      # 0x11c63
movq %r14, %rdi
callq 0x3500
xorl %ecx, %ecx
testl %eax, %eax
sete %cl
movl %ecx, 0x30(%rbx)
movq %r14, (%rsp)
movq %r14, %rdi
callq 0x3190
movq %rax, %r14
movq 0x8(%r15), %rdi
callq 0x3190
leaq (%r14,%rax), %r13
addq $0xc, %r13
movq 0x10(%r15), %rbp
testq %rbp, %rbp
je 0x8bd2
movq 0x18(%r15), %r12
addq $0x8, %r12
movq -0x8(%r12), %rdi
callq 0x3190
movq %rax, %r14
movq (%r12), %rdi
callq 0x3190
addq %r14, %rax
addq %rax, %r13
addq $0x4, %r13
addq $0x10, %r12
decq %rbp
jne 0x8ba9
leaq 0x2(%r13), %r14
movq %r14, 0x38(%rbx)
addq $0x3, %r13
movq %r13, %rdi
callq 0x34c0
movq %rax, 0x40(%rbx)
testq %rax, %rax
je 0x8ccf
movq %rax, %r13
movq %r14, 0x8(%rsp)
movq %rax, %rdi
movq (%rsp), %rsi
callq 0x33a0
movw $0x20, (%rax)
leaq 0x1(%rax), %rdi
movq 0x8(%r15), %rsi
callq 0x33a0
leaq 0xb(%rax), %rdi
movabsq $0x2e312f5054544820, %rcx # imm = 0x2E312F5054544820
movq %rcx, (%rax)
movl $0xa0d31, 0x8(%rax)     # imm = 0xA0D31
cmpq $0x0, 0x10(%r15)
je 0x8c82
xorl %r12d, %r12d
xorl %ebp, %ebp
xorl %r14d, %r14d
movq 0x18(%r15), %rax
movq (%rax,%rbp), %rsi
callq 0x33a0
leaq 0x2(%rax), %rdi
movb %r12b, 0x2(%rax)
movw $0x203a, (%rax)         # imm = 0x203A
movq 0x18(%r15), %rax
movq 0x8(%rax,%rbp), %rsi
callq 0x33a0
leaq 0x2(%rax), %rdi
movb %r12b, 0x2(%rax)
movw $0xa0d, (%rax)          # imm = 0xA0D
incq %r14
addq $0x10, %rbp
cmpq 0x10(%r15), %r14
jb 0x8c40
leaq 0x2(%rdi), %rax
movb $0x0, 0x2(%rdi)
movw $0xa0d, (%rdi)          # imm = 0xA0D
addq 0x8(%rsp), %r13
cmpq %r13, %rax
jne 0x8ceb
movq 0x20(%r15), %rax
movq %rax, 0x48(%rbx)
movq 0x28(%r15), %rax
movq %rax, 0x50(%rbx)
leaq 0x5a(%rip), %rsi        # 0x8d0a
movq 0x10(%rsp), %rdi
movq %rbx, %rdx
callq 0xa2c8
movq %rax, 0x18(%rbx)
testq %rax, %rax
jne 0x8cd9
movq 0x40(%rbx), %rdi
callq 0x3450
movq %rbx, %rdi
callq 0x3450
xorl %ebx, %ebx
movq %rbx, %rax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x8f82(%rip), %rdi      # 0x11c74
leaq 0x8fa8(%rip), %rsi      # 0x11ca1
leaq 0x8fbc(%rip), %rcx      # 0x11cbc
movl $0x148, %edx            # imm = 0x148
callq 0x3200