#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 extract4444rev(int isSwap, const void *packedPixel,
                    GLfloat extractComponents[]) {
  GLushort ushort;
  if (isSwap) {
    ushort = (GLushort)(((GLushort)((const GLubyte *)(packedPixel))[1]) << 8 |
                        ((const GLubyte *)(packedPixel))[0]);
  } else {
    ushort = *(const GLushort *)packedPixel;
  }
  extractComponents[0] = (float)((ushort & 0x000F)) / 15.0;
  extractComponents[1] = (float)((ushort & 0x00F0) >> 4) / 15.0;
  extractComponents[2] = (float)((ushort & 0x0F00) >> 8) / 15.0;
  extractComponents[3] = (float)((ushort & 0xF000) >> 12) / 15.0;
}


x86 assembly (clang, -O0):
<extract4444rev>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
cmpl   $0x0,-0x4(%rbp)
je     1131 <extract4444rev+0x31>
mov    -0x10(%rbp),%rax
mov    0x4(%rax),%eax
shl    $0x8,%eax
mov    -0x10(%rbp),%rcx
or     (%rcx),%eax
mov    %eax,-0x1c(%rbp)
jmp    113a <extract4444rev+0x3a>
mov    -0x10(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
and    $0xf,%eax
cvtsi2ss %eax,%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xeb0(%rip),%xmm1
divsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
mov    -0x18(%rbp),%rax
movss  %xmm0,(%rax)
mov    -0x1c(%rbp),%eax
and    $0xf0,%eax
sar    $0x4,%eax
cvtsi2ss %eax,%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xe85(%rip),%xmm1
divsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
mov    -0x18(%rbp),%rax
movss  %xmm0,0x4(%rax)
mov    -0x1c(%rbp),%eax
and    $0xf00,%eax
sar    $0x8,%eax
cvtsi2ss %eax,%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xe59(%rip),%xmm1
divsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
mov    -0x18(%rbp),%rax
movss  %xmm0,0x8(%rax)
mov    -0x1c(%rbp),%eax
and    $0xf000,%eax
sar    $0xc,%eax
cvtsi2ss %eax,%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xe2d(%rip),%xmm1
divsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
mov    -0x18(%rbp),%rax
movss  %xmm0,0xc(%rax)
pop    %rbp
ret

x86 assembly (clang, -O2):
<extract4444rev>:
test   %edi,%edi
je     110e <extract4444rev+0xe>
mov    0x4(%rsi),%eax
shl    $0x8,%eax
or     (%rsi),%eax
jmp    1110 <extract4444rev+0x10>
mov    (%rsi),%eax
mov    %eax,%ecx
shr    $0x4,%ecx
mov    %eax,%esi
shr    $0x8,%esi
movd   %eax,%xmm0
shr    $0xc,%eax
movd   %eax,%xmm1
movd   %esi,%xmm2
punpckldq %xmm1,%xmm2
movd   %ecx,%xmm1
punpckldq %xmm1,%xmm0
punpcklqdq %xmm2,%xmm0
pand   0xebf(%rip),%xmm0
cvtdq2ps %xmm0,%xmm0
divps  0xec5(%rip),%xmm0
movups %xmm0,(%rdx)
ret

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

LLVM IR (-O2):
define void @extract4444rev(i32 %0, i8* nocapture %1, float* nocapture writeonly %2) {
%4 = icmp eq i32 %0, 0
%5 = bitcast i8* %1 to i32*
br i1 %4, 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* %5
%12 = or i32 %10, %11
br label %15
13: ; preds = %3
%14 = load i32, i32* %5
br label %15
15: ; preds = %13, %6
%16 = phi i32 [ %12, %6 ], [ %14, %13 ]
%17 = lshr i32 %16, 4
%18 = lshr i32 %16, 8
%19 = lshr i32 %16, 12
%20 = insertelement <4 x i32> poison, i32 %16, i64 0
%21 = insertelement <4 x i32> %20, i32 %17, i64 1
%22 = insertelement <4 x i32> %21, i32 %18, i64 2
%23 = insertelement <4 x i32> %22, i32 %19, i64 3
%24 = and <4 x i32> %23, <i32 15, i32 15, i32 15, i32 15>
%25 = sitofp <4 x i32> %24 to <4 x float>
%26 = fdiv <4 x float> %25, <float 1.500000e+01, float 1.500000e+01, float 1.500000e+01, float 1.500000e+01>
%27 = bitcast float* %2 to <4 x float>*
store <4 x float> %26, <4 x float>* %27
ret void
}