#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 /*<<< orphan*/ uint8_t;
typedef int uint16_t;

/* Variables and functions */
void rgb565_lep(const uint16_t d, uint8_t *c) {
  *(c++) = (d >> 8 & 0xf8) | (d >> 13);
  *(c++) = (d >> 3 & 0xfc) | (d >> 9 & 3);
  *(c++) = (d << 3) | (d >> 2 & 7);
}


x86 assembly (clang, -O0):
<rgb565_lep>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x4(%rbp),%ecx
sar    $0x8,%ecx
and    $0xf8,%ecx
mov    -0x4(%rbp),%eax
sar    $0xd,%eax
or     %eax,%ecx
mov    -0x10(%rbp),%rax
mov    %rax,%rdx
add    $0x4,%rdx
mov    %rdx,-0x10(%rbp)
mov    %ecx,(%rax)
mov    -0x4(%rbp),%ecx
sar    $0x3,%ecx
and    $0xfc,%ecx
mov    -0x4(%rbp),%eax
sar    $0x9,%eax
and    $0x3,%eax
or     %eax,%ecx
mov    -0x10(%rbp),%rax
mov    %rax,%rdx
add    $0x4,%rdx
mov    %rdx,-0x10(%rbp)
mov    %ecx,(%rax)
mov    -0x4(%rbp),%ecx
shl    $0x3,%ecx
mov    -0x4(%rbp),%eax
sar    $0x2,%eax
and    $0x7,%eax
or     %eax,%ecx
mov    -0x10(%rbp),%rax
mov    %rax,%rdx
add    $0x4,%rdx
mov    %rdx,-0x10(%rbp)
mov    %ecx,(%rax)
pop    %rbp
ret

x86 assembly (clang, -O2):
<rgb565_lep>:
mov    %edi,%r8d
mov    %edi,%ecx
mov    %edi,%edx
mov    %edi,%eax
shr    $0x2,%eax
and    $0x7,%eax
lea    (%rax,%rdi,8),%eax
shr    $0x8,%edi
and    $0xf8,%edi
sar    $0xd,%r8d
or     %edi,%r8d
mov    %r8d,(%rsi)
shr    $0x3,%ecx
and    $0xfc,%ecx
shr    $0x9,%edx
and    $0x3,%edx
or     %ecx,%edx
mov    %edx,0x4(%rsi)
mov    %eax,0x8(%rsi)
ret

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

LLVM IR (-O2):
define void @rgb565_lep(i32 %0, i32* nocapture writeonly %1) {
%3 = lshr i32 %0, 8
%4 = and i32 %3, 248
%5 = ashr i32 %0, 13
%6 = or i32 %4, %5
%7 = getelementptr inbounds i32, i32* %1, i64 1
store i32 %6, i32* %1
%8 = lshr i32 %0, 3
%9 = and i32 %8, 252
%10 = lshr i32 %0, 9
%11 = and i32 %10, 3
%12 = or i32 %9, %11
%13 = getelementptr inbounds i32, i32* %1, i64 2
store i32 %12, i32* %7
%14 = shl i32 %0, 3
%15 = lshr i32 %0, 2
%16 = and i32 %15, 7
%17 = or i32 %16, %14
store i32 %17, i32* %13
ret void
}