// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x80, %rsp
movq 0x10(%rbp), %rax
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq %rcx, -0x28(%rbp)
movq %r8, -0x30(%rbp)
movq %r9, -0x38(%rbp)
movq -0x18(%rbp), %rdi
callq 0x2120
cmpq $0xff, %rax
ja 0x6c89
movq -0x20(%rbp), %rdi
callq 0x2120
cmpq $0xff, %rax
jbe 0x6ca9
jmp 0x6c8b
leaq 0x7bde(%rip), %rdi      # 0xe870
movb $0x0, %al
callq 0x6a00
callq 0x20a0
movl $0x0, (%rax)
jmp 0x6e7b
movl $0x80000000, %eax       # imm = 0x80000000
cmpq %rax, -0x28(%rbp)
jb 0x6cd4
jmp 0x6cb6
leaq 0x7bd5(%rip), %rdi      # 0xe892
movb $0x0, %al
callq 0x6a00
callq 0x20a0
movl $0x0, (%rax)
jmp 0x6e7b
movl $0x10, %edi
callq 0x2220
movq %rax, -0x40(%rbp)
cmpq $0x0, %rax
jne 0x6ced
jmp 0x6e7b
movq -0x38(%rbp), %rcx
movq -0x40(%rbp), %rax
movq %rcx, (%rax)
movq 0x10(%rbp), %rcx
movq -0x40(%rbp), %rax
movq %rcx, 0x8(%rax)
movq -0x18(%rbp), %rdi
callq 0x2120
addq $0x6, %rax
movq %rax, -0x60(%rbp)
movq -0x20(%rbp), %rdi
callq 0x2120
movq %rax, %rcx
movq -0x60(%rbp), %rax
addq %rcx, %rax
addq $0x4, %rax
addq -0x28(%rbp), %rax
movq %rax, -0x58(%rbp)
movq -0x10(%rbp), %rdi
movq -0x58(%rbp), %rsi
movq -0x40(%rbp), %rcx
leaq 0x149(%rip), %rdx       # 0x6e90
callq 0x8170
movq %rax, -0x48(%rbp)
movq %rax, -0x50(%rbp)
cmpq $0x0, %rax
jne 0x6d5f
jmp 0x6e72
movq -0x50(%rbp), %rdi
movl $0x10000, %esi          # imm = 0x10000
callq 0x6f80
movq -0x50(%rbp), %rax
addq $0x4, %rax
movq %rax, -0x50(%rbp)
movq -0x18(%rbp), %rdi
callq 0x2120
movb %al, %cl
movq -0x50(%rbp), %rax
movq %rax, %rdx
addq $0x1, %rdx
movq %rdx, -0x50(%rbp)
movb %cl, (%rax)
movq -0x50(%rbp), %rax
movq %rax, -0x80(%rbp)
movq -0x18(%rbp), %rax
movq %rax, -0x78(%rbp)
movq -0x18(%rbp), %rdi
callq 0x2120
movq -0x80(%rbp), %rdi
movq -0x78(%rbp), %rsi
movq %rax, %rdx
callq 0x2200
movq -0x18(%rbp), %rdi
callq 0x2120
addq -0x50(%rbp), %rax
movq %rax, -0x50(%rbp)
movq -0x20(%rbp), %rdi
callq 0x2120
movb %al, %cl
movq -0x50(%rbp), %rax
movq %rax, %rdx
addq $0x1, %rdx
movq %rdx, -0x50(%rbp)
movb %cl, (%rax)
movq -0x50(%rbp), %rax
movq %rax, -0x70(%rbp)
movq -0x20(%rbp), %rax
movq %rax, -0x68(%rbp)
movq -0x20(%rbp), %rdi
callq 0x2120
movq -0x70(%rbp), %rdi
movq -0x68(%rbp), %rsi
movq %rax, %rdx
callq 0x2200
movq -0x20(%rbp), %rdi
callq 0x2120
addq -0x50(%rbp), %rax
movq %rax, -0x50(%rbp)
movq -0x50(%rbp), %rdi
movq -0x28(%rbp), %rax
movl %eax, %esi
callq 0x6f80
movq -0x50(%rbp), %rax
addq $0x4, %rax
movq %rax, -0x50(%rbp)
movq -0x50(%rbp), %rdi
movq -0x30(%rbp), %rsi
movq -0x28(%rbp), %rdx
callq 0x2200
movq -0x10(%rbp), %rdi
movq -0x48(%rbp), %rsi
movq -0x58(%rbp), %rdx
callq 0x8300
cmpl $0x0, %eax
je 0x6e69
jmp 0x6e72
movl $0x0, -0x4(%rbp)
jmp 0x6e82
movq -0x40(%rbp), %rdi
callq 0x2040
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
movl -0x4(%rbp), %eax
addq $0x80, %rsp
popq %rbp
retq
nop