#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 uint32_t;
struct can_frame {
  int *data;
};

/* Variables and functions */
void DATA(struct can_frame *frame, uint32_t data, size_t size) {
  frame->data[4] = size > 0 ? data >> 0 & 0xFF : 0;
  frame->data[5] = size > 1 ? data >> 8 & 0xFF : 0;
  frame->data[6] = size > 2 ? data >> 16 & 0xFF : 0;
  frame->data[7] = size > 3 ? data >> 24 & 0xFF : 0;
}


x86 assembly (clang, -O0):
<DATA>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jbe    112d <DATA+0x2d>
mov    -0xc(%rbp),%eax
sar    $0x0,%eax
and    $0xff,%eax
mov    %eax,-0x1c(%rbp)
jmp    1137 <DATA+0x37>
xor    %eax,%eax
mov    %eax,-0x1c(%rbp)
jmp    1137 <DATA+0x37>
mov    -0x1c(%rbp),%ecx
mov    -0x8(%rbp),%rax
mov    (%rax),%rax
mov    %ecx,0x10(%rax)
cmpq   $0x1,-0x18(%rbp)
jbe    1162 <DATA+0x62>
mov    -0xc(%rbp),%eax
sar    $0x8,%eax
and    $0xff,%eax
mov    %eax,-0x20(%rbp)
jmp    116c <DATA+0x6c>
xor    %eax,%eax
mov    %eax,-0x20(%rbp)
jmp    116c <DATA+0x6c>
mov    -0x20(%rbp),%ecx
mov    -0x8(%rbp),%rax
mov    (%rax),%rax
mov    %ecx,0x14(%rax)
cmpq   $0x2,-0x18(%rbp)
jbe    1197 <DATA+0x97>
mov    -0xc(%rbp),%eax
sar    $0x10,%eax
and    $0xff,%eax
mov    %eax,-0x24(%rbp)
jmp    11a1 <DATA+0xa1>
xor    %eax,%eax
mov    %eax,-0x24(%rbp)
jmp    11a1 <DATA+0xa1>
mov    -0x24(%rbp),%ecx
mov    -0x8(%rbp),%rax
mov    (%rax),%rax
mov    %ecx,0x18(%rax)
cmpq   $0x3,-0x18(%rbp)
jbe    11cc <DATA+0xcc>
mov    -0xc(%rbp),%eax
sar    $0x18,%eax
and    $0xff,%eax
mov    %eax,-0x28(%rbp)
jmp    11d6 <DATA+0xd6>
xor    %eax,%eax
mov    %eax,-0x28(%rbp)
jmp    11d6 <DATA+0xd6>
mov    -0x28(%rbp),%ecx
mov    -0x8(%rbp),%rax
mov    (%rax),%rax
mov    %ecx,0x1c(%rax)
pop    %rbp
ret

x86 assembly (clang, -O2):
<DATA>:
mov    %esi,%eax
xor    %ecx,%ecx
test   %rdx,%rdx
movzbl %al,%esi
cmove  %ecx,%esi
mov    (%rdi),%rdi
mov    %esi,0x10(%rdi)
cmp    $0x2,%rdx
movzbl %ah,%esi
cmovb  %ecx,%esi
mov    %esi,0x14(%rdi)
mov    %eax,%esi
shr    $0x10,%esi
cmp    $0x3,%rdx
movzbl %sil,%esi
cmovb  %ecx,%esi
mov    %esi,0x18(%rdi)
shr    $0x18,%eax
cmp    $0x4,%rdx
cmovb  %ecx,%eax
mov    %eax,0x1c(%rdi)
ret

