// File: /workspace/github_c_makefile_star2_O2/Tarsnap[P]kivaloo/liball/../libcperciva/aws/aws_readkeys.c
// Function: aws_readkeys
int
aws_readkeys(const char * fname, char ** key_id, char ** key_secret)
{
	FILE * f;
	char buf[1024];
	char * p;

	/* No keys yet. */
	*key_id = *key_secret = NULL;

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

	/* Read lines of up to 1024 characters. */
	while (fgets(buf, sizeof(buf), f) != NULL) {
		/* Find the first EOL character and truncate. */
		p = buf + strcspn(buf, "\r\n");
		if (*p == '\0') {
			warn0("Missing EOL in %s", fname);
			break;
		} else
			*p = '\0';

		/* Look for the first = character. */
		p = strchr(buf, '=');

		/* Missing separator? */
		if (p == NULL)
			goto err3;

		/* Replace separator with NUL and point p at the value. */
		*p++ = '\0';

		/* We should have ACCESS_KEY_ID or ACCESS_KEY_SECRET. */
		if (strcmp(buf, "ACCESS_KEY_ID") == 0) {
			/* Copy key ID string. */
			if (*key_id != NULL) {
				warn0("ACCESS_KEY_ID specified twice");
				goto err2;
			}
			if ((*key_id = strdup(p)) == NULL)
				goto err2;
		} else if (strcmp(buf, "ACCESS_KEY_SECRET") == 0) {
			/* Copy key secret string. */
			if (*key_secret != NULL) {
				warn0("ACCESS_KEY_SECRET specified twice");
				goto err2;
			}
			if ((*key_secret = strdup(p)) == NULL)
				goto err2;
		} else
			goto err3;
	}

	/* Check for error. */
	if (ferror(f)) {
		warnp("Error reading %s", fname);
		goto err2;
	}

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

	/* Check that we got the necessary keys. */
	if ((*key_id == NULL) || (*key_secret == NULL)) {
		warn0("Need ACCESS_KEY_ID and ACCESS_KEY_SECRET");
		goto err1;
	}

	/* Success! */
	return (0);

err3:
	warn0("Lines in %s must be ACCESS_KEY_(ID|SECRET)=...", fname);
err2:
	if (fclose(f))
		warnp("fclose");
err1:
	free(*key_id);
	if (*key_secret) {
		insecure_memzero(*key_secret, strlen(*key_secret));
		free(*key_secret);
	}
err0:
	/* Failure! */
	return (-1);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x428, %rsp            # imm = 0x428
movq %rdx, %rbx
movq %rsi, %r14
andq $0x0, (%rdx)
movq %rdi, %r12
andq $0x0, (%rsi)
leaq 0xccbf(%rip), %rsi      # 0x1097c
callq 0x3450
testq %rax, %rax
je 0x3dd2
movq %rax, %r15
movq %r12, 0x8(%rsp)
movq %r14, 0x10(%rsp)
leaq 0x20(%rsp), %r13
leaq 0xd09e(%rip), %rbp      # 0x10d82
pushq $0x3d
popq %r12
movq %rax, 0x18(%rsp)
movq %r13, %rdi
movl $0x400, %esi            # imm = 0x400
movq %r15, %rdx
callq 0x3570
testq %rax, %rax
je 0x3e41
movq %r13, %rdi
movq %rbp, %rsi
callq 0x3070
cmpb $0x0, 0x20(%rsp,%rax)
je 0x3e26
movb $0x0, 0x20(%rsp,%rax)
movq %r13, %rdi
movl %r12d, %esi
callq 0x3160
testq %rax, %rax
je 0x3df5
movq %rax, %r14
incq %r14
movb $0x0, (%rax)
movq %r13, %rdi
leaq 0xc469(%rip), %rsi      # 0x101b1
pushq $0xe
popq %rdx
callq 0x33a0
testl %eax, %eax
je 0x3d91
movq %r13, %rdi
leaq 0xc4d0(%rip), %rsi      # 0x1022e
pushq $0x12
popq %rdx
callq 0x33a0
testl %eax, %eax
jne 0x3df5
cmpq $0x0, (%rbx)
jne 0x3ea6
movq %r14, %rdi
callq 0x35f0
movq %rax, (%rbx)
testq %rax, %rax
jne 0x3ced
jmp 0x3ebc
movq %rbx, %r15
movq %rbp, %rbx
movl %r12d, %ebp
movq 0x10(%rsp), %r12
cmpq $0x0, (%r12)
jne 0x3f4d
movq %r14, %rdi
callq 0x35f0
movq %rax, (%r12)
testq %rax, %rax
movl %ebp, %r12d
movq %rbx, %rbp
movq %r15, %rbx
movq 0x18(%rsp), %r15
jne 0x3ced
jmp 0x3ebc
callq 0x3040
cmpl $0x0, (%rax)
je 0x3e0d
movq %rax, %rbx
leaq 0xc3af(%rip), %rdi      # 0x10195
movq %r12, %rsi
xorl %eax, %eax
callq 0x53ad
andl $0x0, (%rbx)
jmp 0x3e1e
leaq 0xc444(%rip), %rdi      # 0x10240
movq 0x8(%rsp), %rsi
xorl %eax, %eax
callq 0x553c
jmp 0x3eb4
leaq 0xc381(%rip), %rdi      # 0x10195
movq %r12, %rsi
xorl %eax, %eax
callq 0x553c
pushq $-0x1
popq %rbp
jmp 0x3f21
leaq 0xc372(%rip), %rdi      # 0x1019f
movq 0x8(%rsp), %rsi
xorl %eax, %eax
callq 0x553c
callq 0x3040
andl $0x0, (%rax)
movq %r15, %rdi
callq 0x3610
testl %eax, %eax
je 0x3e77
callq 0x3040
cmpl $0x0, (%rax)
je 0x3f35
movq %rax, %r14
leaq 0xc39a(%rip), %rdi      # 0x101ff
movq 0x8(%rsp), %rsi
xorl %eax, %eax
callq 0x53ad
andl $0x0, (%r14)
jmp 0x3ebc
movq %r15, %rdi
callq 0x3380
testl %eax, %eax
je 0x3f70
callq 0x3040
cmpl $0x0, (%rax)
movq 0x10(%rsp), %r15
jne 0x3ed7
leaq 0xc373(%rip), %rdi      # 0x10210
xorl %eax, %eax
callq 0x553c
jmp 0x3eec
leaq 0xc330(%rip), %rdi      # 0x101dd
xorl %eax, %eax
callq 0x553c
callq 0x3040
andl $0x0, (%rax)
movq %r15, %rdi
callq 0x3380
testl %eax, %eax
movq 0x10(%rsp), %r15
je 0x3eec
callq 0x3040
cmpl $0x0, (%rax)
je 0x3e96
movq %rax, %r14
leaq 0xc32f(%rip), %rdi      # 0x10210
xorl %eax, %eax
callq 0x53ad
andl $0x0, (%r14)
movq (%r15), %rdi
callq 0x3460
movq (%rbx), %r14
pushq $-0x1
popq %rbp
testq %r14, %r14
je 0x3f21
movq %r14, %rdi
callq 0x3190
leaq 0x146ca(%rip), %rcx     # 0x185d8
movq (%rcx), %rcx
movq %r14, %rdi
movq %rax, %rsi
callq *%rcx
movq (%rbx), %rdi
callq 0x3460
movl %ebp, %eax
addq $0x428, %rsp            # imm = 0x428
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0xc2c3(%rip), %rdi      # 0x101ff
movq 0x8(%rsp), %rsi
xorl %eax, %eax
callq 0x553c
jmp 0x3ebc
leaq 0xc26b(%rip), %rdi      # 0x101bf
xorl %eax, %eax
callq 0x553c
callq 0x3040
andl $0x0, (%rax)
movq %r15, %rbx
movq 0x18(%rsp), %r15
jmp 0x3ebc
movq 0x10(%rsp), %r15
cmpq $0x0, (%r15)
je 0x3f83
xorl %ebp, %ebp
cmpq $0x0, (%rbx)
jne 0x3f21
leaq 0xc28d(%rip), %rdi      # 0x10217
xorl %eax, %eax
callq 0x553c
callq 0x3040
andl $0x0, (%rax)
jmp 0x3eec
nop