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

/* Variables and functions */
int /*<<< orphan*/ assert(int);
int /*<<< orphan*/ mcp2515_spi_select();
int /*<<< orphan*/ mcp2515_spi_transfer(scalar_t__, int /*<<< orphan*/ *);
int /*<<< orphan*/ mcp2515_spi_unselect();
void mcp2515_read_bust(uint8_t regAddr, uint8_t *dataAddr, uint8_t size) {
  uint8_t i;
  assert((dataAddr != NULL) && (size != 0));
  mcp2515_spi_select();
  mcp2515_spi_transfer(0x03, NULL);
  mcp2515_spi_transfer(regAddr, NULL);
  for (i = 0; i <= size; i++)
    mcp2515_spi_transfer(0, dataAddr++);
  mcp2515_spi_unselect();
}


x86 assembly (clang, -O0):
<mcp2515_read_bust>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
xor    %eax,%eax
cmpq   $0x0,-0x10(%rbp)
mov    %al,-0x21(%rbp)
je     116f <mcp2515_read_bust+0x2f>
cmpq   $0x0,-0x18(%rbp)
setne  %al
mov    %al,-0x21(%rbp)
mov    -0x21(%rbp),%al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
mov    $0x0,%al
call   1030 <mcp2515_spi_select@plt>
mov    $0x3,%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
jg     11dd <mcp2515_read_bust+0x9d>
mov    -0x10(%rbp),%rsi
mov    %rsi,%rax
add    $0x8,%rax
mov    %rax,-0x10(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   1050 <mcp2515_spi_transfer@plt>
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
jmp    11a6 <mcp2515_read_bust+0x66>
mov    $0x0,%al
call   1060 <mcp2515_spi_unselect@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mcp2515_read_bust>:
push   %r15
push   %r14
push   %rbx
mov    %rdx,%rbx
mov    %rsi,%r14
mov    %rdi,%r15
test   %rsi,%rsi
setne  %al
test   %rdx,%rdx
setne  %cl
and    %al,%cl
movzbl %cl,%edi
call   1040 <assert@plt>
xor    %eax,%eax
call   1030 <mcp2515_spi_select@plt>
mov    $0x3,%edi
xor    %esi,%esi
call   1050 <mcp2515_spi_transfer@plt>
mov    %r15,%rdi
xor    %esi,%esi
call   1050 <mcp2515_spi_transfer@plt>
test   %rbx,%rbx
js     11a7 <mcp2515_read_bust+0x67>
add    $0x1,%rbx
nopw   0x0(%rax,%rax,1)
lea    0x8(%r14),%r15
xor    %edi,%edi
mov    %r14,%rsi
call   1050 <mcp2515_spi_transfer@plt>
mov    %r15,%r14
add    $0xffffffffffffffff,%rbx
jne    1190 <mcp2515_read_bust+0x50>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %r15
jmp    1060 <mcp2515_spi_unselect@plt>

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

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