#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 rgb15to32_C(const uint8_t *src, uint8_t *dst, unsigned src_size) {
  const uint16_t *end;
  uint8_t *d = (uint8_t *)dst;
  const uint16_t *s = (const uint16_t *)src;
  end = s + src_size / 2;
  while (s < end) {
    register uint16_t bgr;
    bgr = *s++;
    *d++ = (bgr & 0x1F) << 3;
    *d++ = (bgr & 0x3E0) >> 2;
    *d++ = (bgr & 0x7C00) >> 7;
    *d++ = 0;
  }
}


x86 assembly (clang, -O0):
<rgb15to32_C>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rax
mov    -0x14(%rbp),%ecx
shr    $0x1,%ecx
mov    %ecx,%ecx
shl    $0x2,%rcx
add    %rcx,%rax
mov    %rax,-0x20(%rbp)
mov    -0x30(%rbp),%rax
cmp    -0x20(%rbp),%rax
jae    11c6 <rgb15to32_C+0xc6>
mov    -0x30(%rbp),%rax
mov    %rax,%rcx
add    $0x4,%rcx
mov    %rcx,-0x30(%rbp)
mov    (%rax),%eax
mov    %eax,-0x34(%rbp)
mov    -0x34(%rbp),%ecx
and    $0x1f,%ecx
shl    $0x3,%ecx
mov    -0x28(%rbp),%rax
mov    %rax,%rdx
add    $0x4,%rdx
mov    %rdx,-0x28(%rbp)
mov    %ecx,(%rax)
mov    -0x34(%rbp),%ecx
and    $0x3e0,%ecx
sar    $0x2,%ecx
mov    -0x28(%rbp),%rax
mov    %rax,%rdx
add    $0x4,%rdx
mov    %rdx,-0x28(%rbp)
mov    %ecx,(%rax)
mov    -0x34(%rbp),%ecx
and    $0x7c00,%ecx
sar    $0x7,%ecx
mov    -0x28(%rbp),%rax
mov    %rax,%rdx
add    $0x4,%rdx
mov    %rdx,-0x28(%rbp)
mov    %ecx,(%rax)
mov    -0x28(%rbp),%rax
mov    %rax,%rcx
add    $0x4,%rcx
mov    %rcx,-0x28(%rbp)
movl   $0x0,(%rax)
jmp    1136 <rgb15to32_C+0x36>
pop    %rbp
ret

x86 assembly (clang, -O2):
<rgb15to32_C>:
cmp    $0x2,%edx
jb     114c <rgb15to32_C+0x4c>
shr    %edx
lea    (%rdi,%rdx,4),%rax
nopl   0x0(%rax,%rax,1)
mov    (%rdi),%ecx
add    $0x4,%rdi
lea    0x0(,%rcx,8),%edx
movzbl %dl,%edx
mov    %edx,(%rsi)
mov    %ecx,%edx
shr    $0x2,%edx
and    $0xf8,%edx
mov    %edx,0x4(%rsi)
shr    $0x7,%ecx
and    $0xf8,%ecx
mov    %ecx,0x8(%rsi)
movl   $0x0,0xc(%rsi)
add    $0x10,%rsi
cmp    %rax,%rdi
jb     1110 <rgb15to32_C+0x10>
ret

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

LLVM IR (-O2):
define void @rgb15to32_C(i32* %0, i32* nocapture writeonly %1, i32 %2) {
%4 = lshr i32 %2, 1
%5 = zext i32 %4 to i64
%6 = getelementptr inbounds i32, i32* %0, i64 %5
%7 = icmp ult i32 %2, 2
br i1 %7, label %24, label %8
8: ; preds = %3, %8
%9 = phi i32* [ %22, %8 ], [ %1, %3 ]
%10 = phi i32* [ %11, %8 ], [ %0, %3 ]
%11 = getelementptr inbounds i32, i32* %10, i64 1
%12 = load i32, i32* %10
%13 = shl i32 %12, 3
%14 = and i32 %13, 248
%15 = getelementptr inbounds i32, i32* %9, i64 1
store i32 %14, i32* %9
%16 = lshr i32 %12, 2
%17 = and i32 %16, 248
%18 = getelementptr inbounds i32, i32* %9, i64 2
store i32 %17, i32* %15
%19 = lshr i32 %12, 7
%20 = and i32 %19, 248
%21 = getelementptr inbounds i32, i32* %9, i64 3
store i32 %20, i32* %18
%22 = getelementptr inbounds i32, i32* %9, i64 4
store i32 0, i32* %21
%23 = icmp ult i32* %11, %6
br i1 %23, label %8, label %24
24: ; preds = %8, %3
ret void
}