#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;

/* Variables and functions */
int /*<<< orphan*/ assert(int /*<<< orphan*/);
int /*<<< orphan*/ mcp2515_spi_select();
int /*<<< orphan*/ mcp2515_spi_transfer(size_t, int /*<<< orphan*/ *);
int /*<<< orphan*/ mcp2515_spi_unselect();
void mcp2515_write_bust(uint8_t regAddr, uint8_t *dataAddr, uint8_t size) {
  uint8_t i;
  assert(dataAddr != NULL);
  mcp2515_spi_select();
  mcp2515_spi_transfer(0x02, NULL);
  mcp2515_spi_transfer(regAddr, NULL);
  for (i = 0; i < size; i++)
    mcp2515_spi_transfer(dataAddr[i], NULL);
  mcp2515_spi_unselect();
}


x86 assembly (clang, -O0):
<mcp2515_write_bust>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
cmpq   $0x0,-0x10(%rbp)
setne  %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
mov    $0x0,%al
call   1030 <mcp2515_spi_select@plt>
mov    $0x2,%edi
xor    %eax,%eax
mov    %eax,%esi
call   1050 <mcp2515_spi_transfer@plt>
mov    -0x8(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1050 <mcp2515_spi_transfer@plt>
movq   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%rax
cmp    -0x18(%rbp),%rax
jae    11c4 <mcp2515_write_bust+0x84>
mov    -0x10(%rbp),%rax
mov    -0x20(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1050 <mcp2515_spi_transfer@plt>
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
jmp    1190 <mcp2515_write_bust+0x50>
mov    $0x0,%al
call   1060 <mcp2515_spi_unselect@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mcp2515_write_bust>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rdx,%r14
mov    %rsi,%r12
mov    %rdi,%r15
xor    %edi,%edi
test   %rsi,%rsi
setne  %dil
call   1040 <assert@plt>
xor    %eax,%eax
call   1030 <mcp2515_spi_select@plt>
mov    $0x2,%edi
xor    %esi,%esi
call   1050 <mcp2515_spi_transfer@plt>
mov    %r15,%rdi
xor    %esi,%esi
call   1050 <mcp2515_spi_transfer@plt>
test   %r14,%r14
je     11a4 <mcp2515_write_bust+0x64>
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    (%r12,%rbx,8),%rdi
xor    %esi,%esi
call   1050 <mcp2515_spi_transfer@plt>
add    $0x1,%rbx
cmp    %rbx,%r14
jne    1190 <mcp2515_write_bust+0x50>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
jmp    1060 <mcp2515_spi_unselect@plt>

LLVM IR (-O0):
define void @mcp2515_write_bust(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
%8 = load i64*, i64** %5
%9 = icmp ne i64* %8, null
%10 = zext i1 %9 to i32
%11 = call i32 @assert(i32 %10)
%12 = call i32 (...) @mcp2515_spi_select()
%13 = call i32 @mcp2515_spi_transfer(i64 2, i32* null)
%14 = load i64, i64* %4
%15 = call i32 @mcp2515_spi_transfer(i64 %14, i32* null)
store i64 0, i64* %7
br label %16
16: ; preds = %26, %3
%17 = load i64, i64* %7
%18 = load i64, i64* %6
%19 = icmp ult i64 %17, %18
br i1 %19, label %20, label %29
20: ; preds = %16
%21 = load i64*, i64** %5
%22 = load i64, i64* %7
%23 = getelementptr inbounds i64, i64* %21, i64 %22
%24 = load i64, i64* %23
%25 = call i32 @mcp2515_spi_transfer(i64 %24, i32* null)
br label %26
26: ; preds = %20
%27 = load i64, i64* %7
%28 = add i64 %27, 1
store i64 %28, i64* %7
br label %16
29: ; preds = %16
%30 = call i32 (...) @mcp2515_spi_unselect()
ret void
}

LLVM IR (-O2):
define void @mcp2515_write_bust(i64 %0, i64* %1, i64 %2) {
%4 = icmp ne i64* %1, null
%5 = zext i1 %4 to i32
%6 = tail call i32 @assert(i32 %5)
%7 = tail call i32 (...) @mcp2515_spi_select()
%8 = tail call i32 @mcp2515_spi_transfer(i64 2, i32* null)
%9 = tail call i32 @mcp2515_spi_transfer(i64 %0, i32* null)
%10 = icmp eq i64 %2, 0
br i1 %10, label %18, label %11
11: ; preds = %3, %11
%12 = phi i64 [ %16, %11 ], [ 0, %3 ]
%13 = getelementptr inbounds i64, i64* %1, i64 %12
%14 = load i64, i64* %13
%15 = tail call i32 @mcp2515_spi_transfer(i64 %14, i32* null)
%16 = add nuw i64 %12, 1
%17 = icmp eq i64 %16, %2
br i1 %17, label %18, label %11
18: ; preds = %11, %3
%19 = tail call i32 (...) @mcp2515_spi_unselect()
ret void
}