// File: /workspace/github_c_makefile_star2_O1/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 0xba3(%rip), %rsi       # 0x2028
movq %rbx, %rdi
callq 0x1140
testq %rax, %rax
je 0x14d8
movq %rax, %r14
movq %rsp, %rdi
movl $0x800, %esi            # imm = 0x800
movq %rax, %rdx
callq 0x1110
testq %rax, %rax
je 0x14f2
movq %r14, %rdi
callq 0x10d0
cmpl $-0x1, %eax
je 0x152c
leaq 0xb80(%rip), %rdi       # 0x203e
movq %rbx, %rsi
xorl %eax, %eax
callq 0x180f
callq 0x1060
movl $0x0, (%rax)
jmp 0x15df
callq 0x1060
cmpl $0x0, (%rax)
je 0x1566
movq %rax, %r14
leaq 0xb3a(%rip), %rdi       # 0x202a
jmp 0x1550
movq %r14, %rdi
callq 0x1080
testl %eax, %eax
je 0x1572
callq 0x1060
cmpl $0x0, (%rax)
je 0x15ce
movq %rax, %r15
leaq 0xb1e(%rip), %rdi       # 0x2034
movq %rbx, %rsi
xorl %eax, %eax
callq 0x16f0
movl $0x0, (%r15)
jmp 0x15df
movq %r14, %rdi
callq 0x10a0
testl %eax, %eax
je 0x157b
callq 0x1060
cmpl $0x0, (%rax)
je 0x1624
movq %rax, %r14
leaq 0xb17(%rip), %rdi       # 0x2067
movq %rbx, %rsi
xorl %eax, %eax
callq 0x16f0
movl $0x0, (%r14)
jmp 0x1635
leaq 0xabd(%rip), %rdi       # 0x202a
jmp 0x162b
movb $0x0, (%rsp)
jmp 0x14aa
leaq 0xaf0(%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 0x163a
callq 0x1060
cmpl $0x0, (%rax)
je 0x165d
movq %rax, %rbx
leaq 0xab6(%rip), %rdi       # 0x2075
xorl %eax, %eax
callq 0x16f0
movl $0x0, (%rbx)
jmp 0x1635
leaq 0xa5f(%rip), %rdi       # 0x2034
movq %rbx, %rsi
xorl %eax, %eax
callq 0x180f
movq %r14, %rdi
callq 0x10a0
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
testl %eax, %eax
je 0x163a
callq 0x1060
cmpl $0x0, (%rax)
je 0x1614
movq %rax, %r14
leaq 0xa88(%rip), %rdi       # 0x208c
xorl %eax, %eax
callq 0x16f0
movl $0x0, (%r14)
jmp 0x163a
leaq 0xa71(%rip), %rdi       # 0x208c
xorl %eax, %eax
callq 0x180f
jmp 0x163a
leaq 0xa3c(%rip), %rdi       # 0x2067
movq %rbx, %rsi
xorl %eax, %eax
callq 0x180f
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
leaq 0x2aa7(%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 0xa11(%rip), %rdi       # 0x2075
xorl %eax, %eax
callq 0x180f
jmp 0x1635
nopl (%rax)