void writepcmfmt(unsigned char *hdr, int wchannel, int wsrate, int wbits) {
  int Bps;
  Bps = wsrate * wchannel * (wbits / 8);
  *(hdr) = 'f';
  *(hdr + 1) = 'm';
  *(hdr + 2) = 't';
  *(hdr + 3) = 0x20;
  *(hdr + 4) = 0x10;
  *(hdr + 5) = 0;
  *(hdr + 6) = 0;
  *(hdr + 7) = 0;
  *(hdr + 8) = 1;
  *(hdr + 9) = 0;
  *(hdr + 10) = (unsigned char)(wchannel & 0xff);
  *(hdr + 11) = (unsigned char)((wchannel & 0xff00) >> 8);
  *(hdr + 12) = (unsigned char)(wsrate & 0xff);
  *(hdr + 13) = (unsigned char)((wsrate & 0xff00) >> 8);
  *(hdr + 14) = (unsigned char)((wsrate & 0xff0000) >> 16);
  *(hdr + 15) = (unsigned char)((wsrate & 0xff000000) >> 24);
  *(hdr + 16) = (unsigned char)(Bps & 0xff);
  *(hdr + 17) = (unsigned char)((Bps & 0xff00) >> 8);
  *(hdr + 18) = (unsigned char)((Bps & 0xff0000) >> 16);
  *(hdr + 19) = (unsigned char)((Bps & 0xff000000) >> 24);
  *(hdr + 20) = 4;
  *(hdr + 21) = 0;
  *(hdr + 22) = (unsigned char)(wbits & 0xff);
  *(hdr + 23) = (unsigned char)((wbits & 0xff00) >> 8);
}


