#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 {
  unsigned long tx_buf;
  unsigned long rx_buf;
  size_t len;
  int /*<<< orphan*/ delay_usecs;
};

/* Variables and functions */
int /*<<< orphan*/ SPI_IOC_MESSAGE(int);
int ioctl(int, int /*<<< orphan*/, struct spi_ioc_transfer *);
int spi_transfer(int fd, char *in, const char *out, size_t len) {
  struct spi_ioc_transfer transfer = {
      .tx_buf = (unsigned long)out,
      .rx_buf = (unsigned long)in,
      .len = len,
      .delay_usecs = 0,
  };
  return ioctl(fd, SPI_IOC_MESSAGE(1), &transfer);
}


x86 assembly (clang, -O0):
<spi_transfer>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x40(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,-0x30(%rbp)
movl   $0x0,-0x28(%rbp)
mov    -0x4(%rbp),%eax
mov    %eax,-0x44(%rbp)
mov    $0x1,%edi
call   1030 <SPI_IOC_MESSAGE@plt>
mov    -0x44(%rbp),%edi
mov    %eax,%esi
lea    -0x40(%rbp),%rdx
call   1040 <ioctl@plt>
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<spi_transfer>:
push   %rbx
sub    $0x20,%rsp
mov    %edi,%ebx
mov    %rdx,(%rsp)
mov    %rsi,0x8(%rsp)
mov    %rcx,0x10(%rsp)
movl   $0x0,0x18(%rsp)
mov    $0x1,%edi
call   1030 <SPI_IOC_MESSAGE@plt>
mov    %rsp,%rdx
mov    %ebx,%edi
mov    %eax,%esi
call   1040 <ioctl@plt>
add    $0x20,%rsp
pop    %rbx
ret

LLVM IR (-O0):
%struct.spi_ioc_transfer = type { i64, i64, i64, i32 }
define i32 @spi_transfer(i32 %0, i8* %1, i8* %2, i64 %3) {
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i64
%9 = alloca %struct.spi_ioc_transfer
store i32 %0, i32* %5
store i8* %1, i8** %6
store i8* %2, i8** %7
store i64 %3, i64* %8
%10 = getelementptr inbounds %struct.spi_ioc_transfer, %struct.spi_ioc_transfer* %9, i32 0, i32 0
%11 = load i8*, i8** %7
%12 = ptrtoint i8* %11 to i64
store i64 %12, i64* %10
%13 = getelementptr inbounds %struct.spi_ioc_transfer, %struct.spi_ioc_transfer* %9, i32 0, i32 1
%14 = load i8*, i8** %6
%15 = ptrtoint i8* %14 to i64
store i64 %15, i64* %13
%16 = getelementptr inbounds %struct.spi_ioc_transfer, %struct.spi_ioc_transfer* %9, i32 0, i32 2
%17 = load i64, i64* %8
store i64 %17, i64* %16
%18 = getelementptr inbounds %struct.spi_ioc_transfer, %struct.spi_ioc_transfer* %9, i32 0, i32 3
store i32 0, i32* %18
%19 = load i32, i32* %5
%20 = call i32 @SPI_IOC_MESSAGE(i32 1)
%21 = call i32 @ioctl(i32 %19, i32 %20, %struct.spi_ioc_transfer* %9)
ret i32 %21
}

LLVM IR (-O2):
%struct.spi_ioc_transfer = type { i64, i64, i64, i32 }
define i32 @spi_transfer(i32 %0, i8* %1, i8* %2, i64 %3) {
%5 = alloca %struct.spi_ioc_transfer
%6 = bitcast %struct.spi_ioc_transfer* %5 to i8*
%7 = getelementptr inbounds %struct.spi_ioc_transfer, %struct.spi_ioc_transfer* %5, i64 0, i32 0
%8 = ptrtoint i8* %2 to i64
store i64 %8, i64* %7
%9 = getelementptr inbounds %struct.spi_ioc_transfer, %struct.spi_ioc_transfer* %5, i64 0, i32 1
%10 = ptrtoint i8* %1 to i64
store i64 %10, i64* %9
%11 = getelementptr inbounds %struct.spi_ioc_transfer, %struct.spi_ioc_transfer* %5, i64 0, i32 2
store i64 %3, i64* %11
%12 = getelementptr inbounds %struct.spi_ioc_transfer, %struct.spi_ioc_transfer* %5, i64 0, i32 3
store i32 0, i32* %12
%13 = tail call i32 @SPI_IOC_MESSAGE(i32 1)
%14 = call i32 @ioctl(i32 %0, i32 %13, %struct.spi_ioc_transfer* %5)
ret i32 %14
}