#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 spi_ioc_transfer {
  void *cs_change;
  int /*<<< orphan*/ delay_usecs;
  void *speed_hz;
  void *bits_per_word;
  void *len;
  void *rx_buf;
  void *tx_buf;
};
typedef void *__u8;
typedef void *__u64;
typedef void *__u32;
typedef int /*<<< orphan*/ __u16;

/* Variables and functions */
int /*<<< orphan*/ SPI_IOC_MESSAGE(int);
int ioctl(int, int /*<<< orphan*/, struct spi_ioc_transfer *);
int /*<<< orphan*/ memset(struct spi_ioc_transfer *, int /*<<< orphan*/, int);
int spi_transfer_tx_rx_1(int fd, void *buff, __u32 buff_len, __u8 bits,
                         __u32 speed, __u16 delay, __u8 cs_change) {
  struct spi_ioc_transfer tran;
  memset(&tran, 0, sizeof(struct spi_ioc_transfer));
  tran.tx_buf = (__u64)buff;
  tran.rx_buf = (__u64)buff;
  tran.len = buff_len;
  tran.bits_per_word = bits;
  tran.speed_hz = speed;
  tran.delay_usecs = delay;
  tran.cs_change = cs_change;
  return ioctl(fd, SPI_IOC_MESSAGE(1), &tran);
}


x86 assembly (clang, -O0):
<spi_transfer_tx_rx_1>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
mov    0x10(%rbp),%rax
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
mov    %r9d,-0x2c(%rbp)
lea    -0x68(%rbp),%rdi
xor    %esi,%esi
mov    $0x38,%edx
call   1030 <memset@plt>
mov    -0x10(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x40(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x48(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,-0x50(%rbp)
mov    -0x28(%rbp),%rax
mov    %rax,-0x58(%rbp)
mov    -0x2c(%rbp),%eax
mov    %eax,-0x60(%rbp)
mov    0x10(%rbp),%rax
mov    %rax,-0x68(%rbp)
mov    -0x4(%rbp),%eax
mov    %eax,-0x6c(%rbp)
mov    $0x1,%edi
call   1040 <SPI_IOC_MESSAGE@plt>
mov    -0x6c(%rbp),%edi
mov    %eax,%esi
lea    -0x68(%rbp),%rdx
call   1050 <ioctl@plt>
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<spi_transfer_tx_rx_1>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x38,%rsp
mov    %r9d,%r14d
mov    %r8,%r15
mov    %rcx,%r12
mov    %rdx,%rbx
mov    %rsi,%rbp
mov    %edi,%r13d
mov    %rsp,%rdi
xor    %esi,%esi
mov    $0x38,%edx
call   1030 <memset@plt>
mov    %rbp,0x30(%rsp)
mov    %rbp,0x28(%rsp)
mov    %rbx,0x20(%rsp)
mov    %r12,0x18(%rsp)
mov    %r15,0x10(%rsp)
mov    %r14d,0x8(%rsp)
mov    0x70(%rsp),%rax
mov    %rax,(%rsp)
mov    $0x1,%edi
call   1040 <SPI_IOC_MESSAGE@plt>
mov    %r13d,%edi
mov    %eax,%esi
mov    %rsp,%rdx
call   1050 <ioctl@plt>
add    $0x38,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.spi_ioc_transfer = type { i8*, i32, i8*, i8*, i8*, i8*, i8* }
define i32 @spi_transfer_tx_rx_1(i32 %0, i8* %1, i8* %2, i8* %3, i8* %4, i32 %5, i8* %6) {
%8 = alloca i32
%9 = alloca i8*
%10 = alloca i8*
%11 = alloca i8*
%12 = alloca i8*
%13 = alloca i32
%14 = alloca i8*
%15 = alloca %struct.spi_ioc_transfer
store i32 %0, i32* %8
store i8* %1, i8** %9
store i8* %2, i8** %10
store i8* %3, i8** %11
store i8* %4, i8** %12
store i32 %5, i32* %13
store i8* %6, i8** %14
%16 = call i32 @memset(%struct.spi_ioc_transfer* %15, i32 0, i32 56)
%17 = load i8*, i8** %9
%18 = getelementptr inbounds %struct.spi_ioc_transfer, %struct.spi_ioc_transfer* %15, i32 0, i32 6
store i8* %17, i8** %18
%19 = load i8*, i8** %9
%20 = getelementptr inbounds %struct.spi_ioc_transfer, %struct.spi_ioc_transfer* %15, i32 0, i32 5
store i8* %19, i8** %20
%21 = load i8*, i8** %10
%22 = getelementptr inbounds %struct.spi_ioc_transfer, %struct.spi_ioc_transfer* %15, i32 0, i32 4
store i8* %21, i8** %22
%23 = load i8*, i8** %11
%24 = getelementptr inbounds %struct.spi_ioc_transfer, %struct.spi_ioc_transfer* %15, i32 0, i32 3
store i8* %23, i8** %24
%25 = load i8*, i8** %12
%26 = getelementptr inbounds %struct.spi_ioc_transfer, %struct.spi_ioc_transfer* %15, i32 0, i32 2
store i8* %25, i8** %26
%27 = load i32, i32* %13
%28 = getelementptr inbounds %struct.spi_ioc_transfer, %struct.spi_ioc_transfer* %15, i32 0, i32 1
store i32 %27, i32* %28
%29 = load i8*, i8** %14
%30 = getelementptr inbounds %struct.spi_ioc_transfer, %struct.spi_ioc_transfer* %15, i32 0, i32 0
store i8* %29, i8** %30
%31 = load i32, i32* %8
%32 = call i32 @SPI_IOC_MESSAGE(i32 1)
%33 = call i32 @ioctl(i32 %31, i32 %32, %struct.spi_ioc_transfer* %15)
ret i32 %33
}

LLVM IR (-O2):
%struct.spi_ioc_transfer = type { i8*, i32, i8*, i8*, i8*, i8*, i8* }
define i32 @spi_transfer_tx_rx_1(i32 %0, i8* %1, i8* %2, i8* %3, i8* %4, i32 %5, i8* %6) {
%8 = alloca %struct.spi_ioc_transfer
%9 = bitcast %struct.spi_ioc_transfer* %8 to i8*
%10 = call i32 @memset(%struct.spi_ioc_transfer* %8, i32 0, i32 56)
%11 = getelementptr inbounds %struct.spi_ioc_transfer, %struct.spi_ioc_transfer* %8, i64 0, i32 6
store i8* %1, i8** %11
%12 = getelementptr inbounds %struct.spi_ioc_transfer, %struct.spi_ioc_transfer* %8, i64 0, i32 5
store i8* %1, i8** %12
%13 = getelementptr inbounds %struct.spi_ioc_transfer, %struct.spi_ioc_transfer* %8, i64 0, i32 4
store i8* %2, i8** %13
%14 = getelementptr inbounds %struct.spi_ioc_transfer, %struct.spi_ioc_transfer* %8, i64 0, i32 3
store i8* %3, i8** %14
%15 = getelementptr inbounds %struct.spi_ioc_transfer, %struct.spi_ioc_transfer* %8, i64 0, i32 2
store i8* %4, i8** %15
%16 = getelementptr inbounds %struct.spi_ioc_transfer, %struct.spi_ioc_transfer* %8, i64 0, i32 1
store i32 %5, i32* %16
%17 = getelementptr inbounds %struct.spi_ioc_transfer, %struct.spi_ioc_transfer* %8, i64 0, i32 0
store i8* %6, i8** %17
%18 = call i32 @SPI_IOC_MESSAGE(i32 1)
%19 = call i32 @ioctl(i32 %0, i32 %18, %struct.spi_ioc_transfer* %8)
ret i32 %19
}