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

	int dry_run = 1;
	int partition;
	char *device;

	if (nargs != 4) {
		fprintf(stderr,"Usage: mmc write_reliability set <-y|-n|-c> <partition> </path/to/mmcblkX>\n");
		exit(1);
	}

	if (!strcmp("-y", argv[1])) {
		dry_run = 0;
	} else if (!strcmp("-c", argv[1])) {
		dry_run = 2;
	}

	partition = strtol(argv[2], NULL, 10);
	device = argv[3];

	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);
	}

	/* assert not PARTITION_SETTING_COMPLETED */
	if (ext_csd[EXT_CSD_PARTITION_SETTING_COMPLETED])
	{
		printf(" Device is already partitioned\n");
		exit(1);
	}

	/* assert HS_CTRL_REL */
	if (!(ext_csd[EXT_CSD_WR_REL_PARAM] & HS_CTRL_REL)) {
		printf("Cannot set write reliability parameters, WR_REL_SET is "
				"read-only\n");
		exit(1);
	}

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

	printf("Done setting EXT_CSD_WR_REL_SET to 0x%02x on %s\n",
		value, device);

	if (set_partitioning_setting_completed(dry_run, device, fd))
		exit(1);

	return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
subq $0x208, %rsp            # imm = 0x208
cmpl $0x4, %edi
jne 0x5da6
movq %rsi, %rbx
movq 0x8(%rsi), %rcx
movzbl (%rcx), %edx
leal -0x2d(%rdx), %eax
negl %eax
cmpl $0x2d, %edx
jne 0x5ccd
movzbl 0x1(%rcx), %esi
subl $0x79, %esi
jne 0x5caf
movzbl 0x2(%rcx), %esi
negl %esi
testl %esi, %esi
je 0x5d9f
cmpb $0x2d, %dl
jne 0x5ccd
movzbl 0x1(%rcx), %eax
subl $0x63, %eax
jne 0x5ccb
movzbl 0x2(%rcx), %eax
negl %eax
xorl %ebp, %ebp
cmpl $0x1, %eax
adcl $0x1, %ebp
movq 0x10(%rbx), %rdi
xorl %esi, %esi
movl $0xa, %edx
callq 0x3180
movq %rax, %r15
movq 0x18(%rbx), %rbx
movq %rbx, %rdi
movl $0x2, %esi
xorl %eax, %eax
callq 0x31d0
testl %eax, %eax
js 0x5dc5
movl %eax, %r14d
movq %rsp, %rsi
movl %eax, %edi
callq 0x3eac
testl %eax, %eax
jne 0x5dca
cmpb $0x0, 0x9b(%rsp)
jne 0x5dec
testb $0x1, 0xa6(%rsp)
je 0x5df5
movl $0x1, %eax
movl %r15d, %ecx
shll %cl, %eax
orb 0xa7(%rsp), %al
movzbl %al, %r15d
movl %r14d, %edi
movl $0xa7, %esi
movl %r15d, %edx
callq 0x3f3a
testl %eax, %eax
jne 0x5e0a
leaq 0x969f(%rip), %rsi      # 0xf407
movl $0x1, %edi
movl %r15d, %edx
movq %rbx, %rcx
xorl %eax, %eax
callq 0x31c0
movl %ebp, %edi
movq %rbx, %rsi
movl %r14d, %edx
callq 0x5014
testl %eax, %eax
jne 0x5e33
xorl %eax, %eax
addq $0x208, %rsp            # imm = 0x208
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
xorl %ebp, %ebp
jmp 0x5cd5
movq 0x11243(%rip), %rax     # 0x16ff0
movq (%rax), %rdi
leaq 0x95c2(%rip), %rdx      # 0xf379
movl $0x1, %esi
xorl %eax, %eax
callq 0x3240
jmp 0x5e33
callq 0x33fd
movq 0x1121f(%rip), %rax     # 0x16ff0
movq (%rax), %rdi
leaq 0x892a(%rip), %rdx      # 0xe705
movl $0x1, %esi
movq %rbx, %rcx
xorl %eax, %eax
callq 0x3240
jmp 0x5e33
leaq 0x943b(%rip), %rsi      # 0xf22e
jmp 0x5dfc
leaq 0x95c9(%rip), %rsi      # 0xf3c5
movl $0x1, %edi
xorl %eax, %eax
callq 0x31c0
jmp 0x5e33
movq 0x111df(%rip), %rax     # 0x16ff0
movq (%rax), %rdi
leaq 0x893f(%rip), %rdx      # 0xe75a
movl $0x1, %esi
movl %r15d, %ecx
movl $0xa7, %r8d
movq %rbx, %r9
xorl %eax, %eax
callq 0x3240
movl $0x1, %edi
callq 0x3220