#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 */

/* Variables and functions */
int /*<<< orphan*/ ldbs_poke2(unsigned char *, unsigned short);
int /*<<< orphan*/ memset(unsigned char *, int /*<<< orphan*/, int);
int rand();
unsigned short teledisk_crc(unsigned char *, int);
void default_header(unsigned char *header) {
  unsigned short crc;
  memset(header, 0, 12);
  header[0] = 'T';
  header[1] = 'D';
  header[2] = 0;
  header[3] = rand() & 0xFF;
  header[4] = 0x15;
  header[5] = 0;
  header[6] = 3;
  header[7] = 0;
  header[8] = 0;
  header[9] = 1;
  crc = teledisk_crc(header, 10);
  ldbs_poke2(header + 10, crc);
}


x86 assembly (clang, -O0):
<default_header>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
xor    %esi,%esi
mov    $0xc,%edx
call   1040 <memset@plt>
mov    -0x8(%rbp),%rax
movb   $0x54,(%rax)
mov    -0x8(%rbp),%rax
movb   $0x44,0x1(%rax)
mov    -0x8(%rbp),%rax
movb   $0x0,0x2(%rax)
mov    $0x0,%al
call   1060 <rand@plt>
and    $0xff,%eax
mov    %al,%cl
mov    -0x8(%rbp),%rax
mov    %cl,0x3(%rax)
mov    -0x8(%rbp),%rax
movb   $0x15,0x4(%rax)
mov    -0x8(%rbp),%rax
movb   $0x0,0x5(%rax)
mov    -0x8(%rbp),%rax
movb   $0x3,0x6(%rax)
mov    -0x8(%rbp),%rax
movb   $0x0,0x7(%rax)
mov    -0x8(%rbp),%rax
movb   $0x0,0x8(%rax)
mov    -0x8(%rbp),%rax
movb   $0x1,0x9(%rax)
mov    -0x8(%rbp),%rdi
mov    $0xa,%esi
call   1030 <teledisk_crc@plt>
mov    %ax,-0xa(%rbp)
mov    -0x8(%rbp),%rdi
add    $0xa,%rdi
movzwl -0xa(%rbp),%esi
call   1050 <ldbs_poke2@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<default_header>:
push   %rbx
mov    %rdi,%rbx
xor    %esi,%esi
mov    $0xc,%edx
call   1040 <memset@plt>
movw   $0x4454,(%rbx)
movb   $0x0,0x2(%rbx)
xor    %eax,%eax
call   1060 <rand@plt>
mov    %al,0x3(%rbx)
movl   $0x30015,0x4(%rbx)
movw   $0x100,0x8(%rbx)
mov    %rbx,%rdi
mov    $0xa,%esi
call   1030 <teledisk_crc@plt>
add    $0xa,%rbx
movzwl %ax,%esi
mov    %rbx,%rdi
pop    %rbx
jmp    1050 <ldbs_poke2@plt>

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

LLVM IR (-O2):
define void @default_header(i8* %0) {
%2 = tail call i32 @memset(i8* %0, i32 0, i32 12)
store i8 84, i8* %0
%3 = getelementptr inbounds i8, i8* %0, i64 1
store i8 68, i8* %3
%4 = getelementptr inbounds i8, i8* %0, i64 2
store i8 0, i8* %4
%5 = tail call i32 (...) @rand()
%6 = trunc i32 %5 to i8
%7 = getelementptr inbounds i8, i8* %0, i64 3
store i8 %6, i8* %7
%8 = getelementptr inbounds i8, i8* %0, i64 4
store i8 21, i8* %8
%9 = getelementptr inbounds i8, i8* %0, i64 5
store i8 0, i8* %9
%10 = getelementptr inbounds i8, i8* %0, i64 6
store i8 3, i8* %10
%11 = getelementptr inbounds i8, i8* %0, i64 7
store i8 0, i8* %11
%12 = getelementptr inbounds i8, i8* %0, i64 8
store i8 0, i8* %12
%13 = getelementptr inbounds i8, i8* %0, i64 9
store i8 1, i8* %13
%14 = tail call zeroext i16 @teledisk_crc(i8* %0, i32 10)
%15 = getelementptr inbounds i8, i8* %0, i64 10
%16 = tail call i32 @ldbs_poke2(i8* %15, i16 zeroext %14)
ret void
}