// File: /workspace/github_c_makefile_star2_O2/Tarsnap[P]libcperciva/liball/../util/readpass_file.c
// Function: readpass_file
int
readpass_file(char ** passwd, const char * filename)
{
	FILE * f;
	char passbuf[MAXPASSLEN];

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

	/* Get a line from the file. */
	if ((fgets(passbuf, MAXPASSLEN, f)) == NULL) {
		if (ferror(f)) {
			warnp("fread(%s)", filename);
			goto err2;
		} else {
			/* We have a 0-byte password. */
			passbuf[0] = '\0';
		}
	}

	/* Bail if there's the line is too long, or if there's a second line. */
	if (fgetc(f) != EOF) {
		warn0("line too long, or more than 1 line in %s", filename);
		goto err2;
	}

	/* Close the file. */
	if (fclose(f)) {
		warnp("fclose(%s)", filename);
		goto err1;
	}

	/* Truncate at any newline character. */
	passbuf[strcspn(passbuf, "\r\n")] = '\0';

	/* Copy the password out. */
	if ((*passwd = strdup(passbuf)) == NULL) {
		warnp("Cannot allocate memory");
		goto err1;
	}

	/* Clean up. */
	insecure_memzero(passbuf, MAXPASSLEN);

	/* Success! */
	return (0);

err2:
	if (fclose(f))
		warnp("fclose");
err1:
	/* No harm in running this for all error paths. */
	insecure_memzero(passbuf, MAXPASSLEN);

	/* Failure! */
	return (-1);
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
subq $0x800, %rsp            # imm = 0x800
movq %rsi, %rbx
movq %rdi, %r15
leaq 0xcc7(%rip), %rsi       # 0x2028
movq %rbx, %rdi
callq 0x1140
testq %rax, %rax
je 0x13b1
movq %rax, %r14
movq %rsp, %rdi
movl $0x800, %esi            # imm = 0x800
movq %rax, %rdx
callq 0x1110
testq %rax, %rax
je 0x13c7
movq %r14, %rdi
callq 0x10d0
cmpl $-0x1, %eax
je 0x13fe
leaq 0xca4(%rip), %rdi       # 0x203e
movq %rbx, %rsi
xorl %eax, %eax
callq 0x1740
callq 0x1060
andl $0x0, (%rax)
jmp 0x14ab
callq 0x1060
cmpl $0x0, (%rax)
je 0x1435
movq %rax, %r14
leaq 0xc65(%rip), %rdi       # 0x202a
jmp 0x1422
movq %r14, %rdi
callq 0x1080
testl %eax, %eax
je 0x1441
callq 0x1060
cmpl $0x0, (%rax)
je 0x149a
movq %rax, %r15
leaq 0xc49(%rip), %rdi       # 0x2034
movq %rbx, %rsi
xorl %eax, %eax
callq 0x15b1
andl $0x0, (%r15)
jmp 0x14ab
movq %r14, %rdi
callq 0x10a0
testl %eax, %eax
je 0x144a
callq 0x1060
cmpl $0x0, (%rax)
je 0x14eb
movq %rax, %r14
leaq 0xc45(%rip), %rdi       # 0x2067
movq %rbx, %rsi
xorl %eax, %eax
callq 0x15b1
andl $0x0, (%r14)
jmp 0x14fc
leaq 0xbee(%rip), %rdi       # 0x202a
jmp 0x14f2
movb $0x0, (%rsp)
jmp 0x1386
leaq 0xc21(%rip), %rsi       # 0x2072
movq %rsp, %rbx
movq %rbx, %rdi
callq 0x1100
movb $0x0, (%rsp,%rax)
movq %rbx, %rdi
callq 0x1190
movq %rax, (%r15)
xorl %ebx, %ebx
testq %rax, %rax
jne 0x14ff
callq 0x1060
cmpl $0x0, (%rax)
je 0x1522
movq %rax, %rbx
leaq 0xbe7(%rip), %rdi       # 0x2075
xorl %eax, %eax
callq 0x15b1
andl $0x0, (%rbx)
jmp 0x14fc
leaq 0xb93(%rip), %rdi       # 0x2034
movq %rbx, %rsi
xorl %eax, %eax
callq 0x1740
movq %r14, %rdi
callq 0x10a0
pushq $-0x1
popq %rbx
testl %eax, %eax
je 0x14ff
callq 0x1060
cmpl $0x0, (%rax)
je 0x14db
movq %rax, %r14
leaq 0xbbe(%rip), %rdi       # 0x208c
xorl %eax, %eax
callq 0x15b1
andl $0x0, (%r14)
jmp 0x14ff
leaq 0xbaa(%rip), %rdi       # 0x208c
xorl %eax, %eax
callq 0x1740
jmp 0x14ff
leaq 0xb75(%rip), %rdi       # 0x2067
movq %rbx, %rsi
xorl %eax, %eax
callq 0x1740
pushq $-0x1
popq %rbx
leaq 0x2be2(%rip), %rax      # 0x40e8
movq (%rax), %rax
movq %rsp, %rdi
movl $0x800, %esi            # imm = 0x800
callq *%rax
movl %ebx, %eax
addq $0x800, %rsp            # imm = 0x800
popq %rbx
popq %r14
popq %r15
retq
leaq 0xb4c(%rip), %rdi       # 0x2075
xorl %eax, %eax
callq 0x1740
jmp 0x14fc
nop