// File: /workspace/github_c_makefile_star2_O2/blasphemy[P]mmc-utils/lsmmc.c
// Function: process_dir
int process_dir(struct config *config, enum REG_TYPE reg)
{
	char *type = NULL, *cid = NULL, *csd = NULL, *scr = NULL, *ext_csd = NULL;
	int ret = 0;

	if (chdir(config->dir) < 0) {
		fprintf(stderr,
			"MMC/SD information directory '%s' does not exist.\n",
			config->dir);
		return -1;
	}

	type = read_file("type");
	if (!type) {
		fprintf(stderr,
			"Could not read card interface type in directory '%s'.\n",
			config->dir);
		return -1;
	}

	if (strcmp(type, "MMC") && strcmp(type, "SD")) {
		fprintf(stderr, "Unknown type: '%s'\n", type);
		ret = -1;
		goto err;
	}

	switch (reg) {
	case CID:
		cid = read_file("cid");
		if (!cid) {
			fprintf(stderr,
				"Could not read card identity in directory '%s'.\n",
				config->dir);
			ret = -1;
			goto err;
		}
		break;
	case CSD:
		csd = read_file("csd");
		if (!csd) {
			fprintf(stderr,
				"Could not read card specific data in "
				"directory '%s'.\n", config->dir);
			ret = -1;
			goto err;
		}
		break;
	case SCR:
		if (!strcmp(type, "SD")) {
			scr = read_file("scr");
			if (!scr) {
				fprintf(stderr, "Could not read SD card "
					"configuration in directory '%s'.\n",
					config->dir);
				ret = -1;
				goto err;
			}
		}
		break;
	case EXT_CSD:
		if (!strcmp(type, "MMC")) {
			ext_csd = read_file("ext_csd");
			if (!ext_csd) {
				fprintf(stderr, "Could not read extra specific "
					"data in directory '%s'.\n",
					config->dir);
				ret = -1;
				goto err;
			}
		}
		break;
	default:
		goto err;
	}

	print_info(config, type, cid, csd, scr, ext_csd);

err:
	free(ext_csd);
	free(scr);
	free(csd);
	free(cid);
	free(type);

	return ret;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movl %esi, %ebp
movq %rdi, %r15
movq 0x8(%rdi), %rdi
callq 0x30b0
testl %eax, %eax
js 0xad03
leaq 0x87c0(%rip), %rdi      # 0x1345c
callq 0x8216
testq %rax, %rax
je 0xad1a
movq %rax, %rbx
leaq 0x8775(%rip), %rsi      # 0x13425
movq %rax, %rdi
callq 0x3150
testl %eax, %eax
je 0xad42
cmpb $0x53, (%rbx)
jne 0xacd1
cmpb $0x44, 0x1(%rbx)
jne 0xacd1
cmpb $0x0, 0x2(%rbx)
je 0xad42
movq 0xd318(%rip), %rax      # 0x17ff0
movq (%rax), %rdi
leaq 0x87b6(%rip), %rdx      # 0x13498
xorl %r15d, %r15d
pushq $0x1
popq %rsi
movq %rbx, %rcx
xorl %eax, %eax
callq 0x3250
pushq $-0x1
popq %r14
xorl %r13d, %r13d
xorl %ebp, %ebp
xorl %r12d, %r12d
jmp 0xadeb
movq 0xd2e6(%rip), %rax      # 0x17ff0
movq (%rax), %rdi
movq 0x8(%r15), %rcx
leaq 0x8711(%rip), %rdx      # 0x13429
jmp 0xad2f
movq 0xd2cf(%rip), %rax      # 0x17ff0
movq (%rax), %rdi
movq 0x8(%r15), %rcx
leaq 0x8732(%rip), %rdx      # 0x13461
pushq $0x1
popq %rsi
xorl %eax, %eax
callq 0x3250
pushq $-0x1
popq %r14
jmp 0xae13
xorl %r14d, %r14d
cmpl $0x3, %ebp
ja 0xae25
movl %ebp, %ecx
leaq 0x6cd9(%rip), %rdx      # 0x11a30
movslq (%rdx,%rcx,4), %rcx
addq %rdx, %rcx
jmpq *%rcx
leaq 0x8745(%rip), %rdi      # 0x134ac
callq 0x8216
testq %rax, %rax
je 0xae4a
movq %rax, %rcx
jmp 0xadb0
cmpb $0x53, (%rbx)
jne 0xadae
cmpb $0x44, 0x1(%rbx)
jne 0xadae
cmpb $0x0, 0x2(%rbx)
jne 0xadae
leaq 0x8785(%rip), %rdi      # 0x13517
callq 0x8216
testq %rax, %rax
je 0xae98
movq %rax, %rbp
xorl %ecx, %ecx
xorl %r13d, %r13d
jmp 0xadd1
testl %eax, %eax
je 0xae2d
xorl %ecx, %ecx
xorl %r13d, %r13d
jmp 0xadcf
leaq 0x879c(%rip), %rdi      # 0x13558
callq 0x8216
testq %rax, %rax
je 0xae61
movq %rax, %r13
xorl %ecx, %ecx
xorl %ebp, %ebp
xorl %r12d, %r12d
movq %r15, %rdi
movq %rbx, %rsi
movq %rcx, %r15
movq %rcx, %rdx
movq %r13, %rcx
movq %rbp, %r8
callq 0xab60
movq %r12, %rdi
callq 0x3030
movq %rbp, %rdi
callq 0x3030
movq %r13, %rdi
callq 0x3030
movq %r15, %rdi
callq 0x3030
movq %rbx, %rdi
callq 0x3030
movl %r14d, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
xorl %r15d, %r15d
jmp 0xacf6
leaq 0x8720(%rip), %rdi      # 0x13554
callq 0x8216
testq %rax, %rax
je 0xae78
movq %rax, %r12
xorl %ecx, %ecx
xorl %r13d, %r13d
xorl %ebp, %ebp
jmp 0xadd4
movq 0xd19f(%rip), %rax      # 0x17ff0
movq (%rax), %rdi
movq 0x8(%r15), %rcx
leaq 0x8651(%rip), %rdx      # 0x134b0
jmp 0xae8d
movq 0xd188(%rip), %rax      # 0x17ff0
movq (%rax), %rdi
movq 0x8(%r15), %rcx
leaq 0x866b(%rip), %rdx      # 0x134e1
jmp 0xae8d
movq 0xd171(%rip), %rax      # 0x17ff0
movq (%rax), %rdi
movq 0x8(%r15), %rcx
leaq 0x86cf(%rip), %rdx      # 0x1355c
xorl %r15d, %r15d
pushq $0x1
popq %rsi
jmp 0xaceb
movq 0xd151(%rip), %rax      # 0x17ff0
movq (%rax), %rdi
movq 0x8(%r15), %rcx
leaq 0x866e(%rip), %rdx      # 0x1351b
jmp 0xae8d