// File: /workspace/github_c_makefile_star2_O0/blasphemy[P]mmc-utils/lsmmc.c
// Function: read_file
char *read_file(char *name)
{
	char line[4096];
	char *preparsed, *start = line;
	int len;
	FILE *f;

	f = fopen(name, "r");
	if (!f) {
		fprintf(stderr, "Could not open MMC/SD file '%s'.\n", name);
		return NULL;
	}

	preparsed = fgets(line, sizeof(line), f);
	if (!preparsed) {
		if (ferror(f))
			fprintf(stderr, "Could not read MMC/SD file '%s'.\n",
				name);
		else
			fprintf(stderr,
				"Could not read data from MMC/SD file '%s'.\n",
				name);

		if (fclose(f))
			fprintf(stderr, "Could not close MMC/SD file '%s'.\n",
				name);
		return NULL;
	}

	if (fclose(f)) {
		fprintf(stderr, "Could not close MMC/SD file '%s'.\n", name);
		return NULL;
	}

	line[sizeof(line) - 1] = '\0';
	len = strlen(line);

	while (len > 0 && isspace(line[len - 1]))
		len--;

	while (len > 0 && isspace(*start)) {
		start++;
		len--;
	}
	memmove(line, start, len);
	line[len] = '\0';

	return strdup(line);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x1040, %rsp           # imm = 0x1040
movq %rdi, -0x10(%rbp)
leaq -0x1010(%rbp), %rax
movq %rax, -0x1020(%rbp)
movq -0x10(%rbp), %rdi
leaq 0xceca(%rip), %rsi      # 0x17482
callq 0x3190
movq %rax, -0x1030(%rbp)
cmpq $0x0, -0x1030(%rbp)
jne 0xa5f7
movq 0x10a1b(%rip), %rax     # 0x1aff0
movq (%rax), %rdi
movq -0x10(%rbp), %rdx
leaq 0xca6a(%rip), %rsi      # 0x1704d
movb $0x0, %al
callq 0x3180
movq $0x0, -0x8(%rbp)
jmp 0xa800
leaq -0x1010(%rbp), %rdi
movq -0x1030(%rbp), %rdx
movl $0x1000, %esi           # imm = 0x1000
callq 0x3150
movq %rax, -0x1018(%rbp)
cmpq $0x0, -0x1018(%rbp)
jne 0xa6a9
movq -0x1030(%rbp), %rdi
callq 0x3070
cmpl $0x0, %eax
je 0xa653
movq 0x109b4(%rip), %rax     # 0x1aff0
movq (%rax), %rdi
movq -0x10(%rbp), %rdx
leaq 0xca25(%rip), %rsi      # 0x1706f
movb $0x0, %al
callq 0x3180
jmp 0xa66f
movq 0x10996(%rip), %rax     # 0x1aff0
movq (%rax), %rdi
movq -0x10(%rbp), %rdx
leaq 0xca29(%rip), %rsi      # 0x17091
movb $0x0, %al
callq 0x3180
movq -0x1030(%rbp), %rdi
callq 0x3090
cmpl $0x0, %eax
je 0xa69c
movq 0x10969(%rip), %rax     # 0x1aff0
movq (%rax), %rdi
movq -0x10(%rbp), %rdx
leaq 0xca28(%rip), %rsi      # 0x170bd
movb $0x0, %al
callq 0x3180
movq $0x0, -0x8(%rbp)
jmp 0xa800
movq -0x1030(%rbp), %rdi
callq 0x3090
cmpl $0x0, %eax
je 0xa6e3
movq 0x1092f(%rip), %rax     # 0x1aff0
movq (%rax), %rdi
movq -0x10(%rbp), %rdx
leaq 0xc9ee(%rip), %rsi      # 0x170bd
movb $0x0, %al
callq 0x3180
movq $0x0, -0x8(%rbp)
jmp 0xa800
movb $0x0, -0x11(%rbp)
leaq -0x1010(%rbp), %rdi
callq 0x30a0
movl %eax, -0x1024(%rbp)
xorl %eax, %eax
cmpl $0x0, -0x1024(%rbp)
movb %al, -0x1031(%rbp)
jle 0xa73e
callq 0x3270
movq (%rax), %rax
movl -0x1024(%rbp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
movsbl -0x1010(%rbp,%rcx), %ecx
movslq %ecx, %rcx
movzwl (%rax,%rcx,2), %eax
andl $0x2000, %eax           # imm = 0x2000
cmpl $0x0, %eax
setne %al
movb %al, -0x1031(%rbp)
movb -0x1031(%rbp), %al
testb $0x1, %al
jne 0xa74a
jmp 0xa75b
movl -0x1024(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x1024(%rbp)
jmp 0xa6f9
jmp 0xa75d
xorl %eax, %eax
cmpl $0x0, -0x1024(%rbp)
movb %al, -0x1032(%rbp)
jle 0xa798
callq 0x3270
movq (%rax), %rax
movq -0x1020(%rbp), %rcx
movsbl (%rcx), %ecx
movslq %ecx, %rcx
movzwl (%rax,%rcx,2), %eax
andl $0x2000, %eax           # imm = 0x2000
cmpl $0x0, %eax
setne %al
movb %al, -0x1032(%rbp)
movb -0x1032(%rbp), %al
testb $0x1, %al
jne 0xa7a4
jmp 0xa7c7
movq -0x1020(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x1020(%rbp)
movl -0x1024(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x1024(%rbp)
jmp 0xa75d
leaq -0x1010(%rbp), %rdi
movq -0x1020(%rbp), %rsi
movslq -0x1024(%rbp), %rdx
callq 0x31f0
movslq -0x1024(%rbp), %rax
movb $0x0, -0x1010(%rbp,%rax)
leaq -0x1010(%rbp), %rdi
callq 0x3260
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x1040, %rsp           # imm = 0x1040
popq %rbp
retq
nopl (%rax)