void transfer_RGBA16161616_to_RGBA8888(unsigned char *(*output),
                                       unsigned char *input) {
  (*output)[0] = input[0] >> 8;
  (*output)[1] = input[1] >> 8;
  (*output)[2] = input[2] >> 8;
  (*output)[3] = input[3] >> 8;
  (*output) += 4;
}


x86 assembly (clang, -O0):
<transfer_RGBA16161616_to_RGBA8888>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
movzbl (%rax),%eax
sar    $0x8,%eax
mov    %al,%cl
mov    -0x8(%rbp),%rax
mov    (%rax),%rax
mov    %cl,(%rax)
mov    -0x10(%rbp),%rax
movzbl 0x1(%rax),%eax
sar    $0x8,%eax
mov    %al,%cl
mov    -0x8(%rbp),%rax
mov    (%rax),%rax
mov    %cl,0x1(%rax)
mov    -0x10(%rbp),%rax
movzbl 0x2(%rax),%eax
sar    $0x8,%eax
mov    %al,%cl
mov    -0x8(%rbp),%rax
mov    (%rax),%rax
mov    %cl,0x2(%rax)
mov    -0x10(%rbp),%rax
movzbl 0x3(%rax),%eax
sar    $0x8,%eax
mov    %al,%cl
mov    -0x8(%rbp),%rax
mov    (%rax),%rax
mov    %cl,0x3(%rax)
mov    -0x8(%rbp),%rax
mov    (%rax),%rcx
add    $0x4,%rcx
mov    %rcx,(%rax)
pop    %rbp
ret

x86 assembly (clang, -O2):
<transfer_RGBA16161616_to_RGBA8888>:
mov    (%rdi),%rax
movb   $0x0,(%rax)
mov    (%rdi),%rax
movb   $0x0,0x1(%rax)
mov    (%rdi),%rax
movb   $0x0,0x2(%rax)
mov    (%rdi),%rax
movb   $0x0,0x3(%rax)
addq   $0x4,(%rdi)
ret

LLVM IR (-O0):
define void @transfer_RGBA16161616_to_RGBA8888(i8** %0, i8* %1) {
%3 = alloca i8**
%4 = alloca i8*
store i8** %0, i8*** %3
store i8* %1, i8** %4
%5 = load i8*, i8** %4
%6 = getelementptr inbounds i8, i8* %5, i64 0
%7 = load i8, i8* %6
%8 = zext i8 %7 to i32
%9 = ashr i32 %8, 8
%10 = trunc i32 %9 to i8
%11 = load i8**, i8*** %3
%12 = load i8*, i8** %11
%13 = getelementptr inbounds i8, i8* %12, i64 0
store i8 %10, i8* %13
%14 = load i8*, i8** %4
%15 = getelementptr inbounds i8, i8* %14, i64 1
%16 = load i8, i8* %15
%17 = zext i8 %16 to i32
%18 = ashr i32 %17, 8
%19 = trunc i32 %18 to i8
%20 = load i8**, i8*** %3
%21 = load i8*, i8** %20
%22 = getelementptr inbounds i8, i8* %21, i64 1
store i8 %19, i8* %22
%23 = load i8*, i8** %4
%24 = getelementptr inbounds i8, i8* %23, i64 2
%25 = load i8, i8* %24
%26 = zext i8 %25 to i32
%27 = ashr i32 %26, 8
%28 = trunc i32 %27 to i8
%29 = load i8**, i8*** %3
%30 = load i8*, i8** %29
%31 = getelementptr inbounds i8, i8* %30, i64 2
store i8 %28, i8* %31
%32 = load i8*, i8** %4
%33 = getelementptr inbounds i8, i8* %32, i64 3
%34 = load i8, i8* %33
%35 = zext i8 %34 to i32
%36 = ashr i32 %35, 8
%37 = trunc i32 %36 to i8
%38 = load i8**, i8*** %3
%39 = load i8*, i8** %38
%40 = getelementptr inbounds i8, i8* %39, i64 3
store i8 %37, i8* %40
%41 = load i8**, i8*** %3
%42 = load i8*, i8** %41
%43 = getelementptr inbounds i8, i8* %42, i64 4
store i8* %43, i8** %41
ret void
}

LLVM IR (-O2):
define void @transfer_RGBA16161616_to_RGBA8888(i8** nocapture %0, i8* nocapture readnone %1) {
%3 = load i8*, i8** %0
store i8 0, i8* %3
%4 = load i8*, i8** %0
%5 = getelementptr inbounds i8, i8* %4, i64 1
store i8 0, i8* %5
%6 = load i8*, i8** %0
%7 = getelementptr inbounds i8, i8* %6, i64 2
store i8 0, i8* %7
%8 = load i8*, i8** %0
%9 = getelementptr inbounds i8, i8* %8, i64 3
store i8 0, i8* %9
%10 = load i8*, i8** %0
%11 = getelementptr inbounds i8, i8* %10, i64 4
store i8* %11, i8** %0
ret void
}