// File: /workspace/github_c_makefile_star2_O3/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 %r14
pushq %rbx
subq $0x200, %rsp            # imm = 0x200
cmpl $0x5, %edi
jne 0x4ca0
movq %rsi, %rbx
movq 0x8(%rsi), %r14
leaq 0x9fa2(%rip), %rsi      # 0xeaf7
movq %r14, %rdi
callq 0x3150
testl %eax, %eax
je 0x4ba0
leaq 0x9f9f(%rip), %rsi      # 0xeb07
movq %r14, %rdi
callq 0x3150
testl %eax, %eax
je 0x4ba5
leaq 0x9f96(%rip), %rsi      # 0xeb11
movq %r14, %rdi
callq 0x3150
movb $0x10, %r14b
testl %eax, %eax
je 0x4ba8
movq 0x1245f(%rip), %rax     # 0x16ff0
movq (%rax), %rdi
leaq 0x9f7b(%rip), %rdx      # 0xeb16
jmp 0x4d16
xorl %r14d, %r14d
jmp 0x4ba8
movb $0x8, %r14b
movq 0x10(%rbx), %rdi
cmpb $0x78, (%rdi)
jne 0x4bbd
cmpb $0x31, 0x1(%rdi)
jne 0x4bbd
cmpb $0x0, 0x2(%rdi)
je 0x4bd5
leaq 0x9f71(%rip), %rsi      # 0xeb35
callq 0x3150
testl %eax, %eax
jne 0x4d05
orb $0x4, %r14b
movq 0x18(%rbx), %rax
cmpb $0x78, (%rax)
jne 0x4c8d
cmpb $0x31, 0x1(%rax)
jne 0x4bee
cmpb $0x0, 0x2(%rax)
je 0x4c12
cmpb $0x34, 0x1(%rax)
jne 0x4bfe
cmpb $0x0, 0x2(%rax)
je 0x4c87
cmpb $0x38, 0x1(%rax)
jne 0x4c8d
cmpb $0x0, 0x2(%rax)
jne 0x4c8d
orb $0x2, %r14b
movq 0x20(%rbx), %rbx
movq %rbx, %rdi
movl $0x2, %esi
xorl %eax, %eax
callq 0x31d0
testl %eax, %eax
js 0x4cb3
movl %eax, %ebp
movq %rsp, %rsi
movl %eax, %edi
callq 0x3eac
testl %eax, %eax
jne 0x4cb8
movzbl 0xb1(%rsp), %edx
movzbl %r14b, %r14d
leaq 0x9f3f(%rip), %rsi      # 0xeb8f
movl $0x1, %edi
movl %r14d, %ecx
xorl %eax, %eax
callq 0x31c0
movl %ebp, %edi
movl $0xb1, %esi
movl %r14d, %edx
callq 0x3f3a
testl %eax, %eax
jne 0x4cda
movl %ebp, %edi
callq 0x3100
xorl %eax, %eax
addq $0x200, %rsp            # imm = 0x200
popq %rbx
popq %r14
popq %rbp
retq
orb $0x1, %r14b
jmp 0x4c12
movq 0x1235c(%rip), %rax     # 0x16ff0
movq (%rax), %rdi
leaq 0x9ecd(%rip), %rdx      # 0xeb6b
jmp 0x4d16
movq 0x12349(%rip), %rax     # 0x16ff0
movq (%rax), %rdi
leaq 0x9deb(%rip), %rdx      # 0xea9c
jmp 0x4d16
callq 0x337f
movq 0x12331(%rip), %rax     # 0x16ff0
movq (%rax), %rdi
leaq 0x9a3c(%rip), %rdx      # 0xe705
movl $0x1, %esi
movq %rbx, %rcx
xorl %eax, %eax
callq 0x3240
jmp 0x4d22
movq 0x1230f(%rip), %rax     # 0x16ff0
movq (%rax), %rdi
leaq 0x9a6f(%rip), %rdx      # 0xe75a
movl $0x1, %esi
movl %r14d, %ecx
movl $0xb1, %r8d
movq %rbx, %r9
xorl %eax, %eax
callq 0x3240
jmp 0x4d22
movq 0x122e4(%rip), %rax     # 0x16ff0
movq (%rax), %rdi
leaq 0x9e26(%rip), %rdx      # 0xeb3c
movl $0x1, %esi
xorl %eax, %eax
callq 0x3240
movl $0x1, %edi
callq 0x3220