#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 */
typedef int /*<<< orphan*/ tran;
struct spi_ioc_transfer {
  void *cs_change;
  void *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 void *__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_2(int fd, void *tx_buff, __u32 tx_buff_len,
                         void *rx_buff, __u32 rx_buff_len, __u8 bits,
                         __u32 speed, __u16 delay, __u8 cs_change) {
  struct spi_ioc_transfer tran[2];
  memset(tran, 0, sizeof(tran));
  tran[0].tx_buf = (__u64)tx_buff;
  tran[0].len = tx_buff_len;
  tran[0].bits_per_word = bits;
  tran[0].speed_hz = speed;
  tran[0].delay_usecs = delay;
  tran[0].cs_change = cs_change;
  tran[1].rx_buf = (__u64)rx_buff;
  tran[1].len = rx_buff_len;
  tran[1].bits_per_word = bits;
  tran[1].speed_hz = speed;
  tran[1].delay_usecs = delay;
  tran[1].cs_change = cs_change;
  return ioctl(fd, SPI_IOC_MESSAGE(2), tran);
}


x86 assembly (clang, -O0):
<spi_transfer_tx_rx_2>:
push   %rbp
mov    %rsp,%rbp
sub    $0xb0,%rsp
mov    0x20(%rbp),%rax
mov    0x18(%rbp),%rax
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    %r9,-0x30(%rbp)
lea    -0xa0(%rbp),%rdi
xor    %esi,%esi
mov    $0x70,%edx
call   1030 <memset@plt>
mov    -0x10(%rbp),%rax
mov    %rax,-0x70(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x80(%rbp)
mov    -0x30(%rbp),%rax
mov    %rax,-0x88(%rbp)
mov    0x10(%rbp),%rax
mov    %rax,-0x90(%rbp)
mov    0x18(%rbp),%rax
mov    %rax,-0x98(%rbp)
mov    0x20(%rbp),%rax
mov    %rax,-0xa0(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,-0x40(%rbp)
mov    -0x28(%rbp),%rax
mov    %rax,-0x48(%rbp)
mov    -0x30(%rbp),%rax
mov    %rax,-0x50(%rbp)
mov    0x10(%rbp),%rax
mov    %rax,-0x58(%rbp)
mov    0x18(%rbp),%rax
mov    %rax,-0x60(%rbp)
mov    0x20(%rbp),%rax
mov    %rax,-0x68(%rbp)
mov    -0x4(%rbp),%eax
mov    %eax,-0xa4(%rbp)
mov    $0x2,%edi
call   1040 <SPI_IOC_MESSAGE@plt>
mov    -0xa4(%rbp),%edi
mov    %eax,%esi
lea    -0xa0(%rbp),%rdx
call   1050 <ioctl@plt>
add    $0xb0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<spi_transfer_tx_rx_2>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x78,%rsp
mov    %r9,%rbx
mov    %r8,%r15
mov    %rcx,%r12
mov    %rdx,%r13
mov    %rsi,%rbp
mov    %edi,%r14d
mov    %rsp,%rdi
xor    %esi,%esi
mov    $0x70,%edx
call   1030 <memset@plt>
mov    %rbp,0x30(%rsp)
mov    %r13,0x20(%rsp)
mov    %rbx,0x18(%rsp)
mov    0xb0(%rsp),%rdx
mov    %rdx,0x10(%rsp)
mov    0xb8(%rsp),%rcx
mov    %rcx,0x8(%rsp)
mov    0xc0(%rsp),%rax
mov    %rax,(%rsp)
mov    %r12,0x60(%rsp)
mov    %r15,0x58(%rsp)
mov    %rbx,0x50(%rsp)
mov    %rdx,0x48(%rsp)
mov    %rcx,0x40(%rsp)
mov    %rax,0x38(%rsp)
mov    $0x2,%edi
call   1040 <SPI_IOC_MESSAGE@plt>
mov    %r14d,%edi
mov    %eax,%esi
mov    %rsp,%rdx
call   1050 <ioctl@plt>
add    $0x78,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.spi_ioc_transfer = type { i8*, i8*, i8*, i8*, i8*, i8*, i8* }
define i32 @spi_transfer_tx_rx_2(i32 %0, i8* %1, i8* %2, i8* %3, i8* %4, i8* %5, i8* %6, i8* %7, i8* %8) {
%10 = alloca i32
%11 = alloca i8*
%12 = alloca i8*
%13 = alloca i8*
%14 = alloca i8*
%15 = alloca i8*
%16 = alloca i8*
%17 = alloca i8*
%18 = alloca i8*
%19 = alloca [2 x %struct.spi_ioc_transfer]
store i32 %0, i32* %10
store i8* %1, i8** %11
store i8* %2, i8** %12
store i8* %3, i8** %13
store i8* %4, i8** %14
store i8* %5, i8** %15
store i8* %6, i8** %16
store i8* %7, i8** %17
store i8* %8, i8** %18
%20 = getelementptr inbounds [2 x %struct.spi_ioc_transfer], [2 x %struct.spi_ioc_transfer]* %19, i64 0, i64 0
%21 = call i32 @memset(%struct.spi_ioc_transfer* %20, i32 0, i32 112)
%22 = load i8*, i8** %11
%23 = getelementptr inbounds [2 x %struct.spi_ioc_transfer], [2 x %struct.spi_ioc_transfer]* %19, i64 0, i64 0
%24 = getelementptr inbounds %struct.spi_ioc_transfer, %struct.spi_ioc_transfer* %23, i32 0, i32 6
store i8* %22, i8** %24
%25 = load i8*, i8** %12
%26 = getelementptr inbounds [2 x %struct.spi_ioc_transfer], [2 x %struct.spi_ioc_transfer]* %19, i64 0, i64 0
%27 = getelementptr inbounds %struct.spi_ioc_transfer, %struct.spi_ioc_transfer* %26, i32 0, i32 4
store i8* %25, i8** %27
%28 = load i8*, i8** %15
%29 = getelementptr inbounds [2 x %struct.spi_ioc_transfer], [2 x %struct.spi_ioc_transfer]* %19, i64 0, i64 0
%30 = getelementptr inbounds %struct.spi_ioc_transfer, %struct.spi_ioc_transfer* %29, i32 0, i32 3
store i8* %28, i8** %30
%31 = load i8*, i8** %16
%32 = getelementptr inbounds [2 x %struct.spi_ioc_transfer], [2 x %struct.spi_ioc_transfer]* %19, i64 0, i64 0
%33 = getelementptr inbounds %struct.spi_ioc_transfer, %struct.spi_ioc_transfer* %32, i32 0, i32 2
store i8* %31, i8** %33
%34 = load i8*, i8** %17
%35 = getelementptr inbounds [2 x %struct.spi_ioc_transfer], [2 x %struct.spi_ioc_transfer]* %19, i64 0, i64 0
%36 = getelementptr inbounds %struct.spi_ioc_transfer, %struct.spi_ioc_transfer* %35, i32 0, i32 1
store i8* %34, i8** %36
%37 = load i8*, i8** %18
%38 = getelementptr inbounds [2 x %struct.spi_ioc_transfer], [2 x %struct.spi_ioc_transfer]* %19, i64 0, i64 0
%39 = getelementptr inbounds %struct.spi_ioc_transfer, %struct.spi_ioc_transfer* %38, i32 0, i32 0
store i8* %37, i8** %39
%40 = load i8*, i8** %13
%41 = getelementptr inbounds [2 x %struct.spi_ioc_transfer], [2 x %struct.spi_ioc_transfer]* %19, i64 0, i64 1
%42 = getelementptr inbounds %struct.spi_ioc_transfer, %struct.spi_ioc_transfer* %41, i32 0, i32 5
store i8* %40, i8** %42
%43 = load i8*, i8** %14
%44 = getelementptr inbounds [2 x %struct.spi_ioc_transfer], [2 x %struct.spi_ioc_transfer]* %19, i64 0, i64 1
%45 = getelementptr inbounds %struct.spi_ioc_transfer, %struct.spi_ioc_transfer* %44, i32 0, i32 4
store i8* %43, i8** %45
%46 = load i8*, i8** %15
%47 = getelementptr inbounds [2 x %struct.spi_ioc_transfer], [2 x %struct.spi_ioc_transfer]* %19, i64 0, i64 1
%48 = getelementptr inbounds %struct.spi_ioc_transfer, %struct.spi_ioc_transfer* %47, i32 0, i32 3
store i8* %46, i8** %48
%49 = load i8*, i8** %16
%50 = getelementptr inbounds [2 x %struct.spi_ioc_transfer], [2 x %struct.spi_ioc_transfer]* %19, i64 0, i64 1
%51 = getelementptr inbounds %struct.spi_ioc_transfer, %struct.spi_ioc_transfer* %50, i32 0, i32 2
store i8* %49, i8** %51
%52 = load i8*, i8** %17
%53 = getelementptr inbounds [2 x %struct.spi_ioc_transfer], [2 x %struct.spi_ioc_transfer]* %19, i64 0, i64 1
%54 = getelementptr inbounds %struct.spi_ioc_transfer, %struct.spi_ioc_transfer* %53, i32 0, i32 1
store i8* %52, i8** %54
%55 = load i8*, i8** %18
%56 = getelementptr inbounds [2 x %struct.spi_ioc_transfer], [2 x %struct.spi_ioc_transfer]* %19, i64 0, i64 1
%57 = getelementptr inbounds %struct.spi_ioc_transfer, %struct.spi_ioc_transfer* %56, i32 0, i32 0
store i8* %55, i8** %57
%58 = load i32, i32* %10
%59 = call i32 @SPI_IOC_MESSAGE(i32 2)
%60 = getelementptr inbounds [2 x %struct.spi_ioc_transfer], [2 x %struct.spi_ioc_transfer]* %19, i64 0, i64 0
%61 = call i32 @ioctl(i32 %58, i32 %59, %struct.spi_ioc_transfer* %60)
ret i32 %61
}

LLVM IR (-O2):
%struct.spi_ioc_transfer = type { i8*, i8*, i8*, i8*, i8*, i8*, i8* }
define i32 @spi_transfer_tx_rx_2(i32 %0, i8* %1, i8* %2, i8* %3, i8* %4, i8* %5, i8* %6, i8* %7, i8* %8) {
%10 = alloca [2 x %struct.spi_ioc_transfer]
%11 = bitcast [2 x %struct.spi_ioc_transfer]* %10 to i8*
%12 = getelementptr inbounds [2 x %struct.spi_ioc_transfer], [2 x %struct.spi_ioc_transfer]* %10, i64 0, i64 0
%13 = call i32 @memset(%struct.spi_ioc_transfer* %12, i32 0, i32 112)
%14 = getelementptr inbounds [2 x %struct.spi_ioc_transfer], [2 x %struct.spi_ioc_transfer]* %10, i64 0, i64 0, i32 6
store i8* %1, i8** %14
%15 = getelementptr inbounds [2 x %struct.spi_ioc_transfer], [2 x %struct.spi_ioc_transfer]* %10, i64 0, i64 0, i32 4
store i8* %2, i8** %15
%16 = getelementptr inbounds [2 x %struct.spi_ioc_transfer], [2 x %struct.spi_ioc_transfer]* %10, i64 0, i64 0, i32 3
store i8* %5, i8** %16
%17 = getelementptr inbounds [2 x %struct.spi_ioc_transfer], [2 x %struct.spi_ioc_transfer]* %10, i64 0, i64 0, i32 2
store i8* %6, i8** %17
%18 = getelementptr inbounds [2 x %struct.spi_ioc_transfer], [2 x %struct.spi_ioc_transfer]* %10, i64 0, i64 0, i32 1
store i8* %7, i8** %18
%19 = getelementptr inbounds [2 x %struct.spi_ioc_transfer], [2 x %struct.spi_ioc_transfer]* %10, i64 0, i64 0, i32 0
store i8* %8, i8** %19
%20 = getelementptr inbounds [2 x %struct.spi_ioc_transfer], [2 x %struct.spi_ioc_transfer]* %10, i64 0, i64 1, i32 5
store i8* %3, i8** %20
%21 = getelementptr inbounds [2 x %struct.spi_ioc_transfer], [2 x %struct.spi_ioc_transfer]* %10, i64 0, i64 1, i32 4
store i8* %4, i8** %21
%22 = getelementptr inbounds [2 x %struct.spi_ioc_transfer], [2 x %struct.spi_ioc_transfer]* %10, i64 0, i64 1, i32 3
store i8* %5, i8** %22
%23 = getelementptr inbounds [2 x %struct.spi_ioc_transfer], [2 x %struct.spi_ioc_transfer]* %10, i64 0, i64 1, i32 2
store i8* %6, i8** %23
%24 = getelementptr inbounds [2 x %struct.spi_ioc_transfer], [2 x %struct.spi_ioc_transfer]* %10, i64 0, i64 1, i32 1
store i8* %7, i8** %24
%25 = getelementptr inbounds [2 x %struct.spi_ioc_transfer], [2 x %struct.spi_ioc_transfer]* %10, i64 0, i64 1, i32 0
store i8* %8, i8** %25
%26 = call i32 @SPI_IOC_MESSAGE(i32 2)
%27 = call i32 @ioctl(i32 %0, i32 %26, %struct.spi_ioc_transfer* %12)
ret i32 %27
}