// File: /workspace/github_c_makefile_star2_O2/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 $0x28, %rsp
movq %r9, %r13
movq %r8, %rbp
movq %rcx, %r14
movq %rdx, 0x8(%rsp)
movq %rsi, %r12
movq %rdi, %r15
movl $0xd0, %edi
callq 0x34d0
testq %rax, %rax
je 0x871c
movq %rax, %rbx
movq %r15, (%rax)
orl $-0x1, 0x8(%rax)
xorps %xmm0, %xmm0
movups %xmm0, 0x10(%rax)
movups %xmm0, 0x20(%rax)
movq %r14, 0x60(%rax)
movq %rbp, 0x68(%rax)
movq %r13, 0x58(%rax)
andq $0x0, 0x70(%rax)
andq $0x0, 0x80(%rax)
movq 0x8(%rsp), %rax
movq %rax, 0x98(%rbx)
andq $0x0, 0xa0(%rbx)
andl $0x0, 0xa8(%rbx)
movups %xmm0, 0xb0(%rbx)
movups %xmm0, 0xc0(%rbx)
movq (%r12), %r14
leaq 0x86b0(%rip), %rsi      # 0x10c33
movq %r14, %rdi
callq 0x3510
xorl %ecx, %ecx
testl %eax, %eax
sete %cl
movl %ecx, 0x30(%rbx)
movq %r14, 0x20(%rsp)
movq %r14, %rdi
callq 0x3190
movq %rax, %r14
movq 0x8(%r12), %rdi
callq 0x3190
leaq (%r14,%rax), %rdi
addq $0xc, %rdi
movq %r12, 0x10(%rsp)
movq 0x10(%r12), %rbp
pushq $0x8
popq %r12
subq $0x1, %rbp
jb 0x8614
movq %r15, %r13
movq %rbx, %r15
movq 0x10(%rsp), %rax
movq 0x18(%rax), %rbx
movq %rdi, 0x8(%rsp)
movq -0x8(%rbx,%r12), %rdi
callq 0x3190
movq %rax, %r14
movq (%rbx,%r12), %rdi
movq %r15, %rbx
movq %r13, %r15
callq 0x3190
movq 0x8(%rsp), %rdi
addq %r14, %rax
addq %rax, %rdi
addq $0x4, %rdi
movq %rdi, 0x38(%rbx)
addq $0x10, %r12
jmp 0x85c5
leaq 0x2(%rdi), %r14
movq %r14, 0x38(%rbx)
addq $0x3, %rdi
callq 0x34d0
movq %rax, 0x40(%rbx)
testq %rax, %rax
je 0x8714
movq %r14, 0x8(%rsp)
movq %rax, 0x18(%rsp)
movq %rax, %rdi
movq 0x20(%rsp), %rsi
callq 0x33b0
movw $0x20, (%rax)
leaq 0x1(%rax), %rdi
movq 0x10(%rsp), %r13
movq 0x8(%r13), %rsi
callq 0x33b0
leaq 0xb(%rax), %rdi
movabsq $0x2e312f5054544820, %rcx # imm = 0x2E312F5054544820
movq %rcx, (%rax)
movl $0xa0d31, 0x8(%rax)     # imm = 0xA0D31
xorl %r12d, %r12d
xorl %ebp, %ebp
xorl %r14d, %r14d
cmpq 0x10(%r13), %r14
jae 0x86c4
movq 0x18(%r13), %rax
movq (%rax,%rbp), %rsi
callq 0x33b0
leaq 0x2(%rax), %rdi
movb %r12b, 0x2(%rax)
movw $0x203a, (%rax)         # imm = 0x203A
movq 0x18(%r13), %rax
movq 0x8(%rax,%rbp), %rsi
callq 0x33b0
leaq 0x2(%rax), %rdi
movb %r12b, 0x2(%rax)
movw $0xa0d, (%rax)          # imm = 0xA0D
incq %r14
addq $0x10, %rbp
jmp 0x8680
leaq 0x2(%rdi), %rax
movb $0x0, 0x2(%rdi)
movw $0xa0d, (%rdi)          # imm = 0xA0D
movq 0x18(%rsp), %rcx
addq 0x8(%rsp), %rcx
cmpq %rcx, %rax
jne 0x8730
movq 0x20(%r13), %rax
movq %rax, 0x48(%rbx)
movq 0x28(%r13), %rax
movq %rax, 0x50(%rbx)
leaq 0x58(%rip), %rsi        # 0x874f
movq %r15, %rdi
movq %rbx, %rdx
callq 0x9b94
movq %rax, 0x18(%rbx)
testq %rax, %rax
jne 0x871e
movq 0x40(%rbx), %rdi
callq 0x3460
movq %rbx, %rdi
callq 0x3460
xorl %ebx, %ebx
movq %rbx, %rax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x850d(%rip), %rdi      # 0x10c44
leaq 0x8533(%rip), %rsi      # 0x10c71
leaq 0x8547(%rip), %rcx      # 0x10c8c
movl $0x148, %edx            # imm = 0x148
callq 0x3210