#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*/ shoveComponents;
typedef int GLushort;
typedef double GLfloat;

/* Variables and functions */
int /*<<< orphan*/ assert(int);
void shove1555rev(const GLfloat shoveComponents[], int index,
                  void *packedPixel) {
  assert(0.0 <= shoveComponents[0] && shoveComponents[0] <= 1.0);
  assert(0.0 <= shoveComponents[1] && shoveComponents[1] <= 1.0);
  assert(0.0 <= shoveComponents[2] && shoveComponents[2] <= 1.0);
  assert(0.0 <= shoveComponents[3] && shoveComponents[3] <= 1.0);
  ((GLushort *)packedPixel)[index] =
      ((GLushort)((shoveComponents[0] * 31) + 0.5)) & 0x001F;
  ((GLushort *)packedPixel)[index] |=
      ((GLushort)((shoveComponents[1] * 31) + 0.5) << 5) & 0x03E0;
  ((GLushort *)packedPixel)[index] |=
      ((GLushort)((shoveComponents[2] * 31) + 0.5) << 10) & 0x7C00;
  ((GLushort *)packedPixel)[index] |=
      ((GLushort)((shoveComponents[3]) + 0.5) << 15) & 0x8000;
}


x86 assembly (clang, -O0):
<shove1555rev>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x8(%rbp),%rax
movsd  (%rax),%xmm0
xor    %eax,%eax
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
mov    %al,-0x19(%rbp)
jb     1153 <shove1555rev+0x43>
mov    -0x8(%rbp),%rax
movsd  0xeb7(%rip),%xmm0
ucomisd (%rax),%xmm0
setae  %al
mov    %al,-0x19(%rbp)
mov    -0x19(%rbp),%al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
mov    -0x8(%rbp),%rax
movsd  0x8(%rax),%xmm0
xor    %eax,%eax
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
mov    %al,-0x1a(%rbp)
jb     1192 <shove1555rev+0x82>
mov    -0x8(%rbp),%rax
movsd  0xe79(%rip),%xmm0
ucomisd 0x8(%rax),%xmm0
setae  %al
mov    %al,-0x1a(%rbp)
mov    -0x1a(%rbp),%al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
mov    -0x8(%rbp),%rax
movsd  0x10(%rax),%xmm0
xor    %eax,%eax
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
mov    %al,-0x1b(%rbp)
jb     11d1 <shove1555rev+0xc1>
mov    -0x8(%rbp),%rax
movsd  0xe3a(%rip),%xmm0
ucomisd 0x10(%rax),%xmm0
setae  %al
mov    %al,-0x1b(%rbp)
mov    -0x1b(%rbp),%al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
mov    -0x8(%rbp),%rax
movsd  0x18(%rax),%xmm0
xor    %eax,%eax
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
mov    %al,-0x1c(%rbp)
jb     1210 <shove1555rev+0x100>
mov    -0x8(%rbp),%rax
movsd  0xdfb(%rip),%xmm0
ucomisd 0x18(%rax),%xmm0
setae  %al
mov    %al,-0x1c(%rbp)
mov    -0x1c(%rbp),%al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
mov    -0x8(%rbp),%rax
movsd  (%rax),%xmm0
movsd  0xde3(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  0xdcf(%rip),%xmm1
addsd  %xmm1,%xmm0
cvttsd2si %xmm0,%edx
and    $0x1f,%edx
mov    -0x18(%rbp),%rax
movslq -0xc(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x8(%rbp),%rax
movsd  0x8(%rax),%xmm0
movsd  0xdb0(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  0xd9c(%rip),%xmm1
addsd  %xmm1,%xmm0
cvttsd2si %xmm0,%edx
shl    $0x5,%edx
and    $0x3e0,%edx
mov    -0x18(%rbp),%rax
movslq -0xc(%rbp),%rcx
or     (%rax,%rcx,4),%edx
mov    %edx,(%rax,%rcx,4)
mov    -0x8(%rbp),%rax
movsd  0x10(%rax),%xmm0
movsd  0xd74(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  0xd60(%rip),%xmm1
addsd  %xmm1,%xmm0
cvttsd2si %xmm0,%edx
shl    $0xa,%edx
and    $0x7c00,%edx
mov    -0x18(%rbp),%rax
movslq -0xc(%rbp),%rcx
or     (%rax,%rcx,4),%edx
mov    %edx,(%rax,%rcx,4)
mov    -0x8(%rbp),%rax
movsd  0xd35(%rip),%xmm0
addsd  0x18(%rax),%xmm0
cvttsd2si %xmm0,%edx
shl    $0xf,%edx
and    $0x8000,%edx
mov    -0x18(%rbp),%rax
movslq -0xc(%rbp),%rcx
or     (%rax,%rcx,4),%edx
mov    %edx,(%rax,%rcx,4)
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<shove1555rev>:
push   %rbp
push   %r14
push   %rbx
mov    %rdi,%rbx
movsd  (%rdi),%xmm0
xorpd  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
setae  %al
movsd  0xed2(%rip),%xmm1
ucomisd %xmm0,%xmm1
mov    %rdx,%r14
mov    %esi,%ebp
setae  %cl
and    %al,%cl
movzbl %cl,%edi
call   1030 <assert@plt>
movsd  0x8(%rbx),%xmm0
ucomisd 0xec7(%rip),%xmm0
setae  %al
movsd  0xea4(%rip),%xmm1
ucomisd %xmm0,%xmm1
setae  %cl
and    %al,%cl
movzbl %cl,%edi
call   1030 <assert@plt>
movsd  0x10(%rbx),%xmm0
ucomisd 0xe9e(%rip),%xmm0
setae  %al
movsd  0xe7b(%rip),%xmm1
ucomisd %xmm0,%xmm1
setae  %cl
and    %al,%cl
movzbl %cl,%edi
call   1030 <assert@plt>
movsd  0x18(%rbx),%xmm0
ucomisd 0xe75(%rip),%xmm0
setae  %al
movsd  0xe52(%rip),%xmm1
ucomisd %xmm0,%xmm1
setae  %cl
and    %al,%cl
movzbl %cl,%edi
call   1030 <assert@plt>
movsd  0xe41(%rip),%xmm0
movsd  (%rbx),%xmm1
mulsd  %xmm0,%xmm1
movsd  0xe39(%rip),%xmm2
addsd  %xmm2,%xmm1
cvttsd2si %xmm1,%eax
and    $0x1f,%eax
movsd  0x8(%rbx),%xmm1
mulsd  %xmm0,%xmm1
addsd  %xmm2,%xmm1
cvttsd2si %xmm1,%ecx
and    $0x1f,%ecx
shl    $0x5,%ecx
mulsd  0x10(%rbx),%xmm0
or     %eax,%ecx
addsd  %xmm2,%xmm0
cvttsd2si %xmm0,%eax
movslq %ebp,%rdx
and    $0x1f,%eax
shl    $0xa,%eax
or     %ecx,%eax
addsd  0x18(%rbx),%xmm2
cvttsd2si %xmm2,%ecx
shl    $0xf,%ecx
movzwl %cx,%ecx
or     %eax,%ecx
mov    %ecx,(%r14,%rdx,4)
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define void @shove1555rev(double* %0, i32 %1, i8* %2) {
%4 = alloca double*
%5 = alloca i32
%6 = alloca i8*
store double* %0, double** %4
store i32 %1, i32* %5
store i8* %2, i8** %6
%7 = load double*, double** %4
%8 = getelementptr inbounds double, double* %7, i64 0
%9 = load double, double* %8
%10 = fcmp ole double 0.000000e+00, %9
br i1 %10, label %11, label %16
11: ; preds = %3
%12 = load double*, double** %4
%13 = getelementptr inbounds double, double* %12, i64 0
%14 = load double, double* %13
%15 = fcmp ole double %14, 1.000000e+00
br label %16
16: ; preds = %11, %3
%17 = phi i1 [ false, %3 ], [ %15, %11 ]
%18 = zext i1 %17 to i32
%19 = call i32 @assert(i32 %18)
%20 = load double*, double** %4
%21 = getelementptr inbounds double, double* %20, i64 1
%22 = load double, double* %21
%23 = fcmp ole double 0.000000e+00, %22
br i1 %23, label %24, label %29
24: ; preds = %16
%25 = load double*, double** %4
%26 = getelementptr inbounds double, double* %25, i64 1
%27 = load double, double* %26
%28 = fcmp ole double %27, 1.000000e+00
br label %29
29: ; preds = %24, %16
%30 = phi i1 [ false, %16 ], [ %28, %24 ]
%31 = zext i1 %30 to i32
%32 = call i32 @assert(i32 %31)
%33 = load double*, double** %4
%34 = getelementptr inbounds double, double* %33, i64 2
%35 = load double, double* %34
%36 = fcmp ole double 0.000000e+00, %35
br i1 %36, label %37, label %42
37: ; preds = %29
%38 = load double*, double** %4
%39 = getelementptr inbounds double, double* %38, i64 2
%40 = load double, double* %39
%41 = fcmp ole double %40, 1.000000e+00
br label %42
42: ; preds = %37, %29
%43 = phi i1 [ false, %29 ], [ %41, %37 ]
%44 = zext i1 %43 to i32
%45 = call i32 @assert(i32 %44)
%46 = load double*, double** %4
%47 = getelementptr inbounds double, double* %46, i64 3
%48 = load double, double* %47
%49 = fcmp ole double 0.000000e+00, %48
br i1 %49, label %50, label %55
50: ; preds = %42
%51 = load double*, double** %4
%52 = getelementptr inbounds double, double* %51, i64 3
%53 = load double, double* %52
%54 = fcmp ole double %53, 1.000000e+00
br label %55
55: ; preds = %50, %42
%56 = phi i1 [ false, %42 ], [ %54, %50 ]
%57 = zext i1 %56 to i32
%58 = call i32 @assert(i32 %57)
%59 = load double*, double** %4
%60 = getelementptr inbounds double, double* %59, i64 0
%61 = load double, double* %60
%62 = call double @llvm.fmuladd.f64(double %61, double 3.100000e+01, double 5.000000e-01)
%63 = fptosi double %62 to i32
%64 = and i32 %63, 31
%65 = load i8*, i8** %6
%66 = bitcast i8* %65 to i32*
%67 = load i32, i32* %5
%68 = sext i32 %67 to i64
%69 = getelementptr inbounds i32, i32* %66, i64 %68
store i32 %64, i32* %69
%70 = load double*, double** %4
%71 = getelementptr inbounds double, double* %70, i64 1
%72 = load double, double* %71
%73 = call double @llvm.fmuladd.f64(double %72, double 3.100000e+01, double 5.000000e-01)
%74 = fptosi double %73 to i32
%75 = shl i32 %74, 5
%76 = and i32 %75, 992
%77 = load i8*, i8** %6
%78 = bitcast i8* %77 to i32*
%79 = load i32, i32* %5
%80 = sext i32 %79 to i64
%81 = getelementptr inbounds i32, i32* %78, i64 %80
%82 = load i32, i32* %81
%83 = or i32 %82, %76
store i32 %83, i32* %81
%84 = load double*, double** %4
%85 = getelementptr inbounds double, double* %84, i64 2
%86 = load double, double* %85
%87 = call double @llvm.fmuladd.f64(double %86, double 3.100000e+01, double 5.000000e-01)
%88 = fptosi double %87 to i32
%89 = shl i32 %88, 10
%90 = and i32 %89, 31744
%91 = load i8*, i8** %6
%92 = bitcast i8* %91 to i32*
%93 = load i32, i32* %5
%94 = sext i32 %93 to i64
%95 = getelementptr inbounds i32, i32* %92, i64 %94
%96 = load i32, i32* %95
%97 = or i32 %96, %90
store i32 %97, i32* %95
%98 = load double*, double** %4
%99 = getelementptr inbounds double, double* %98, i64 3
%100 = load double, double* %99
%101 = fadd double %100, 5.000000e-01
%102 = fptosi double %101 to i32
%103 = shl i32 %102, 15
%104 = and i32 %103, 32768
%105 = load i8*, i8** %6
%106 = bitcast i8* %105 to i32*
%107 = load i32, i32* %5
%108 = sext i32 %107 to i64
%109 = getelementptr inbounds i32, i32* %106, i64 %108
%110 = load i32, i32* %109
%111 = or i32 %110, %104
store i32 %111, i32* %109
ret void
}

LLVM IR (-O2):
define void @shove1555rev(double* nocapture %0, i32 %1, i8* nocapture writeonly %2) {
%4 = load double, double* %0
%5 = fcmp oge double %4, 0.000000e+00
%6 = fcmp ole double %4, 1.000000e+00
%7 = and i1 %5, %6
%8 = zext i1 %7 to i32
%9 = tail call i32 @assert(i32 %8)
%10 = getelementptr inbounds double, double* %0, i64 1
%11 = load double, double* %10
%12 = fcmp oge double %11, 0.000000e+00
%13 = fcmp ole double %11, 1.000000e+00
%14 = and i1 %12, %13
%15 = zext i1 %14 to i32
%16 = tail call i32 @assert(i32 %15)
%17 = getelementptr inbounds double, double* %0, i64 2
%18 = load double, double* %17
%19 = fcmp oge double %18, 0.000000e+00
%20 = fcmp ole double %18, 1.000000e+00
%21 = and i1 %19, %20
%22 = zext i1 %21 to i32
%23 = tail call i32 @assert(i32 %22)
%24 = getelementptr inbounds double, double* %0, i64 3
%25 = load double, double* %24
%26 = fcmp oge double %25, 0.000000e+00
%27 = fcmp ole double %25, 1.000000e+00
%28 = and i1 %26, %27
%29 = zext i1 %28 to i32
%30 = tail call i32 @assert(i32 %29)
%31 = load double, double* %0
%32 = tail call double @llvm.fmuladd.f64(double %31, double 3.100000e+01, double 5.000000e-01)
%33 = fptosi double %32 to i32
%34 = and i32 %33, 31
%35 = bitcast i8* %2 to i32*
%36 = sext i32 %1 to i64
%37 = getelementptr inbounds i32, i32* %35, i64 %36
%38 = load double, double* %10
%39 = tail call double @llvm.fmuladd.f64(double %38, double 3.100000e+01, double 5.000000e-01)
%40 = fptosi double %39 to i32
%41 = shl i32 %40, 5
%42 = and i32 %41, 992
%43 = or i32 %42, %34
%44 = load double, double* %17
%45 = tail call double @llvm.fmuladd.f64(double %44, double 3.100000e+01, double 5.000000e-01)
%46 = fptosi double %45 to i32
%47 = shl i32 %46, 10
%48 = and i32 %47, 31744
%49 = or i32 %48, %43
%50 = load double, double* %24
%51 = fadd double %50, 5.000000e-01
%52 = fptosi double %51 to i32
%53 = shl i32 %52, 15
%54 = and i32 %53, 32768
%55 = or i32 %54, %49
store i32 %55, i32* %37
ret void
}