// File: /workspace/github_c_makefile_star2_O0/Tarsnap[P]kivaloo/kvlds-undump/main.c
// Function: readfile
static struct kvldskey *
readfile(const char * dir, const char * fname)
{
	char * s;
	FILE * f;
	struct stat sb;
	uint8_t buf[255];
	struct kvldskey * k;

	/* Construct file name. */
	if (asprintf(&s, "%s/%s", dir, fname) == -1) {
		warnp("asprintf");
		goto err0;
	}

	/* Open file. */
	if ((f = fopen(s, "rb")) == NULL) {
		warnp("fopen(%s)", s);
		goto err1;
	}

	/* Figure out how large the file is. */
	if (fstat(fileno(f), &sb)) {
		warnp("fstat(%s)", s);
		goto err2;
	}

	/* Sanity-check. */
	if (!S_ISREG(sb.st_mode)) {
		warn0("Not a regular file: %s", s);
		goto err2;
	}
	if (sb.st_size > 255) {
		warn0("File is too large (%ju bytes): %s",
		    (intmax_t)(sb.st_size), s);
		goto err2;
	}

	/* Read value. */
	if (fread(buf, (size_t)sb.st_size, 1, f) != 1) {
		warnp("fread(%s)", s);
		goto err2;
	}

	/* Construct kvlds key. */
	if ((k = kvldskey_create(buf, (size_t)sb.st_size)) == NULL)
		goto err2;

	/* Close file and free file name. */
	if (fclose(f))
		warnp("fclose");
	free(s);

	/* Success! */
	return (k);

err2:
	if (fclose(f))
		warnp("fclose");
err1:
	free(s);
err0:
	/* Failure! */
	return (NULL);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x1d0, %rsp            # imm = 0x1D0
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq -0x10(%rbp), %rdx
movq -0x18(%rbp), %rcx
leaq -0x20(%rbp), %rdi
leaq 0xe283(%rip), %rsi      # 0x11229
movb $0x0, %al
callq 0x3270
cmpl $-0x1, %eax
jne 0x2fee
jmp 0x2fb4
callq 0x20a0
cmpl $0x0, (%rax)
je 0x2fd9
leaq 0xe26a(%rip), %rdi      # 0x1122f
movb $0x0, %al
callq 0x44a0
callq 0x20a0
movl $0x0, (%rax)
jmp 0x2fe7
leaq 0xe24f(%rip), %rdi      # 0x1122f
movb $0x0, %al
callq 0x46f0
jmp 0x2fe9
jmp 0x324e
movq -0x20(%rbp), %rdi
leaq 0xe23f(%rip), %rsi      # 0x11238
callq 0x2320
movq %rax, -0x28(%rbp)
cmpq $0x0, %rax
jne 0x304c
jmp 0x300a
callq 0x20a0
cmpl $0x0, (%rax)
je 0x3033
movq -0x20(%rbp), %rsi
leaq 0xe21c(%rip), %rdi      # 0x1123b
movb $0x0, %al
callq 0x44a0
callq 0x20a0
movl $0x0, (%rax)
jmp 0x3045
movq -0x20(%rbp), %rsi
leaq 0xe1fd(%rip), %rdi      # 0x1123b
movb $0x0, %al
callq 0x46f0
jmp 0x3047
jmp 0x3245
movq -0x28(%rbp), %rdi
callq 0x2270
movl %eax, %edi
leaq -0xb8(%rbp), %rsi
callq 0x23b0
cmpl $0x0, %eax
je 0x30ac
jmp 0x306a
callq 0x20a0
cmpl $0x0, (%rax)
je 0x3093
movq -0x20(%rbp), %rsi
leaq 0xe1c6(%rip), %rdi      # 0x11245
movb $0x0, %al
callq 0x44a0
callq 0x20a0
movl $0x0, (%rax)
jmp 0x30a5
movq -0x20(%rbp), %rsi
leaq 0xe1a7(%rip), %rdi      # 0x11245
movb $0x0, %al
callq 0x46f0
jmp 0x30a7
jmp 0x31fc
movl -0xa0(%rbp), %eax
andl $0xf000, %eax           # imm = 0xF000
cmpl $0x8000, %eax           # imm = 0x8000
je 0x30e2
jmp 0x30c0
movq -0x20(%rbp), %rsi
leaq 0xe184(%rip), %rdi      # 0x1124f
movb $0x0, %al
callq 0x46f0
callq 0x20a0
movl $0x0, (%rax)
jmp 0x31fc
cmpq $0xff, -0x88(%rbp)
jle 0x311a
jmp 0x30f1
movq -0x88(%rbp), %rsi
movq -0x20(%rbp), %rdx
leaq 0xe163(%rip), %rdi      # 0x11266
movb $0x0, %al
callq 0x46f0
callq 0x20a0
movl $0x0, (%rax)
jmp 0x31fc
leaq -0x1c0(%rbp), %rdi
movq -0x88(%rbp), %rsi
movq -0x28(%rbp), %rcx
movl $0x1, %edx
callq 0x20d0
cmpq $0x1, %rax
je 0x317d
jmp 0x313e
callq 0x20a0
cmpl $0x0, (%rax)
je 0x3167
movq -0x20(%rbp), %rsi
leaq 0xe135(%rip), %rdi      # 0x11288
movb $0x0, %al
callq 0x44a0
callq 0x20a0
movl $0x0, (%rax)
jmp 0x3179
movq -0x20(%rbp), %rsi
leaq 0xe116(%rip), %rdi      # 0x11288
movb $0x0, %al
callq 0x46f0
jmp 0x317b
jmp 0x31fc
leaq -0x1c0(%rbp), %rdi
movq -0x88(%rbp), %rsi
callq 0x4930
movq %rax, -0x1c8(%rbp)
cmpq $0x0, %rax
jne 0x319f
jmp 0x31fc
movq -0x28(%rbp), %rdi
callq 0x2120
cmpl $0x0, %eax
je 0x31e6
jmp 0x31af
callq 0x20a0
cmpl $0x0, (%rax)
je 0x31d4
leaq 0xe0d2(%rip), %rdi      # 0x11292
movb $0x0, %al
callq 0x44a0
callq 0x20a0
movl $0x0, (%rax)
jmp 0x31e2
leaq 0xe0b7(%rip), %rdi      # 0x11292
movb $0x0, %al
callq 0x46f0
jmp 0x31e4
jmp 0x31e6
movq -0x20(%rbp), %rdi
callq 0x2040
movq -0x1c8(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0x3256
movq -0x28(%rbp), %rdi
callq 0x2120
cmpl $0x0, %eax
je 0x3243
jmp 0x320c
callq 0x20a0
cmpl $0x0, (%rax)
je 0x3231
leaq 0xe075(%rip), %rdi      # 0x11292
movb $0x0, %al
callq 0x44a0
callq 0x20a0
movl $0x0, (%rax)
jmp 0x323f
leaq 0xe05a(%rip), %rdi      # 0x11292
movb $0x0, %al
callq 0x46f0
jmp 0x3241
jmp 0x3243
jmp 0x3245
movq -0x20(%rbp), %rdi
callq 0x2040
movq $0x0, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x1d0, %rsp            # imm = 0x1D0
popq %rbp
retq
nopw %cs:(%rax,%rax)
nopl (%rax)