#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 uint8_t;
typedef int uint32_t;

/* Variables and functions */
void colorTransform16To24bpp(uint32_t color, uint8_t *red, uint8_t *green,
                             uint8_t *blue) {
  uint8_t redValue = (color & 0x0000F800) >> 11;
  uint8_t greenValue = (color & 0x000007E0) >> 5;
  uint8_t blueValue = (color & 0x0000001F);
  redValue <<= 3;
  greenValue <<= 2;
  blueValue <<= 3;
  *red = redValue;
  *green = greenValue;
  *blue = blueValue;
  return;
}


x86 assembly (clang, -O0):
<colorTransform16To24bpp>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    -0x4(%rbp),%eax
and    $0xf800,%eax
sar    $0xb,%eax
mov    %eax,-0x24(%rbp)
mov    -0x4(%rbp),%eax
and    $0x7e0,%eax
sar    $0x5,%eax
mov    %eax,-0x28(%rbp)
mov    -0x4(%rbp),%eax
and    $0x1f,%eax
mov    %eax,-0x2c(%rbp)
mov    -0x24(%rbp),%eax
shl    $0x3,%eax
mov    %eax,-0x24(%rbp)
mov    -0x28(%rbp),%eax
shl    $0x2,%eax
mov    %eax,-0x28(%rbp)
mov    -0x2c(%rbp),%eax
shl    $0x3,%eax
mov    %eax,-0x2c(%rbp)
mov    -0x24(%rbp),%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x28(%rbp),%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x2c(%rbp),%ecx
mov    -0x20(%rbp),%rax
mov    %ecx,(%rax)
pop    %rbp
ret

x86 assembly (clang, -O2):
<colorTransform16To24bpp>:
mov    %edi,%r8d
shr    $0x8,%r8d
and    $0xf8,%r8d
mov    %edi,%eax
shr    $0x3,%eax
and    $0xfc,%eax
shl    $0x3,%edi
movzbl %dil,%edi
mov    %r8d,(%rsi)
mov    %eax,(%rdx)
mov    %edi,(%rcx)
ret

LLVM IR (-O0):
define void @colorTransform16To24bpp(i32 %0, i32* %1, i32* %2, i32* %3) {
%5 = alloca i32
%6 = alloca i32*
%7 = alloca i32*
%8 = alloca i32*
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
store i32 %0, i32* %5
store i32* %1, i32** %6
store i32* %2, i32** %7
store i32* %3, i32** %8
%12 = load i32, i32* %5
%13 = and i32 %12, 63488
%14 = ashr i32 %13, 11
store i32 %14, i32* %9
%15 = load i32, i32* %5
%16 = and i32 %15, 2016
%17 = ashr i32 %16, 5
store i32 %17, i32* %10
%18 = load i32, i32* %5
%19 = and i32 %18, 31
store i32 %19, i32* %11
%20 = load i32, i32* %9
%21 = shl i32 %20, 3
store i32 %21, i32* %9
%22 = load i32, i32* %10
%23 = shl i32 %22, 2
store i32 %23, i32* %10
%24 = load i32, i32* %11
%25 = shl i32 %24, 3
store i32 %25, i32* %11
%26 = load i32, i32* %9
%27 = load i32*, i32** %6
store i32 %26, i32* %27
%28 = load i32, i32* %10
%29 = load i32*, i32** %7
store i32 %28, i32* %29
%30 = load i32, i32* %11
%31 = load i32*, i32** %8
store i32 %30, i32* %31
ret void
}

LLVM IR (-O2):
define void @colorTransform16To24bpp(i32 %0, i32* nocapture writeonly %1, i32* nocapture writeonly %2, i32* nocapture writeonly %3) {
%5 = lshr i32 %0, 8
%6 = and i32 %5, 248
%7 = lshr i32 %0, 3
%8 = and i32 %7, 252
%9 = shl i32 %0, 3
%10 = and i32 %9, 248
store i32 %6, i32* %1
store i32 %8, i32* %2
store i32 %10, i32* %3
ret void
}