// File: /workspace/github_c_makefile_star2_O3/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 0xb4d7
leaq 0x7fb0(%rip), %rdi      # 0x1341c
callq 0x878f
testq %rax, %rax
je 0xb4ee
movq %rax, %rbx
leaq 0x7f65(%rip), %rsi      # 0x133e5
movq %rax, %rdi
callq 0x3150
testl %eax, %eax
je 0xb51a
cmpb $0x53, (%rbx)
jne 0xb4a1
cmpb $0x44, 0x1(%rbx)
jne 0xb4a1
cmpb $0x0, 0x2(%rbx)
je 0xb51a
movq 0xbb48(%rip), %rax      # 0x16ff0
movq (%rax), %rdi
leaq 0x7fa6(%rip), %rdx      # 0x13458
xorl %r15d, %r15d
movl $0x1, %esi
movq %rbx, %rcx
xorl %eax, %eax
callq 0x3240
movl $0xffffffff, %r14d      # imm = 0xFFFFFFFF
xorl %r13d, %r13d
xorl %ebp, %ebp
xorl %r12d, %r12d
jmp 0xb5c3
movq 0xbb12(%rip), %rax      # 0x16ff0
movq (%rax), %rdi
movq 0x8(%r15), %rcx
leaq 0x7efd(%rip), %rdx      # 0x133e9
jmp 0xb503
movq 0xbafb(%rip), %rax      # 0x16ff0
movq (%rax), %rdi
movq 0x8(%r15), %rcx
leaq 0x7f1e(%rip), %rdx      # 0x13421
movl $0x1, %esi
xorl %eax, %eax
callq 0x3240
movl $0xffffffff, %r14d      # imm = 0xFFFFFFFF
jmp 0xb5eb
xorl %r14d, %r14d
cmpl $0x3, %ebp
ja 0xb5fd
movl %ebp, %ecx
leaq 0x64c1(%rip), %rdx      # 0x119f0
movslq (%rdx,%rcx,4), %rcx
addq %rdx, %rcx
jmpq *%rcx
leaq 0x7f2d(%rip), %rdi      # 0x1346c
callq 0x878f
testq %rax, %rax
je 0xb622
movq %rax, %rcx
jmp 0xb588
cmpb $0x53, (%rbx)
jne 0xb586
cmpb $0x44, 0x1(%rbx)
jne 0xb586
cmpb $0x0, 0x2(%rbx)
jne 0xb586
leaq 0x7f6d(%rip), %rdi      # 0x134d7
callq 0x878f
testq %rax, %rax
je 0xb672
movq %rax, %rbp
xorl %ecx, %ecx
xorl %r13d, %r13d
jmp 0xb5a9
testl %eax, %eax
je 0xb605
xorl %ecx, %ecx
xorl %r13d, %r13d
jmp 0xb5a7
leaq 0x7f84(%rip), %rdi      # 0x13518
callq 0x878f
testq %rax, %rax
je 0xb639
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 0xb32e
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 0xb4ca
leaq 0x7f08(%rip), %rdi      # 0x13514
callq 0x878f
testq %rax, %rax
je 0xb650
movq %rax, %r12
xorl %ecx, %ecx
xorl %r13d, %r13d
xorl %ebp, %ebp
jmp 0xb5ac
movq 0xb9c7(%rip), %rax      # 0x16ff0
movq (%rax), %rdi
movq 0x8(%r15), %rcx
leaq 0x7e39(%rip), %rdx      # 0x13470
jmp 0xb665
movq 0xb9b0(%rip), %rax      # 0x16ff0
movq (%rax), %rdi
movq 0x8(%r15), %rcx
leaq 0x7e53(%rip), %rdx      # 0x134a1
jmp 0xb665
movq 0xb999(%rip), %rax      # 0x16ff0
movq (%rax), %rdi
movq 0x8(%r15), %rcx
leaq 0x7eb7(%rip), %rdx      # 0x1351c
xorl %r15d, %r15d
movl $0x1, %esi
jmp 0xb4bd
movq 0xb977(%rip), %rax      # 0x16ff0
movq (%rax), %rdi
movq 0x8(%r15), %rcx
leaq 0x7e54(%rip), %rdx      # 0x134db
jmp 0xb665