// File: /workspace/github_c_makefile_star2_O0/blasphemy[P]mmc-utils/mmc_cmds.c
// Function: set_partitioning_setting_completed
int set_partitioning_setting_completed(int dry_run, const char * const device,
		int fd)
{
	int ret;

	if (dry_run == 1) {
		fprintf(stderr, "NOT setting PARTITION_SETTING_COMPLETED\n");
		fprintf(stderr, "These changes will not take effect neither "
			"now nor after a power cycle\n");
		return 1;
	} else if (dry_run == 2) {
		printf("-c given, expecting more partition settings before "
			"writing PARTITION_SETTING_COMPLETED\n");
		return 0;
	}

	fprintf(stderr, "setting OTP PARTITION_SETTING_COMPLETED!\n");
	ret = write_extcsd_value(fd, EXT_CSD_PARTITION_SETTING_COMPLETED, 0x1);
	if (ret) {
		fprintf(stderr, "Could not write 0x1 to "
			"EXT_CSD[%d] in %s\n",
			EXT_CSD_PARTITION_SETTING_COMPLETED, device);
		return 1;
	}

	__u32 response;
	ret = send_status(fd, &response);
	if (ret) {
		fprintf(stderr, "Could not get response to SEND_STATUS "
			"from %s\n", device);
		return 1;
	}

	if (response & R1_SWITCH_ERROR) {
		fprintf(stderr, "Setting OTP PARTITION_SETTING_COMPLETED "
			"failed on %s\n", device);
		return 1;
	}

	fprintf(stderr, "Setting OTP PARTITION_SETTING_COMPLETED on "
		"%s SUCCESS\n", device);
	fprintf(stderr, "Device power cycle needed for settings to "
		"take effect.\n"
		"Confirm that PARTITION_SETTING_COMPLETED bit is set "
		"using 'extcsd read' after power cycle\n");

	return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movl %edi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl %edx, -0x14(%rbp)
cmpl $0x1, -0x8(%rbp)
jne 0x5a64
movq 0x155c1(%rip), %rax     # 0x1aff0
movq (%rax), %rdi
leaq 0xe2d9(%rip), %rsi      # 0x13d12
movb $0x0, %al
callq 0x3180
movq 0x155a9(%rip), %rax     # 0x1aff0
movq (%rax), %rdi
leaq 0xe2ea(%rip), %rsi      # 0x13d3b
movb $0x0, %al
callq 0x3180
movl $0x1, -0x4(%rbp)
jmp 0x5b8d
cmpl $0x2, -0x8(%rbp)
jne 0x5a84
leaq 0xe312(%rip), %rdi      # 0x13d83
movb $0x0, %al
callq 0x30c0
movl $0x0, -0x4(%rbp)
jmp 0x5b8d
jmp 0x5a86
movq 0x15563(%rip), %rax     # 0x1aff0
movq (%rax), %rdi
leaq 0xe344(%rip), %rsi      # 0x13ddb
movb $0x0, %al
callq 0x3180
movl -0x14(%rbp), %edi
movl $0x9b, %esi
movl $0x1, %edx
callq 0x3f30
movl %eax, -0x18(%rbp)
cmpl $0x0, -0x18(%rbp)
je 0x5ae6
movq 0x15530(%rip), %rax     # 0x1aff0
movq (%rax), %rdi
movq -0x10(%rbp), %rcx
leaq 0xe337(%rip), %rsi      # 0x13e05
movl $0x9b, %edx
movb $0x0, %al
callq 0x3180
movl $0x1, -0x4(%rbp)
jmp 0x5b8d
movl -0x14(%rbp), %edi
leaq -0x1c(%rbp), %rsi
callq 0x3fc0
movl %eax, -0x18(%rbp)
cmpl $0x0, -0x18(%rbp)
je 0x5b20
movq 0x154ee(%rip), %rax     # 0x1aff0
movq (%rax), %rdi
movq -0x10(%rbp), %rdx
leaq 0xe31f(%rip), %rsi      # 0x13e2f
movb $0x0, %al
callq 0x3180
movl $0x1, -0x4(%rbp)
jmp 0x5b8d
movl -0x1c(%rbp), %eax
andl $0x80, %eax
cmpl $0x0, %eax
je 0x5b52
movq 0x154bc(%rip), %rax     # 0x1aff0
movq (%rax), %rdi
movq -0x10(%rbp), %rdx
leaq 0xe31c(%rip), %rsi      # 0x13e5e
movb $0x0, %al
callq 0x3180
movl $0x1, -0x4(%rbp)
jmp 0x5b8d
movq 0x15497(%rip), %rax     # 0x1aff0
movq (%rax), %rdi
movq -0x10(%rbp), %rdx
leaq 0xe32d(%rip), %rsi      # 0x13e94
movb $0x0, %al
callq 0x3180
movq 0x1547b(%rip), %rax     # 0x1aff0
movq (%rax), %rdi
leaq 0xe34c(%rip), %rsi      # 0x13ecb
movb $0x0, %al
callq 0x3180
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x20, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)