// File: /workspace/github_c_makefile_star2_O3/Tarsnap[P]kivaloo/liball/../lib/proto_s3/proto_s3_client.c
// Function: proto_s3_request_put
int
proto_s3_request_put(struct wire_requestqueue * Q, const char * bucket,
    const char * object, size_t buflen, const uint8_t * buf,
    int (* callback)(void *, int), void * cookie)
{
	struct put_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 buflen. */
	if (buflen >= PROTO_S3_MAXLEN) {
		warn0("PUT length is too long");
		goto err0;
	}

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

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

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

	/* Construct request. */
	be32enc(p, PROTO_S3_PUT);
	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, (uint32_t)buflen);
	p += 4;
	memcpy(p, buf, buflen);

	/* 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, (%rsp)
movq %r8, 0x20(%rsp)
movq %rcx, %r15
movq %rdx, %r12
movq %rsi, %r13
movq %rdi, %rbp
movq %rsi, %rdi
callq 0x2110
cmpq $0xff, %rax
ja 0x43ca
movq %rax, %rbx
movq %r12, %rdi
callq 0x2110
cmpq $0x100, %rax            # imm = 0x100
jb 0x43f9
leaq 0x60b4(%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
movq %rax, %r14
movq %r15, %rax
shrq $0x1f, %rax
je 0x440e
leaq 0x609b(%rip), %rdi      # 0xa4a7
jmp 0x43d1
movq %rbp, 0x8(%rsp)
movl $0x10, %edi
callq 0x2200
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
testq %rax, %rax
je 0x43e8
movq 0x60(%rsp), %rcx
movq (%rsp), %rdx
movq %rdx, (%rax)
movq %rcx, 0x8(%rax)
addq %r15, %rbx
addq %r14, %rbx
addq $0xa, %rbx
leaq 0xe5(%rip), %rdx        # 0x452d
movq 0x8(%rsp), %rdi
movq %rbx, %rsi
movq %rax, (%rsp)
movq %rax, %rcx
callq 0x52ca
testq %rax, %rax
je 0x4518
movl $0x100, (%rax)          # imm = 0x100
movq %r13, %rdi
movq %r15, 0x10(%rsp)
movq %rax, %r15
callq 0x2110
movq %rbx, 0x18(%rsp)
leaq 0x5(%r15), %rbx
movb %al, 0x4(%r15)
movq %r13, %rdi
callq 0x2110
movq %rbx, %rdi
movq %r13, %rsi
movq %rax, %rdx
callq 0x21e0
movq %r13, %rdi
callq 0x2110
movq %rax, %rbx
leaq (%r15,%rax), %r13
addq $0x5, %r13
movq %r12, %rdi
callq 0x2110
leaq (%r15,%rbx), %r14
addq $0x6, %r14
movb %al, 0x5(%r15,%rbx)
movq %r12, %rdi
callq 0x2110
movq %r14, %rdi
movq %r12, %rsi
movq %rax, %rdx
callq 0x21e0
movq %r12, %rdi
callq 0x2110
movq 0x10(%rsp), %rdx
movl %edx, %ecx
bswapl %ecx
leaq (%rax,%r13), %rdi
addq $0x5, %rdi
movl %ecx, -0x4(%rdi)
movq 0x20(%rsp), %rsi
callq 0x21e0
movq 0x8(%rsp), %rdi
movq %r15, %rsi
movq 0x18(%rsp), %rdx
callq 0x55c5
testl %eax, %eax
je 0x4526
movq (%rsp), %rdi
callq 0x2040
jmp 0x43e8
xorl %ebp, %ebp
jmp 0x43e8