#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(char *, int, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ writeLeInt16(int /*<<< orphan*/ *, int);
int /*<<< orphan*/ writeLeInt32(int /*<<< orphan*/ *, int);
void wavWriteHeader(FILE *f, int length) {
  char riff[4] = "RIFF";
  char wave[4] = "WAVE";
  char fmt[4] = "fmt ";
  char data[4] = "data";
  int chunkSize = 36 + length * 1 * 2;
  fwrite(riff, 4, 1, f);
  writeLeInt32(f, chunkSize);
  fwrite(wave, 4, 1, f);
  fwrite(fmt, 4, 1, f);
  writeLeInt32(f, 16);
  writeLeInt16(f, 1);
  writeLeInt16(f, 1);
  writeLeInt32(f, 96000);
  writeLeInt32(f, 96000 * 1 * 2);
  writeLeInt16(f, 1 * 2);
  writeLeInt16(f, 2 * 8);
  fwrite(data, 4, 1, f);
  writeLeInt32(f, length * 1 * 2);
}


x86 assembly (clang, -O0):
<wavWriteHeader>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    0xebb(%rip),%eax
mov    %eax,-0x10(%rbp)
mov    0xeb6(%rip),%eax
mov    %eax,-0x14(%rbp)
mov    0xeb1(%rip),%eax
mov    %eax,-0x18(%rbp)
mov    0xeac(%rip),%eax
mov    %eax,-0x1c(%rbp)
mov    -0xc(%rbp),%eax
shl    $0x0,%eax
shl    $0x1,%eax
add    $0x24,%eax
mov    %eax,-0x20(%rbp)
lea    -0x10(%rbp),%rdi
mov    -0x8(%rbp),%rcx
mov    $0x4,%esi
mov    $0x1,%edx
call   1050 <fwrite@plt>
mov    -0x8(%rbp),%rdi
mov    -0x20(%rbp),%esi
call   1040 <writeLeInt32@plt>
lea    -0x14(%rbp),%rdi
mov    -0x8(%rbp),%rcx
mov    $0x4,%esi
mov    $0x1,%edx
call   1050 <fwrite@plt>
lea    -0x18(%rbp),%rdi
mov    -0x8(%rbp),%rcx
mov    $0x4,%esi
mov    $0x1,%edx
call   1050 <fwrite@plt>
mov    -0x8(%rbp),%rdi
mov    $0x10,%esi
call   1040 <writeLeInt32@plt>
mov    -0x8(%rbp),%rdi
mov    $0x1,%esi
call   1030 <writeLeInt16@plt>
mov    -0x8(%rbp),%rdi
mov    $0x1,%esi
call   1030 <writeLeInt16@plt>
mov    -0x8(%rbp),%rdi
mov    $0x17700,%esi
call   1040 <writeLeInt32@plt>
mov    -0x8(%rbp),%rdi
mov    $0x2ee00,%esi
call   1040 <writeLeInt32@plt>
mov    -0x8(%rbp),%rdi
mov    $0x2,%esi
call   1030 <writeLeInt16@plt>
mov    -0x8(%rbp),%rdi
mov    $0x10,%esi
call   1030 <writeLeInt16@plt>
lea    -0x1c(%rbp),%rdi
mov    -0x8(%rbp),%rcx
mov    $0x4,%esi
mov    $0x1,%edx
call   1050 <fwrite@plt>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
shl    $0x0,%esi
shl    $0x1,%esi
call   1040 <writeLeInt32@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<wavWriteHeader>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %rdi,%rbx
movl   $0x46464952,0xc(%rsp)
46
movl   $0x45564157,0x8(%rsp)
45
movl   $0x20746d66,0x4(%rsp)
20
movl   $0x61746164,(%rsp)
lea    (%rsi,%rsi,1),%ebp
add    $0x24,%ebp
mov    %esi,%r14d
add    %esi,%r14d
lea    0xc(%rsp),%rdi
mov    $0x4,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
call   1050 <fwrite@plt>
mov    %rbx,%rdi
mov    %ebp,%esi
call   1040 <writeLeInt32@plt>
lea    0x8(%rsp),%rdi
mov    $0x4,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
call   1050 <fwrite@plt>
lea    0x4(%rsp),%rdi
mov    $0x4,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
call   1050 <fwrite@plt>
mov    %rbx,%rdi
mov    $0x10,%esi
call   1040 <writeLeInt32@plt>
mov    %rbx,%rdi
mov    $0x1,%esi
call   1030 <writeLeInt16@plt>
mov    %rbx,%rdi
mov    $0x1,%esi
call   1030 <writeLeInt16@plt>
mov    %rbx,%rdi
mov    $0x17700,%esi
call   1040 <writeLeInt32@plt>
mov    %rbx,%rdi
mov    $0x2ee00,%esi
call   1040 <writeLeInt32@plt>
mov    %rbx,%rdi
mov    $0x2,%esi
call   1030 <writeLeInt16@plt>
mov    %rbx,%rdi
mov    $0x10,%esi
call   1030 <writeLeInt16@plt>
mov    %rsp,%rdi
mov    $0x4,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
call   1050 <fwrite@plt>
mov    %rbx,%rdi
mov    %r14d,%esi
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
jmp    1040 <writeLeInt32@plt>

LLVM IR (-O0):
@__const.wavWriteHeader.riff = [4 x i8] c"RIFF"
@__const.wavWriteHeader.wave = [4 x i8] c"WAVE"
@__const.wavWriteHeader.fmt = [4 x i8] c"fmt "
@__const.wavWriteHeader.data = [4 x i8] c"data"
define void @wavWriteHeader(i32* %0, i32 %1) {
%3 = alloca i32*
%4 = alloca i32
%5 = alloca [4 x i8]
%6 = alloca [4 x i8]
%7 = alloca [4 x i8]
%8 = alloca [4 x i8]
%9 = alloca i32
store i32* %0, i32** %3
store i32 %1, i32* %4
%10 = bitcast [4 x i8]* %5 to i8*
%11 = bitcast [4 x i8]* %6 to i8*
%12 = bitcast [4 x i8]* %7 to i8*
%13 = bitcast [4 x i8]* %8 to i8*
%14 = load i32, i32* %4
%15 = mul nsw i32 %14, 1
%16 = mul nsw i32 %15, 2
%17 = add nsw i32 36, %16
store i32 %17, i32* %9
%18 = getelementptr inbounds [4 x i8], [4 x i8]* %5, i64 0, i64 0
%19 = load i32*, i32** %3
%20 = call i32 @fwrite(i8* %18, i32 4, i32 1, i32* %19)
%21 = load i32*, i32** %3
%22 = load i32, i32* %9
%23 = call i32 @writeLeInt32(i32* %21, i32 %22)
%24 = getelementptr inbounds [4 x i8], [4 x i8]* %6, i64 0, i64 0
%25 = load i32*, i32** %3
%26 = call i32 @fwrite(i8* %24, i32 4, i32 1, i32* %25)
%27 = getelementptr inbounds [4 x i8], [4 x i8]* %7, i64 0, i64 0
%28 = load i32*, i32** %3
%29 = call i32 @fwrite(i8* %27, i32 4, i32 1, i32* %28)
%30 = load i32*, i32** %3
%31 = call i32 @writeLeInt32(i32* %30, i32 16)
%32 = load i32*, i32** %3
%33 = call i32 @writeLeInt16(i32* %32, i32 1)
%34 = load i32*, i32** %3
%35 = call i32 @writeLeInt16(i32* %34, i32 1)
%36 = load i32*, i32** %3
%37 = call i32 @writeLeInt32(i32* %36, i32 96000)
%38 = load i32*, i32** %3
%39 = call i32 @writeLeInt32(i32* %38, i32 192000)
%40 = load i32*, i32** %3
%41 = call i32 @writeLeInt16(i32* %40, i32 2)
%42 = load i32*, i32** %3
%43 = call i32 @writeLeInt16(i32* %42, i32 16)
%44 = getelementptr inbounds [4 x i8], [4 x i8]* %8, i64 0, i64 0
%45 = load i32*, i32** %3
%46 = call i32 @fwrite(i8* %44, i32 4, i32 1, i32* %45)
%47 = load i32*, i32** %3
%48 = load i32, i32* %4
%49 = mul nsw i32 %48, 1
%50 = mul nsw i32 %49, 2
%51 = call i32 @writeLeInt32(i32* %47, i32 %50)
ret void
}

LLVM IR (-O2):
define void @wavWriteHeader(i32* %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = bitcast i32* %3 to i8*
store i32 1179011410, i32* %3
%8 = bitcast i32* %4 to i8*
store i32 1163280727, i32* %4
%9 = bitcast i32* %5 to i8*
store i32 544501094, i32* %5
%10 = bitcast i32* %6 to i8*
store i32 1635017060, i32* %6
%11 = shl nsw i32 %1, 1
%12 = add nsw i32 %11, 36
%13 = call i32 @fwrite(i8* %7, i32 4, i32 1, i32* %0)
%14 = tail call i32 @writeLeInt32(i32* %0, i32 %12)
%15 = call i32 @fwrite(i8* %8, i32 4, i32 1, i32* %0)
%16 = call i32 @fwrite(i8* %9, i32 4, i32 1, i32* %0)
%17 = tail call i32 @writeLeInt32(i32* %0, i32 16)
%18 = tail call i32 @writeLeInt16(i32* %0, i32 1)
%19 = tail call i32 @writeLeInt16(i32* %0, i32 1)
%20 = tail call i32 @writeLeInt32(i32* %0, i32 96000)
%21 = tail call i32 @writeLeInt32(i32* %0, i32 192000)
%22 = tail call i32 @writeLeInt16(i32* %0, i32 2)
%23 = tail call i32 @writeLeInt16(i32* %0, i32 16)
%24 = call i32 @fwrite(i8* %10, i32 4, i32 1, i32* %0)
%25 = tail call i32 @writeLeInt32(i32* %0, i32 %11)
ret void
}