// File: /workspace/github_c_makefile_star2_O3/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, %r15
movl $0x20, %edi
callq 0x2160
testq %rax, %rax
je 0x5c50
movq %rax, %rbx
cmpb $0x2d, (%r15)
jne 0x5a63
cmpb $0x0, 0x1(%r15)
je 0x5aa8
leaq 0x9624(%rip), %rsi      # 0xf08e
movq %r15, %rdi
callq 0x2170
movq %rax, %r14
testq %rax, %rax
jne 0x5ab2
callq 0x2370
cmpl $0x0, (%rax)
je 0x5b84
movq %rax, %r14
leaq 0x99d7(%rip), %rdi      # 0xf469
movq %r15, %rsi
xorl %eax, %eax
callq 0xc0bc
movl $0x0, (%r14)
jmp 0x5c34
movq 0xf539(%rip), %rax      # 0x14fe8
movq (%rax), %r14
leaq 0x8(%rsp), %rdi
callq 0x6138
leaq 0x70(%rsp), %rdi
movl $0x1, %esi
movl $0x2000, %edx           # imm = 0x2000
movq %r14, %rcx
callq 0x2360
testq %rax, %rax
je 0x5b0a
leaq 0x8(%rsp), %r12
leaq 0x70(%rsp), %r13
movq %r12, %rdi
movq %r13, %rsi
movq %rax, %rdx
callq 0x63d1
movl $0x1, %esi
movl $0x2000, %edx           # imm = 0x2000
movq %r13, %rdi
movq %r14, %rcx
callq 0x2360
testq %rax, %rax
jne 0x5ae2
movq %r14, %rdi
callq 0x23e0
movq 0xf4cf(%rip), %r13      # 0x14fe8
movq (%r13), %rbp
testl %eax, %eax
je 0x5b5e
cmpq %rbp, %r14
je 0x5bc4
movq %r14, %rdi
callq 0x23f0
testl %eax, %eax
je 0x5bc4
callq 0x2370
cmpl $0x0, (%rax)
je 0x5bb6
movq %rax, %r14
leaq 0x9960(%rip), %rdi      # 0xf4ae
xorl %eax, %eax
callq 0xc0bc
movl $0x0, (%r14)
jmp 0x5bc4
callq 0x2370
movq %rax, %r12
movl (%rax), %eax
cmpq %rbp, %r14
je 0x5b9a
leaq 0x9923(%rip), %rdi      # 0xf497
movq %r15, %rsi
testl %eax, %eax
je 0x5bd3
xorl %eax, %eax
callq 0xc0bc
jmp 0x5bac
leaq 0x98de(%rip), %rdi      # 0xf469
movq %r15, %rsi
xorl %eax, %eax
callq 0xc1db
jmp 0x5c34
leaq 0x98dd(%rip), %rdi      # 0xf47e
testl %eax, %eax
je 0x5bdc
xorl %eax, %eax
callq 0xc0bc
movl $0x0, (%r12)
jmp 0x5be3
leaq 0x98f1(%rip), %rdi      # 0xf4ae
xorl %eax, %eax
callq 0xc1db
leaq 0x8(%rsp), %rsi
movq %rbx, %rdi
callq 0x64c9
jmp 0x5c52
xorl %eax, %eax
callq 0xc1db
jmp 0x5be3
xorl %eax, %eax
callq 0xc1db
cmpq (%r13), %r14
je 0x5c27
movq %r14, %rdi
callq 0x23f0
testl %eax, %eax
je 0x5c27
callq 0x2370
cmpl $0x0, (%rax)
je 0x5c19
movq %rax, %r14
leaq 0x98a5(%rip), %rdi      # 0xf4ae
xorl %eax, %eax
callq 0xc0bc
movl $0x0, (%r14)
jmp 0x5c27
leaq 0x988e(%rip), %rdi      # 0xf4ae
xorl %eax, %eax
callq 0xc1db
leaq 0x8(%rsp), %rsi
movq %rbx, %rdi
callq 0x64c9
leaq 0xf99d(%rip), %rax      # 0x155d8
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