#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 double GLint;
typedef double GLdouble;
typedef double GLclampd;

/* Variables and functions */
double GL_FALSE;
double GL_TRUE;
int /*<<< orphan*/ __gluInvertMatrixd(double *, double *);
int /*<<< orphan*/ __gluMultMatricesd(double const *, double const *, double *);
int /*<<< orphan*/ __gluMultMatrixVecd(double *, double *, double *);
GLint gluUnProject4(GLdouble winx, GLdouble winy, GLdouble winz, GLdouble clipw,
                    const GLdouble modelMatrix[16],
                    const GLdouble projMatrix[16], const GLint viewport[4],
                    GLclampd near, GLclampd far, GLdouble *objx, GLdouble *objy,
                    GLdouble *objz, GLdouble *objw) {
  double finalMatrix[16];
  double in[4];
  double out[4];
  __gluMultMatricesd(modelMatrix, projMatrix, finalMatrix);
  if (!__gluInvertMatrixd(finalMatrix, finalMatrix))
    return (GL_FALSE);
  in[0] = winx;
  in[1] = winy;
  in[2] = winz;
  in[3] = clipw;
  in[0] = (in[0] - viewport[0]) / viewport[2];
  in[1] = (in[1] - viewport[1]) / viewport[3];
  in[2] = (in[2] - near) / (far - near);
  in[0] = in[0] * 2 - 1;
  in[1] = in[1] * 2 - 1;
  in[2] = in[2] * 2 - 1;
  __gluMultMatrixVecd(finalMatrix, in, out);
  if (out[3] == 0.0)
    return (GL_FALSE);
  *objx = out[0];
  *objy = out[1];
  *objz = out[2];
  *objw = out[3];
  return (GL_TRUE);
}


