// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x60, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq %rcx, -0x28(%rbp)
movq %r8, -0x30(%rbp)
movq %r9, -0x38(%rbp)
movl $0xd0, %edi
callq 0x34c0
movq %rax, -0x40(%rbp)
cmpq $0x0, %rax
jne 0xc489
jmp 0xc828
movq -0x10(%rbp), %rcx
movq -0x40(%rbp), %rax
movq %rcx, (%rax)
movq -0x40(%rbp), %rax
movl $0xffffffff, 0x8(%rax)  # imm = 0xFFFFFFFF
movq -0x40(%rbp), %rax
movq $0x0, 0x10(%rax)
movq -0x40(%rbp), %rax
movq $0x0, 0x18(%rax)
movq -0x40(%rbp), %rax
movq $0x0, 0x20(%rax)
movq -0x40(%rbp), %rax
movq $0x0, 0x28(%rax)
movq -0x28(%rbp), %rcx
movq -0x40(%rbp), %rax
movq %rcx, 0x60(%rax)
movq -0x30(%rbp), %rcx
movq -0x40(%rbp), %rax
movq %rcx, 0x68(%rax)
movq -0x38(%rbp), %rcx
movq -0x40(%rbp), %rax
movq %rcx, 0x58(%rax)
movq -0x40(%rbp), %rax
movq $0x0, 0x70(%rax)
movq -0x40(%rbp), %rax
movq $0x0, 0x80(%rax)
movq -0x20(%rbp), %rcx
movq -0x40(%rbp), %rax
movq %rcx, 0x98(%rax)
movq -0x40(%rbp), %rax
movq $0x0, 0xa0(%rax)
movq -0x40(%rbp), %rax
movl $0x0, 0xa8(%rax)
movq -0x40(%rbp), %rax
movq $0x0, 0xb0(%rax)
movq -0x40(%rbp), %rax
movq $0x0, 0xb8(%rax)
movq -0x40(%rbp), %rax
movq $0x0, 0xc0(%rax)
movq -0x40(%rbp), %rax
movq $0x0, 0xc8(%rax)
movq -0x18(%rbp), %rax
movq (%rax), %rdi
leaq 0x1294b(%rip), %rsi     # 0x1eecf
callq 0x3500
cmpl $0x0, %eax
jne 0xc59b
movq -0x40(%rbp), %rax
movl $0x1, 0x30(%rax)
jmp 0xc5a6
movq -0x40(%rbp), %rax
movl $0x0, 0x30(%rax)
movq -0x18(%rbp), %rax
movq (%rax), %rdi
callq 0x31a0
addq $0x1, %rax
movq %rax, -0x58(%rbp)
movq -0x18(%rbp), %rax
movq 0x8(%rax), %rdi
callq 0x31a0
movq -0x58(%rbp), %rcx
addq %rax, %rcx
addq $0xb, %rcx
movq -0x40(%rbp), %rax
movq %rcx, 0x38(%rax)
movq $0x0, -0x50(%rbp)
movq -0x50(%rbp), %rax
movq -0x18(%rbp), %rcx
cmpq 0x10(%rcx), %rax
jae 0xc650
movq -0x18(%rbp), %rax
movq 0x18(%rax), %rax
movq -0x50(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movq (%rax), %rdi
callq 0x31a0
movq %rax, -0x60(%rbp)
movq -0x18(%rbp), %rax
movq 0x18(%rax), %rax
movq -0x50(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movq 0x8(%rax), %rdi
callq 0x31a0
movq -0x60(%rbp), %rcx
addq %rax, %rcx
addq $0x4, %rcx
movq -0x40(%rbp), %rax
addq 0x38(%rax), %rcx
movq %rcx, 0x38(%rax)
movq -0x50(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x50(%rbp)
jmp 0xc5e2
movq -0x40(%rbp), %rax
movq 0x38(%rax), %rcx
addq $0x2, %rcx
movq %rcx, 0x38(%rax)
movq -0x40(%rbp), %rax
movq 0x38(%rax), %rdi
addq $0x1, %rdi
callq 0x34c0
movq -0x40(%rbp), %rcx
movq %rax, 0x40(%rcx)
movq %rax, -0x48(%rbp)
cmpq $0x0, %rax
jne 0xc688
jmp 0xc81f
movq -0x48(%rbp), %rdi
movq -0x18(%rbp), %rax
movq (%rax), %rsi
callq 0x33d0
movq %rax, -0x48(%rbp)
movq -0x48(%rbp), %rdi
leaq 0x11ec4(%rip), %rsi     # 0x1e56b
callq 0x33d0
movq %rax, -0x48(%rbp)
movq -0x48(%rbp), %rdi
movq -0x18(%rbp), %rax
movq 0x8(%rax), %rsi
callq 0x33d0
movq %rax, -0x48(%rbp)
movq -0x48(%rbp), %rdi
leaq 0x12804(%rip), %rsi     # 0x1eed4
callq 0x33d0
movq %rax, -0x48(%rbp)
movq $0x0, -0x50(%rbp)
movq -0x50(%rbp), %rax
movq -0x18(%rbp), %rcx
cmpq 0x10(%rcx), %rax
jae 0xc773
movq -0x48(%rbp), %rdi
movq -0x18(%rbp), %rax
movq 0x18(%rax), %rax
movq -0x50(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movq (%rax), %rsi
callq 0x33d0
movq %rax, -0x48(%rbp)
movq -0x48(%rbp), %rdi
leaq 0x11e49(%rip), %rsi     # 0x1e56a
callq 0x33d0
movq %rax, -0x48(%rbp)
movq -0x48(%rbp), %rdi
movq -0x18(%rbp), %rax
movq 0x18(%rax), %rax
movq -0x50(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movq 0x8(%rax), %rsi
callq 0x33d0
movq %rax, -0x48(%rbp)
movq -0x48(%rbp), %rdi
leaq 0x128c5(%rip), %rsi     # 0x1f01e
callq 0x33d0
movq %rax, -0x48(%rbp)
movq -0x50(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x50(%rbp)
jmp 0xc6e1
movq -0x48(%rbp), %rdi
leaq 0x128a0(%rip), %rsi     # 0x1f01e
callq 0x33d0
movq %rax, -0x48(%rbp)
movq -0x48(%rbp), %rax
movq -0x40(%rbp), %rcx
movq 0x40(%rcx), %rcx
movq -0x40(%rbp), %rdx
addq 0x38(%rdx), %rcx
cmpq %rcx, %rax
jne 0xc7a2
jmp 0xc7c1
leaq 0x12737(%rip), %rdi     # 0x1eee0
leaq 0x1275d(%rip), %rsi     # 0x1ef0d
movl $0x148, %edx            # imm = 0x148
leaq 0x1276c(%rip), %rcx     # 0x1ef28
callq 0x3240
movq -0x18(%rbp), %rax
movq 0x20(%rax), %rcx
movq -0x40(%rbp), %rax
movq %rcx, 0x48(%rax)
movq -0x18(%rbp), %rax
movq 0x28(%rax), %rcx
movq -0x40(%rbp), %rax
movq %rcx, 0x50(%rax)
movq -0x40(%rbp), %rax
movq (%rax), %rdi
movq -0x40(%rbp), %rdx
leaq 0x4d(%rip), %rsi        # 0xc840
callq 0xef60
movq -0x40(%rbp), %rcx
movq %rax, 0x18(%rcx)
cmpq $0x0, %rax
jne 0xc808
jmp 0xc812
movq -0x40(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0xc830
movq -0x40(%rbp), %rax
movq 0x40(%rax), %rdi
callq 0x3460
movq -0x40(%rbp), %rdi
callq 0x3460
movq $0x0, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x60, %rsp
popq %rbp
retq
nopw (%rax,%rax)