// File: /workspace/github_c_makefile_star2_O3/Tarsnap[P]kivaloo/liball/../lib/proto_s3/proto_s3_client.c
// Function: proto_s3_request_range
int
proto_s3_request_range(struct wire_requestqueue * Q, const char * bucket,
    const char * object, uint32_t offset, uint32_t len,
    int (* callback)(void *, int, size_t, const uint8_t *), void * cookie)
{
	struct get_cookie * C;
	uint8_t *rbuf, *p;
	size_t rlen;

	/* Validate bucket and object name lengths. */
	if ((strlen(bucket) > 255) || (strlen(object) > 255)) {
		warn0("Bucket or object name is too long");
		goto err0;
	}

	/* Validate maxlen. */
	if (len > PROTO_S3_MAXLEN) {
		warn0("RANGE length is too long");
		goto err0;
	}

	/* Bake a cookie. */
	if ((C = malloc(sizeof(struct get_cookie))) == NULL)
		goto err0;
	C->callback = callback;
	C->cookie = cookie;

	/* Compute request packet size. */
	rlen = 6 + strlen(bucket) + strlen(object) + 8;

	/* Start writing a request. */
	if ((p = rbuf =
	    wire_requestqueue_add_getbuf(Q, rlen, callback_range, C)) == NULL)
		goto err1;

	/* Construct request. */
	be32enc(p, PROTO_S3_RANGE);
	p += 4;
	*p++ = (uint8_t)strlen(bucket);
	memcpy(p, bucket, strlen(bucket));
	p += strlen(bucket);
	*p++ = (uint8_t)strlen(object);
	memcpy(p, object, strlen(object));
	p += strlen(object);
	be32enc(p, offset);
	p += 4;
	be32enc(p, len);

	/* Finish writing request. */
	if (wire_requestqueue_add_done(Q, rbuf, rlen))
		goto err1;

	/* Success! */
	return (0);

err1:
	free(C);
err0:
	/* Failure! */
	return (-1);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %r9, %r13
movl %r8d, 0x8(%rsp)
movl %ecx, 0xc(%rsp)
movq %rdx, %r12
movq %rsi, %r15
movq %rdi, %rbp
movq %rsi, %rdi
callq 0x2110
cmpq $0xff, %rax
ja 0x4890
movq %rax, %rbx
movq %r12, %rdi
callq 0x2110
cmpq $0x100, %rax            # imm = 0x100
jb 0x48bf
leaq 0x5bee(%rip), %rdi      # 0xa485
xorl %eax, %eax
callq 0x425f
callq 0x2090
movl $0x0, (%rax)
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
movl %ebp, %eax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
cmpl $0x80000001, 0x8(%rsp)  # imm = 0x80000001
jb 0x48d2
leaq 0x5c0d(%rip), %rdi      # 0xa4dd
jmp 0x4897
movq %rax, %r14
movq %rbp, 0x10(%rsp)
movl $0x10, %edi
callq 0x2200
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
testq %rax, %rax
je 0x48ae
movq 0x60(%rsp), %rcx
movq %r13, (%rax)
movq %rcx, 0x8(%rax)
addq %r14, %rbx
addq $0xe, %rbx
leaq 0x108(%rip), %rdx       # 0x4a10
movq 0x10(%rsp), %rdi
movq %rbx, %rsi
movq %rax, 0x20(%rsp)
movq %rax, %rcx
callq 0x52ca
testq %rax, %rax
je 0x49fa
movq %rax, %r13
movl $0x11000100, (%rax)     # imm = 0x11000100
movq %r15, %rdi
callq 0x2110
movq %rbx, 0x18(%rsp)
leaq 0x5(%r13), %rbx
movb %al, 0x4(%r13)
movq %r15, %rdi
callq 0x2110
movq %rbx, %rdi
movq %r15, %rsi
movq %rax, %rdx
callq 0x21e0
movq %r15, %rdi
callq 0x2110
movq %rax, %rbx
leaq (%rax,%r13), %r15
addq $0x5, %r15
movq %r12, %rdi
callq 0x2110
leaq (%rbx,%r13), %r14
addq $0x6, %r14
movb %al, 0x5(%r13,%rbx)
movq %r12, %rdi
callq 0x2110
movq %r14, %rdi
movq %r12, %rsi
movq %rax, %rdx
callq 0x21e0
movq %r12, %rdi
callq 0x2110
movl 0xc(%rsp), %edx
movl %edx, %ecx
rolw $0x8, %cx
movq %r15, %rsi
movw %cx, 0x3(%rax,%r15)
movl %edx, %ecx
shrl $0x10, %ecx
movb %cl, 0x2(%rax,%r15)
shrl $0x18, %edx
movb %dl, 0x1(%rax,%r15)
movl 0x8(%rsp), %edx
movb %dl, 0x8(%rax,%r15)
movb %dh, 0x7(%rax,%rsi)
movl %edx, %ecx
shrl $0x10, %ecx
movb %cl, 0x6(%rax,%r15)
shrl $0x18, %edx
movb %dl, 0x5(%rax,%r15)
movq 0x10(%rsp), %rdi
movq %r13, %rsi
movq 0x18(%rsp), %rdx
callq 0x55c5
testl %eax, %eax
je 0x4a09
movq 0x20(%rsp), %rdi
callq 0x2040
jmp 0x48ae
xorl %ebp, %ebp
jmp 0x48ae