// File: /workspace/github_c_makefile_star2_O1/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
pushq %rax
movq %r9, %r12
movq %r8, %r13
movq %rcx, %rbp
movq %rdx, (%rsp)
movq %rsi, %r14
movq %rdi, %r15
movl $0xd0, %edi
callq 0x34c0
testq %rax, %rax
je 0x8e3c
movq %rax, %rbx
movq %r15, (%rax)
movl $0xffffffff, 0x8(%rax)  # imm = 0xFFFFFFFF
xorps %xmm0, %xmm0
movups %xmm0, 0x10(%rax)
movups %xmm0, 0x20(%rax)
movq %rbp, 0x60(%rax)
movq %r13, 0x68(%rax)
movq %r12, 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 (%r14), %r15
leaq 0x9125(%rip), %rsi      # 0x11deb
movq %r15, %rdi
callq 0x3500
xorl %ecx, %ecx
testl %eax, %eax
sete %cl
movl %ecx, 0x30(%rbx)
movq %r15, (%rsp)
movq %r15, %rdi
callq 0x3190
movq %rax, %r12
movq 0x8(%r14), %rdi
callq 0x3190
addq %r12, %rax
addq $0xc, %rax
movq %rax, 0x38(%rbx)
movq 0x10(%r14), %r13
testq %r13, %r13
je 0x8d3c
movq 0x18(%r14), %rbp
movq 0x38(%rbx), %r15
addq $0x8, %rbp
movq -0x8(%rbp), %rdi
callq 0x3190
movq %rax, %r12
movq (%rbp), %rdi
callq 0x3190
addq %r12, %rax
addq %rax, %r15
addq $0x4, %r15
movq %r15, 0x38(%rbx)
addq $0x10, %rbp
decq %r13
jne 0x8d10
movq 0x38(%rbx), %rdi
leaq 0x2(%rdi), %rax
movq %rax, 0x38(%rbx)
addq $0x3, %rdi
callq 0x34c0
movq %rax, 0x40(%rbx)
testq %rax, %rax
je 0x8e34
movq %rax, %rdi
movq (%rsp), %rsi
callq 0x33a0
movw $0x20, (%rax)
leaq 0x1(%rax), %rdi
movq 0x8(%r14), %rsi
callq 0x33a0
leaq 0xb(%rax), %rdi
movabsq $0x2e312f5054544820, %rcx # imm = 0x2E312F5054544820
movq %rcx, (%rax)
movl $0xa0d31, 0x8(%rax)     # imm = 0xA0D31
cmpq $0x0, 0x10(%r14)
je 0x8de6
xorl %r15d, %r15d
xorl %r12d, %r12d
xorl %r13d, %r13d
movq 0x18(%r14), %rax
movq (%rax,%r12), %rsi
callq 0x33a0
leaq 0x2(%rax), %rdi
movb %r15b, 0x2(%rax)
movw $0x203a, (%rax)         # imm = 0x203A
movq 0x18(%r14), %rax
movq 0x8(%rax,%r12), %rsi
callq 0x33a0
leaq 0x2(%rax), %rdi
movb %r15b, 0x2(%rax)
movw $0xa0d, (%rax)          # imm = 0xA0D
incq %r13
addq $0x10, %r12
cmpq 0x10(%r14), %r13
jb 0x8da4
leaq 0x2(%rdi), %rax
movb $0x0, 0x2(%rdi)
movw $0xa0d, (%rdi)          # imm = 0xA0D
movq 0x40(%rbx), %rcx
addq 0x38(%rbx), %rcx
cmpq %rcx, %rax
jne 0x8e50
movq 0x20(%r14), %rax
movq %rax, 0x48(%rbx)
movq 0x28(%r14), %rax
movq %rax, 0x50(%rbx)
movq (%rbx), %rdi
leaq 0x55(%rip), %rsi        # 0x8e6f
movq %rbx, %rdx
callq 0xa458
movq %rax, 0x18(%rbx)
testq %rax, %rax
jne 0x8e3e
movq 0x40(%rbx), %rdi
callq 0x3450
movq %rbx, %rdi
callq 0x3450
xorl %ebx, %ebx
movq %rbx, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x8fa5(%rip), %rdi      # 0x11dfc
leaq 0x8fcb(%rip), %rsi      # 0x11e29
leaq 0x8fdf(%rip), %rcx      # 0x11e44
movl $0x148, %edx            # imm = 0x148
callq 0x3200