// File: /workspace/github_c_makefile_star2_O2/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 0x44db
movq %rax, %rbx
movq %r12, %rdi
callq 0x2110
cmpq $0x100, %rax            # imm = 0x100
jb 0x4505
leaq 0x4fa3(%rip), %rdi      # 0x9485
xorl %eax, %eax
callq 0x3e48
callq 0x2090
andl $0x0, (%rax)
pushq $-0x1
popq %rbp
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 0x4518
leaq 0x4fc7(%rip), %rdi      # 0x94dd
jmp 0x44e2
movq %rax, %r14
movq %rbp, 0x10(%rsp)
pushq $0x10
popq %rdi
callq 0x2200
pushq $-0x1
popq %rbp
testq %rax, %rax
je 0x44f4
movq 0x60(%rsp), %rcx
movq %r13, (%rax)
movq %rcx, 0x8(%rax)
addq %r14, %rbx
addq $0xe, %rbx
leaq 0x108(%rip), %rdx       # 0x4652
movq 0x10(%rsp), %rdi
movq %rbx, %rsi
movq %rax, 0x20(%rsp)
movq %rax, %rcx
callq 0x4dfb
testq %rax, %rax
je 0x463c
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 0x501d
testl %eax, %eax
je 0x464b
movq 0x20(%rsp), %rdi
callq 0x2040
jmp 0x44f4
xorl %ebp, %ebp
jmp 0x44f4