// File: /workspace/github_c_makefile_star2_O1/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 0xb558
leaq 0x7f32(%rip), %rdi      # 0x1342f
callq 0x8883
testq %rax, %rax
je 0xb5a7
movq %rax, %rbx
leaq 0x7ee3(%rip), %rsi      # 0x133f8
movq %rax, %rdi
callq 0x3150
movl %eax, %r12d
testl %eax, %eax
je 0xb56f
leaq 0x7eca(%rip), %rsi      # 0x133f5
movq %rbx, %rdi
callq 0x3150
testl %eax, %eax
je 0xb56f
movq 0xbab2(%rip), %rax      # 0x16ff0
movq (%rax), %rdi
leaq 0x7f23(%rip), %rdx      # 0x1346b
xorl %r15d, %r15d
movl $0x1, %esi
movq %rbx, %rcx
jmp 0xb6cf
movq 0xba91(%rip), %rax      # 0x16ff0
movq (%rax), %rdi
movq 0x8(%r15), %rcx
leaq 0x7e8f(%rip), %rdx      # 0x133fc
jmp 0xb5bc
xorl %r14d, %r14d
cmpl $0x3, %ebp
ja 0xb648
movl %ebp, %eax
leaq 0x647c(%rip), %rcx      # 0x11a00
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
leaq 0x7eeb(%rip), %rdi      # 0x1347f
callq 0x8883
testq %rax, %rax
je 0xb66d
movq %rax, %rcx
jmp 0xb60c
movq 0xba42(%rip), %rax      # 0x16ff0
movq (%rax), %rdi
movq 0x8(%r15), %rcx
leaq 0x7e78(%rip), %rdx      # 0x13434
movl $0x1, %esi
xorl %eax, %eax
callq 0x3240
movl $0xffffffff, %r14d      # imm = 0xFFFFFFFF
jmp 0xb70c
leaq 0x7e1b(%rip), %rsi      # 0x133f5
movq %rbx, %rdi
callq 0x3150
testl %eax, %eax
jne 0xb60a
leaq 0x7efd(%rip), %rdi      # 0x134ea
callq 0x8883
testq %rax, %rax
je 0xb69b
movq %rax, %rbp
xorl %ecx, %ecx
xorl %r13d, %r13d
jmp 0xb629
testl %r12d, %r12d
je 0xb650
xorl %ecx, %ecx
xorl %r13d, %r13d
jmp 0xb627
leaq 0x7f13(%rip), %rdi      # 0x1352b
callq 0x8883
testq %rax, %rax
je 0xb684
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 0xb3de
jmp 0xb6e4
xorl %r15d, %r15d
jmp 0xb6dc
leaq 0x7ed0(%rip), %rdi      # 0x13527
callq 0x8883
testq %rax, %rax
je 0xb6b2
movq %rax, %r12
xorl %ecx, %ecx
xorl %r13d, %r13d
xorl %ebp, %ebp
jmp 0xb62c
movq 0xb97c(%rip), %rax      # 0x16ff0
movq (%rax), %rdi
movq 0x8(%r15), %rcx
leaq 0x7e01(%rip), %rdx      # 0x13483
jmp 0xb6c7
movq 0xb965(%rip), %rax      # 0x16ff0
movq (%rax), %rdi
movq 0x8(%r15), %rcx
leaq 0x7e1b(%rip), %rdx      # 0x134b4
jmp 0xb6c7
movq 0xb94e(%rip), %rax      # 0x16ff0
movq (%rax), %rdi
movq 0x8(%r15), %rcx
leaq 0x7e3e(%rip), %rdx      # 0x134ee
jmp 0xb6c7
movq 0xb937(%rip), %rax      # 0x16ff0
movq (%rax), %rdi
movq 0x8(%r15), %rcx
leaq 0x7e68(%rip), %rdx      # 0x1352f
xorl %r15d, %r15d
movl $0x1, %esi
xorl %eax, %eax
callq 0x3240
movl $0xffffffff, %r14d      # imm = 0xFFFFFFFF
xorl %r13d, %r13d
xorl %ebp, %ebp
xorl %r12d, %r12d
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