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

	/* Did we fail?  (EOF while reading a chunk header is a failure.) */
	if (status)
		return (fail(H));

	/* Peek at the incoming data. */
	netbuf_read_peek(H->R, &buf, &buflen);

	/* Look for an EOL. */
	eolpos = findeol(buf, buflen);

	/* If we found one, handle the line. */
	if (eolpos != buflen) {
		/*
		 * Parse the chunk length; it's always in base 16, and allow
		 * trailing characters to accommodate the EOL.  ${buf} is not
		 * NUL-terminated but it does contain an EOL, so the cast is
		 * safe.
		 */
		if (PARSENUM_EX(&clen, (const char *)buf, 0, SIZE_MAX, 16, 1)) {
			/* Print ${buf} carefully (it's not NUL-terminated). */
			if (eolpos <= INT_MAX)
				warnp("parsenum failed on %.*s", (int)eolpos,
				    buf);
			else
				warnp("parsenum failed on %.*s", INT_MAX, buf);
			return (fail(H));
		}

		/* Consume the line and EOL. */
		netbuf_read_consume(H->R, eolpos + 2);

		/* If this is zero, we're done! */
		if (clen == 0)
			return (docallback(H));

		/* Otherwise, check that it's not too big. */
		if (clen > H->res_bodylen_max - H->res.bodylen)
			return (toobig(H));
		if (clen > SIZE_MAX - 2)
			return (toobig(H));

		/* Read the chunk data plus extra EOL (we strip it later). */
		H->readlen = clen + 2;
		return (callback_readdata(H, 0));
	}

	/* If we've read MAXCHLEN bytes, we should have gotten an EOL. */
	if (buflen >= MAXCHLEN)
		return (fail(H));

	/* Wait until some more data arrives. */
	if (netbuf_read_wait(H->R, buflen + 1, callback_chunkedheader, H))
		return (die(H));

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

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rdi, %rbx
testl %esi, %esi
je 0x8f44
movq %rbx, %rdi
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
jmp 0x8961
movq 0x28(%rbx), %rdi
leaq 0x8(%rsp), %r14
leaq 0x10(%rsp), %r15
movq %r14, %rsi
movq %r15, %rdx
callq 0x93cb
movq (%r14), %r12
movq (%r15), %r14
movq %r12, %rdi
movq %r14, %rsi
callq 0x8e5e
cmpq %r14, %rax
jne 0x8fb1
cmpq $0x100, %r14            # imm = 0x100
jae 0x9044
movq 0x28(%rbx), %rdi
incq %r14
leaq -0x6f(%rip), %rdx       # 0x8f1f
movq %r14, %rsi
movq %rbx, %rcx
callq 0x93e4
testl %eax, %eax
je 0x9058
movq %rbx, %rdi
callq 0x881d
pushq $-0x1
popq %rax
jmp 0x904c
movq %rax, %r15
callq 0x3040
movq %rax, %r14
andl $0x0, (%rax)
pushq $0x10
popq %rsi
pushq $0x1
popq %rdx
movq %r12, %rdi
callq 0x907d
cmpl $0x0, (%r14)
je 0x8fed
cmpq $0x7fffffff, %r15       # imm = 0x7FFFFFFF
ja 0x9028
movq 0x8(%rsp), %rdx
leaq 0x7f76(%rip), %rdi      # 0x10f5e
movl %r15d, %esi
jmp 0x9039
movq %rax, %r12
movq 0x28(%rbx), %rdi
addq $0x2, %r15
movq %r15, %rsi
callq 0x9643
testq %r12, %r12
je 0x905c
movq 0x98(%rbx), %rax
subq 0xc0(%rbx), %rax
cmpq %rax, %r12
ja 0x901e
cmpq $-0x2, %r12
jb 0x9066
movq %rbx, %rdi
callq 0x919f
jmp 0x904c
movq 0x8(%rsp), %rdx
leaq 0x7f2a(%rip), %rdi      # 0x10f5e
movl $0x7fffffff, %esi       # imm = 0x7FFFFFFF
xorl %eax, %eax
callq 0x53ad
andl $0x0, (%r14)
movq %rbx, %rdi
callq 0x8961
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
xorl %eax, %eax
jmp 0x904c
movq %rbx, %rdi
callq 0x8ef0
jmp 0x904c
addq $0x2, %r12
movq %r12, 0x90(%rbx)
movq %rbx, %rdi
xorl %esi, %esi
callq 0x91c8
jmp 0x904c