#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_freq(unsigned char *data, uint16_t freq) {
  uint16_t crcdata;
  data[0] = (0x01);
  data[1] = (0x06);
  data[2] = (0x20);
  data[3] = (0x01);
  data[5] = (uint8_t)(freq & 0x00ff);
  data[4] = (uint8_t)(freq >> 8);
  crcdata = crc(data, 6);
  data[6] = (uint8_t)(crcdata & 0x00ff);
  data[7] = (uint8_t)(crcdata >> 8);
}


x86 assembly (clang, -O0):
<fill_cmd_freq>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%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   $0x1,0x3(%rax)
mov    -0xc(%rbp),%eax
and    $0xff,%eax
mov    %al,%cl
mov    -0x8(%rbp),%rax
mov    %cl,0x5(%rax)
mov    -0xc(%rbp),%eax
sar    $0x8,%eax
mov    %al,%cl
mov    -0x8(%rbp),%rax
mov    %cl,0x4(%rax)
mov    -0x8(%rbp),%rdi
mov    $0x6,%esi
call   1030 <crc@plt>
mov    %eax,-0x10(%rbp)
mov    -0x10(%rbp),%eax
and    $0xff,%eax
mov    %al,%cl
mov    -0x8(%rbp),%rax
mov    %cl,0x6(%rax)
mov    -0x10(%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_freq>:
push   %rbx
mov    %esi,%eax
mov    %rdi,%rbx
movl   $0x1200601,(%rdi)
mov    %al,0x5(%rdi)
mov    %ah,0x4(%rdi)
mov    $0x6,%esi
call   1030 <crc@plt>
mov    %ax,0x6(%rbx)
pop    %rbx
ret

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

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