#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 uint8_t;
typedef int uint32_t;
struct spi_ioc_transfer {
  uintptr_t tx_buf;
  uintptr_t rx_buf;
  int len;
  int bits_per_word;
  scalar_t__ cs_change;
  scalar_t__ delay_usecs;
  scalar_t__ speed_hz;
};

/* Variables and functions */
int /*<<< orphan*/ SPI_IOC_MESSAGE(int);
int SPI_getBitsPerWord(int);
scalar_t__ ioctl(int, int /*<<< orphan*/, struct spi_ioc_transfer *);
int /*<<< orphan*/ memset(void *, int /*<<< orphan*/, int);
int SPI_transaction(int spidev_fd, void *tx_buffer, int n_tx_words,
                    void *rx_buffer, int n_rx_words) {
  uint8_t bits_per_word;
  uint32_t n_tx_bytes, n_rx_bytes;
  struct spi_ioc_transfer transfers[2];
  int n_transfers;
  bits_per_word = SPI_getBitsPerWord(spidev_fd);
  if (bits_per_word < 0)
    return bits_per_word;
  n_tx_bytes = (uint32_t)(((float)(bits_per_word * n_tx_words)) / 8.0 + 0.5);
  n_rx_bytes = (uint32_t)(((float)(bits_per_word * n_rx_words)) / 8.0 + 0.5);
  if (!n_rx_bytes && !n_tx_bytes)
    return 0;
  if (n_rx_bytes > 4096)
    n_rx_bytes = 4096;
  if (n_tx_bytes > 4096)
    n_tx_bytes = 4096;
  n_transfers = 0;
  if (n_tx_bytes) {
    memset((void *)&transfers[n_transfers], 0, sizeof(struct spi_ioc_transfer));
    transfers[n_transfers].tx_buf = (uintptr_t)tx_buffer;
    transfers[n_transfers].rx_buf = 0;
    transfers[n_transfers].len = n_tx_bytes;
    transfers[n_transfers].speed_hz = 0;
    transfers[n_transfers].delay_usecs = 0;
    transfers[n_transfers].bits_per_word = bits_per_word;
    transfers[n_transfers].cs_change = 0;
    ++n_transfers;
  }
  if (n_rx_bytes) {
    memset((void *)&transfers[n_transfers], 0, sizeof(struct spi_ioc_transfer));
    transfers[n_transfers].tx_buf = 0;
    transfers[n_transfers].rx_buf = (uintptr_t)rx_buffer;
    transfers[n_transfers].len = n_rx_bytes + 1;
    transfers[n_transfers].speed_hz = 0;
    transfers[n_transfers].delay_usecs = 0;
    transfers[n_transfers].bits_per_word = bits_per_word;
    transfers[n_transfers].cs_change = 0;
    ++n_transfers;
  }
  if (ioctl(spidev_fd, SPI_IOC_MESSAGE(n_transfers), transfers) < 0)
    return -1;
  return (n_rx_bytes << 3) / bits_per_word;
}


