#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 uint16_t;

/* Variables and functions */
void transfer_RGB888_to_RGBA16161616(uint16_t *(*output),
                                     unsigned char *input) {
  (*output)[0] = (input[0] << 8) | input[0];
  (*output)[1] = (input[1] << 8) | input[1];
  (*output)[2] = (input[2] << 8) | input[2];
  (*output)[3] = 0xffff;
  (*output) += 4;
}


x86 assembly (clang, -O0):
<transfer_RGB888_to_RGBA16161616>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
movzbl (%rax),%ecx
shl    $0x8,%ecx
mov    -0x10(%rbp),%rax
movzbl (%rax),%eax
or     %eax,%ecx
mov    -0x8(%rbp),%rax
mov    (%rax),%rax
mov    %ecx,(%rax)
mov    -0x10(%rbp),%rax
movzbl 0x1(%rax),%ecx
shl    $0x8,%ecx
mov    -0x10(%rbp),%rax
movzbl 0x1(%rax),%eax
or     %eax,%ecx
mov    -0x8(%rbp),%rax
mov    (%rax),%rax
mov    %ecx,0x4(%rax)
mov    -0x10(%rbp),%rax
movzbl 0x2(%rax),%ecx
shl    $0x8,%ecx
mov    -0x10(%rbp),%rax
movzbl 0x2(%rax),%eax
or     %eax,%ecx
mov    -0x8(%rbp),%rax
mov    (%rax),%rax
mov    %ecx,0x8(%rax)
mov    -0x8(%rbp),%rax
mov    (%rax),%rax
movl   $0xffff,0xc(%rax)
mov    -0x8(%rbp),%rax
mov    (%rax),%rcx
add    $0x10,%rcx
mov    %rcx,(%rax)
pop    %rbp
ret

x86 assembly (clang, -O2):
<transfer_RGB888_to_RGBA16161616>:
movzbl (%rsi),%eax
mov    %eax,%ecx
shl    $0x8,%ecx
or     %eax,%ecx
mov    (%rdi),%rax
mov    %ecx,(%rax)
movzbl 0x1(%rsi),%ecx
mov    %ecx,%edx
shl    $0x8,%edx
or     %ecx,%edx
mov    %edx,0x4(%rax)
movzbl 0x2(%rsi),%ecx
mov    %ecx,%edx
shl    $0x8,%edx
or     %ecx,%edx
mov    %edx,0x8(%rax)
movl   $0xffff,0xc(%rax)
add    $0x10,%rax
mov    %rax,(%rdi)
ret

LLVM IR (-O0):
define void @transfer_RGB888_to_RGBA16161616(i32** %0, i8* %1) {
%3 = alloca i32**
%4 = alloca i8*
store i32** %0, i32*** %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 = shl i32 %8, 8
%10 = load i8*, i8** %4
%11 = getelementptr inbounds i8, i8* %10, i64 0
%12 = load i8, i8* %11
%13 = zext i8 %12 to i32
%14 = or i32 %9, %13
%15 = load i32**, i32*** %3
%16 = load i32*, i32** %15
%17 = getelementptr inbounds i32, i32* %16, i64 0
store i32 %14, i32* %17
%18 = load i8*, i8** %4
%19 = getelementptr inbounds i8, i8* %18, i64 1
%20 = load i8, i8* %19
%21 = zext i8 %20 to i32
%22 = shl i32 %21, 8
%23 = load i8*, i8** %4
%24 = getelementptr inbounds i8, i8* %23, i64 1
%25 = load i8, i8* %24
%26 = zext i8 %25 to i32
%27 = or i32 %22, %26
%28 = load i32**, i32*** %3
%29 = load i32*, i32** %28
%30 = getelementptr inbounds i32, i32* %29, i64 1
store i32 %27, i32* %30
%31 = load i8*, i8** %4
%32 = getelementptr inbounds i8, i8* %31, i64 2
%33 = load i8, i8* %32
%34 = zext i8 %33 to i32
%35 = shl i32 %34, 8
%36 = load i8*, i8** %4
%37 = getelementptr inbounds i8, i8* %36, i64 2
%38 = load i8, i8* %37
%39 = zext i8 %38 to i32
%40 = or i32 %35, %39
%41 = load i32**, i32*** %3
%42 = load i32*, i32** %41
%43 = getelementptr inbounds i32, i32* %42, i64 2
store i32 %40, i32* %43
%44 = load i32**, i32*** %3
%45 = load i32*, i32** %44
%46 = getelementptr inbounds i32, i32* %45, i64 3
store i32 65535, i32* %46
%47 = load i32**, i32*** %3
%48 = load i32*, i32** %47
%49 = getelementptr inbounds i32, i32* %48, i64 4
store i32* %49, i32** %47
ret void
}

LLVM IR (-O2):
define void @transfer_RGB888_to_RGBA16161616(i32** nocapture %0, i8* nocapture %1) {
%3 = load i8, i8* %1
%4 = zext i8 %3 to i32
%5 = shl nuw nsw i32 %4, 8
%6 = or i32 %5, %4
%7 = load i32*, i32** %0
store i32 %6, i32* %7
%8 = getelementptr inbounds i8, i8* %1, i64 1
%9 = load i8, i8* %8
%10 = zext i8 %9 to i32
%11 = shl nuw nsw i32 %10, 8
%12 = or i32 %11, %10
%13 = getelementptr inbounds i32, i32* %7, i64 1
store i32 %12, i32* %13
%14 = getelementptr inbounds i8, i8* %1, i64 2
%15 = load i8, i8* %14
%16 = zext i8 %15 to i32
%17 = shl nuw nsw i32 %16, 8
%18 = or i32 %17, %16
%19 = getelementptr inbounds i32, i32* %7, i64 2
store i32 %18, i32* %19
%20 = getelementptr inbounds i32, i32* %7, i64 3
store i32 65535, i32* %20
%21 = getelementptr inbounds i32, i32* %7, i64 4
store i32* %21, i32** %0
ret void
}