#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 unsigned char uint8_t;
typedef int uint16_t;

/* Variables and functions */
int crc(unsigned char *, int);
void fill_cmd_run(unsigned char *data) {
  uint16_t crcdata;
  data[0] = (0x01);
  data[1] = (0x06);
  data[2] = (0x20);
  data[3] = (0x00);
  data[4] = (0b00000000);
  data[5] = (0b00000010);
  crcdata = crc(data, 6);
  data[6] = (uint8_t)(crcdata & 0x00ff);
  data[7] = (uint8_t)(crcdata >> 8);
}


x86 assembly (clang, -O0):
<fill_cmd_run>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
movb   $0x1,(%rax)
mov    -0x8(%rbp),%rax
movb   $0x6,0x1(%rax)
mov    -0x8(%rbp),%rax
movb   $0x20,0x2(%rax)
mov    -0x8(%rbp),%rax
movb   $0x0,0x3(%rax)
mov    -0x8(%rbp),%rax
movb   $0x0,0x4(%rax)
mov    -0x8(%rbp),%rax
movb   $0x2,0x5(%rax)
mov    -0x8(%rbp),%rdi
mov    $0x6,%esi
call   1030 <crc@plt>
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%eax
and    $0xff,%eax
mov    %al,%cl
mov    -0x8(%rbp),%rax
mov    %cl,0x6(%rax)
mov    -0xc(%rbp),%eax
sar    $0x8,%eax
mov    %al,%cl
mov    -0x8(%rbp),%rax
mov    %cl,0x7(%rax)
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fill_cmd_run>:
push   %rbx
mov    %rdi,%rbx
movl   $0x200601,(%rdi)
movw   $0x200,0x4(%rdi)
mov    $0x6,%esi
call   1030 <crc@plt>
mov    %ax,0x6(%rbx)
pop    %rbx
ret

LLVM IR (-O0):
define void @fill_cmd_run(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
store i8* %0, i8** %2
%4 = load i8*, i8** %2
%5 = getelementptr inbounds i8, i8* %4, i64 0
store i8 1, i8* %5
%6 = load i8*, i8** %2
%7 = getelementptr inbounds i8, i8* %6, i64 1
store i8 6, i8* %7
%8 = load i8*, i8** %2
%9 = getelementptr inbounds i8, i8* %8, i64 2
store i8 32, i8* %9
%10 = load i8*, i8** %2
%11 = getelementptr inbounds i8, i8* %10, i64 3
store i8 0, i8* %11
%12 = load i8*, i8** %2
%13 = getelementptr inbounds i8, i8* %12, i64 4
store i8 0, i8* %13
%14 = load i8*, i8** %2
%15 = getelementptr inbounds i8, i8* %14, i64 5
store i8 2, i8* %15
%16 = load i8*, i8** %2
%17 = call i32 @crc(i8* %16, i32 6)
store i32 %17, i32* %3
%18 = load i32, i32* %3
%19 = and i32 %18, 255
%20 = trunc i32 %19 to i8
%21 = load i8*, i8** %2
%22 = getelementptr inbounds i8, i8* %21, i64 6
store i8 %20, i8* %22
%23 = load i32, i32* %3
%24 = ashr i32 %23, 8
%25 = trunc i32 %24 to i8
%26 = load i8*, i8** %2
%27 = getelementptr inbounds i8, i8* %26, i64 7
store i8 %25, i8* %27
ret void
}

LLVM IR (-O2):
define void @fill_cmd_run(i8* %0) {
store i8 1, i8* %0
%2 = getelementptr inbounds i8, i8* %0, i64 1
store i8 6, i8* %2
%3 = getelementptr inbounds i8, i8* %0, i64 2
store i8 32, i8* %3
%4 = getelementptr inbounds i8, i8* %0, i64 3
store i8 0, i8* %4
%5 = getelementptr inbounds i8, i8* %0, i64 4
store i8 0, i8* %5
%6 = getelementptr inbounds i8, i8* %0, i64 5
store i8 2, i8* %6
%7 = tail call i32 @crc(i8* %0, i32 6)
%8 = trunc i32 %7 to i8
%9 = getelementptr inbounds i8, i8* %0, i64 6
store i8 %8, i8* %9
%10 = lshr i32 %7, 8
%11 = trunc i32 %10 to i8
%12 = getelementptr inbounds i8, i8* %0, i64 7
store i8 %11, i8* %12
ret void
}