x86 assembly (clang, -O0):
<SPI_transaction>:
push   %rbp
mov    %rsp,%rbp
sub    $0xa0,%rsp
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8d,-0x24(%rbp)
mov    -0x8(%rbp),%edi
call   1060 <SPI_getBitsPerWord@plt>
mov    %eax,-0x28(%rbp)
cmpl   $0x0,-0x28(%rbp)
jge    117d <SPI_transaction+0x3d>
mov    -0x28(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    1479 <SPI_transaction+0x339>
mov    -0x28(%rbp),%eax
imul   -0x14(%rbp),%eax
cvtsi2ss %eax,%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xe74(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  0xe60(%rip),%xmm1
addsd  %xmm1,%xmm0
cvttsd2si %xmm0,%eax
mov    %eax,-0x2c(%rbp)
mov    -0x28(%rbp),%eax
imul   -0x24(%rbp),%eax
cvtsi2ss %eax,%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xe46(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  0xe32(%rip),%xmm1
addsd  %xmm1,%xmm0
cvttsd2si %xmm0,%eax
mov    %eax,-0x30(%rbp)
cmpl   $0x0,-0x30(%rbp)
jne    11f9 <SPI_transaction+0xb9>
cmpl   $0x0,-0x2c(%rbp)
jne    11f9 <SPI_transaction+0xb9>
movl   $0x0,-0x4(%rbp)
jmp    1479 <SPI_transaction+0x339>
cmpl   $0x1000,-0x30(%rbp)
jle    120d <SPI_transaction+0xcd>
movl   $0x1000,-0x30(%rbp)
cmpl   $0x1000,-0x2c(%rbp)
jle    1221 <SPI_transaction+0xe1>
movl   $0x1000,-0x2c(%rbp)
movl   $0x0,-0x94(%rbp)
cmpl   $0x0,-0x2c(%rbp)
je     132b <SPI_transaction+0x1eb>
movslq -0x94(%rbp),%rax
lea    -0x90(%rbp),%rdi
imul   $0x30,%rax,%rax
add    %rax,%rdi
xor    %esi,%esi
mov    $0x30,%edx
call   1030 <memset@plt>
mov    -0x10(%rbp),%rcx
movslq -0x94(%rbp),%rdx
lea    -0x90(%rbp),%rax
imul   $0x30,%rdx,%rdx
add    %rdx,%rax
mov    %rcx,(%rax)
movslq -0x94(%rbp),%rcx
lea    -0x90(%rbp),%rax
imul   $0x30,%rcx,%rcx
add    %rcx,%rax
movq   $0x0,0x8(%rax)
mov    -0x2c(%rbp),%ecx
movslq -0x94(%rbp),%rdx
lea    -0x90(%rbp),%rax
imul   $0x30,%rdx,%rdx
add    %rdx,%rax
mov    %ecx,0x10(%rax)
movslq -0x94(%rbp),%rcx
lea    -0x90(%rbp),%rax
imul   $0x30,%rcx,%rcx
add    %rcx,%rax
movq   $0x0,0x28(%rax)
movslq -0x94(%rbp),%rcx
lea    -0x90(%rbp),%rax
imul   $0x30,%rcx,%rcx
add    %rcx,%rax
movq   $0x0,0x20(%rax)
mov    -0x28(%rbp),%ecx
movslq -0x94(%rbp),%rdx
lea    -0x90(%rbp),%rax
imul   $0x30,%rdx,%rdx
add    %rdx,%rax
mov    %ecx,0x14(%rax)
movslq -0x94(%rbp),%rcx
lea    -0x90(%rbp),%rax
imul   $0x30,%rcx,%rcx
add    %rcx,%rax
movq   $0x0,0x18(%rax)
mov    -0x94(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x94(%rbp)
cmpl   $0x0,-0x30(%rbp)
je     142e <SPI_transaction+0x2ee>
movslq -0x94(%rbp),%rax
lea    -0x90(%rbp),%rdi
imul   $0x30,%rax,%rax
add    %rax,%rdi
xor    %esi,%esi
mov    $0x30,%edx
call   1030 <memset@plt>
movslq -0x94(%rbp),%rcx
lea    -0x90(%rbp),%rax
imul   $0x30,%rcx,%rcx
add    %rcx,%rax
movq   $0x0,(%rax)
mov    -0x20(%rbp),%rcx
movslq -0x94(%rbp),%rdx
lea    -0x90(%rbp),%rax
imul   $0x30,%rdx,%rdx
add    %rdx,%rax
mov    %rcx,0x8(%rax)
mov    -0x30(%rbp),%ecx
add    $0x1,%ecx
movslq -0x94(%rbp),%rdx
lea    -0x90(%rbp),%rax
imul   $0x30,%rdx,%rdx
add    %rdx,%rax
mov    %ecx,0x10(%rax)
movslq -0x94(%rbp),%rcx
lea    -0x90(%rbp),%rax
imul   $0x30,%rcx,%rcx
add    %rcx,%rax
movq   $0x0,0x28(%rax)
movslq -0x94(%rbp),%rcx
lea    -0x90(%rbp),%rax
imul   $0x30,%rcx,%rcx
add    %rcx,%rax
movq   $0x0,0x20(%rax)
mov    -0x28(%rbp),%ecx
movslq -0x94(%rbp),%rdx
lea    -0x90(%rbp),%rax
imul   $0x30,%rdx,%rdx
add    %rdx,%rax
mov    %ecx,0x14(%rax)
movslq -0x94(%rbp),%rcx
lea    -0x90(%rbp),%rax
imul   $0x30,%rcx,%rcx
add    %rcx,%rax
movq   $0x0,0x18(%rax)
mov    -0x94(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x94(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,-0x98(%rbp)
mov    -0x94(%rbp),%edi
call   1040 <SPI_IOC_MESSAGE@plt>
mov    -0x98(%rbp),%edi
mov    %eax,%esi
lea    -0x90(%rbp),%rdx
call   1050 <ioctl@plt>
cmp    $0x0,%rax
jge    146c <SPI_transaction+0x32c>
movl   $0xffffffff,-0x4(%rbp)
jmp    1479 <SPI_transaction+0x339>
mov    -0x30(%rbp),%eax
shl    $0x3,%eax
cltd
idivl  -0x28(%rbp)
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0xa0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<SPI_transaction>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x68,%rsp
mov    %r8d,%ebp
mov    %rcx,%r15
mov    %edx,%ebx
mov    %rsi,%r12
mov    %edi,%r14d
call   1060 <SPI_getBitsPerWord@plt>
mov    %eax,%r13d
test   %eax,%eax
js     128c <SPI_transaction+0x14c>
imul   %r13d,%ebx
cvtsi2ss %ebx,%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xe80(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  0xe7c(%rip),%xmm2
addsd  %xmm2,%xmm0
cvttsd2si %xmm0,%ecx
imul   %r13d,%ebp
xorps  %xmm0,%xmm0
cvtsi2ss %ebp,%xmm0
cvtss2sd %xmm0,%xmm0
mulsd  %xmm1,%xmm0
addsd  %xmm2,%xmm0
cvttsd2si %xmm0,%ebp
xor    %eax,%eax
mov    %ebp,%edx
or     %ecx,%edx
je     129f <SPI_transaction+0x15f>
cmp    $0x1000,%ebp
mov    $0x1000,%ebx
cmovge %ebx,%ebp
cmp    $0x1000,%ecx
cmovl  %ecx,%ebx
test   %ebx,%ebx
je     1291 <SPI_transaction+0x151>
mov    %rsp,%rdi
xor    %esi,%esi
mov    $0x30,%edx
call   1030 <memset@plt>
mov    %r12,(%rsp)
movq   $0x0,0x8(%rsp)
mov    %ebx,0x10(%rsp)
xorpd  %xmm0,%xmm0
movapd %xmm0,0x20(%rsp)
mov    %r13d,0x14(%rsp)
movq   $0x0,0x18(%rsp)
mov    $0x1,%r12d
test   %ebp,%ebp
je     1267 <SPI_transaction+0x127>
mov    %r12d,%eax
lea    (%rax,%rax,2),%rbx
shl    $0x4,%rbx
lea    (%rsp,%rbx,1),%rdi
xor    %esi,%esi
mov    $0x30,%edx
call   1030 <memset@plt>
movq   $0x0,(%rsp,%rbx,1)
mov    %r15,0x8(%rsp,%rbx,1)
lea    0x1(%rbp),%eax
mov    %eax,0x10(%rsp,%rbx,1)
xorpd  %xmm0,%xmm0
movapd %xmm0,0x20(%rsp,%rbx,1)
mov    %r13d,0x14(%rsp,%rbx,1)
movq   $0x0,0x18(%rsp,%rbx,1)
add    $0x1,%r12d
mov    %r12d,%edi
call   1040 <SPI_IOC_MESSAGE@plt>
mov    %rsp,%rdx
mov    %r14d,%edi
mov    %eax,%esi
call   1050 <ioctl@plt>
test   %rax,%rax
js     129a <SPI_transaction+0x15a>
shl    $0x3,%ebp
mov    %ebp,%eax
cltd
idiv   %r13d
jmp    129f <SPI_transaction+0x15f>
mov    %r13d,%eax
jmp    129f <SPI_transaction+0x15f>
xor    %r12d,%r12d
test   %ebp,%ebp
jne    121c <SPI_transaction+0xdc>
jmp    1267 <SPI_transaction+0x127>
mov    $0xffffffff,%eax
add    $0x68,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.spi_ioc_transfer = type { i64, i64, i32, i32, i64, i64, i64 }
define i32 @SPI_transaction(i32 %0, i8* %1, i32 %2, i8* %3, i32 %4) {
%6 = alloca i32
%7 = alloca i32
%8 = alloca i8*
%9 = alloca i32
%10 = alloca i8*
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
%15 = alloca [2 x %struct.spi_ioc_transfer]
%16 = alloca i32
store i32 %0, i32* %7
store i8* %1, i8** %8
store i32 %2, i32* %9
store i8* %3, i8** %10
store i32 %4, i32* %11
%17 = load i32, i32* %7
%18 = call i32 @SPI_getBitsPerWord(i32 %17)
store i32 %18, i32* %12
%19 = load i32, i32* %12
%20 = icmp slt i32 %19, 0
br i1 %20, label %21, label %23
21: ; preds = %5
%22 = load i32, i32* %12
store i32 %22, i32* %6
br label %154
23: ; preds = %5
%24 = load i32, i32* %12
%25 = load i32, i32* %9
%26 = mul nsw i32 %24, %25
%27 = sitofp i32 %26 to float
%28 = fpext float %27 to double
%29 = fdiv double %28, 8.000000e+00
%30 = fadd double %29, 5.000000e-01
%31 = fptosi double %30 to i32
store i32 %31, i32* %13
%32 = load i32, i32* %12
%33 = load i32, i32* %11
%34 = mul nsw i32 %32, %33
%35 = sitofp i32 %34 to float
%36 = fpext float %35 to double
%37 = fdiv double %36, 8.000000e+00
%38 = fadd double %37, 5.000000e-01
%39 = fptosi double %38 to i32
store i32 %39, i32* %14
%40 = load i32, i32* %14
%41 = icmp ne i32 %40, 0
br i1 %41, label %46, label %42
42: ; preds = %23
%43 = load i32, i32* %13
%44 = icmp ne i32 %43, 0
br i1 %44, label %46, label %45
45: ; preds = %42
store i32 0, i32* %6
br label %154
46: ; preds = %42, %23
%47 = load i32, i32* %14
%48 = icmp sgt i32 %47, 4096
br i1 %48, label %49, label %50
49: ; preds = %46
store i32 4096, i32* %14
br label %50
50: ; preds = %49, %46
%51 = load i32, i32* %13
%52 = icmp sgt i32 %51, 4096
br i1 %52, label %53, label %54
53: ; preds = %50
store i32 4096, i32* %13
br label %54
54: ; preds = %53, %50
store i32 0, i32* %16
%55 = load i32, i32* %13
%56 = icmp ne i32 %55, 0
br i1 %56, label %57, label %97
57: ; preds = %54
%58 = load i32, i32* %16
%59 = sext i32 %58 to i64
%60 = getelementptr inbounds [2 x %struct.spi_ioc_transfer], [2 x %struct.spi_ioc_transfer]* %15, i64 0, i64 %59
%61 = bitcast %struct.spi_ioc_transfer* %60 to i8*
%62 = call i32 @memset(i8* %61, i32 0, i32 48)
%63 = load i8*, i8** %8
%64 = ptrtoint i8* %63 to i64
%65 = load i32, i32* %16
%66 = sext i32 %65 to i64
%67 = getelementptr inbounds [2 x %struct.spi_ioc_transfer], [2 x %struct.spi_ioc_transfer]* %15, i64 0, i64 %66
%68 = getelementptr inbounds %struct.spi_ioc_transfer, %struct.spi_ioc_transfer* %67, i32 0, i32 0
store i64 %64, i64* %68
%69 = load i32, i32* %16
%70 = sext i32 %69 to i64
%71 = getelementptr inbounds [2 x %struct.spi_ioc_transfer], [2 x %struct.spi_ioc_transfer]* %15, i64 0, i64 %70
%72 = getelementptr inbounds %struct.spi_ioc_transfer, %struct.spi_ioc_transfer* %71, i32 0, i32 1
store i64 0, i64* %72
%73 = load i32, i32* %13
%74 = load i32, i32* %16
%75 = sext i32 %74 to i64
%76 = getelementptr inbounds [2 x %struct.spi_ioc_transfer], [2 x %struct.spi_ioc_transfer]* %15, i64 0, i64 %75
%77 = getelementptr inbounds %struct.spi_ioc_transfer, %struct.spi_ioc_transfer* %76, i32 0, i32 2
store i32 %73, i32* %77
%78 = load i32, i32* %16
%79 = sext i32 %78 to i64
%80 = getelementptr inbounds [2 x %struct.spi_ioc_transfer], [2 x %struct.spi_ioc_transfer]* %15, i64 0, i64 %79
%81 = getelementptr inbounds %struct.spi_ioc_transfer, %struct.spi_ioc_transfer* %80, i32 0, i32 6
store i64 0, i64* %81
%82 = load i32, i32* %16
%83 = sext i32 %82 to i64
%84 = getelementptr inbounds [2 x %struct.spi_ioc_transfer], [2 x %struct.spi_ioc_transfer]* %15, i64 0, i64 %83
%85 = getelementptr inbounds %struct.spi_ioc_transfer, %struct.spi_ioc_transfer* %84, i32 0, i32 5
store i64 0, i64* %85
%86 = load i32, i32* %12
%87 = load i32, i32* %16
%88 = sext i32 %87 to i64
%89 = getelementptr inbounds [2 x %struct.spi_ioc_transfer], [2 x %struct.spi_ioc_transfer]* %15, i64 0, i64 %88
%90 = getelementptr inbounds %struct.spi_ioc_transfer, %struct.spi_ioc_transfer* %89, i32 0, i32 3
store i32 %86, i32* %90
%91 = load i32, i32* %16
%92 = sext i32 %91 to i64
%93 = getelementptr inbounds [2 x %struct.spi_ioc_transfer], [2 x %struct.spi_ioc_transfer]* %15, i64 0, i64 %92
%94 = getelementptr inbounds %struct.spi_ioc_transfer, %struct.spi_ioc_transfer* %93, i32 0, i32 4
store i64 0, i64* %94
%95 = load i32, i32* %16
%96 = add nsw i32 %95, 1
store i32 %96, i32* %16
br label %97
97: ; preds = %57, %54
%98 = load i32, i32* %14
%99 = icmp ne i32 %98, 0
br i1 %99, label %100, label %141
100: ; preds = %97
%101 = load i32, i32* %16
%102 = sext i32 %101 to i64
%103 = getelementptr inbounds [2 x %struct.spi_ioc_transfer], [2 x %struct.spi_ioc_transfer]* %15, i64 0, i64 %102
%104 = bitcast %struct.spi_ioc_transfer* %103 to i8*
%105 = call i32 @memset(i8* %104, i32 0, i32 48)
%106 = load i32, i32* %16
%107 = sext i32 %106 to i64
%108 = getelementptr inbounds [2 x %struct.spi_ioc_transfer], [2 x %struct.spi_ioc_transfer]* %15, i64 0, i64 %107
%109 = getelementptr inbounds %struct.spi_ioc_transfer, %struct.spi_ioc_transfer* %108, i32 0, i32 0
store i64 0, i64* %109
%110 = load i8*, i8** %10
%111 = ptrtoint i8* %110 to i64
%112 = load i32, i32* %16
%113 = sext i32 %112 to i64
%114 = getelementptr inbounds [2 x %struct.spi_ioc_transfer], [2 x %struct.spi_ioc_transfer]* %15, i64 0, i64 %113
%115 = getelementptr inbounds %struct.spi_ioc_transfer, %struct.spi_ioc_transfer* %114, i32 0, i32 1
store i64 %111, i64* %115
%116 = load i32, i32* %14
%117 = add nsw i32 %116, 1
%118 = load i32, i32* %16
%119 = sext i32 %118 to i64
%120 = getelementptr inbounds [2 x %struct.spi_ioc_transfer], [2 x %struct.spi_ioc_transfer]* %15, i64 0, i64 %119
%121 = getelementptr inbounds %struct.spi_ioc_transfer, %struct.spi_ioc_transfer* %120, i32 0, i32 2
store i32 %117, i32* %121
%122 = load i32, i32* %16
%123 = sext i32 %122 to i64
%124 = getelementptr inbounds [2 x %struct.spi_ioc_transfer], [2 x %struct.spi_ioc_transfer]* %15, i64 0, i64 %123
%125 = getelementptr inbounds %struct.spi_ioc_transfer, %struct.spi_ioc_transfer* %124, i32 0, i32 6
store i64 0, i64* %125
%126 = load i32, i32* %16
%127 = sext i32 %126 to i64
%128 = getelementptr inbounds [2 x %struct.spi_ioc_transfer], [2 x %struct.spi_ioc_transfer]* %15, i64 0, i64 %127
%129 = getelementptr inbounds %struct.spi_ioc_transfer, %struct.spi_ioc_transfer* %128, i32 0, i32 5
store i64 0, i64* %129
%130 = load i32, i32* %12
%131 = load i32, i32* %16
%132 = sext i32 %131 to i64
%133 = getelementptr inbounds [2 x %struct.spi_ioc_transfer], [2 x %struct.spi_ioc_transfer]* %15, i64 0, i64 %132
%134 = getelementptr inbounds %struct.spi_ioc_transfer, %struct.spi_ioc_transfer* %133, i32 0, i32 3
store i32 %130, i32* %134
%135 = load i32, i32* %16
%136 = sext i32 %135 to i64
%137 = getelementptr inbounds [2 x %struct.spi_ioc_transfer], [2 x %struct.spi_ioc_transfer]* %15, i64 0, i64 %136
%138 = getelementptr inbounds %struct.spi_ioc_transfer, %struct.spi_ioc_transfer* %137, i32 0, i32 4
store i64 0, i64* %138
%139 = load i32, i32* %16
%140 = add nsw i32 %139, 1
store i32 %140, i32* %16
br label %141
141: ; preds = %100, %97
%142 = load i32, i32* %7
%143 = load i32, i32* %16
%144 = call i32 @SPI_IOC_MESSAGE(i32 %143)
%145 = getelementptr inbounds [2 x %struct.spi_ioc_transfer], [2 x %struct.spi_ioc_transfer]* %15, i64 0, i64 0
%146 = call i64 @ioctl(i32 %142, i32 %144, %struct.spi_ioc_transfer* %145)
%147 = icmp slt i64 %146, 0
br i1 %147, label %148, label %149
148: ; preds = %141
store i32 -1, i32* %6
br label %154
149: ; preds = %141
%150 = load i32, i32* %14
%151 = shl i32 %150, 3
%152 = load i32, i32* %12
%153 = sdiv i32 %151, %152
store i32 %153, i32* %6
br label %154
154: ; preds = %149, %148, %45, %21
%155 = load i32, i32* %6
ret i32 %155
}

LLVM IR (-O2):
%struct.spi_ioc_transfer = type { i64, i64, i32, i32, i64, i64, i64 }
define i32 @SPI_transaction(i32 %0, i8* %1, i32 %2, i8* %3, i32 %4) {
%6 = alloca [2 x %struct.spi_ioc_transfer]
%7 = bitcast [2 x %struct.spi_ioc_transfer]* %6 to i8*
%8 = tail call i32 @SPI_getBitsPerWord(i32 %0)
%9 = icmp slt i32 %8, 0
br i1 %9, label %69, label %10
10: ; preds = %5
%11 = mul nsw i32 %8, %2
%12 = sitofp i32 %11 to float
%13 = fpext float %12 to double
%14 = fmul double %13, 1.250000e-01
%15 = fadd double %14, 5.000000e-01
%16 = fptosi double %15 to i32
%17 = mul nsw i32 %8, %4
%18 = sitofp i32 %17 to float
%19 = fpext float %18 to double
%20 = fmul double %19, 1.250000e-01
%21 = fadd double %20, 5.000000e-01
%22 = fptosi double %21 to i32
%23 = icmp ne i32 %22, 0
%24 = icmp ne i32 %16, 0
%25 = select i1 %23, i1 true, i1 %24
br i1 %25, label %26, label %69
26: ; preds = %10
%27 = icmp slt i32 %22, 4096
%28 = select i1 %27, i32 %22, i32 4096
%29 = icmp slt i32 %16, 4096
%30 = select i1 %29, i32 %16, i32 4096
%31 = icmp eq i32 %30, 0
br i1 %31, label %42, label %32
32: ; preds = %26
%33 = call i32 @memset(i8* %7, i32 0, i32 48)
%34 = ptrtoint i8* %1 to i64
%35 = getelementptr inbounds [2 x %struct.spi_ioc_transfer], [2 x %struct.spi_ioc_transfer]* %6, i64 0, i64 0, i32 0
store i64 %34, i64* %35
%36 = getelementptr inbounds [2 x %struct.spi_ioc_transfer], [2 x %struct.spi_ioc_transfer]* %6, i64 0, i64 0, i32 1
store i64 0, i64* %36
%37 = getelementptr inbounds [2 x %struct.spi_ioc_transfer], [2 x %struct.spi_ioc_transfer]* %6, i64 0, i64 0, i32 2
store i32 %30, i32* %37
%38 = getelementptr inbounds [2 x %struct.spi_ioc_transfer], [2 x %struct.spi_ioc_transfer]* %6, i64 0, i64 0, i32 5
%39 = getelementptr inbounds [2 x %struct.spi_ioc_transfer], [2 x %struct.spi_ioc_transfer]* %6, i64 0, i64 0, i32 3
%40 = bitcast i64* %38 to i8*
store i32 %8, i32* %39
%41 = getelementptr inbounds [2 x %struct.spi_ioc_transfer], [2 x %struct.spi_ioc_transfer]* %6, i64 0, i64 0, i32 4
store i64 0, i64* %41
br label %42
42: ; preds = %32, %26
%43 = phi i32 [ 1, %32 ], [ 0, %26 ]
%44 = icmp eq i32 %28, 0
br i1 %44, label %60, label %45
45: ; preds = %42
%46 = zext i32 %43 to i64
%47 = getelementptr inbounds [2 x %struct.spi_ioc_transfer], [2 x %struct.spi_ioc_transfer]* %6, i64 0, i64 %46
%48 = bitcast %struct.spi_ioc_transfer* %47 to i8*
%49 = call i32 @memset(i8* %48, i32 0, i32 48)
%50 = getelementptr inbounds %struct.spi_ioc_transfer, %struct.spi_ioc_transfer* %47, i64 0, i32 0
store i64 0, i64* %50
%51 = ptrtoint i8* %3 to i64
%52 = getelementptr inbounds [2 x %struct.spi_ioc_transfer], [2 x %struct.spi_ioc_transfer]* %6, i64 0, i64 %46, i32 1
store i64 %51, i64* %52
%53 = add nsw i32 %28, 1
%54 = getelementptr inbounds [2 x %struct.spi_ioc_transfer], [2 x %struct.spi_ioc_transfer]* %6, i64 0, i64 %46, i32 2
store i32 %53, i32* %54
%55 = getelementptr inbounds [2 x %struct.spi_ioc_transfer], [2 x %struct.spi_ioc_transfer]* %6, i64 0, i64 %46, i32 5
%56 = getelementptr inbounds [2 x %struct.spi_ioc_transfer], [2 x %struct.spi_ioc_transfer]* %6, i64 0, i64 %46, i32 3
%57 = bitcast i64* %55 to i8*
store i32 %8, i32* %56
%58 = getelementptr inbounds [2 x %struct.spi_ioc_transfer], [2 x %struct.spi_ioc_transfer]* %6, i64 0, i64 %46, i32 4
store i64 0, i64* %58
%59 = add nuw nsw i32 %43, 1
br label %60
60: ; preds = %45, %42
%61 = phi i32 [ %59, %45 ], [ %43, %42 ]
%62 = call i32 @SPI_IOC_MESSAGE(i32 %61)
%63 = getelementptr inbounds [2 x %struct.spi_ioc_transfer], [2 x %struct.spi_ioc_transfer]* %6, i64 0, i64 0
%64 = call i64 @ioctl(i32 %0, i32 %62, %struct.spi_ioc_transfer* %63)
%65 = icmp slt i64 %64, 0
br i1 %65, label %69, label %66
66: ; preds = %60
%67 = shl i32 %28, 3
%68 = sdiv i32 %67, %8
br label %69
69: ; preds = %60, %10, %5, %66
%70 = phi i32 [ %68, %66 ], [ %8, %5 ], [ 0, %10 ], [ -1, %60 ]
ret i32 %70
}