LLVM IR (-O0):
%struct.can_frame = type { i32* }
define void @DATA(%struct.can_frame* %0, i32 %1, i64 %2) {
%4 = alloca %struct.can_frame*
%5 = alloca i32
%6 = alloca i64
store %struct.can_frame* %0, %struct.can_frame** %4
store i32 %1, i32* %5
store i64 %2, i64* %6
%7 = load i64, i64* %6
%8 = icmp ugt i64 %7, 0
br i1 %8, label %9, label %13
9: ; preds = %3
%10 = load i32, i32* %5
%11 = ashr i32 %10, 0
%12 = and i32 %11, 255
br label %14
13: ; preds = %3
br label %14
14: ; preds = %13, %9
%15 = phi i32 [ %12, %9 ], [ 0, %13 ]
%16 = load %struct.can_frame*, %struct.can_frame** %4
%17 = getelementptr inbounds %struct.can_frame, %struct.can_frame* %16, i32 0, i32 0
%18 = load i32*, i32** %17
%19 = getelementptr inbounds i32, i32* %18, i64 4
store i32 %15, i32* %19
%20 = load i64, i64* %6
%21 = icmp ugt i64 %20, 1
br i1 %21, label %22, label %26
22: ; preds = %14
%23 = load i32, i32* %5
%24 = ashr i32 %23, 8
%25 = and i32 %24, 255
br label %27
26: ; preds = %14
br label %27
27: ; preds = %26, %22
%28 = phi i32 [ %25, %22 ], [ 0, %26 ]
%29 = load %struct.can_frame*, %struct.can_frame** %4
%30 = getelementptr inbounds %struct.can_frame, %struct.can_frame* %29, i32 0, i32 0
%31 = load i32*, i32** %30
%32 = getelementptr inbounds i32, i32* %31, i64 5
store i32 %28, i32* %32
%33 = load i64, i64* %6
%34 = icmp ugt i64 %33, 2
br i1 %34, label %35, label %39
35: ; preds = %27
%36 = load i32, i32* %5
%37 = ashr i32 %36, 16
%38 = and i32 %37, 255
br label %40
39: ; preds = %27
br label %40
40: ; preds = %39, %35
%41 = phi i32 [ %38, %35 ], [ 0, %39 ]
%42 = load %struct.can_frame*, %struct.can_frame** %4
%43 = getelementptr inbounds %struct.can_frame, %struct.can_frame* %42, i32 0, i32 0
%44 = load i32*, i32** %43
%45 = getelementptr inbounds i32, i32* %44, i64 6
store i32 %41, i32* %45
%46 = load i64, i64* %6
%47 = icmp ugt i64 %46, 3
br i1 %47, label %48, label %52
48: ; preds = %40
%49 = load i32, i32* %5
%50 = ashr i32 %49, 24
%51 = and i32 %50, 255
br label %53
52: ; preds = %40
br label %53
53: ; preds = %52, %48
%54 = phi i32 [ %51, %48 ], [ 0, %52 ]
%55 = load %struct.can_frame*, %struct.can_frame** %4
%56 = getelementptr inbounds %struct.can_frame, %struct.can_frame* %55, i32 0, i32 0
%57 = load i32*, i32** %56
%58 = getelementptr inbounds i32, i32* %57, i64 7
store i32 %54, i32* %58
ret void
}

LLVM IR (-O2):
%struct.can_frame = type { i32* }
define void @DATA(%struct.can_frame* nocapture %0, i32 %1, i64 %2) {
%4 = icmp eq i64 %2, 0
%5 = and i32 %1, 255
%6 = select i1 %4, i32 0, i32 %5
%7 = getelementptr inbounds %struct.can_frame, %struct.can_frame* %0, i64 0, i32 0
%8 = load i32*, i32** %7
%9 = getelementptr inbounds i32, i32* %8, i64 4
store i32 %6, i32* %9
%10 = icmp ugt i64 %2, 1
%11 = lshr i32 %1, 8
%12 = and i32 %11, 255
%13 = select i1 %10, i32 %12, i32 0
%14 = getelementptr inbounds i32, i32* %8, i64 5
store i32 %13, i32* %14
%15 = icmp ugt i64 %2, 2
%16 = lshr i32 %1, 16
%17 = and i32 %16, 255
%18 = select i1 %15, i32 %17, i32 0
%19 = getelementptr inbounds i32, i32* %8, i64 6
store i32 %18, i32* %19
%20 = icmp ugt i64 %2, 3
%21 = lshr i32 %1, 24
%22 = select i1 %20, i32 %21, i32 0
%23 = getelementptr inbounds i32, i32* %8, i64 7
store i32 %22, i32* %23
ret void
}