// File: /workspace/github_c_makefile_star2_O0/Tarsnap[P]kivaloo/s3/dispatch.c
// Function: callback_response
static int
callback_response(void * cookie, struct http_response * res)
{
	struct request * R = cookie;
	struct dispatch_state * D = R->D;
	const char * s_clen;
	uint32_t clen;

	/* Send appropriate response back to the client. */
	switch (R->R.type) {
	case PROTO_S3_PUT:
		if (proto_s3_response_put(D->writeq, R->R.ID, res->status))
			goto err1;
		break;
	case PROTO_S3_GET:
		/* Verify that we have a body and the ETag is correct. */
		if ((res->body == NULL) || (s3_verifyetag(res) == 0))
			res->status = 0;

		/* Sanity check. */
		assert((res->bodylen == (size_t)-1) ||
		    (res->bodylen <= UINT32_MAX));

		/* Send the response. */
		if (proto_s3_response_get(D->writeq, R->R.ID, res->status,
		    (uint32_t)res->bodylen, res->body))
			goto err1;
		break;
	case PROTO_S3_RANGE:
		/* Sanity check. */
		assert((res->bodylen == (size_t)-1) ||
		    (res->bodylen <= UINT32_MAX));

		/* Send the response. */
		if (proto_s3_response_range(D->writeq, R->R.ID, res->status,
		    (uint32_t)res->bodylen, res->body))
			goto err1;
		break;
	case PROTO_S3_HEAD:
		/* Look for a Content-Length header. */
		if ((s_clen = http_findheader(res->headers,
		    res->nheaders, "Content-Length")) == NULL) {
			/* We have no Content-Length header. */
			clen = (uint32_t)(-1);
		} else {
			/* Parse in base 10, no trailing characters. */
			if (PARSENUM_EX(&clen, s_clen, 10, 0)) {
				warnp("Invalid Content-Length: %s", s_clen);
				clen = (uint32_t)(-1);
			}
		}

		/* Send the response. */
		if (proto_s3_response_head(D->writeq, R->R.ID, res->status,
		    clen))
			goto err1;
		break;
	case PROTO_S3_DELETE:
		if (proto_s3_response_delete(D->writeq, R->R.ID, res->status))
			goto err1;
	}

	/* Free the response body buffer. */
	free(res->body);

	/* Remove this request from the in-progress list. */
	request_dequeue(D, R);

	/* Success! */
	return (0);

err1:
	free(res->body);
	request_dequeue(D, R);

	/* Failure! */
	return (-1);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x20(%rbp)
movq -0x20(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x28(%rbp)
movq -0x20(%rbp), %rax
movl 0x20(%rax), %eax
addl $0xffff0000, %eax       # imm = 0xFFFF0000
movl %eax, %ecx
movq %rcx, -0x40(%rbp)
subl $0x30, %eax
ja 0x4d38
movq -0x40(%rbp), %rax
leaq 0x19b9f(%rip), %rcx     # 0x1e608
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq -0x28(%rbp), %rax
movq 0x20(%rax), %rdi
movq -0x20(%rbp), %rax
movq 0x18(%rax), %rsi
movq -0x18(%rbp), %rax
movl (%rax), %edx
callq 0xf7b0
cmpl $0x0, %eax
je 0x4a97
jmp 0x4d5b
jmp 0x4d38
movq -0x18(%rbp), %rax
cmpq $0x0, 0x20(%rax)
je 0x4ab5
movq -0x18(%rbp), %rdi
callq 0x10900
cmpl $0x0, %eax
jne 0x4abf
movq -0x18(%rbp), %rax
movl $0x0, (%rax)
movq -0x18(%rbp), %rax
cmpq $-0x1, 0x18(%rax)
je 0x4ad9
movq -0x18(%rbp), %rax
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
cmpq %rcx, 0x18(%rax)
ja 0x4adb
jmp 0x4afa
leaq 0x19de7(%rip), %rdi     # 0x1e8c9
leaq 0x19bf5(%rip), %rsi     # 0x1e6de
movl $0x111, %edx            # imm = 0x111
leaq 0x19e11(%rip), %rcx     # 0x1e906
callq 0x2200
movq -0x28(%rbp), %rax
movq 0x20(%rax), %rdi
movq -0x20(%rbp), %rax
movq 0x18(%rax), %rsi
movq -0x18(%rbp), %rax
movl (%rax), %edx
movq -0x18(%rbp), %rax
movq 0x18(%rax), %rax
movl %eax, %ecx
movq -0x18(%rbp), %rax
movq 0x20(%rax), %r8
callq 0xf8d0
cmpl $0x0, %eax
je 0x4b31
jmp 0x4d5b
jmp 0x4d38
movq -0x18(%rbp), %rax
cmpq $-0x1, 0x18(%rax)
je 0x4b50
movq -0x18(%rbp), %rax
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
cmpq %rcx, 0x18(%rax)
ja 0x4b52
jmp 0x4b71
leaq 0x19d70(%rip), %rdi     # 0x1e8c9
leaq 0x19b7e(%rip), %rsi     # 0x1e6de
movl $0x11b, %edx            # imm = 0x11B
leaq 0x19d9a(%rip), %rcx     # 0x1e906
callq 0x2200
movq -0x28(%rbp), %rax
movq 0x20(%rax), %rdi
movq -0x20(%rbp), %rax
movq 0x18(%rax), %rsi
movq -0x18(%rbp), %rax
movl (%rax), %edx
movq -0x18(%rbp), %rax
movq 0x18(%rax), %rax
movl %eax, %ecx
movq -0x18(%rbp), %rax
movq 0x20(%rax), %r8
callq 0xf8d0
cmpl $0x0, %eax
je 0x4ba8
jmp 0x4d5b
jmp 0x4d38
movq -0x18(%rbp), %rax
movq 0x10(%rax), %rdi
movq -0x18(%rbp), %rax
movq 0x8(%rax), %rsi
leaq 0x19d78(%rip), %rdx     # 0x1e93c
callq 0x7830
movq %rax, -0x30(%rbp)
cmpq $0x0, %rax
jne 0x4bdf
movl $0xffffffff, -0x34(%rbp) # imm = 0xFFFFFFFF
jmp 0x4ce8
callq 0x20a0
movl $0x0, (%rax)
movl $0x1, -0x34(%rbp)
movl -0x34(%rbp), %eax
shrl %eax
movl %eax, -0x34(%rbp)
cmpl $0x0, %eax
jbe 0x4c2f
movq 0x223f3(%rip), %rax     # 0x26ff8
movq (%rax), %rdi
leaq 0x19d3c(%rip), %rsi     # 0x1e94b
leaq 0x19d93(%rip), %rdx     # 0x1e9a9
leaq 0x19ac1(%rip), %rcx     # 0x1e6de
movl $0x12a, %r8d            # imm = 0x12A
movb $0x0, %al
callq 0x22e0
callq 0x2090
movl $0xffffffff, -0x34(%rbp) # imm = 0xFFFFFFFF
movb $0x1, %al
testb $0x1, %al
jne 0x4c3e
jmp 0x4c63
movq -0x30(%rbp), %rdi
movl -0x34(%rbp), %eax
movl %eax, %edx
movl -0x34(%rbp), %eax
movl %eax, %ecx
xorl %eax, %eax
movl %eax, %esi
movl $0xa, %r8d
xorl %r9d, %r9d
callq 0x4d90
movl %eax, -0x34(%rbp)
jmp 0x4c94
movq 0x2238e(%rip), %rax     # 0x26ff8
movq (%rax), %rdi
leaq 0x19d47(%rip), %rsi     # 0x1e9bb
leaq 0x19d2e(%rip), %rdx     # 0x1e9a9
leaq 0x19a5c(%rip), %rcx     # 0x1e6de
movl $0x12a, %r8d            # imm = 0x12A
movb $0x0, %al
callq 0x22e0
callq 0x2090
jmp 0x4c96
callq 0x20a0
cmpl $0x0, (%rax)
je 0x4ce6
jmp 0x4ca2
callq 0x20a0
cmpl $0x0, (%rax)
je 0x4ccb
movq -0x30(%rbp), %rsi
leaq 0x19d75(%rip), %rdi     # 0x1ea2c
movb $0x0, %al
callq 0xe670
callq 0x20a0
movl $0x0, (%rax)
jmp 0x4cdd
movq -0x30(%rbp), %rsi
leaq 0x19d56(%rip), %rdi     # 0x1ea2c
movb $0x0, %al
callq 0xe8c0
jmp 0x4cdf
movl $0xffffffff, -0x34(%rbp) # imm = 0xFFFFFFFF
jmp 0x4ce8
movq -0x28(%rbp), %rax
movq 0x20(%rax), %rdi
movq -0x20(%rbp), %rax
movq 0x18(%rax), %rsi
movq -0x18(%rbp), %rax
movl (%rax), %edx
movl -0x34(%rbp), %ecx
xorl %eax, %eax
movl %eax, %r8d
callq 0xf8d0
cmpl $0x0, %eax
je 0x4d12
jmp 0x4d5b
jmp 0x4d38
movq -0x28(%rbp), %rax
movq 0x20(%rax), %rdi
movq -0x20(%rbp), %rax
movq 0x18(%rax), %rsi
movq -0x18(%rbp), %rax
movl (%rax), %edx
callq 0xf7b0
cmpl $0x0, %eax
je 0x4d36
jmp 0x4d5b
jmp 0x4d38
movq -0x18(%rbp), %rax
movq 0x20(%rax), %rdi
callq 0x2040
movq -0x28(%rbp), %rdi
movq -0x20(%rbp), %rsi
callq 0x4880
movl $0x0, -0x4(%rbp)
jmp 0x4d7c
movq -0x18(%rbp), %rax
movq 0x20(%rax), %rdi
callq 0x2040
movq -0x28(%rbp), %rdi
movq -0x20(%rbp), %rsi
callq 0x4880
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
movl -0x4(%rbp), %eax
addq $0x40, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)