#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;
struct can_frame {
  int can_id;
  int can_dlc;
  int *data;
};
typedef int canid_t;

/* Variables and functions */
int /*<<< orphan*/ assert(int);
int can_send_frame(int, struct can_frame *);
int /*<<< orphan*/ memcpy(int *, int *, int);
int can_send_load_buffer(int fd, canid_t addr, uint8_t len, uint8_t *data) {
  struct can_frame msg;
  assert(len <= 6);
  assert(len % 2 == 0);
  msg.can_id = addr | 1 << 31;
  msg.can_dlc = 8;
  msg.data[0] = 0x04;
  msg.data[1] = len / 2;
  memcpy(&msg.data[2], data, len);
  return can_send_frame(fd, &msg);
}


x86 assembly (clang, -O0):
<can_send_load_buffer>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
mov    %rcx,-0x18(%rbp)
cmpl   $0x6,-0xc(%rbp)
setle  %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
mov    -0xc(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
mov    -0x8(%rbp),%eax
or     $0x80000000,%eax
mov    %eax,-0x28(%rbp)
movl   $0x8,-0x24(%rbp)
mov    -0x20(%rbp),%rax
movl   $0x4,(%rax)
mov    -0xc(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    -0x20(%rbp),%rax
mov    %ecx,0x4(%rax)
mov    -0x20(%rbp),%rdi
add    $0x8,%rdi
mov    -0x18(%rbp),%rsi
mov    -0xc(%rbp),%edx
call   1050 <memcpy@plt>
mov    -0x4(%rbp),%edi
lea    -0x28(%rbp),%rsi
call   1030 <can_send_frame@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<can_send_load_buffer>:
push   %rbx
mov    %edx,%ebx
xor    %edi,%edi
cmp    $0x7,%edx
not    %ebx
setl   %dil
call   1030 <assert@plt>
and    $0x1,%ebx
mov    %ebx,%edi
call   1030 <assert@plt>

LLVM IR (-O0):
%struct.can_frame = type { i32, i32, i32* }
define i32 @can_send_load_buffer(i32 %0, i32 %1, i32 %2, i32* %3) {
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32*
%9 = alloca %struct.can_frame
store i32 %0, i32* %5
store i32 %1, i32* %6
store i32 %2, i32* %7
store i32* %3, i32** %8
%10 = load i32, i32* %7
%11 = icmp sle i32 %10, 6
%12 = zext i1 %11 to i32
%13 = call i32 @assert(i32 %12)
%14 = load i32, i32* %7
%15 = srem i32 %14, 2
%16 = icmp eq i32 %15, 0
%17 = zext i1 %16 to i32
%18 = call i32 @assert(i32 %17)
%19 = load i32, i32* %6
%20 = or i32 %19, -2147483648
%21 = getelementptr inbounds %struct.can_frame, %struct.can_frame* %9, i32 0, i32 0
store i32 %20, i32* %21
%22 = getelementptr inbounds %struct.can_frame, %struct.can_frame* %9, i32 0, i32 1
store i32 8, i32* %22
%23 = getelementptr inbounds %struct.can_frame, %struct.can_frame* %9, i32 0, i32 2
%24 = load i32*, i32** %23
%25 = getelementptr inbounds i32, i32* %24, i64 0
store i32 4, i32* %25
%26 = load i32, i32* %7
%27 = sdiv i32 %26, 2
%28 = getelementptr inbounds %struct.can_frame, %struct.can_frame* %9, i32 0, i32 2
%29 = load i32*, i32** %28
%30 = getelementptr inbounds i32, i32* %29, i64 1
store i32 %27, i32* %30
%31 = getelementptr inbounds %struct.can_frame, %struct.can_frame* %9, i32 0, i32 2
%32 = load i32*, i32** %31
%33 = getelementptr inbounds i32, i32* %32, i64 2
%34 = load i32*, i32** %8
%35 = load i32, i32* %7
%36 = call i32 @memcpy(i32* %33, i32* %34, i32 %35)
%37 = load i32, i32* %5
%38 = call i32 @can_send_frame(i32 %37, %struct.can_frame* %9)
ret i32 %38
}

LLVM IR (-O2):
define i32 @can_send_load_buffer(i32 %0, i32 %1, i32 %2, i32* %3) {
%5 = icmp slt i32 %2, 7
%6 = zext i1 %5 to i32
%7 = tail call i32 @assert(i32 %6)
%8 = and i32 %2, 1
%9 = xor i32 %8, 1
%10 = tail call i32 @assert(i32 %9)
unreachable
}