x86 assembly (clang, -O0):
<writepcmfmt>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    %ecx,-0x14(%rbp)
mov    -0x10(%rbp),%eax
imul   -0xc(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x14(%rbp),%eax
mov    $0x8,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    -0x1c(%rbp),%eax
imul   %ecx,%eax
mov    %eax,-0x18(%rbp)
mov    -0x8(%rbp),%rax
movb   $0x66,(%rax)
mov    -0x8(%rbp),%rax
movb   $0x6d,0x1(%rax)
mov    -0x8(%rbp),%rax
movb   $0x74,0x2(%rax)
mov    -0x8(%rbp),%rax
movb   $0x20,0x3(%rax)
mov    -0x8(%rbp),%rax
movb   $0x10,0x4(%rax)
mov    -0x8(%rbp),%rax
movb   $0x0,0x5(%rax)
mov    -0x8(%rbp),%rax
movb   $0x0,0x6(%rax)
mov    -0x8(%rbp),%rax
movb   $0x0,0x7(%rax)
mov    -0x8(%rbp),%rax
movb   $0x1,0x8(%rax)
mov    -0x8(%rbp),%rax
movb   $0x0,0x9(%rax)
mov    -0xc(%rbp),%eax
and    $0xff,%eax
mov    %al,%cl
mov    -0x8(%rbp),%rax
mov    %cl,0xa(%rax)
mov    -0xc(%rbp),%eax
and    $0xff00,%eax
sar    $0x8,%eax
mov    %al,%cl
mov    -0x8(%rbp),%rax
mov    %cl,0xb(%rax)
mov    -0x10(%rbp),%eax
and    $0xff,%eax
mov    %al,%cl
mov    -0x8(%rbp),%rax
mov    %cl,0xc(%rax)
mov    -0x10(%rbp),%eax
and    $0xff00,%eax
sar    $0x8,%eax
mov    %al,%cl
mov    -0x8(%rbp),%rax
mov    %cl,0xd(%rax)
mov    -0x10(%rbp),%eax
and    $0xff0000,%eax
sar    $0x10,%eax
mov    %al,%cl
mov    -0x8(%rbp),%rax
mov    %cl,0xe(%rax)
mov    -0x10(%rbp),%eax
and    $0xff000000,%eax
shr    $0x18,%eax
mov    %al,%cl
mov    -0x8(%rbp),%rax
mov    %cl,0xf(%rax)
mov    -0x18(%rbp),%eax
and    $0xff,%eax
mov    %al,%cl
mov    -0x8(%rbp),%rax
mov    %cl,0x10(%rax)
mov    -0x18(%rbp),%eax
and    $0xff00,%eax
sar    $0x8,%eax
mov    %al,%cl
mov    -0x8(%rbp),%rax
mov    %cl,0x11(%rax)
mov    -0x18(%rbp),%eax
and    $0xff0000,%eax
sar    $0x10,%eax
mov    %al,%cl
mov    -0x8(%rbp),%rax
mov    %cl,0x12(%rax)
mov    -0x18(%rbp),%eax
and    $0xff000000,%eax
shr    $0x18,%eax
mov    %al,%cl
mov    -0x8(%rbp),%rax
mov    %cl,0x13(%rax)
mov    -0x8(%rbp),%rax
movb   $0x4,0x14(%rax)
mov    -0x8(%rbp),%rax
movb   $0x0,0x15(%rax)
mov    -0x14(%rbp),%eax
and    $0xff,%eax
mov    %al,%cl
mov    -0x8(%rbp),%rax
mov    %cl,0x16(%rax)
mov    -0x14(%rbp),%eax
and    $0xff00,%eax
sar    $0x8,%eax
mov    %al,%cl
mov    -0x8(%rbp),%rax
mov    %cl,0x17(%rax)
pop    %rbp
ret

x86 assembly (clang, -O2):
<writepcmfmt>:
push   %rbx
mov    %ecx,%r8d
mov    %esi,%ebx
mov    %edx,%ecx
imul   %esi,%ecx
test   %r8d,%r8d
lea    0x7(%r8),%eax
cmovns %r8d,%eax
sar    $0x3,%eax
imul   %ecx,%eax
movabs $0x1020746d66,%rcx
mov    %rcx,(%rdi)
movw   $0x1,0x8(%rdi)
mov    %bl,0xa(%rdi)
mov    %bh,0xb(%rdi)
mov    %dl,0xc(%rdi)
mov    %dh,0xd(%rdi)
mov    %edx,%ecx
shr    $0x10,%ecx
mov    %cl,0xe(%rdi)
shr    $0x18,%edx
mov    %dl,0xf(%rdi)
mov    %al,0x10(%rdi)
mov    %ah,0x11(%rdi)
mov    %eax,%ecx
shr    $0x10,%ecx
mov    %cl,0x12(%rdi)
shr    $0x18,%eax
mov    %al,0x13(%rdi)
movw   $0x4,0x14(%rdi)
mov    %r8,%rax
mov    %al,0x16(%rdi)
mov    %ah,0x17(%rdi)
pop    %rbx
ret

LLVM IR (-O0):
define void @writepcmfmt(i8* %0, i32 %1, i32 %2, i32 %3) {
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
store i8* %0, i8** %5
store i32 %1, i32* %6
store i32 %2, i32* %7
store i32 %3, i32* %8
%10 = load i32, i32* %7
%11 = load i32, i32* %6
%12 = mul nsw i32 %10, %11
%13 = load i32, i32* %8
%14 = sdiv i32 %13, 8
%15 = mul nsw i32 %12, %14
store i32 %15, i32* %9
%16 = load i8*, i8** %5
store i8 102, i8* %16
%17 = load i8*, i8** %5
%18 = getelementptr inbounds i8, i8* %17, i64 1
store i8 109, i8* %18
%19 = load i8*, i8** %5
%20 = getelementptr inbounds i8, i8* %19, i64 2
store i8 116, i8* %20
%21 = load i8*, i8** %5
%22 = getelementptr inbounds i8, i8* %21, i64 3
store i8 32, i8* %22
%23 = load i8*, i8** %5
%24 = getelementptr inbounds i8, i8* %23, i64 4
store i8 16, i8* %24
%25 = load i8*, i8** %5
%26 = getelementptr inbounds i8, i8* %25, i64 5
store i8 0, i8* %26
%27 = load i8*, i8** %5
%28 = getelementptr inbounds i8, i8* %27, i64 6
store i8 0, i8* %28
%29 = load i8*, i8** %5
%30 = getelementptr inbounds i8, i8* %29, i64 7
store i8 0, i8* %30
%31 = load i8*, i8** %5
%32 = getelementptr inbounds i8, i8* %31, i64 8
store i8 1, i8* %32
%33 = load i8*, i8** %5
%34 = getelementptr inbounds i8, i8* %33, i64 9
store i8 0, i8* %34
%35 = load i32, i32* %6
%36 = and i32 %35, 255
%37 = trunc i32 %36 to i8
%38 = load i8*, i8** %5
%39 = getelementptr inbounds i8, i8* %38, i64 10
store i8 %37, i8* %39
%40 = load i32, i32* %6
%41 = and i32 %40, 65280
%42 = ashr i32 %41, 8
%43 = trunc i32 %42 to i8
%44 = load i8*, i8** %5
%45 = getelementptr inbounds i8, i8* %44, i64 11
store i8 %43, i8* %45
%46 = load i32, i32* %7
%47 = and i32 %46, 255
%48 = trunc i32 %47 to i8
%49 = load i8*, i8** %5
%50 = getelementptr inbounds i8, i8* %49, i64 12
store i8 %48, i8* %50
%51 = load i32, i32* %7
%52 = and i32 %51, 65280
%53 = ashr i32 %52, 8
%54 = trunc i32 %53 to i8
%55 = load i8*, i8** %5
%56 = getelementptr inbounds i8, i8* %55, i64 13
store i8 %54, i8* %56
%57 = load i32, i32* %7
%58 = and i32 %57, 16711680
%59 = ashr i32 %58, 16
%60 = trunc i32 %59 to i8
%61 = load i8*, i8** %5
%62 = getelementptr inbounds i8, i8* %61, i64 14
store i8 %60, i8* %62
%63 = load i32, i32* %7
%64 = and i32 %63, -16777216
%65 = lshr i32 %64, 24
%66 = trunc i32 %65 to i8
%67 = load i8*, i8** %5
%68 = getelementptr inbounds i8, i8* %67, i64 15
store i8 %66, i8* %68
%69 = load i32, i32* %9
%70 = and i32 %69, 255
%71 = trunc i32 %70 to i8
%72 = load i8*, i8** %5
%73 = getelementptr inbounds i8, i8* %72, i64 16
store i8 %71, i8* %73
%74 = load i32, i32* %9
%75 = and i32 %74, 65280
%76 = ashr i32 %75, 8
%77 = trunc i32 %76 to i8
%78 = load i8*, i8** %5
%79 = getelementptr inbounds i8, i8* %78, i64 17
store i8 %77, i8* %79
%80 = load i32, i32* %9
%81 = and i32 %80, 16711680
%82 = ashr i32 %81, 16
%83 = trunc i32 %82 to i8
%84 = load i8*, i8** %5
%85 = getelementptr inbounds i8, i8* %84, i64 18
store i8 %83, i8* %85
%86 = load i32, i32* %9
%87 = and i32 %86, -16777216
%88 = lshr i32 %87, 24
%89 = trunc i32 %88 to i8
%90 = load i8*, i8** %5
%91 = getelementptr inbounds i8, i8* %90, i64 19
store i8 %89, i8* %91
%92 = load i8*, i8** %5
%93 = getelementptr inbounds i8, i8* %92, i64 20
store i8 4, i8* %93
%94 = load i8*, i8** %5
%95 = getelementptr inbounds i8, i8* %94, i64 21
store i8 0, i8* %95
%96 = load i32, i32* %8
%97 = and i32 %96, 255
%98 = trunc i32 %97 to i8
%99 = load i8*, i8** %5
%100 = getelementptr inbounds i8, i8* %99, i64 22
store i8 %98, i8* %100
%101 = load i32, i32* %8
%102 = and i32 %101, 65280
%103 = ashr i32 %102, 8
%104 = trunc i32 %103 to i8
%105 = load i8*, i8** %5
%106 = getelementptr inbounds i8, i8* %105, i64 23
store i8 %104, i8* %106
ret void
}

LLVM IR (-O2):
define void @writepcmfmt(i8* writeonly %0, i32 %1, i32 %2, i32 %3) {
%5 = mul nsw i32 %2, %1
%6 = sdiv i32 %3, 8
%7 = mul nsw i32 %5, %6
store i8 102, i8* %0
%8 = getelementptr inbounds i8, i8* %0, i64 1
store i8 109, i8* %8
%9 = getelementptr inbounds i8, i8* %0, i64 2
store i8 116, i8* %9
%10 = getelementptr inbounds i8, i8* %0, i64 3
store i8 32, i8* %10
%11 = getelementptr inbounds i8, i8* %0, i64 4
store i8 16, i8* %11
%12 = getelementptr inbounds i8, i8* %0, i64 5
store i8 0, i8* %12
%13 = getelementptr inbounds i8, i8* %0, i64 6
store i8 0, i8* %13
%14 = getelementptr inbounds i8, i8* %0, i64 7
store i8 0, i8* %14
%15 = getelementptr inbounds i8, i8* %0, i64 8
store i8 1, i8* %15
%16 = getelementptr inbounds i8, i8* %0, i64 9
store i8 0, i8* %16
%17 = trunc i32 %1 to i8
%18 = getelementptr inbounds i8, i8* %0, i64 10
store i8 %17, i8* %18
%19 = lshr i32 %1, 8
%20 = trunc i32 %19 to i8
%21 = getelementptr inbounds i8, i8* %0, i64 11
store i8 %20, i8* %21
%22 = trunc i32 %2 to i8
%23 = getelementptr inbounds i8, i8* %0, i64 12
store i8 %22, i8* %23
%24 = lshr i32 %2, 8
%25 = trunc i32 %24 to i8
%26 = getelementptr inbounds i8, i8* %0, i64 13
store i8 %25, i8* %26
%27 = lshr i32 %2, 16
%28 = trunc i32 %27 to i8
%29 = getelementptr inbounds i8, i8* %0, i64 14
store i8 %28, i8* %29
%30 = lshr i32 %2, 24
%31 = trunc i32 %30 to i8
%32 = getelementptr inbounds i8, i8* %0, i64 15
store i8 %31, i8* %32
%33 = trunc i32 %7 to i8
%34 = getelementptr inbounds i8, i8* %0, i64 16
store i8 %33, i8* %34
%35 = lshr i32 %7, 8
%36 = trunc i32 %35 to i8
%37 = getelementptr inbounds i8, i8* %0, i64 17
store i8 %36, i8* %37
%38 = lshr i32 %7, 16
%39 = trunc i32 %38 to i8
%40 = getelementptr inbounds i8, i8* %0, i64 18
store i8 %39, i8* %40
%41 = lshr i32 %7, 24
%42 = trunc i32 %41 to i8
%43 = getelementptr inbounds i8, i8* %0, i64 19
store i8 %42, i8* %43
%44 = getelementptr inbounds i8, i8* %0, i64 20
store i8 4, i8* %44
%45 = getelementptr inbounds i8, i8* %0, i64 21
store i8 0, i8* %45
%46 = trunc i32 %3 to i8
%47 = getelementptr inbounds i8, i8* %0, i64 22
store i8 %46, i8* %47
%48 = lshr i32 %3, 8
%49 = trunc i32 %48 to i8
%50 = getelementptr inbounds i8, i8* %0, i64 23
store i8 %49, i8* %50
ret void
}