// File: /workspace/github_c_makefile_star2_O1/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
movl $0x20, %edi
callq 0x2160
testq %rax, %rax
je 0x3c17
movq %rax, %rbx
leaq 0x899a(%rip), %rsi      # 0xc3bb
movq %r14, %rdi
callq 0x23a0
testl %eax, %eax
je 0x3a72
leaq 0x865a(%rip), %rsi      # 0xc08e
movq %r14, %rdi
callq 0x2170
movq %rax, %r15
testq %rax, %rax
jne 0x3a7c
callq 0x2370
cmpl $0x0, (%rax)
je 0x3b6a
movq %rax, %r15
leaq 0x8961(%rip), %rdi      # 0xc3bd
movq %r14, %rsi
xorl %eax, %eax
callq 0x9f98
movl $0x0, (%r15)
jmp 0x3bfb
movq 0xe56f(%rip), %rax      # 0x11fe8
movq (%rax), %r15
leaq 0x8(%rsp), %rdi
callq 0x4100
leaq 0x70(%rsp), %rdi
movl $0x1, %esi
movl $0x2000, %edx           # imm = 0x2000
movq %r15, %rcx
callq 0x2360
testq %rax, %rax
je 0x3ad4
leaq 0x8(%rsp), %r12
leaq 0x70(%rsp), %r13
movq %r12, %rdi
movq %r13, %rsi
movq %rax, %rdx
callq 0x4392
movl $0x1, %esi
movl $0x2000, %edx           # imm = 0x2000
movq %r13, %rdi
movq %r15, %rcx
callq 0x2360
testq %rax, %rax
jne 0x3aac
movq %r15, %rdi
callq 0x23e0
movq 0xe505(%rip), %r13      # 0x11fe8
movq (%r13), %rbp
testl %eax, %eax
je 0x3b28
cmpq %rbp, %r15
je 0x3b8b
movq %r15, %rdi
callq 0x23f0
testl %eax, %eax
je 0x3b8b
callq 0x2370
cmpl $0x0, (%rax)
je 0x3b7d
movq %rax, %r14
leaq 0x88ea(%rip), %rdi      # 0xc402
xorl %eax, %eax
callq 0x9f98
movl $0x0, (%r14)
jmp 0x3b8b
callq 0x2370
movq %rax, %r12
movl (%rax), %eax
cmpq %rbp, %r15
je 0x3b4e
leaq 0x88ad(%rip), %rdi      # 0xc3eb
movq %r14, %rsi
testl %eax, %eax
je 0x3b9a
xorl %eax, %eax
callq 0x9f98
jmp 0x3b60
leaq 0x887d(%rip), %rdi      # 0xc3d2
testl %eax, %eax
je 0x3ba3
xorl %eax, %eax
callq 0x9f98
movl $0x0, (%r12)
jmp 0x3baa
leaq 0x884c(%rip), %rdi      # 0xc3bd
movq %r14, %rsi
xorl %eax, %eax
callq 0xa0b7
jmp 0x3bfb
leaq 0x887e(%rip), %rdi      # 0xc402
xorl %eax, %eax
callq 0xa0b7
leaq 0x8(%rsp), %rsi
movq %rbx, %rdi
callq 0x448a
jmp 0x3c19
xorl %eax, %eax
callq 0xa0b7
jmp 0x3baa
xorl %eax, %eax
callq 0xa0b7
cmpq (%r13), %r15
je 0x3bee
movq %r15, %rdi
callq 0x23f0
testl %eax, %eax
je 0x3bee
callq 0x2370
cmpl $0x0, (%rax)
je 0x3be0
movq %rax, %r14
leaq 0x8832(%rip), %rdi      # 0xc402
xorl %eax, %eax
callq 0x9f98
movl $0x0, (%r14)
jmp 0x3bee
leaq 0x881b(%rip), %rdi      # 0xc402
xorl %eax, %eax
callq 0xa0b7
leaq 0x8(%rsp), %rsi
movq %rbx, %rdi
callq 0x448a
leaq 0xe9d6(%rip), %rax      # 0x125d8
movq (%rax), %rax
movl $0x20, %esi
movq %rbx, %rdi
callq *%rax
movq %rbx, %rdi
callq 0x2220
xorl %ebx, %ebx
movq %rbx, %rax
addq $0x2078, %rsp           # imm = 0x2078
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq