#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 /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ fwrite(unsigned char *, int, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ putlong(unsigned char *, int);
int /*<<< orphan*/ putword(unsigned char *, int);
void fwrite_wav_hed(int len, int freq, FILE *fp) {
  static unsigned char hed[0x2c] = {
      'R',  'I',  'F',  'F',  0,    0,    0,    0,    'W',  'A',  'V',
      'E',  'f',  'm',  't',  ' ',  0x10, 0,    0,    0,    0x01, 0x00,
      0x02, 0x00, 0x44, 0xac, 0x00, 0x00, 0x10, 0xb1, 0x02, 0x00, 0x04,
      0x00, 0x10, 0x00, 'd',  'a',  't',  'a',  0,    0,    0,    0};
  putword(hed + 0x16, 1);
  putlong(hed + 0x18, freq);
  putlong(hed + 0x1c, freq * 2);
  putword(hed + 0x20, 0x02);
  putword(hed + 0x22, 0x10);
  putlong(hed + 4, len + 0x2c - 4);
  putlong(hed + 0x28, len);
  fwrite(hed, 1, 0x2c, fp);
}


x86 assembly (clang, -O0):
<fwrite_wav_hed>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %rdx,-0x10(%rbp)
lea    0x2ef7(%rip),%rdi
add    $0x16,%rdi
mov    $0x1,%esi
call   1030 <putword@plt>
mov    -0x8(%rbp),%esi
lea    0x2edf(%rip),%rdi
add    $0x18,%rdi
call   1040 <putlong@plt>
mov    -0x8(%rbp),%esi
shl    $0x1,%esi
lea    0x2ec9(%rip),%rdi
add    $0x1c,%rdi
call   1040 <putlong@plt>
lea    0x2eb9(%rip),%rdi
add    $0x20,%rdi
mov    $0x2,%esi
call   1030 <putword@plt>
lea    0x2ea4(%rip),%rdi
add    $0x22,%rdi
mov    $0x10,%esi
call   1030 <putword@plt>
mov    -0x4(%rbp),%esi
add    $0x2c,%esi
sub    $0x4,%esi
lea    0x2e86(%rip),%rdi
add    $0x4,%rdi
call   1040 <putlong@plt>
mov    -0x4(%rbp),%esi
lea    0x2e73(%rip),%rdi
add    $0x28,%rdi
call   1040 <putlong@plt>
mov    -0x10(%rbp),%rcx
lea    0x2e5f(%rip),%rdi
mov    $0x1,%esi
mov    $0x2c,%edx
call   1050 <fwrite@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fwrite_wav_hed>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rdx,%r14
mov    %esi,%ebp
mov    %edi,%ebx
lea    0x2f11(%rip),%rdi
mov    $0x1,%esi
call   1030 <putword@plt>
lea    0x2eea(%rip),%r15
lea    0x2efb(%rip),%rdi
mov    %ebp,%esi
call   1040 <putlong@plt>
add    %ebp,%ebp
lea    0x2eef(%rip),%rdi
mov    %ebp,%esi
call   1040 <putlong@plt>
lea    0x2ee5(%rip),%rdi
mov    $0x2,%esi
call   1030 <putword@plt>
lea    0x2ed6(%rip),%rdi
mov    $0x10,%esi
call   1030 <putword@plt>
lea    0x28(%rbx),%esi
lea    0x2ea4(%rip),%rdi
call   1040 <putlong@plt>
lea    0x2ebc(%rip),%rdi
mov    %ebx,%esi
call   1040 <putlong@plt>
mov    %r15,%rdi
mov    $0x1,%esi
mov    $0x2c,%edx
mov    %r14,%rcx
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1050 <fwrite@plt>

LLVM IR (-O0):
@fwrite_wav_hed.hed = internal global [44 x i8] c"RIFF\00\00\00\00WAVEfmt \10\00\00\00\01\00\02\00D\AC\00\00\10\B1\02\00\04\00\10\00data\00\00\00\00"
define void @fwrite_wav_hed(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 = call i32 @putword(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @fwrite_wav_hed.hed, i64 0, i64 22), i32 1)
%8 = load i32, i32* %5
%9 = call i32 @putlong(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @fwrite_wav_hed.hed, i64 0, i64 24), i32 %8)
%10 = load i32, i32* %5
%11 = mul nsw i32 %10, 2
%12 = call i32 @putlong(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @fwrite_wav_hed.hed, i64 0, i64 28), i32 %11)
%13 = call i32 @putword(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @fwrite_wav_hed.hed, i64 0, i64 32), i32 2)
%14 = call i32 @putword(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @fwrite_wav_hed.hed, i64 0, i64 34), i32 16)
%15 = load i32, i32* %4
%16 = add nsw i32 %15, 44
%17 = sub nsw i32 %16, 4
%18 = call i32 @putlong(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @fwrite_wav_hed.hed, i64 0, i64 4), i32 %17)
%19 = load i32, i32* %4
%20 = call i32 @putlong(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @fwrite_wav_hed.hed, i64 0, i64 40), i32 %19)
%21 = load i32*, i32** %6
%22 = call i32 @fwrite(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @fwrite_wav_hed.hed, i64 0, i64 0), i32 1, i32 44, i32* %21)
ret void
}

LLVM IR (-O2):
@fwrite_wav_hed.hed = internal global [44 x i8] c"RIFF\00\00\00\00WAVEfmt \10\00\00\00\01\00\02\00D\AC\00\00\10\B1\02\00\04\00\10\00data\00\00\00\00"
define void @fwrite_wav_hed(i32 %0, i32 %1, i32* nocapture %2) {
%4 = tail call i32 @putword(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @fwrite_wav_hed.hed, i64 0, i64 22), i32 1)
%5 = tail call i32 @putlong(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @fwrite_wav_hed.hed, i64 0, i64 24), i32 %1)
%6 = shl nsw i32 %1, 1
%7 = tail call i32 @putlong(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @fwrite_wav_hed.hed, i64 0, i64 28), i32 %6)
%8 = tail call i32 @putword(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @fwrite_wav_hed.hed, i64 0, i64 32), i32 2)
%9 = tail call i32 @putword(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @fwrite_wav_hed.hed, i64 0, i64 34), i32 16)
%10 = add nsw i32 %0, 40
%11 = tail call i32 @putlong(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @fwrite_wav_hed.hed, i64 0, i64 4), i32 %10)
%12 = tail call i32 @putlong(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @fwrite_wav_hed.hed, i64 0, i64 40), i32 %0)
%13 = tail call i32 @fwrite(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @fwrite_wav_hed.hed, i64 0, i64 0), i32 1, i32 44, i32* %2)
ret void
}