// File: /workspace/github_c_makefile_star2_O0/Tarsnap[P]kivaloo/kvlds-undump/main.c
// Function: callback_pair
static int
callback_pair(void * cookie, struct kvldskey ** key, struct kvldskey ** value)
{
	struct undumpstate * C = cookie;
	struct dirent * d;
	uint8_t len;
	uint8_t buf[255];

	/* Filesystem or stdout? */
	if (C->d != NULL) {
		/* Find a directory. */
		do {
			errno = 0;
			if ((d = readdir(C->d)) == NULL) {
				if (errno == 0)
					goto nomore;
				warnp("readdir");
				goto err0;
			}

			/* Skip "." and "..". */
			if ((strcmp(d->d_name, ".") != 0) &&
			    (strcmp(d->d_name, "..") != 0))
				break;
		} while (1);

		/* Read key and value. */
		if ((*key = readfile(d->d_name, "k")) == NULL)
			goto err0;
		if ((*value = readfile(d->d_name, "v")) == NULL)
			goto err1;
	} else {
		/* Read key from stdin. */
		if (fread(&len, 1, 1, stdin) != 1) {
			if (feof(stdin))
				goto nomore;
			goto err0;
		}
		/*
		 * len is uint8_t, so it will be 0..255 (inclusive).
		 * Read that many bytes from stdin; we don't accept eof here
		 * because that would indicate a buffer underrun in buf.
		 */
		if (fread(&buf, len, 1, stdin) != 1)
			goto err0;
		if ((*key = kvldskey_create(buf, len)) == NULL)
			goto err0;

		/* Read value from stdin (same security rationale as above). */
		if (fread(&len, 1, 1, stdin) != 1)
			goto err1;
		if (fread(&buf, len, 1, stdin) != 1)
			goto err1;
		if ((*value = kvldskey_create(buf, len)) == NULL)
			goto err1;
	}

	/* Done another key-value pair. */
	C->N++;

	/* Success! */
	return (0);

nomore:
	/* No more key-value pairs; but we were successful. */
	*key = *value = NULL;
	return (0);

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

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x130, %rsp            # imm = 0x130
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x28(%rbp)
movq -0x28(%rbp), %rax
cmpq $0x0, (%rax)
je 0x2e1e
jmp 0x2d1f
callq 0x20a0
movl $0x0, (%rax)
movq -0x28(%rbp), %rax
movq (%rax), %rdi
callq 0x2280
movq %rax, -0x30(%rbp)
cmpq $0x0, %rax
jne 0x2d8b
callq 0x20a0
cmpl $0x0, (%rax)
jne 0x2d4f
jmp 0x2f38
jmp 0x2d51
callq 0x20a0
cmpl $0x0, (%rax)
je 0x2d76
leaq 0xe4ba(%rip), %rdi      # 0x1121c
movb $0x0, %al
callq 0x44a0
callq 0x20a0
movl $0x0, (%rax)
jmp 0x2d84
leaq 0xe49f(%rip), %rdi      # 0x1121c
movb $0x0, %al
callq 0x46f0
jmp 0x2d86
jmp 0x2f63
movq -0x30(%rbp), %rdi
addq $0x13, %rdi
leaq 0xe48b(%rip), %rsi      # 0x11225
callq 0x2220
cmpl $0x0, %eax
je 0x2dbf
movq -0x30(%rbp), %rdi
addq $0x13, %rdi
leaq 0xe471(%rip), %rsi      # 0x11224
callq 0x2220
cmpl $0x0, %eax
je 0x2dbf
jmp 0x2dcd
jmp 0x2dc1
movb $0x1, %al
testb $0x1, %al
jne 0x2d1f
jmp 0x2dcd
movq -0x30(%rbp), %rdi
addq $0x13, %rdi
leaq 0xe44b(%rip), %rsi      # 0x11227
callq 0x2f80
movq -0x18(%rbp), %rcx
movq %rax, (%rcx)
cmpq $0x0, %rax
jne 0x2df3
jmp 0x2f63
movq -0x30(%rbp), %rdi
addq $0x13, %rdi
leaq 0xe2ba(%rip), %rsi      # 0x110bc
callq 0x2f80
movq -0x20(%rbp), %rcx
movq %rax, (%rcx)
cmpq $0x0, %rax
jne 0x2e19
jmp 0x2f57
jmp 0x2f1f
movq 0x141b3(%rip), %rax     # 0x16fd8
movq (%rax), %rcx
leaq -0x31(%rbp), %rdi
movl $0x1, %edx
movq %rdx, %rsi
callq 0x20d0
cmpq $0x1, %rax
je 0x2e5d
movq 0x14192(%rip), %rax     # 0x16fd8
movq (%rax), %rdi
callq 0x2240
cmpl $0x0, %eax
je 0x2e58
jmp 0x2f38
jmp 0x2f63
movzbl -0x31(%rbp), %eax
movl %eax, %esi
movq 0x1416e(%rip), %rax     # 0x16fd8
movq (%rax), %rcx
leaq -0x130(%rbp), %rdi
movl $0x1, %edx
callq 0x20d0
cmpq $0x1, %rax
je 0x2e89
jmp 0x2f63
leaq -0x130(%rbp), %rdi
movzbl -0x31(%rbp), %eax
movl %eax, %esi
callq 0x4930
movq -0x18(%rbp), %rcx
movq %rax, (%rcx)
cmpq $0x0, %rax
jne 0x2ead
jmp 0x2f63
movq 0x14124(%rip), %rax     # 0x16fd8
movq (%rax), %rcx
leaq -0x31(%rbp), %rdi
movl $0x1, %edx
movq %rdx, %rsi
callq 0x20d0
cmpq $0x1, %rax
je 0x2ed3
jmp 0x2f57
movzbl -0x31(%rbp), %eax
movl %eax, %esi
movq 0x140f8(%rip), %rax     # 0x16fd8
movq (%rax), %rcx
leaq -0x130(%rbp), %rdi
movl $0x1, %edx
callq 0x20d0
cmpq $0x1, %rax
je 0x2efc
jmp 0x2f57
leaq -0x130(%rbp), %rdi
movzbl -0x31(%rbp), %eax
movl %eax, %esi
callq 0x4930
movq -0x20(%rbp), %rcx
movq %rax, (%rcx)
cmpq $0x0, %rax
jne 0x2f1d
jmp 0x2f57
jmp 0x2f1f
movq -0x28(%rbp), %rax
movq 0x8(%rax), %rcx
addq $0x1, %rcx
movq %rcx, 0x8(%rax)
movl $0x0, -0x4(%rbp)
jmp 0x2f6a
movq -0x20(%rbp), %rax
movq $0x0, (%rax)
movq -0x18(%rbp), %rax
movq $0x0, (%rax)
movl $0x0, -0x4(%rbp)
jmp 0x2f6a
movq -0x18(%rbp), %rax
movq (%rax), %rdi
callq 0x2040
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
movl -0x4(%rbp), %eax
addq $0x130, %rsp            # imm = 0x130
popq %rbp
retq
nopw %cs:(%rax,%rax)