// File: /workspace/github_c_makefile_star2_O0/Tarsnap[P]kivaloo/liball/../libcperciva/http/http.c
// Function: callback_readdata
static int
callback_readdata(void * cookie, int status)
{
	struct http_cookie * H = cookie;
	uint8_t * buf;
	size_t buflen;
	size_t waitlen;

	/*
	 * Did we fail to read?  (EOF counts as a failure in this case, since
	 * we know exactly how many bytes of data should be arriving.)
	 */
	if (status)
		return (fail(H));

	/* What data has arrived? */
	netbuf_read_peek(H->R, &buf, &buflen);

	/* Don't bite off more than we can chew. */
	if (buflen > H->readlen)
		buflen = H->readlen;

	/* Add this to our internal buffer. */
	if (addbody(H, buf, buflen))
		return (die(H));

	/* Consume the data. */
	netbuf_read_consume(H->R, buflen);

	/* Adjust our remaining-read-length value. */
	H->readlen -= buflen;

	/* Are we done reading this block? */
	if (H->readlen == 0) {
		/* Was this just one chunk from a chunked encoding? */
		if (H->chunked) {
			/* Strip the trailing EOL. */
			H->res.bodylen -= 2;

			/* Get the next chunk. */
			return (callback_chunkedheader(H, 0));
		}

		/* If not, just do the callback. */
		return (docallback(H));
	}

	/*
	 * Wait for the MIN(remaining read length, 1 MB) to arrive.  This is
	 * a compromise between performance (larger reads have less overhead)
	 * and saving memory (if we're reading a large block, we don't want
	 * to buffer the whole thing twice).
	 */
	if (H->readlen > 1024 * 1024)
		waitlen = 1024 * 1024;
	else
		waitlen = H->readlen;

	/* Wait for more data to arrive. */
	if (netbuf_read_wait(H->R, waitlen, callback_readdata, H))
		return (die(H));

	/* Success! */
	return (0);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x10(%rbp)
movl %esi, -0x14(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x20(%rbp)
cmpl $0x0, -0x14(%rbp)
je 0xdd6e
movq -0x20(%rbp), %rdi
callq 0xcc10
movl %eax, -0x4(%rbp)
jmp 0xdea3
movq -0x20(%rbp), %rax
movq 0x28(%rax), %rdi
leaq -0x28(%rbp), %rsi
leaq -0x30(%rbp), %rdx
callq 0xe0f0
movq -0x30(%rbp), %rax
movq -0x20(%rbp), %rcx
cmpq 0x90(%rcx), %rax
jbe 0xdda3
movq -0x20(%rbp), %rax
movq 0x90(%rax), %rax
movq %rax, -0x30(%rbp)
movq -0x20(%rbp), %rdi
movq -0x28(%rbp), %rsi
movq -0x30(%rbp), %rdx
callq 0xdeb0
cmpl $0x0, %eax
je 0xddca
movq -0x20(%rbp), %rdi
callq 0xcc50
movl %eax, -0x4(%rbp)
jmp 0xdea3
movq -0x20(%rbp), %rax
movq 0x28(%rax), %rdi
movq -0x30(%rbp), %rsi
callq 0xe600
movq -0x30(%rbp), %rdx
movq -0x20(%rbp), %rax
movq 0x90(%rax), %rcx
subq %rdx, %rcx
movq %rcx, 0x90(%rax)
movq -0x20(%rbp), %rax
cmpq $0x0, 0x90(%rax)
jne 0xde43
movq -0x20(%rbp), %rax
cmpl $0x0, 0x88(%rax)
je 0xde35
movq -0x20(%rbp), %rax
movq 0xc0(%rax), %rcx
subq $0x2, %rcx
movq %rcx, 0xc0(%rax)
movq -0x20(%rbp), %rdi
xorl %esi, %esi
callq 0xd710
movl %eax, -0x4(%rbp)
jmp 0xdea3
movq -0x20(%rbp), %rdi
callq 0xd6c0
movl %eax, -0x4(%rbp)
jmp 0xdea3
movq -0x20(%rbp), %rax
cmpq $0x100000, 0x90(%rax) # imm = 0x100000
jbe 0xde5e
movq $0x100000, -0x38(%rbp)  # imm = 0x100000
jmp 0xde6d
movq -0x20(%rbp), %rax
movq 0x90(%rax), %rax
movq %rax, -0x38(%rbp)
movq -0x20(%rbp), %rax
movq 0x28(%rax), %rdi
movq -0x38(%rbp), %rsi
movq -0x20(%rbp), %rcx
leaq -0x144(%rip), %rdx      # 0xdd40
callq 0xe130
cmpl $0x0, %eax
je 0xde9c
movq -0x20(%rbp), %rdi
callq 0xcc50
movl %eax, -0x4(%rbp)
jmp 0xdea3
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x40, %rsp
popq %rbp
retq
nopl (%rax)