#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 size_t uint8_t;
typedef size_t uint32_t;

/* Variables and functions */
scalar_t__ spi_tx_is_full(size_t *);
void spi_r(uint32_t *spi, uint8_t *data, uint8_t size) {
  uint8_t i;
  for (i = 0; i < size; ++i) {
    while (spi_tx_is_full(spi))
      ;
    spi[0x008 / 4] = data[i];
  }
}


x86 assembly (clang, -O0):
<spi_r>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
movq   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%rax
cmp    -0x18(%rbp),%rax
jae    117c <spi_r+0x6c>
jmp    113f <spi_r+0x2f>
mov    -0x8(%rbp),%rdi
call   1030 <spi_tx_is_full@plt>
cmp    $0x0,%rax
je     1157 <spi_r+0x47>
jmp    113f <spi_r+0x2f>
mov    -0x10(%rbp),%rax
mov    -0x20(%rbp),%rcx
mov    (%rax,%rcx,8),%rcx
mov    -0x8(%rbp),%rax
mov    %rcx,0x10(%rax)
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
jmp    112c <spi_r+0x1c>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<spi_r>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
test   %rdx,%rdx
je     114e <spi_r+0x3e>
mov    %rdx,%r15
mov    %rsi,%r14
mov    %rdi,%rbx
xor    %r12d,%r12d
nopl   0x0(%rax)
mov    %rbx,%rdi
call   1030 <spi_tx_is_full@plt>
test   %rax,%rax
jne    1130 <spi_r+0x20>
mov    (%r14,%r12,8),%rax
mov    %rax,0x10(%rbx)
add    $0x1,%r12
cmp    %r15,%r12
jne    1130 <spi_r+0x20>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define void @spi_r(i64* %0, i64* %1, i64 %2) {
%4 = alloca i64*
%5 = alloca i64*
%6 = alloca i64
%7 = alloca i64
store i64* %0, i64** %4
store i64* %1, i64** %5
store i64 %2, i64* %6
store i64 0, i64* %7
br label %8
8: ; preds = %25, %3
%9 = load i64, i64* %7
%10 = load i64, i64* %6
%11 = icmp ult i64 %9, %10
br i1 %11, label %12, label %28
12: ; preds = %8
br label %13
13: ; preds = %17, %12
%14 = load i64*, i64** %4
%15 = call i64 @spi_tx_is_full(i64* %14)
%16 = icmp ne i64 %15, 0
br i1 %16, label %17, label %18
17: ; preds = %13
br label %13
18: ; preds = %13
%19 = load i64*, i64** %5
%20 = load i64, i64* %7
%21 = getelementptr inbounds i64, i64* %19, i64 %20
%22 = load i64, i64* %21
%23 = load i64*, i64** %4
%24 = getelementptr inbounds i64, i64* %23, i64 2
store i64 %22, i64* %24
br label %25
25: ; preds = %18
%26 = load i64, i64* %7
%27 = add i64 %26, 1
store i64 %27, i64* %7
br label %8
28: ; preds = %8
ret void
}

LLVM IR (-O2):
define void @spi_r(i64* %0, i64* nocapture %1, i64 %2) {
%4 = icmp eq i64 %2, 0
br i1 %4, label %17, label %5
5: ; preds = %3
%6 = getelementptr inbounds i64, i64* %0, i64 2
br label %7
7: ; preds = %5, %12
%8 = phi i64 [ 0, %5 ], [ %15, %12 ]
br label %9
9: ; preds = %7, %9
%10 = tail call i64 @spi_tx_is_full(i64* %0)
%11 = icmp eq i64 %10, 0
br i1 %11, label %12, label %9
12: ; preds = %9
%13 = getelementptr inbounds i64, i64* %1, i64 %8
%14 = load i64, i64* %13
store i64 %14, i64* %6
%15 = add nuw i64 %8, 1
%16 = icmp eq i64 %15, %2
br i1 %16, label %17, label %7
17: ; preds = %12, %3
ret void
}