// File: /workspace/github_c_makefile_star2_O3/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 $0x408, %rsp            # imm = 0x408
movq %rdx, %rbx
movq %rsi, %r14
movq %rdi, %r12
xorl %eax, %eax
movq %rax, (%rdx)
movq %rax, (%rsi)
leaq 0xdbd7(%rip), %rsi      # 0x119ac
callq 0x3440
testq %rax, %rax
je 0x3eeb
movq %rax, %r15
movq %rsp, %rdi
movl $0x400, %esi            # imm = 0x400
movq %rax, %rdx
callq 0x3560
testq %rax, %rax
je 0x3f5e
leaq 0xdfac(%rip), %r13      # 0x11db2
movq %rsp, %rbp
movq %rbp, %rdi
movq %r13, %rsi
callq 0x3070
cmpb $0x0, (%rsp,%rax)
je 0x3f42
movb $0x0, (%rsp,%rax)
movq %rbp, %rdi
movl $0x3d, %esi
callq 0x3160
testq %rax, %rax
je 0x3f2c
movq %rax, %rcx
incq %rax
movb $0x0, (%rcx)
movq (%rsp), %rcx
movabsq $0x4b5f535345434341, %rdx # imm = 0x4B5F535345434341
xorq %rdx, %rcx
movq 0x6(%rsp), %rdx
movabsq $0x44495f59454b5f, %rsi # imm = 0x44495F59454B5F
xorq %rsi, %rdx
orq %rcx, %rdx
je 0x3eb2
movzwl 0x10(%rsp), %ecx
movd %ecx, %xmm0
pcmpeqb 0xd336(%rip), %xmm0     # 0x111b0
movdqa (%rsp), %xmm1
pcmpeqb 0xd319(%rip), %xmm1     # 0x111a0
pand %xmm0, %xmm1
pmovmskb %xmm1, %ecx
cmpl $0xffff, %ecx           # imm = 0xFFFF
jne 0x3f2c
cmpq $0x0, (%rbx)
jne 0x3fde
movq %rax, %rdi
callq 0x35e0
movq %rax, (%rbx)
jmp 0x3ec7
cmpq $0x0, (%r14)
jne 0x3fe7
movq %rax, %rdi
callq 0x35e0
movq %rax, (%r14)
testq %rax, %rax
je 0x4000
movq %rbp, %rdi
movl $0x400, %esi            # imm = 0x400
movq %r15, %rdx
callq 0x3560
testq %rax, %rax
jne 0x3e09
jmp 0x3f5e
callq 0x3040
cmpl $0x0, (%rax)
je 0x3f11
movq %rax, %rbx
leaq 0xd2c1(%rip), %rdi      # 0x111c0
movq %r12, %rsi
xorl %eax, %eax
callq 0x57b8
movl $0x0, (%rbx)
jmp 0x3f22
leaq 0xd2a8(%rip), %rdi      # 0x111c0
movq %r12, %rsi
xorl %eax, %eax
callq 0x58d7
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
jmp 0x4075
leaq 0xd338(%rip), %rdi      # 0x1126b
movq %r12, %rsi
xorl %eax, %eax
callq 0x58d7
jmp 0x3ff5
leaq 0xd281(%rip), %rdi      # 0x111ca
movq %r12, %rsi
xorl %eax, %eax
callq 0x58d7
callq 0x3040
movl $0x0, (%rax)
movq %r15, %rdi
callq 0x3600
testl %eax, %eax
je 0x3f92
callq 0x3040
cmpl $0x0, (%rax)
je 0x3fcb
movq %rax, %r13
leaq 0xd2ac(%rip), %rdi      # 0x1122a
movq %r12, %rsi
xorl %eax, %eax
callq 0x57b8
movl $0x0, (%r13)
jmp 0x4000
movq %r15, %rdi
callq 0x3370
testl %eax, %eax
jne 0x400c
cmpq $0x0, (%r14)
je 0x3fb0
xorl %ebp, %ebp
cmpq $0x0, (%rbx)
jne 0x4075
leaq 0xd28b(%rip), %rdi      # 0x11242
xorl %eax, %eax
callq 0x58d7
callq 0x3040
movl $0x0, (%rax)
jmp 0x403e
leaq 0xd258(%rip), %rdi      # 0x1122a
movq %r12, %rsi
xorl %eax, %eax
callq 0x58d7
jmp 0x4000
leaq 0xd223(%rip), %rdi      # 0x11208
jmp 0x3fee
leaq 0xd1fc(%rip), %rdi      # 0x111ea
xorl %eax, %eax
callq 0x58d7
callq 0x3040
movl $0x0, (%rax)
movq %r15, %rdi
callq 0x3370
testl %eax, %eax
je 0x403e
callq 0x3040
cmpl $0x0, (%rax)
je 0x4030
movq %rax, %r15
leaq 0xd21b(%rip), %rdi      # 0x1123b
xorl %eax, %eax
callq 0x57b8
movl $0x0, (%r15)
jmp 0x403e
leaq 0xd204(%rip), %rdi      # 0x1123b
xorl %eax, %eax
callq 0x58d7
movq (%r14), %rdi
callq 0x3450
movq (%rbx), %r14
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
testq %r14, %r14
je 0x4075
movq %r14, %rdi
callq 0x3190
leaq 0x14576(%rip), %rcx     # 0x185d8
movq (%rcx), %rcx
movq %r14, %rdi
movq %rax, %rsi
callq *%rcx
movq (%rbx), %rdi
callq 0x3450
movl %ebp, %eax
addq $0x408, %rsp            # imm = 0x408
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nopl (%rax)