// File: /workspace/github_c_makefile_star2_O0/Tarsnap[P]kivaloo/liball/../lib/proto_lbs/proto_lbs_server.c
// Function: proto_lbs_request_parse
static int
proto_lbs_request_parse(const struct wire_packet * P,
    struct proto_lbs_request * R)
{

	/* Sanity check. */
	assert(P->len <= UINT32_MAX);

	/* Store request ID. */
	R->ID = P->ID;

	/* Sanity-check packet length. */
	if (P->len < 4)
		goto err0;

	/* Figure out request type. */
	R->type = be32dec(&P->buf[0]);

	/* Parse packet. */
	switch (R->type) {
	case PROTO_LBS_PARAMS:
	case PROTO_LBS_PARAMS2:
		if (P->len != 4)
			goto err0;
		/* Nothing to parse. */
		break;
	case PROTO_LBS_GET:
		if (P->len != 12)
			goto err0;
		R->r.get.blkno = be64dec(&P->buf[4]);
		break;
	case PROTO_LBS_APPEND:
		if (P->len < 16)
			goto err0;
		R->r.append.nblks = be32dec(&P->buf[4]);
		R->r.append.blkno = be64dec(&P->buf[8]);
		if (R->r.append.nblks == 0)
			goto err0;
		if ((P->len - 16) % R->r.append.nblks)
			goto err0;
		R->r.append.blklen = (uint32_t)((P->len - 16) /
		    R->r.append.nblks);
		if ((R->r.append.buf = malloc(P->len - 16)) == NULL)
			goto err0;
		memcpy(R->r.append.buf, &P->buf[16], P->len - 16);
		break;
	case PROTO_LBS_FREE:
		if (P->len != 12)
			goto err0;
		R->r.free.blkno = be64dec(&P->buf[4]);
		break;
	default:
		goto err0;
	}

	/* Success! */
	return (0);

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

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq -0x10(%rbp), %rax
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
cmpq %rcx, 0x8(%rax)
ja 0xe431
jmp 0xe450
leaq 0x6c15(%rip), %rdi      # 0x1504d
leaq 0x6b40(%rip), %rsi      # 0x14f7f
movl $0x15, %edx
leaq 0x6c17(%rip), %rcx      # 0x15062
callq 0x21b0
movq -0x10(%rbp), %rax
movq (%rax), %rcx
movq -0x18(%rbp), %rax
movq %rcx, (%rax)
movq -0x10(%rbp), %rax
cmpq $0x4, 0x8(%rax)
jae 0xe46e
jmp 0xe60a
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rdi
callq 0xeab0
movl %eax, %ecx
movq -0x18(%rbp), %rax
movl %ecx, 0x8(%rax)
movq -0x18(%rbp), %rax
movl 0x8(%rax), %eax
movq %rax, -0x20(%rbp)
subq $0x4, %rax
ja 0xe5ff
movq -0x20(%rbp), %rax
leaq 0x6aa8(%rip), %rcx      # 0x14f4c
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq -0x10(%rbp), %rax
cmpq $0x4, 0x8(%rax)
je 0xe4bd
jmp 0xe60a
jmp 0xe601
movq -0x10(%rbp), %rax
cmpq $0xc, 0x8(%rax)
je 0xe4d2
jmp 0xe60a
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rdi
addq $0x4, %rdi
callq 0xeaf0
movq %rax, %rcx
movq -0x18(%rbp), %rax
movq %rcx, 0x10(%rax)
jmp 0xe601
movq -0x10(%rbp), %rax
cmpq $0x10, 0x8(%rax)
jae 0xe503
jmp 0xe60a
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rdi
addq $0x4, %rdi
callq 0xeab0
movl %eax, %ecx
movq -0x18(%rbp), %rax
movl %ecx, 0x10(%rax)
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rdi
addq $0x8, %rdi
callq 0xeaf0
movq %rax, %rcx
movq -0x18(%rbp), %rax
movq %rcx, 0x18(%rax)
movq -0x18(%rbp), %rax
cmpl $0x0, 0x10(%rax)
jne 0xe548
jmp 0xe60a
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
subq $0x10, %rax
movq -0x18(%rbp), %rcx
movl 0x10(%rcx), %ecx
xorl %edx, %edx
divq %rcx
cmpq $0x0, %rdx
je 0xe56b
jmp 0xe60a
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
subq $0x10, %rax
movq -0x18(%rbp), %rcx
movl 0x10(%rcx), %ecx
xorl %edx, %edx
divq %rcx
movl %eax, %ecx
movq -0x18(%rbp), %rax
movl %ecx, 0x14(%rax)
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rdi
subq $0x10, %rdi
callq 0x2280
movq -0x18(%rbp), %rcx
movq %rax, 0x20(%rcx)
cmpq $0x0, %rax
jne 0xe5ad
jmp 0xe60a
movq -0x18(%rbp), %rax
movq 0x20(%rax), %rdi
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rsi
addq $0x10, %rsi
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rdx
subq $0x10, %rdx
callq 0x2260
jmp 0xe601
movq -0x10(%rbp), %rax
cmpq $0xc, 0x8(%rax)
je 0xe5e1
jmp 0xe60a
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rdi
addq $0x4, %rdi
callq 0xeaf0
movq %rax, %rcx
movq -0x18(%rbp), %rax
movq %rcx, 0x10(%rax)
jmp 0xe601
jmp 0xe60a
movl $0x0, -0x4(%rbp)
jmp 0xe611
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
movl -0x4(%rbp), %eax
addq $0x20, %rsp
popq %rbp
retq
nopw (%rax,%rax)