void init_channel(int channel, int pan, unsigned long dataptr, int len) {
  volatile unsigned int *hwptr =
      ((volatile unsigned int *)(void *)(0x800000 + (channel << 7)));
  hwptr[0] = 0x4200 | (dataptr >> 16);
  hwptr[1] = dataptr & 0xffff;
  hwptr[3] = len;
  hwptr[6] = 0;
  ((volatile unsigned char *)(hwptr + 9))[4] = 0x24;
  ((volatile unsigned char *)(hwptr + 9))[1] = 0xf;
  ((volatile unsigned char *)(hwptr + 9))[5] = 0;
  ((volatile unsigned char *)(hwptr + 9))[0] = pan;
  hwptr[4] = 0x1f;
}


x86 assembly (clang, -O0):
<init_channel>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %rdx,-0x10(%rbp)
mov    %ecx,-0x14(%rbp)
mov    -0x4(%rbp),%eax
shl    $0x7,%eax
add    $0x800000,%eax
cltq
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rax
shr    $0x10,%rax
or     $0x4200,%rax
mov    %eax,%ecx
mov    -0x20(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x10(%rbp),%rax
and    $0xffff,%rax
mov    %eax,%ecx
mov    -0x20(%rbp),%rax
mov    %ecx,0x4(%rax)
mov    -0x14(%rbp),%ecx
mov    -0x20(%rbp),%rax
mov    %ecx,0xc(%rax)
mov    -0x20(%rbp),%rax
movl   $0x0,0x18(%rax)
mov    -0x20(%rbp),%rax
movb   $0x24,0x28(%rax)
mov    -0x20(%rbp),%rax
movb   $0xf,0x25(%rax)
mov    -0x20(%rbp),%rax
movb   $0x0,0x29(%rax)
mov    -0x8(%rbp),%eax
mov    %al,%cl
mov    -0x20(%rbp),%rax
mov    %cl,0x24(%rax)
mov    -0x20(%rbp),%rax
movl   $0x1f,0x10(%rax)
pop    %rbp
ret

x86 assembly (clang, -O2):
<init_channel>:
shl    $0x7,%edi
movslq %edi,%rax
movzwl %dx,%edi
shr    $0x10,%rdx
or     $0x4200,%edx
mov    %edx,0x800000(%rax)
mov    %edi,0x800004(%rax)
mov    %ecx,0x80000c(%rax)
movl   $0x0,0x800018(%rax)
movb   $0x24,0x800028(%rax)
movb   $0xf,0x800025(%rax)
movb   $0x0,0x800029(%rax)
mov    %sil,0x800024(%rax)
movl   $0x1f,0x800010(%rax)
ret

LLVM IR (-O0):
define void @init_channel(i32 %0, i32 %1, i64 %2, i32 %3) {
%5 = alloca i32
%6 = alloca i32
%7 = alloca i64
%8 = alloca i32
%9 = alloca i32*
store i32 %0, i32* %5
store i32 %1, i32* %6
store i64 %2, i64* %7
store i32 %3, i32* %8
%10 = load i32, i32* %5
%11 = shl i32 %10, 7
%12 = add nsw i32 8388608, %11
%13 = sext i32 %12 to i64
%14 = inttoptr i64 %13 to i8*
%15 = bitcast i8* %14 to i32*
store i32* %15, i32** %9
%16 = load i64, i64* %7
%17 = lshr i64 %16, 16
%18 = or i64 16896, %17
%19 = trunc i64 %18 to i32
%20 = load i32*, i32** %9
%21 = getelementptr inbounds i32, i32* %20, i64 0
store volatile i32 %19, i32* %21
%22 = load i64, i64* %7
%23 = and i64 %22, 65535
%24 = trunc i64 %23 to i32
%25 = load i32*, i32** %9
%26 = getelementptr inbounds i32, i32* %25, i64 1
store volatile i32 %24, i32* %26
%27 = load i32, i32* %8
%28 = load i32*, i32** %9
%29 = getelementptr inbounds i32, i32* %28, i64 3
store volatile i32 %27, i32* %29
%30 = load i32*, i32** %9
%31 = getelementptr inbounds i32, i32* %30, i64 6
store volatile i32 0, i32* %31
%32 = load i32*, i32** %9
%33 = getelementptr inbounds i32, i32* %32, i64 9
%34 = bitcast i32* %33 to i8*
%35 = getelementptr inbounds i8, i8* %34, i64 4
store volatile i8 36, i8* %35
%36 = load i32*, i32** %9
%37 = getelementptr inbounds i32, i32* %36, i64 9
%38 = bitcast i32* %37 to i8*
%39 = getelementptr inbounds i8, i8* %38, i64 1
store volatile i8 15, i8* %39
%40 = load i32*, i32** %9
%41 = getelementptr inbounds i32, i32* %40, i64 9
%42 = bitcast i32* %41 to i8*
%43 = getelementptr inbounds i8, i8* %42, i64 5
store volatile i8 0, i8* %43
%44 = load i32, i32* %6
%45 = trunc i32 %44 to i8
%46 = load i32*, i32** %9
%47 = getelementptr inbounds i32, i32* %46, i64 9
%48 = bitcast i32* %47 to i8*
%49 = getelementptr inbounds i8, i8* %48, i64 0
store volatile i8 %45, i8* %49
%50 = load i32*, i32** %9
%51 = getelementptr inbounds i32, i32* %50, i64 4
store volatile i32 31, i32* %51
ret void
}

LLVM IR (-O2):
define void @init_channel(i32 %0, i32 %1, i64 %2, i32 %3) {
%5 = shl i32 %0, 7
%6 = add nsw i32 %5, 8388608
%7 = sext i32 %6 to i64
%8 = inttoptr i64 %7 to i32*
%9 = lshr i64 %2, 16
%10 = trunc i64 %9 to i32
%11 = or i32 %10, 16896
store volatile i32 %11, i32* %8
%12 = trunc i64 %2 to i32
%13 = and i32 %12, 65535
%14 = getelementptr inbounds i32, i32* %8, i64 1
store volatile i32 %13, i32* %14
%15 = getelementptr inbounds i32, i32* %8, i64 3
store volatile i32 %3, i32* %15
%16 = getelementptr inbounds i32, i32* %8, i64 6
store volatile i32 0, i32* %16
%17 = getelementptr inbounds i32, i32* %8, i64 9
%18 = bitcast i32* %17 to i8*
%19 = getelementptr inbounds i32, i32* %8, i64 10
%20 = bitcast i32* %19 to i8*
store volatile i8 36, i8* %20
%21 = getelementptr inbounds i8, i8* %18, i64 1
store volatile i8 15, i8* %21
%22 = getelementptr inbounds i8, i8* %18, i64 5
store volatile i8 0, i8* %22
%23 = trunc i32 %1 to i8
store volatile i8 %23, i8* %18
%24 = getelementptr inbounds i32, i32* %8, i64 4
store volatile i32 31, i32* %24
ret void
}