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

/* Variables and functions */
int mdv_csum(int *, int);
int /*<<< orphan*/ memcpy(int *, int *, int);
int /*<<< orphan*/ memset(int *, int /*<<< orphan*/, int);
int /*<<< orphan*/ strncpy(int *, char *, int);
void mdv_make_bufhdr(uint8_t *buf, uint8_t rec, uint8_t *bits) {
  memset(buf, 0, 14);
  buf[0] = 0;
  buf[1] = rec;
  buf[2] = 0;
  buf[3] = 2;
  strncpy(buf + 4, "FUZIX     ", 10);
  buf[14] = mdv_csum(buf, 14);
  memcpy(buf + 15, bits, 512);
  buf[527] = mdv_csum(buf + 15, 512);
}


x86 assembly (clang, -O0):
<mdv_make_bufhdr>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
xor    %esi,%esi
mov    $0xe,%edx
call   1040 <memset@plt>
mov    -0x8(%rbp),%rax
movl   $0x0,(%rax)
mov    -0xc(%rbp),%ecx
mov    -0x8(%rbp),%rax
mov    %ecx,0x4(%rax)
mov    -0x8(%rbp),%rax
movl   $0x0,0x8(%rax)
mov    -0x8(%rbp),%rax
movl   $0x2,0xc(%rax)
mov    -0x8(%rbp),%rdi
add    $0x10,%rdi
lea    0xe64(%rip),%rsi
mov    $0xa,%edx
call   1030 <strncpy@plt>
mov    -0x8(%rbp),%rdi
mov    $0xe,%esi
call   1050 <mdv_csum@plt>
mov    %eax,%ecx
mov    -0x8(%rbp),%rax
mov    %ecx,0x38(%rax)
mov    -0x8(%rbp),%rdi
add    $0x3c,%rdi
mov    -0x18(%rbp),%rsi
mov    $0x200,%edx
call   1060 <memcpy@plt>
mov    -0x8(%rbp),%rdi
add    $0x3c,%rdi
mov    $0x200,%esi
call   1050 <mdv_csum@plt>
mov    %eax,%ecx
mov    -0x8(%rbp),%rax
mov    %ecx,0x83c(%rax)
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mdv_make_bufhdr>:
push   %rbp
push   %r14
push   %rbx
mov    %rdx,%r14
mov    %esi,%ebp
mov    %rdi,%rbx
xor    %esi,%esi
mov    $0xe,%edx
call   1040 <memset@plt>
movl   $0x0,(%rbx)
mov    %ebp,0x4(%rbx)
movabs $0x200000000,%rax
mov    %rax,0x8(%rbx)
lea    0x10(%rbx),%rdi
lea    0xe86(%rip),%rsi
mov    $0xa,%edx
call   1030 <strncpy@plt>
mov    %rbx,%rdi
mov    $0xe,%esi
call   1050 <mdv_csum@plt>
mov    %eax,0x38(%rbx)
lea    0x3c(%rbx),%rbp
mov    %rbp,%rdi
mov    %r14,%rsi
mov    $0x200,%edx
call   1060 <memcpy@plt>
mov    %rbp,%rdi
mov    $0x200,%esi
call   1050 <mdv_csum@plt>
mov    %eax,0x83c(%rbx)
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [11 x i8] c"FUZIX \00"
define void @mdv_make_bufhdr(i32* %0, i32 %1, i32* %2) {
%4 = alloca i32*
%5 = alloca i32
%6 = alloca i32*
store i32* %0, i32** %4
store i32 %1, i32* %5
store i32* %2, i32** %6
%7 = load i32*, i32** %4
%8 = call i32 @memset(i32* %7, i32 0, i32 14)
%9 = load i32*, i32** %4
%10 = getelementptr inbounds i32, i32* %9, i64 0
store i32 0, i32* %10
%11 = load i32, i32* %5
%12 = load i32*, i32** %4
%13 = getelementptr inbounds i32, i32* %12, i64 1
store i32 %11, i32* %13
%14 = load i32*, i32** %4
%15 = getelementptr inbounds i32, i32* %14, i64 2
store i32 0, i32* %15
%16 = load i32*, i32** %4
%17 = getelementptr inbounds i32, i32* %16, i64 3
store i32 2, i32* %17
%18 = load i32*, i32** %4
%19 = getelementptr inbounds i32, i32* %18, i64 4
%20 = call i32 @strncpy(i32* %19, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i32 10)
%21 = load i32*, i32** %4
%22 = call i32 @mdv_csum(i32* %21, i32 14)
%23 = load i32*, i32** %4
%24 = getelementptr inbounds i32, i32* %23, i64 14
store i32 %22, i32* %24
%25 = load i32*, i32** %4
%26 = getelementptr inbounds i32, i32* %25, i64 15
%27 = load i32*, i32** %6
%28 = call i32 @memcpy(i32* %26, i32* %27, i32 512)
%29 = load i32*, i32** %4
%30 = getelementptr inbounds i32, i32* %29, i64 15
%31 = call i32 @mdv_csum(i32* %30, i32 512)
%32 = load i32*, i32** %4
%33 = getelementptr inbounds i32, i32* %32, i64 527
store i32 %31, i32* %33
ret void
}

LLVM IR (-O2):
@.str = [11 x i8] c"FUZIX \00"
define void @mdv_make_bufhdr(i32* %0, i32 %1, i32* %2) {
%4 = tail call i32 @memset(i32* %0, i32 0, i32 14)
store i32 0, i32* %0
%5 = getelementptr inbounds i32, i32* %0, i64 1
store i32 %1, i32* %5
%6 = getelementptr inbounds i32, i32* %0, i64 2
store i32 0, i32* %6
%7 = getelementptr inbounds i32, i32* %0, i64 3
store i32 2, i32* %7
%8 = getelementptr inbounds i32, i32* %0, i64 4
%9 = tail call i32 @strncpy(i32* %8, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i32 10)
%10 = tail call i32 @mdv_csum(i32* %0, i32 14)
%11 = getelementptr inbounds i32, i32* %0, i64 14
store i32 %10, i32* %11
%12 = getelementptr inbounds i32, i32* %0, i64 15
%13 = tail call i32 @memcpy(i32* %12, i32* %2, i32 512)
%14 = tail call i32 @mdv_csum(i32* %12, i32 512)
%15 = getelementptr inbounds i32, i32* %0, i64 527
store i32 %14, i32* %15
ret void
}