#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */
struct mmc_ioc_cmd {
  int write_flag;
  int opcode;
  int flags;
  int /*<<< orphan*/ arg;
};

/* Variables and functions */
int /*<<< orphan*/ build_cmd6_args(int /*<<< orphan*/, int, int, int);
int /*<<< orphan*/ memset(struct mmc_ioc_cmd *, int /*<<< orphan*/, int);
int send_cmd(int, struct mmc_ioc_cmd *);
int set_ext_csd(int fd, int offset, int value) {
  int ret = 0;
  int args = 0;
  struct mmc_ioc_cmd cmd;
  memset(&cmd, 0, sizeof(struct mmc_ioc_cmd));
  cmd.write_flag = 1;
  cmd.opcode = 6;
  cmd.arg = build_cmd6_args(0, value, offset, 0x3);
  cmd.flags = 0x049d;
  ret = send_cmd(fd, &cmd);
  return ret;
}


x86 assembly (clang, -O0):
<set_ext_csd>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
lea    -0x28(%rbp),%rdi
xor    %esi,%esi
mov    $0x10,%edx
call   1030 <memset@plt>
movl   $0x1,-0x28(%rbp)
movl   $0x6,-0x24(%rbp)
mov    -0xc(%rbp),%esi
mov    -0x8(%rbp),%edx
xor    %edi,%edi
mov    $0x3,%ecx
call   1040 <build_cmd6_args@plt>
mov    %eax,-0x1c(%rbp)
movl   $0x49d,-0x20(%rbp)
mov    -0x4(%rbp),%edi
lea    -0x28(%rbp),%rsi
call   1050 <send_cmd@plt>
mov    %eax,-0x10(%rbp)
mov    -0x10(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<set_ext_csd>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x18,%rsp
mov    %edx,%ebx
mov    %esi,%ebp
mov    %edi,%r14d
lea    0x8(%rsp),%r15
mov    %r15,%rdi
xor    %esi,%esi
mov    $0x10,%edx
call   1030 <memset@plt>
movabs $0x600000001,%rax
mov    %rax,0x8(%rsp)
xor    %edi,%edi
mov    %ebx,%esi
mov    %ebp,%edx
mov    $0x3,%ecx
call   1040 <build_cmd6_args@plt>
mov    %eax,0x14(%rsp)
movl   $0x49d,0x10(%rsp)
mov    %r14d,%edi
mov    %r15,%rsi
call   1050 <send_cmd@plt>
add    $0x18,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.mmc_ioc_cmd = type { i32, i32, i32, i32 }
define i32 @set_ext_csd(i32 %0, i32 %1, i32 %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca %struct.mmc_ioc_cmd
store i32 %0, i32* %4
store i32 %1, i32* %5
store i32 %2, i32* %6
store i32 0, i32* %7
store i32 0, i32* %8
%10 = call i32 @memset(%struct.mmc_ioc_cmd* %9, i32 0, i32 16)
%11 = getelementptr inbounds %struct.mmc_ioc_cmd, %struct.mmc_ioc_cmd* %9, i32 0, i32 0
store i32 1, i32* %11
%12 = getelementptr inbounds %struct.mmc_ioc_cmd, %struct.mmc_ioc_cmd* %9, i32 0, i32 1
store i32 6, i32* %12
%13 = load i32, i32* %6
%14 = load i32, i32* %5
%15 = call i32 @build_cmd6_args(i32 0, i32 %13, i32 %14, i32 3)
%16 = getelementptr inbounds %struct.mmc_ioc_cmd, %struct.mmc_ioc_cmd* %9, i32 0, i32 3
store i32 %15, i32* %16
%17 = getelementptr inbounds %struct.mmc_ioc_cmd, %struct.mmc_ioc_cmd* %9, i32 0, i32 2
store i32 1181, i32* %17
%18 = load i32, i32* %4
%19 = call i32 @send_cmd(i32 %18, %struct.mmc_ioc_cmd* %9)
store i32 %19, i32* %7
%20 = load i32, i32* %7
ret i32 %20
}

LLVM IR (-O2):
%struct.mmc_ioc_cmd = type { i32, i32, i32, i32 }
define i32 @set_ext_csd(i32 %0, i32 %1, i32 %2) {
%4 = alloca %struct.mmc_ioc_cmd
%5 = bitcast %struct.mmc_ioc_cmd* %4 to i8*
%6 = call i32 @memset(%struct.mmc_ioc_cmd* %4, i32 0, i32 16)
%7 = getelementptr inbounds %struct.mmc_ioc_cmd, %struct.mmc_ioc_cmd* %4, i64 0, i32 0
store i32 1, i32* %7
%8 = getelementptr inbounds %struct.mmc_ioc_cmd, %struct.mmc_ioc_cmd* %4, i64 0, i32 1
store i32 6, i32* %8
%9 = call i32 @build_cmd6_args(i32 0, i32 %2, i32 %1, i32 3)
%10 = getelementptr inbounds %struct.mmc_ioc_cmd, %struct.mmc_ioc_cmd* %4, i64 0, i32 3
store i32 %9, i32* %10
%11 = getelementptr inbounds %struct.mmc_ioc_cmd, %struct.mmc_ioc_cmd* %4, i64 0, i32 2
store i32 1181, i32* %11
%12 = call i32 @send_cmd(i32 %0, %struct.mmc_ioc_cmd* %4)
ret i32 %12
}