x86 assembly (clang, -O0):
<gluUnProject4>:
push   %rbp
mov    %rsp,%rbp
sub    $0x130,%rsp
mov    0x10(%rbp),%rax
movsd  %xmm0,-0x10(%rbp)
movsd  %xmm1,-0x18(%rbp)
movsd  %xmm2,-0x20(%rbp)
movsd  %xmm3,-0x28(%rbp)
mov    %rdi,-0x30(%rbp)
mov    %rsi,-0x38(%rbp)
mov    %rdx,-0x40(%rbp)
movsd  %xmm4,-0x48(%rbp)
movsd  %xmm5,-0x50(%rbp)
mov    %rcx,-0x58(%rbp)
mov    %r8,-0x60(%rbp)
mov    %r9,-0x68(%rbp)
mov    -0x30(%rbp),%rdi
mov    -0x38(%rbp),%rsi
lea    -0xf0(%rbp),%rdx
call   1030 <__gluMultMatricesd@plt>
lea    -0xf0(%rbp),%rdi
lea    -0xf0(%rbp),%rsi
call   1040 <__gluInvertMatrixd@plt>
cmp    $0x0,%eax
jne    11ba <gluUnProject4+0x8a>
mov    0x2e3c(%rip),%rax
movsd  (%rax),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    134e <gluUnProject4+0x21e>
movsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x110(%rbp)
ff
movsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x108(%rbp)
ff
movsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x100(%rbp)
ff
movsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0xf8(%rbp)
ff
movsd  -0x110(%rbp),%xmm0
ff
mov    -0x40(%rbp),%rax
subsd  (%rax),%xmm0
mov    -0x40(%rbp),%rax
divsd  0x10(%rax),%xmm0
movsd  %xmm0,-0x110(%rbp)
ff
movsd  -0x108(%rbp),%xmm0
ff
mov    -0x40(%rbp),%rax
subsd  0x8(%rax),%xmm0
mov    -0x40(%rbp),%rax
divsd  0x18(%rax),%xmm0
movsd  %xmm0,-0x108(%rbp)
ff
movsd  -0x100(%rbp),%xmm0
ff
subsd  -0x48(%rbp),%xmm0
movsd  -0x50(%rbp),%xmm1
subsd  -0x48(%rbp),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x100(%rbp)
ff
movsd  -0x110(%rbp),%xmm0
ff
addsd  %xmm0,%xmm0
movsd  0xd98(%rip),%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x110(%rbp)
ff
movsd  -0x108(%rbp),%xmm0
ff
addsd  %xmm0,%xmm0
movsd  0xd78(%rip),%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x108(%rbp)
ff
movsd  -0x100(%rbp),%xmm0
ff
addsd  %xmm0,%xmm0
movsd  0xd58(%rip),%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x100(%rbp)
ff
lea    -0xf0(%rbp),%rdi
lea    -0x110(%rbp),%rsi
lea    -0x130(%rbp),%rdx
call   1050 <__gluMultMatrixVecd@plt>
movsd  -0x118(%rbp),%xmm0
ff
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    12fe <gluUnProject4+0x1ce>
jp     12fe <gluUnProject4+0x1ce>
mov    0x2cf8(%rip),%rax
movsd  (%rax),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    134e <gluUnProject4+0x21e>
movsd  -0x130(%rbp),%xmm0
ff
mov    -0x58(%rbp),%rax
movsd  %xmm0,(%rax)
movsd  -0x128(%rbp),%xmm0
ff
mov    -0x60(%rbp),%rax
movsd  %xmm0,(%rax)
movsd  -0x120(%rbp),%xmm0
ff
mov    -0x68(%rbp),%rax
movsd  %xmm0,(%rax)
movsd  -0x118(%rbp),%xmm0
ff
mov    0x10(%rbp),%rax
movsd  %xmm0,(%rax)
mov    0x2c93(%rip),%rax
movsd  (%rax),%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x130,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<gluUnProject4>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x100,%rsp
mov    %r9,%r14
mov    %r8,%r15
mov    %rcx,%r12
movsd  %xmm5,0x10(%rsp)
movsd  %xmm4,0x8(%rsp)
mov    %rdx,%r13
movsd  %xmm3,(%rsp)
movsd  %xmm2,0x18(%rsp)
movapd %xmm1,0x40(%rsp)
movapd %xmm0,0x50(%rsp)
lea    0x80(%rsp),%rbx
mov    %rbx,%rdx
call   1030 <__gluMultMatricesd@plt>
mov    %rbx,%rdi
mov    %rbx,%rsi
call   1040 <__gluInvertMatrixd@plt>
mov    0x2e57(%rip),%rbx
test   %eax,%eax
je     1264 <gluUnProject4+0x134>
movsd  (%rsp),%xmm0
movsd  %xmm0,0x78(%rsp)
movapd 0x50(%rsp),%xmm3
unpcklpd 0x40(%rsp),%xmm3
movupd 0x0(%r13),%xmm0
subpd  %xmm0,%xmm3
movupd 0x10(%r13),%xmm0
divpd  %xmm0,%xmm3
movsd  0x18(%rsp),%xmm0
movsd  0x8(%rsp),%xmm2
subsd  %xmm2,%xmm0
movsd  0x10(%rsp),%xmm1
subsd  %xmm2,%xmm1
divsd  %xmm1,%xmm0
addpd  %xmm3,%xmm3
addpd  0xe12(%rip),%xmm3
movapd %xmm3,0x60(%rsp)
addsd  %xmm0,%xmm0
addsd  0xe10(%rip),%xmm0
movsd  %xmm0,0x70(%rsp)
lea    0x80(%rsp),%rdi
lea    0x60(%rsp),%rsi
lea    0x20(%rsp),%rdx
call   1050 <__gluMultMatrixVecd@plt>
movsd  0x38(%rsp),%xmm0
xorpd  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    122f <gluUnProject4+0xff>
jnp    1264 <gluUnProject4+0x134>
mov    0x130(%rsp),%rax
movsd  0x20(%rsp),%xmm1
movsd  %xmm1,(%r12)
movsd  0x28(%rsp),%xmm1
movsd  %xmm1,(%r15)
movsd  0x30(%rsp),%xmm1
movsd  %xmm1,(%r14)
movsd  %xmm0,(%rax)
mov    0x2d74(%rip),%rbx
movsd  (%rbx),%xmm0
add    $0x100,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@GL_FALSE = global double 0.000000e+00
@GL_TRUE = global double 0.000000e+00
define double @gluUnProject4(double %0, double %1, double %2, double %3, double* %4, double* %5, double* %6, double %7, double %8, double* %9, double* %10, double* %11, double* %12) {
%14 = alloca double
%15 = alloca double
%16 = alloca double
%17 = alloca double
%18 = alloca double
%19 = alloca double*
%20 = alloca double*
%21 = alloca double*
%22 = alloca double
%23 = alloca double
%24 = alloca double*
%25 = alloca double*
%26 = alloca double*
%27 = alloca double*
%28 = alloca [16 x double]
%29 = alloca [4 x double]
%30 = alloca [4 x double]
store double %0, double* %15
store double %1, double* %16
store double %2, double* %17
store double %3, double* %18
store double* %4, double** %19
store double* %5, double** %20
store double* %6, double** %21
store double %7, double* %22
store double %8, double* %23
store double* %9, double** %24
store double* %10, double** %25
store double* %11, double** %26
store double* %12, double** %27
%31 = load double*, double** %19
%32 = load double*, double** %20
%33 = getelementptr inbounds [16 x double], [16 x double]* %28, i64 0, i64 0
%34 = call i32 @__gluMultMatricesd(double* %31, double* %32, double* %33)
%35 = getelementptr inbounds [16 x double], [16 x double]* %28, i64 0, i64 0
%36 = getelementptr inbounds [16 x double], [16 x double]* %28, i64 0, i64 0
%37 = call i32 @__gluInvertMatrixd(double* %35, double* %36)
%38 = icmp ne i32 %37, 0
br i1 %38, label %41, label %39
39: ; preds = %13
%40 = load double, double* @GL_FALSE
store double %40, double* %14
br label %116
41: ; preds = %13
%42 = load double, double* %15
%43 = getelementptr inbounds [4 x double], [4 x double]* %29, i64 0, i64 0
store double %42, double* %43
%44 = load double, double* %16
%45 = getelementptr inbounds [4 x double], [4 x double]* %29, i64 0, i64 1
store double %44, double* %45
%46 = load double, double* %17
%47 = getelementptr inbounds [4 x double], [4 x double]* %29, i64 0, i64 2
store double %46, double* %47
%48 = load double, double* %18
%49 = getelementptr inbounds [4 x double], [4 x double]* %29, i64 0, i64 3
store double %48, double* %49
%50 = getelementptr inbounds [4 x double], [4 x double]* %29, i64 0, i64 0
%51 = load double, double* %50
%52 = load double*, double** %21
%53 = getelementptr inbounds double, double* %52, i64 0
%54 = load double, double* %53
%55 = fsub double %51, %54
%56 = load double*, double** %21
%57 = getelementptr inbounds double, double* %56, i64 2
%58 = load double, double* %57
%59 = fdiv double %55, %58
%60 = getelementptr inbounds [4 x double], [4 x double]* %29, i64 0, i64 0
store double %59, double* %60
%61 = getelementptr inbounds [4 x double], [4 x double]* %29, i64 0, i64 1
%62 = load double, double* %61
%63 = load double*, double** %21
%64 = getelementptr inbounds double, double* %63, i64 1
%65 = load double, double* %64
%66 = fsub double %62, %65
%67 = load double*, double** %21
%68 = getelementptr inbounds double, double* %67, i64 3
%69 = load double, double* %68
%70 = fdiv double %66, %69
%71 = getelementptr inbounds [4 x double], [4 x double]* %29, i64 0, i64 1
store double %70, double* %71
%72 = getelementptr inbounds [4 x double], [4 x double]* %29, i64 0, i64 2
%73 = load double, double* %72
%74 = load double, double* %22
%75 = fsub double %73, %74
%76 = load double, double* %23
%77 = load double, double* %22
%78 = fsub double %76, %77
%79 = fdiv double %75, %78
%80 = getelementptr inbounds [4 x double], [4 x double]* %29, i64 0, i64 2
store double %79, double* %80
%81 = getelementptr inbounds [4 x double], [4 x double]* %29, i64 0, i64 0
%82 = load double, double* %81
%83 = call double @llvm.fmuladd.f64(double %82, double 2.000000e+00, double -1.000000e+00)
%84 = getelementptr inbounds [4 x double], [4 x double]* %29, i64 0, i64 0
store double %83, double* %84
%85 = getelementptr inbounds [4 x double], [4 x double]* %29, i64 0, i64 1
%86 = load double, double* %85
%87 = call double @llvm.fmuladd.f64(double %86, double 2.000000e+00, double -1.000000e+00)
%88 = getelementptr inbounds [4 x double], [4 x double]* %29, i64 0, i64 1
store double %87, double* %88
%89 = getelementptr inbounds [4 x double], [4 x double]* %29, i64 0, i64 2
%90 = load double, double* %89
%91 = call double @llvm.fmuladd.f64(double %90, double 2.000000e+00, double -1.000000e+00)
%92 = getelementptr inbounds [4 x double], [4 x double]* %29, i64 0, i64 2
store double %91, double* %92
%93 = getelementptr inbounds [16 x double], [16 x double]* %28, i64 0, i64 0
%94 = getelementptr inbounds [4 x double], [4 x double]* %29, i64 0, i64 0
%95 = getelementptr inbounds [4 x double], [4 x double]* %30, i64 0, i64 0
%96 = call i32 @__gluMultMatrixVecd(double* %93, double* %94, double* %95)
%97 = getelementptr inbounds [4 x double], [4 x double]* %30, i64 0, i64 3
%98 = load double, double* %97
%99 = fcmp oeq double %98, 0.000000e+00
br i1 %99, label %100, label %102
100: ; preds = %41
%101 = load double, double* @GL_FALSE
store double %101, double* %14
br label %116
102: ; preds = %41
%103 = getelementptr inbounds [4 x double], [4 x double]* %30, i64 0, i64 0
%104 = load double, double* %103
%105 = load double*, double** %24
store double %104, double* %105
%106 = getelementptr inbounds [4 x double], [4 x double]* %30, i64 0, i64 1
%107 = load double, double* %106
%108 = load double*, double** %25
store double %107, double* %108
%109 = getelementptr inbounds [4 x double], [4 x double]* %30, i64 0, i64 2
%110 = load double, double* %109
%111 = load double*, double** %26
store double %110, double* %111
%112 = getelementptr inbounds [4 x double], [4 x double]* %30, i64 0, i64 3
%113 = load double, double* %112
%114 = load double*, double** %27
store double %113, double* %114
%115 = load double, double* @GL_TRUE
store double %115, double* %14
br label %116
116: ; preds = %102, %100, %39
%117 = load double, double* %14
ret double %117
}

LLVM IR (-O2):
@GL_FALSE = global double 0.000000e+00
@GL_TRUE = global double 0.000000e+00
define double @gluUnProject4(double %0, double %1, double %2, double %3, double* %4, double* %5, double* nocapture %6, double %7, double %8, double* nocapture writeonly %9, double* nocapture writeonly %10, double* nocapture writeonly %11, double* nocapture writeonly %12) {
%14 = alloca [16 x double]
%15 = alloca [4 x double]
%16 = alloca [4 x double]
%17 = bitcast [16 x double]* %14 to i8*
%18 = bitcast [4 x double]* %15 to i8*
%19 = bitcast [4 x double]* %16 to i8*
%20 = getelementptr inbounds [16 x double], [16 x double]* %14, i64 0, i64 0
%21 = call i32 @__gluMultMatricesd(double* %4, double* %5, double* %20)
%22 = call i32 @__gluInvertMatrixd(double* %20, double* %20)
%23 = icmp eq i32 %22, 0
br i1 %23, label %54, label %24
24: ; preds = %13
%25 = getelementptr inbounds [4 x double], [4 x double]* %15, i64 0, i64 0
%26 = getelementptr inbounds [4 x double], [4 x double]* %15, i64 0, i64 2
%27 = getelementptr inbounds [4 x double], [4 x double]* %15, i64 0, i64 3
store double %3, double* %27
%28 = getelementptr inbounds double, double* %6, i64 2
%29 = bitcast double* %6 to <2 x double>*
%30 = load <2 x double>, <2 x double>* %29
%31 = insertelement <2 x double> poison, double %0, i64 0
%32 = insertelement <2 x double> %31, double %1, i64 1
%33 = fsub <2 x double> %32, %30
%34 = bitcast double* %28 to <2 x double>*
%35 = load <2 x double>, <2 x double>* %34
%36 = fdiv <2 x double> %33, %35
%37 = fsub double %2, %7
%38 = fsub double %8, %7
%39 = fdiv double %37, %38
%40 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %36, <2 x double> <double 2.000000e+00, double 2.000000e+00>, <2 x double> <double -1.000000e+00, double -1.000000e+00>)
%41 = bitcast [4 x double]* %15 to <2 x double>*
store <2 x double> %40, <2 x double>* %41
%42 = call double @llvm.fmuladd.f64(double %39, double 2.000000e+00, double -1.000000e+00)
store double %42, double* %26
%43 = getelementptr inbounds [4 x double], [4 x double]* %16, i64 0, i64 0
%44 = call i32 @__gluMultMatrixVecd(double* %20, double* %25, double* %43)
%45 = getelementptr inbounds [4 x double], [4 x double]* %16, i64 0, i64 3
%46 = load double, double* %45
%47 = fcmp oeq double %46, 0.000000e+00
br i1 %47, label %54, label %48
48: ; preds = %24
%49 = load double, double* %43
store double %49, double* %9
%50 = getelementptr inbounds [4 x double], [4 x double]* %16, i64 0, i64 1
%51 = load double, double* %50
store double %51, double* %10
%52 = getelementptr inbounds [4 x double], [4 x double]* %16, i64 0, i64 2
%53 = load double, double* %52
store double %53, double* %11
store double %46, double* %12
br label %54
54: ; preds = %24, %13, %48
%55 = phi double* [ @GL_TRUE, %48 ], [ @GL_FALSE, %13 ], [ @GL_FALSE, %24 ]
%56 = load double, double* %55
ret double %56
}