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

/* Variables and functions */
void RGBP_to_RGB3(uint8_t *out, const uint8_t *in, int in_size) {
  int x;
  for (x = 0; x < in_size / 2; x++, in += 2, out += 3) {
    out[0] = (in[1] & 248);
    out[1] = (((in[0] & 224) >> 3) + (in[1] << 5));
    out[2] = (in[0] << 3);
  }
}


x86 assembly (clang, -O0):
<RGBP_to_RGB3>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x14(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    -0x1c(%rbp),%eax
cmp    %ecx,%eax
jge    119f <RGBP_to_RGB3+0x9f>
mov    -0x10(%rbp),%rax
mov    0x4(%rax),%ecx
and    $0xf8,%ecx
mov    -0x8(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x10(%rbp),%rax
mov    (%rax),%ecx
and    $0xe0,%ecx
sar    $0x3,%ecx
mov    -0x10(%rbp),%rax
mov    0x4(%rax),%eax
shl    $0x5,%eax
add    %eax,%ecx
mov    -0x8(%rbp),%rax
mov    %ecx,0x4(%rax)
mov    -0x10(%rbp),%rax
mov    (%rax),%ecx
shl    $0x3,%ecx
mov    -0x8(%rbp),%rax
mov    %ecx,0x8(%rax)
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x10(%rbp)
mov    -0x8(%rbp),%rax
add    $0xc,%rax
mov    %rax,-0x8(%rbp)
jmp    1116 <RGBP_to_RGB3+0x16>
pop    %rbp
ret

x86 assembly (clang, -O2):
<RGBP_to_RGB3>:
cmp    $0x2,%edx
jl     1154 <RGBP_to_RGB3+0x54>
mov    %edx,%eax
shr    $0x1f,%eax
add    %edx,%eax
sar    %eax
mov    %eax,%r9d
xor    %ecx,%ecx
mov    $0xf8,%r8d
nopl   0x0(%rax)
mov    0x4(%rsi,%rcx,8),%edx
and    %r8d,%edx
mov    %edx,(%rdi)
mov    (%rsi,%rcx,8),%edx
mov    0x4(%rsi,%rcx,8),%eax
shr    $0x3,%edx
and    $0x1c,%edx
shl    $0x5,%eax
or     %edx,%eax
mov    %eax,0x4(%rdi)
mov    (%rsi,%rcx,8),%eax
shl    $0x3,%eax
mov    %eax,0x8(%rdi)
add    $0x1,%rcx
add    $0xc,%rdi
cmp    %ecx,%r9d
jne    1120 <RGBP_to_RGB3+0x20>
ret

LLVM IR (-O0):
define void @RGBP_to_RGB3(i32* %0, i32* %1, i32 %2) {
%4 = alloca i32*
%5 = alloca i32*
%6 = alloca i32
%7 = alloca i32
store i32* %0, i32** %4
store i32* %1, i32** %5
store i32 %2, i32* %6
store i32 0, i32* %7
br label %8
8: ; preds = %38, %3
%9 = load i32, i32* %7
%10 = load i32, i32* %6
%11 = sdiv i32 %10, 2
%12 = icmp slt i32 %9, %11
br i1 %12, label %13, label %45
13: ; preds = %8
%14 = load i32*, i32** %5
%15 = getelementptr inbounds i32, i32* %14, i64 1
%16 = load i32, i32* %15
%17 = and i32 %16, 248
%18 = load i32*, i32** %4
%19 = getelementptr inbounds i32, i32* %18, i64 0
store i32 %17, i32* %19
%20 = load i32*, i32** %5
%21 = getelementptr inbounds i32, i32* %20, i64 0
%22 = load i32, i32* %21
%23 = and i32 %22, 224
%24 = ashr i32 %23, 3
%25 = load i32*, i32** %5
%26 = getelementptr inbounds i32, i32* %25, i64 1
%27 = load i32, i32* %26
%28 = shl i32 %27, 5
%29 = add nsw i32 %24, %28
%30 = load i32*, i32** %4
%31 = getelementptr inbounds i32, i32* %30, i64 1
store i32 %29, i32* %31
%32 = load i32*, i32** %5
%33 = getelementptr inbounds i32, i32* %32, i64 0
%34 = load i32, i32* %33
%35 = shl i32 %34, 3
%36 = load i32*, i32** %4
%37 = getelementptr inbounds i32, i32* %36, i64 2
store i32 %35, i32* %37
br label %38
38: ; preds = %13
%39 = load i32, i32* %7
%40 = add nsw i32 %39, 1
store i32 %40, i32* %7
%41 = load i32*, i32** %5
%42 = getelementptr inbounds i32, i32* %41, i64 2
store i32* %42, i32** %5
%43 = load i32*, i32** %4
%44 = getelementptr inbounds i32, i32* %43, i64 3
store i32* %44, i32** %4
br label %8
45: ; preds = %8
ret void
}

LLVM IR (-O2):
define void @RGBP_to_RGB3(i32* nocapture writeonly %0, i32* nocapture %1, i32 %2) {
%4 = sdiv i32 %2, 2
%5 = icmp sgt i32 %2, 1
br i1 %5, label %6, label %27
6: ; preds = %3, %6
%7 = phi i32 [ %23, %6 ], [ 0, %3 ]
%8 = phi i32* [ %25, %6 ], [ %0, %3 ]
%9 = phi i32* [ %24, %6 ], [ %1, %3 ]
%10 = getelementptr inbounds i32, i32* %9, i64 1
%11 = load i32, i32* %10
%12 = and i32 %11, 248
store i32 %12, i32* %8
%13 = load i32, i32* %9
%14 = lshr i32 %13, 3
%15 = and i32 %14, 28
%16 = load i32, i32* %10
%17 = shl i32 %16, 5
%18 = or i32 %15, %17
%19 = getelementptr inbounds i32, i32* %8, i64 1
store i32 %18, i32* %19
%20 = load i32, i32* %9
%21 = shl i32 %20, 3
%22 = getelementptr inbounds i32, i32* %8, i64 2
store i32 %21, i32* %22
%23 = add nuw nsw i32 %7, 1
%24 = getelementptr inbounds i32, i32* %9, i64 2
%25 = getelementptr inbounds i32, i32* %8, i64 3
%26 = icmp eq i32 %23, %4
br i1 %26, label %27, label %6
27: ; preds = %6, %3
ret void
}