#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 GLushort;
typedef int GLubyte;
typedef float GLfloat;

/* Variables and functions */
void extract565rev(int isSwap, const void *packedPixel,
                   GLfloat extractComponents[]) {
  GLushort ushort = *(const GLushort *)packedPixel;
  if (isSwap) {
    ushort = (GLushort)(((GLushort)((const GLubyte *)(packedPixel))[1]) << 8 |
                        ((const GLubyte *)(packedPixel))[0]);
  } else {
    ushort = *(const GLushort *)packedPixel;
  }
  extractComponents[0] = (float)((ushort & 0x001F)) / 31.0;
  extractComponents[1] = (float)((ushort & 0x07E0) >> 5) / 63.0;
  extractComponents[2] = (float)((ushort & 0xF800) >> 11) / 31.0;
}


x86 assembly (clang, -O0):
<extract565rev>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0x1c(%rbp)
cmpl   $0x0,-0x4(%rbp)
je     113a <extract565rev+0x3a>
mov    -0x10(%rbp),%rax
mov    0x4(%rax),%eax
shl    $0x8,%eax
mov    -0x10(%rbp),%rcx
or     (%rcx),%eax
mov    %eax,-0x1c(%rbp)
jmp    1143 <extract565rev+0x43>
mov    -0x10(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
and    $0x1f,%eax
cvtsi2ss %eax,%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xea7(%rip),%xmm1
divsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
mov    -0x18(%rbp),%rax
movss  %xmm0,(%rax)
mov    -0x1c(%rbp),%eax
and    $0x7e0,%eax
sar    $0x5,%eax
cvtsi2ss %eax,%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xe84(%rip),%xmm1
divsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
mov    -0x18(%rbp),%rax
movss  %xmm0,0x4(%rax)
mov    -0x1c(%rbp),%eax
and    $0xf800,%eax
sar    $0xb,%eax
cvtsi2ss %eax,%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xe50(%rip),%xmm1
divsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
mov    -0x18(%rbp),%rax
movss  %xmm0,0x8(%rax)
pop    %rbp
ret

x86 assembly (clang, -O2):
<extract565rev>:
test   %edi,%edi
je     110e <extract565rev+0xe>
mov    0x4(%rsi),%eax
shl    $0x8,%eax
or     (%rsi),%eax
jmp    1110 <extract565rev+0x10>
mov    (%rsi),%eax
mov    %eax,%ecx
and    $0x1f,%ecx
cvtsi2ss %ecx,%xmm0
movss  0xedf(%rip),%xmm1
mov    %eax,%ecx
shr    $0x5,%ecx
and    $0x3f,%ecx
cvtsi2ss %ecx,%xmm2
divss  %xmm1,%xmm0
divss  0xecb(%rip),%xmm2
shr    $0xb,%eax
and    $0x1f,%eax
cvtsi2ss %eax,%xmm3
movss  %xmm0,(%rdx)
movss  %xmm2,0x4(%rdx)
divss  %xmm1,%xmm3
movss  %xmm3,0x8(%rdx)
ret

LLVM IR (-O0):
define void @extract565rev(i32 %0, i8* %1, float* %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca float*
%7 = alloca i32
store i32 %0, i32* %4
store i8* %1, i8** %5
store float* %2, float** %6
%8 = load i8*, i8** %5
%9 = bitcast i8* %8 to i32*
%10 = load i32, i32* %9
store i32 %10, i32* %7
%11 = load i32, i32* %4
%12 = icmp ne i32 %11, 0
br i1 %12, label %13, label %24
13: ; preds = %3
%14 = load i8*, i8** %5
%15 = bitcast i8* %14 to i32*
%16 = getelementptr inbounds i32, i32* %15, i64 1
%17 = load i32, i32* %16
%18 = shl i32 %17, 8
%19 = load i8*, i8** %5
%20 = bitcast i8* %19 to i32*
%21 = getelementptr inbounds i32, i32* %20, i64 0
%22 = load i32, i32* %21
%23 = or i32 %18, %22
store i32 %23, i32* %7
br label %28
24: ; preds = %3
%25 = load i8*, i8** %5
%26 = bitcast i8* %25 to i32*
%27 = load i32, i32* %26
store i32 %27, i32* %7
br label %28
28: ; preds = %24, %13
%29 = load i32, i32* %7
%30 = and i32 %29, 31
%31 = sitofp i32 %30 to float
%32 = fpext float %31 to double
%33 = fdiv double %32, 3.100000e+01
%34 = fptrunc double %33 to float
%35 = load float*, float** %6
%36 = getelementptr inbounds float, float* %35, i64 0
store float %34, float* %36
%37 = load i32, i32* %7
%38 = and i32 %37, 2016
%39 = ashr i32 %38, 5
%40 = sitofp i32 %39 to float
%41 = fpext float %40 to double
%42 = fdiv double %41, 6.300000e+01
%43 = fptrunc double %42 to float
%44 = load float*, float** %6
%45 = getelementptr inbounds float, float* %44, i64 1
store float %43, float* %45
%46 = load i32, i32* %7
%47 = and i32 %46, 63488
%48 = ashr i32 %47, 11
%49 = sitofp i32 %48 to float
%50 = fpext float %49 to double
%51 = fdiv double %50, 3.100000e+01
%52 = fptrunc double %51 to float
%53 = load float*, float** %6
%54 = getelementptr inbounds float, float* %53, i64 2
store float %52, float* %54
ret void
}

LLVM IR (-O2):
define void @extract565rev(i32 %0, i8* nocapture %1, float* nocapture writeonly %2) {
%4 = bitcast i8* %1 to i32*
%5 = icmp eq i32 %0, 0
br i1 %5, label %13, label %6
6: ; preds = %3
%7 = getelementptr inbounds i8, i8* %1, i64 4
%8 = bitcast i8* %7 to i32*
%9 = load i32, i32* %8
%10 = shl i32 %9, 8
%11 = load i32, i32* %4
%12 = or i32 %10, %11
br label %15
13: ; preds = %3
%14 = load i32, i32* %4
br label %15
15: ; preds = %13, %6
%16 = phi i32 [ %12, %6 ], [ %14, %13 ]
%17 = and i32 %16, 31
%18 = sitofp i32 %17 to float
%19 = fdiv float %18, 3.100000e+01
store float %19, float* %2
%20 = lshr i32 %16, 5
%21 = and i32 %20, 63
%22 = sitofp i32 %21 to float
%23 = fdiv float %22, 6.300000e+01
%24 = getelementptr inbounds float, float* %2, i64 1
store float %23, float* %24
%25 = lshr i32 %16, 11
%26 = and i32 %25, 31
%27 = sitofp i32 %26 to float
%28 = fdiv float %27, 3.100000e+01
%29 = getelementptr inbounds float, float* %2, i64 2
store float %28, float* %29
ret void
}