// File: /workspace/github_c_makefile_star2_O1/blasphemy[P]mmc-utils/mmc_cmds.c
// Function: do_boot_bus_conditions_set
int do_boot_bus_conditions_set(int nargs, char **argv)
{
	__u8 ext_csd[512];
	__u8 value = 0;
	int fd, ret;
	char *device;

	if (nargs != 5) {
		fprintf(stderr, "Usage: mmc: bootbus set <boot_mode> <reset_boot_bus_conditions> <boot_bus_width> <device>\n");
		exit(1);
	}

	if (strcmp(argv[1], "single_backward") == 0)
		value |= 0;
	else if (strcmp(argv[1], "single_hs") == 0)
		value |= 0x8;
	else if (strcmp(argv[1], "dual") == 0)
		value |= 0x10;
	else {
		fprintf(stderr, "illegal <boot_mode> specified\n");
		exit(1);
	}

	if (strcmp(argv[2], "x1") == 0)
		value |= 0;
	else if (strcmp(argv[2], "retain") == 0)
		value |= 0x4;
	else {
		fprintf(stderr,
			"illegal <reset_boot_bus_conditions> specified\n");
		exit(1);
	}

	if (strcmp(argv[3], "x1") == 0)
		value |= 0;
	else if (strcmp(argv[3], "x4") == 0)
		value |= 0x1;
	else if (strcmp(argv[3], "x8") == 0)
		value |= 0x2;
	else {
		fprintf(stderr,	"illegal <boot_bus_width> specified\n");
		exit(1);
	}

	device = argv[4];
	fd = open(device, O_RDWR);
	if (fd < 0) {
		perror("open");
		exit(1);
	}

	ret = read_extcsd(fd, ext_csd);
	if (ret) {
		fprintf(stderr, "Could not read EXT_CSD from %s\n", device);
		exit(1);
	}
	printf("Changing ext_csd[BOOT_BUS_CONDITIONS] from 0x%02x to 0x%02x\n",
		ext_csd[EXT_CSD_BOOT_BUS_CONDITIONS], value);

	ret = write_extcsd_value(fd, EXT_CSD_BOOT_BUS_CONDITIONS, value);
	if (ret) {
		fprintf(stderr, "Could not write 0x%02x to "
			"EXT_CSD[%d] in %s\n",
			value, EXT_CSD_BOOT_BUS_CONDITIONS, device);
		exit(1);
	}
	close(fd);
	return ret;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
subq $0x208, %rsp            # imm = 0x208
cmpl $0x5, %edi
jne 0x4cea
movq %rsi, %rbx
movq 0x8(%rsi), %r14
leaq 0x9f50(%rip), %rsi      # 0xeaf7
movq %r14, %rdi
callq 0x3150
testl %eax, %eax
je 0x4bf2
leaq 0x9f4d(%rip), %rsi      # 0xeb07
movq %r14, %rdi
callq 0x3150
testl %eax, %eax
je 0x4bf7
leaq 0x9f44(%rip), %rsi      # 0xeb11
movq %r14, %rdi
callq 0x3150
movb $0x10, %r15b
testl %eax, %eax
je 0x4bfa
movq 0x1240d(%rip), %rax     # 0x16ff0
movq (%rax), %rdi
leaq 0x9f29(%rip), %rdx      # 0xeb16
jmp 0x4d73
xorl %r15d, %r15d
jmp 0x4bfa
movb $0x8, %r15b
movq 0x10(%rbx), %r14
leaq 0x9f30(%rip), %rsi      # 0xeb35
movq %r14, %rdi
callq 0x3150
testl %eax, %eax
je 0x4c2c
leaq 0x9f20(%rip), %rsi      # 0xeb38
movq %r14, %rdi
callq 0x3150
testl %eax, %eax
jne 0x4d4f
orb $0x4, %r15b
movq 0x18(%rbx), %r14
leaq 0x9efe(%rip), %rsi      # 0xeb35
movq %r14, %rdi
callq 0x3150
testl %eax, %eax
je 0x4c77
leaq 0x9f24(%rip), %rsi      # 0xeb6e
movq %r14, %rdi
callq 0x3150
testl %eax, %eax
je 0x4c73
leaq 0x9f14(%rip), %rsi      # 0xeb71
movq %r14, %rdi
callq 0x3150
testl %eax, %eax
jne 0x4d62
orb $0x2, %r15b
jmp 0x4c77
orb $0x1, %r15b
movq 0x20(%rbx), %rbx
movq %rbx, %rdi
movl $0x2, %esi
xorl %eax, %eax
callq 0x31d0
testl %eax, %eax
js 0x4cfd
movl %eax, %ebp
movq %rsp, %rsi
movl %eax, %edi
callq 0x3ef8
testl %eax, %eax
jne 0x4d02
movzbl 0xb1(%rsp), %edx
movzbl %r15b, %r14d
leaq 0x9ee7(%rip), %rsi      # 0xeb98
movl $0x1, %edi
movl %r14d, %ecx
xorl %eax, %eax
callq 0x31c0
movl %ebp, %edi
movl $0xb1, %esi
movl %r14d, %edx
callq 0x3f8e
testl %eax, %eax
jne 0x4d24
movl %ebp, %edi
callq 0x3100
xorl %eax, %eax
addq $0x208, %rsp            # imm = 0x208
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
movq 0x122ff(%rip), %rax     # 0x16ff0
movq (%rax), %rdi
leaq 0x9da1(%rip), %rdx      # 0xea9c
jmp 0x4d73
callq 0x336b
movq 0x122e7(%rip), %rax     # 0x16ff0
movq (%rax), %rdi
leaq 0x99f2(%rip), %rdx      # 0xe705
movl $0x1, %esi
movq %rbx, %rcx
xorl %eax, %eax
callq 0x3240
jmp 0x4d7f
movq 0x122c5(%rip), %rax     # 0x16ff0
movq (%rax), %rdi
leaq 0x9a25(%rip), %rdx      # 0xe75a
movl $0x1, %esi
movl %r14d, %ecx
movl $0xb1, %r8d
movq %rbx, %r9
xorl %eax, %eax
callq 0x3240
jmp 0x4d7f
movq 0x1229a(%rip), %rax     # 0x16ff0
movq (%rax), %rdi
leaq 0x9ddf(%rip), %rdx      # 0xeb3f
jmp 0x4d73
movq 0x12287(%rip), %rax     # 0x16ff0
movq (%rax), %rdi
leaq 0x9e01(%rip), %rdx      # 0xeb74
movl $0x1, %esi
xorl %eax, %eax
callq 0x3240
movl $0x1, %edi
callq 0x3220