// File: /workspace/github_c_makefile_star2_O2/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
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x2078, %rsp           # imm = 0x2078
movq %rdi, %r14
pushq $0x20
popq %rdi
callq 0x2160
testq %rax, %rax
je 0x39bc
movq %rax, %rbx
cmpb $0x2d, (%r14)
jne 0x380a
cmpb $0x0, 0x1(%r14)
je 0x384c
leaq 0x887d(%rip), %rsi      # 0xc08e
movq %r14, %rdi
callq 0x2170
movq %rax, %r15
testq %rax, %rax
jne 0x3856
callq 0x2370
cmpl $0x0, (%rax)
je 0x390a
movq %rax, %r15
leaq 0x8b82(%rip), %rdi      # 0xc3bb
movq %r14, %rsi
xorl %eax, %eax
callq 0x955d
andl $0x0, (%r15)
jmp 0x39b4
movq 0xe795(%rip), %rax      # 0x11fe8
movq (%rax), %r15
leaq 0x8(%rsp), %r12
movq %r12, %rdi
callq 0x3e74
leaq 0x70(%rsp), %r13
pushq $0x1
popq %rbp
movl $0x2000, %edx           # imm = 0x2000
movq %r13, %rdi
movq %rbp, %rsi
movq %r15, %rcx
callq 0x2360
testq %rax, %rax
je 0x3893
movq %r12, %rdi
movq %r13, %rsi
movq %rax, %rdx
callq 0x3fde
jmp 0x386b
movq %r15, %rdi
callq 0x23e0
movq 0xe746(%rip), %r13      # 0x11fe8
movq (%r13), %rbp
testl %eax, %eax
je 0x38e4
cmpq %rbp, %r15
je 0x3947
movq %r15, %rdi
callq 0x23f0
testl %eax, %eax
je 0x3947
callq 0x2370
cmpl $0x0, (%rax)
je 0x3939
movq %rax, %r14
leaq 0x8b29(%rip), %rdi      # 0xc400
xorl %eax, %eax
callq 0x955d
andl $0x0, (%r14)
jmp 0x3947
callq 0x2370
movq %rax, %r12
movl (%rax), %eax
cmpq %rbp, %r15
je 0x3920
leaq 0x8aef(%rip), %rdi      # 0xc3e9
movq %r14, %rsi
testl %eax, %eax
je 0x3956
xorl %eax, %eax
callq 0x955d
jmp 0x3932
leaq 0x8aaa(%rip), %rdi      # 0xc3bb
movq %r14, %rsi
xorl %eax, %eax
callq 0x96ec
jmp 0x39b4
leaq 0x8aa9(%rip), %rdi      # 0xc3d0
testl %eax, %eax
je 0x395f
xorl %eax, %eax
callq 0x955d
andl $0x0, (%r12)
jmp 0x3966
leaq 0x8ac0(%rip), %rdi      # 0xc400
xorl %eax, %eax
callq 0x96ec
leaq 0x8(%rsp), %rsi
movq %rbx, %rdi
callq 0x40d0
jmp 0x39be
xorl %eax, %eax
callq 0x96ec
jmp 0x3966
xorl %eax, %eax
callq 0x96ec
cmpq (%r13), %r15
je 0x39a7
movq %r15, %rdi
callq 0x23f0
testl %eax, %eax
je 0x39a7
callq 0x2370
cmpl $0x0, (%rax)
je 0x3999
movq %rax, %r14
leaq 0x8a74(%rip), %rdi      # 0xc400
xorl %eax, %eax
callq 0x955d
andl $0x0, (%r14)
jmp 0x39a7
leaq 0x8a60(%rip), %rdi      # 0xc400
xorl %eax, %eax
callq 0x96ec
leaq 0x8(%rsp), %rsi
movq %rbx, %rdi
callq 0x40d0
movq %rbx, %rdi
callq 0x39d3
xorl %ebx, %ebx
movq %rbx, %rax
addq $0x2078, %rsp           # imm = 0x2078
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq