#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;
  scalar_t__ rx_buf;
};
typedef void *__u8;
typedef scalar_t__ __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_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.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_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    -0x60(%rbp),%rdi
xor    %esi,%esi
mov    $0x30,%edx
call   1030 <memset@plt>
mov    -0x10(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x40(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,-0x48(%rbp)
mov    -0x28(%rbp),%rax
mov    %rax,-0x50(%rbp)
mov    -0x2c(%rbp),%eax
mov    %eax,-0x58(%rbp)
mov    0x10(%rbp),%rax
mov    %rax,-0x60(%rbp)
mov    -0x4(%rbp),%eax
mov    %eax,-0x64(%rbp)
mov    $0x1,%edi
call   1040 <SPI_IOC_MESSAGE@plt>
mov    -0x64(%rbp),%edi
mov    %eax,%esi
lea    -0x60(%rbp),%rdx
call   1050 <ioctl@plt>
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<spi_transfer_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
lea    0x8(%rsp),%rdi
xor    %esi,%esi
mov    $0x30,%edx
call   1030 <memset@plt>
mov    %rbp,0x30(%rsp)
mov    %rbx,0x28(%rsp)
mov    %r12,0x20(%rsp)
mov    %r15,0x18(%rsp)
mov    %r14d,0x10(%rsp)
mov    0x70(%rsp),%rax
mov    %rax,0x8(%rsp)
mov    $0x1,%edi
call   1040 <SPI_IOC_MESSAGE@plt>
mov    %r13d,%edi
mov    %eax,%esi
lea    0x8(%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*, i64 }
define i32 @spi_transfer_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 48)
%17 = load i8*, i8** %9
%18 = ptrtoint i8* %17 to i64
%19 = getelementptr inbounds %struct.spi_ioc_transfer, %struct.spi_ioc_transfer* %15, i32 0, i32 5
store i64 %18, i64* %19
%20 = load i8*, i8** %10
%21 = getelementptr inbounds %struct.spi_ioc_transfer, %struct.spi_ioc_transfer* %15, i32 0, i32 4
store i8* %20, i8** %21
%22 = load i8*, i8** %11
%23 = getelementptr inbounds %struct.spi_ioc_transfer, %struct.spi_ioc_transfer* %15, i32 0, i32 3
store i8* %22, i8** %23
%24 = load i8*, i8** %12
%25 = getelementptr inbounds %struct.spi_ioc_transfer, %struct.spi_ioc_transfer* %15, i32 0, i32 2
store i8* %24, i8** %25
%26 = load i32, i32* %13
%27 = getelementptr inbounds %struct.spi_ioc_transfer, %struct.spi_ioc_transfer* %15, i32 0, i32 1
store i32 %26, i32* %27
%28 = load i8*, i8** %14
%29 = getelementptr inbounds %struct.spi_ioc_transfer, %struct.spi_ioc_transfer* %15, i32 0, i32 0
store i8* %28, i8** %29
%30 = load i32, i32* %8
%31 = call i32 @SPI_IOC_MESSAGE(i32 1)
%32 = call i32 @ioctl(i32 %30, i32 %31, %struct.spi_ioc_transfer* %15)
ret i32 %32
}

LLVM IR (-O2):
%struct.spi_ioc_transfer = type { i8*, i32, i8*, i8*, i8*, i64 }
define i32 @spi_transfer_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 48)
%11 = ptrtoint i8* %1 to i64
%12 = getelementptr inbounds %struct.spi_ioc_transfer, %struct.spi_ioc_transfer* %8, i64 0, i32 5
store i64 %11, i64* %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
}