// File: /workspace/github_c_makefile_star2_O0/Tarsnap[P]spiped/perftests/standalone-enc/../../lib/proto/proto_crypt.c
// Function: proto_crypt_secret
struct proto_secret *
proto_crypt_secret(const char * filename)
{
	SHA256_CTX ctx;
	FILE * f;
	struct proto_secret * K;
	uint8_t buf[BUFSIZ];
	size_t lenread;

	/* Allocate a protocol secret structure. */
	if ((K = malloc(sizeof(struct proto_secret))) == NULL)
		goto err0;

	/* Open the file, or use stdin if requested. */
	if (strcmp(filename, STDIN_FILENAME) == 0) {
		f = stdin;
	} else if ((f = fopen(filename, "r")) == NULL) {
		warnp("Cannot open file: %s", filename);
		goto err1;
	}

	/* Initialize the SHA256 hash context. */
	SHA256_Init(&ctx);

	/* Read the file until we hit EOF. */
	while ((lenread = fread(buf, 1, BUFSIZ, f)) > 0)
		SHA256_Update(&ctx, buf, lenread);

	/* Did we hit EOF? */
	if (!feof(f)) {
		if (f == stdin) {
			warnp("Error reading from stdin");
		} else {
			warnp("Error reading file: %s", filename);
		}

		goto err2;
	}

	/* Close the file if it isn't stdin. */
	if ((f != stdin) && fclose(f))
		warnp("fclose");

	/* Compute the final hash and wipe context state. */
	SHA256_Final(K->K, &ctx);

	/* Success! */
	return (K);

err2:
	/* Close the file if it isn't stdin. */
	if ((f != stdin) && fclose(f))
		warnp("fclose");

	/* Wipe context state. */
	SHA256_Final(K->K, &ctx);
err1:
	proto_crypt_secret_free(K);
err0:
	/* Failure! */
	return (NULL);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20a0, %rsp           # imm = 0x20A0
movq %rdi, -0x10(%rbp)
movl $0x20, %edi
callq 0x2150
movq %rax, -0x88(%rbp)
cmpq $0x0, %rax
jne 0x4a0b
jmp 0x4c5e
movq -0x10(%rbp), %rdi
leaq 0x13a10(%rip), %rsi     # 0x18426
callq 0x2370
cmpl $0x0, %eax
jne 0x4a30
movq 0x1a5c1(%rip), %rax     # 0x1efe8
movq (%rax), %rax
movq %rax, -0x80(%rbp)
jmp 0x4a90
movq -0x10(%rbp), %rdi
leaq 0x13673(%rip), %rsi     # 0x180ae
callq 0x2160
movq %rax, -0x80(%rbp)
cmpq $0x0, %rax
jne 0x4a8e
jmp 0x4a4c
callq 0x2340
cmpl $0x0, (%rax)
je 0x4a75
movq -0x10(%rbp), %rsi
leaq 0x139c7(%rip), %rdi     # 0x18428
movb $0x0, %al
callq 0x14390
callq 0x2340
movl $0x0, (%rax)
jmp 0x4a87
movq -0x10(%rbp), %rsi
leaq 0x139a8(%rip), %rdi     # 0x18428
movb $0x0, %al
callq 0x145e0
jmp 0x4a89
jmp 0x4c52
jmp 0x4a90
leaq -0x78(%rbp), %rdi
callq 0x56b0
leaq -0x2090(%rbp), %rdi
movq -0x80(%rbp), %rcx
movl $0x1, %esi
movl $0x2000, %edx           # imm = 0x2000
callq 0x2330
movq %rax, -0x2098(%rbp)
cmpq $0x0, %rax
jbe 0x4ad9
leaq -0x2090(%rbp), %rsi
movq -0x2098(%rbp), %rdx
leaq -0x78(%rbp), %rdi
callq 0x5850
jmp 0x4a99
movq -0x80(%rbp), %rdi
callq 0x23b0
cmpl $0x0, %eax
jne 0x4b77
movq -0x80(%rbp), %rax
movq 0x1a4f2(%rip), %rcx     # 0x1efe8
cmpq (%rcx), %rax
jne 0x4b34
jmp 0x4afd
callq 0x2340
cmpl $0x0, (%rax)
je 0x4b22
leaq 0x1392f(%rip), %rdi     # 0x1843d
movb $0x0, %al
callq 0x14390
callq 0x2340
movl $0x0, (%rax)
jmp 0x4b30
leaq 0x13914(%rip), %rdi     # 0x1843d
movb $0x0, %al
callq 0x145e0
jmp 0x4b32
jmp 0x4b75
jmp 0x4b36
callq 0x2340
cmpl $0x0, (%rax)
je 0x4b5f
movq -0x10(%rbp), %rsi
leaq 0x1390b(%rip), %rdi     # 0x18456
movb $0x0, %al
callq 0x14390
callq 0x2340
movl $0x0, (%rax)
jmp 0x4b71
movq -0x10(%rbp), %rsi
leaq 0x138ec(%rip), %rdi     # 0x18456
movb $0x0, %al
callq 0x145e0
jmp 0x4b73
jmp 0x4b75
jmp 0x4beb
movq -0x80(%rbp), %rax
movq 0x1a466(%rip), %rcx     # 0x1efe8
cmpq (%rcx), %rax
je 0x4bce
movq -0x80(%rbp), %rdi
callq 0x23c0
cmpl $0x0, %eax
je 0x4bce
jmp 0x4b97
callq 0x2340
cmpl $0x0, (%rax)
je 0x4bbc
leaq 0x138c5(%rip), %rdi     # 0x1846d
movb $0x0, %al
callq 0x14390
callq 0x2340
movl $0x0, (%rax)
jmp 0x4bca
leaq 0x138aa(%rip), %rdi     # 0x1846d
movb $0x0, %al
callq 0x145e0
jmp 0x4bcc
jmp 0x4bce
movq -0x88(%rbp), %rdi
leaq -0x78(%rbp), %rsi
callq 0x5a20
movq -0x88(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0x4c66
movq -0x80(%rbp), %rax
movq 0x1a3f2(%rip), %rcx     # 0x1efe8
cmpq (%rcx), %rax
je 0x4c42
movq -0x80(%rbp), %rdi
callq 0x23c0
cmpl $0x0, %eax
je 0x4c42
jmp 0x4c0b
callq 0x2340
cmpl $0x0, (%rax)
je 0x4c30
leaq 0x13851(%rip), %rdi     # 0x1846d
movb $0x0, %al
callq 0x14390
callq 0x2340
movl $0x0, (%rax)
jmp 0x4c3e
leaq 0x13836(%rip), %rdi     # 0x1846d
movb $0x0, %al
callq 0x145e0
jmp 0x4c40
jmp 0x4c42
movq -0x88(%rbp), %rdi
leaq -0x78(%rbp), %rsi
callq 0x5a20
movq -0x88(%rbp), %rdi
callq 0x4c80
movq $0x0, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x20a0, %rsp           # imm = 0x20A0
popq %rbp
retq
nopw %cs:(%rax,%rax)