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

/* Variables and functions */
int /*<<< orphan*/ assert(int);
void shove565(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);
  ((GLushort *)packedPixel)[index] =
      ((GLushort)((shoveComponents[0] * 31) + 0.5) << 11) & 0xf800;
  ((GLushort *)packedPixel)[index] |=
      ((GLushort)((shoveComponents[1] * 63) + 0.5) << 5) & 0x07e0;
  ((GLushort *)packedPixel)[index] |=
      ((GLushort)((shoveComponents[2] * 31) + 0.5)) & 0x001f;
}


x86 assembly (clang, -O0):
<shove565>:
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 <shove565+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 <shove565+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 <shove565+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  (%rax),%xmm0
movsd  0xe1a(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  0xe16(%rip),%xmm1
addsd  %xmm1,%xmm0
cvttsd2si %xmm0,%edx
shl    $0xb,%edx
and    $0xf800,%edx
mov    -0x18(%rbp),%rax
movslq -0xc(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x8(%rbp),%rax
movsd  0x8(%rax),%xmm0
movsd  0xdf1(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  0xddd(%rip),%xmm1
addsd  %xmm1,%xmm0
cvttsd2si %xmm0,%edx
shl    $0x5,%edx
and    $0x7e0,%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  0xda5(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  0xda1(%rip),%xmm1
addsd  %xmm1,%xmm0
cvttsd2si %xmm0,%edx
and    $0x1f,%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):
<shove565>:
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 0xecf(%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 0xea6(%rip),%xmm0
setae  %al
movsd  0xe7b(%rip),%xmm1
ucomisd %xmm0,%xmm1
setae  %cl
and    %al,%cl
movzbl %cl,%edi
call   1030 <assert@plt>
movsd  0xe6a(%rip),%xmm0
movsd  (%rbx),%xmm1
mulsd  %xmm0,%xmm1
movsd  0xe62(%rip),%xmm2
addsd  %xmm2,%xmm1
cvttsd2si %xmm1,%eax
shl    $0xb,%eax
movsd  0x8(%rbx),%xmm1
mulsd  0xe52(%rip),%xmm1
movzwl %ax,%eax
addsd  %xmm2,%xmm1
cvttsd2si %xmm1,%ecx
movslq %ebp,%rdx
and    $0x3f,%ecx
mulsd  0x10(%rbx),%xmm0
shl    $0x5,%ecx
addsd  %xmm2,%xmm0
cvttsd2si %xmm0,%esi
or     %eax,%ecx
and    $0x1f,%esi
or     %ecx,%esi
mov    %esi,(%r14,%rdx,4)
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define void @shove565(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 0
%48 = load double, double* %47
%49 = call double @llvm.fmuladd.f64(double %48, double 3.100000e+01, double 5.000000e-01)
%50 = fptosi double %49 to i32
%51 = shl i32 %50, 11
%52 = and i32 %51, 63488
%53 = load i8*, i8** %6
%54 = bitcast i8* %53 to i32*
%55 = load i32, i32* %5
%56 = sext i32 %55 to i64
%57 = getelementptr inbounds i32, i32* %54, i64 %56
store i32 %52, i32* %57
%58 = load double*, double** %4
%59 = getelementptr inbounds double, double* %58, i64 1
%60 = load double, double* %59
%61 = call double @llvm.fmuladd.f64(double %60, double 6.300000e+01, double 5.000000e-01)
%62 = fptosi double %61 to i32
%63 = shl i32 %62, 5
%64 = and i32 %63, 2016
%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
%70 = load i32, i32* %69
%71 = or i32 %70, %64
store i32 %71, i32* %69
%72 = load double*, double** %4
%73 = getelementptr inbounds double, double* %72, i64 2
%74 = load double, double* %73
%75 = call double @llvm.fmuladd.f64(double %74, double 3.100000e+01, double 5.000000e-01)
%76 = fptosi double %75 to i32
%77 = and i32 %76, 31
%78 = load i8*, i8** %6
%79 = bitcast i8* %78 to i32*
%80 = load i32, i32* %5
%81 = sext i32 %80 to i64
%82 = getelementptr inbounds i32, i32* %79, i64 %81
%83 = load i32, i32* %82
%84 = or i32 %83, %77
store i32 %84, i32* %82
ret void
}

LLVM IR (-O2):
define void @shove565(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 = load double, double* %0
%25 = tail call double @llvm.fmuladd.f64(double %24, double 3.100000e+01, double 5.000000e-01)
%26 = fptosi double %25 to i32
%27 = shl i32 %26, 11
%28 = and i32 %27, 63488
%29 = bitcast i8* %2 to i32*
%30 = sext i32 %1 to i64
%31 = getelementptr inbounds i32, i32* %29, i64 %30
%32 = load double, double* %10
%33 = tail call double @llvm.fmuladd.f64(double %32, double 6.300000e+01, double 5.000000e-01)
%34 = fptosi double %33 to i32
%35 = shl i32 %34, 5
%36 = and i32 %35, 2016
%37 = or i32 %36, %28
%38 = load double, double* %17
%39 = tail call double @llvm.fmuladd.f64(double %38, double 3.100000e+01, double 5.000000e-01)
%40 = fptosi double %39 to i32
%41 = and i32 %40, 31
%42 = or i32 %37, %41
store i32 %42, i32* %31
ret void
}