#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*/ GLfloat;

/* Variables and functions */
int /*<<< orphan*/ GL_MODELVIEW_MATRIX;
int /*<<< orphan*/ glGetFloatv(int /*<<< orphan*/, int /*<<< orphan*/ *);
int /*<<< orphan*/ invert4d(float **, float **);
int /*<<< orphan*/ normalize(float *, float *, float *);
int getViewAxis(void) {
  float viewDir[3];
  float mat[4][4], vinv[4][4];
  float maxf, xy, yz, zx;
  int im;
  glGetFloatv(GL_MODELVIEW_MATRIX, (GLfloat *)mat);
  invert4d(mat, vinv);
  viewDir[0] = -vinv[2][0];
  viewDir[1] = -vinv[2][1];
  viewDir[2] = -vinv[2][2];
  normalize(&viewDir[0], &viewDir[1], &viewDir[2]);
  xy = viewDir[2];
  yz = viewDir[0];
  zx = viewDir[1];
  maxf = (((xy) >= 0) ? (xy) : -(xy));
  im = (xy < 0.0) ? 1 : 4;
  if (maxf <= (((yz) >= 0) ? (yz) : -(yz))) {
    maxf = (((yz) >= 0) ? (yz) : -(yz));
    im = (yz < 0.0) ? 2 : 5;
  }
  if (maxf <= (((zx) >= 0) ? (zx) : -(zx))) {
    maxf = (((zx) >= 0) ? (zx) : -(zx));
    im = (zx < 0.0) ? 3 : 6;
  }
  return (im);
}


x86 assembly (clang, -O0):
<getViewAxis>:
push   %rbp
mov    %rsp,%rbp
sub    $0xc0,%rsp
mov    0x2ea6(%rip),%rax
mov    (%rax),%edi
lea    -0x50(%rbp),%rsi
call   1050 <glGetFloatv@plt>
lea    -0x50(%rbp),%rdi
lea    -0x90(%rbp),%rsi
call   1030 <invert4d@plt>
movss  -0x70(%rbp),%xmm0
movd   %xmm0,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm0
movss  %xmm0,-0xc(%rbp)
movss  -0x6c(%rbp),%xmm0
movd   %xmm0,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm0
movss  %xmm0,-0x8(%rbp)
movss  -0x68(%rbp),%xmm0
movd   %xmm0,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm0
movss  %xmm0,-0x4(%rbp)
lea    -0xc(%rbp),%rdi
lea    -0xc(%rbp),%rsi
add    $0x4,%rsi
lea    -0xc(%rbp),%rdx
add    $0x8,%rdx
call   1040 <normalize@plt>
movss  -0x4(%rbp),%xmm0
movss  %xmm0,-0x98(%rbp)
ff
movss  -0xc(%rbp),%xmm0
movss  %xmm0,-0x9c(%rbp)
ff
movss  -0x8(%rbp),%xmm0
movss  %xmm0,-0xa0(%rbp)
ff
movss  -0x98(%rbp),%xmm0
ff
xorps  %xmm1,%xmm1
ucomiss %xmm1,%xmm0
jb     120b <getViewAxis+0xdb>
movss  -0x98(%rbp),%xmm0
ff
movss  %xmm0,-0xa8(%rbp)
ff
jmp    1228 <getViewAxis+0xf8>
movss  -0x98(%rbp),%xmm0
ff
movd   %xmm0,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm0
movss  %xmm0,-0xa8(%rbp)
ff
movss  -0xa8(%rbp),%xmm0
ff
movss  %xmm0,-0x94(%rbp)
ff
movss  -0x98(%rbp),%xmm0
ff
cvtss2sd %xmm0,%xmm1
xorps  %xmm0,%xmm0
mov    $0x4,%eax
mov    $0x1,%ecx
ucomisd %xmm1,%xmm0
cmova  %ecx,%eax
mov    %eax,-0xa4(%rbp)
movss  -0x94(%rbp),%xmm0
ff
movss  %xmm0,-0xac(%rbp)
ff
movss  -0x9c(%rbp),%xmm0
ff
xorps  %xmm1,%xmm1
ucomiss %xmm1,%xmm0
jb     1297 <getViewAxis+0x167>
movss  -0x9c(%rbp),%xmm0
ff
movss  %xmm0,-0xb0(%rbp)
ff
jmp    12b4 <getViewAxis+0x184>
movss  -0x9c(%rbp),%xmm0
ff
movd   %xmm0,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm0
movss  %xmm0,-0xb0(%rbp)
ff
movss  -0xac(%rbp),%xmm1
ff
movss  -0xb0(%rbp),%xmm0
ff
ucomiss %xmm1,%xmm0
jb     1349 <getViewAxis+0x219>
movss  -0x9c(%rbp),%xmm0
ff
xorps  %xmm1,%xmm1
ucomiss %xmm1,%xmm0
jb     12f6 <getViewAxis+0x1c6>
movss  -0x9c(%rbp),%xmm0
ff
movss  %xmm0,-0xb4(%rbp)
ff
jmp    1313 <getViewAxis+0x1e3>
movss  -0x9c(%rbp),%xmm0
ff
movd   %xmm0,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm0
movss  %xmm0,-0xb4(%rbp)
ff
movss  -0xb4(%rbp),%xmm0
ff
movss  %xmm0,-0x94(%rbp)
ff
movss  -0x9c(%rbp),%xmm0
ff
cvtss2sd %xmm0,%xmm1
xorps  %xmm0,%xmm0
mov    $0x5,%eax
mov    $0x2,%ecx
ucomisd %xmm1,%xmm0
cmova  %ecx,%eax
mov    %eax,-0xa4(%rbp)
movss  -0x94(%rbp),%xmm0
ff
movss  %xmm0,-0xb8(%rbp)
ff
movss  -0xa0(%rbp),%xmm0
ff
xorps  %xmm1,%xmm1
ucomiss %xmm1,%xmm0
jb     1382 <getViewAxis+0x252>
movss  -0xa0(%rbp),%xmm0
ff
movss  %xmm0,-0xbc(%rbp)
ff
jmp    139f <getViewAxis+0x26f>
movss  -0xa0(%rbp),%xmm0
ff
movd   %xmm0,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm0
movss  %xmm0,-0xbc(%rbp)
ff
movss  -0xb8(%rbp),%xmm1
ff
movss  -0xbc(%rbp),%xmm0
ff
ucomiss %xmm1,%xmm0
jb     1434 <getViewAxis+0x304>
movss  -0xa0(%rbp),%xmm0
ff
xorps  %xmm1,%xmm1
ucomiss %xmm1,%xmm0
jb     13e1 <getViewAxis+0x2b1>
movss  -0xa0(%rbp),%xmm0
ff
movss  %xmm0,-0xc0(%rbp)
ff
jmp    13fe <getViewAxis+0x2ce>
movss  -0xa0(%rbp),%xmm0
ff
movd   %xmm0,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm0
movss  %xmm0,-0xc0(%rbp)
ff
movss  -0xc0(%rbp),%xmm0
ff
movss  %xmm0,-0x94(%rbp)
ff
movss  -0xa0(%rbp),%xmm0
ff
cvtss2sd %xmm0,%xmm1
xorps  %xmm0,%xmm0
mov    $0x6,%eax
mov    $0x3,%ecx
ucomisd %xmm1,%xmm0
cmova  %ecx,%eax
mov    %eax,-0xa4(%rbp)
mov    -0xa4(%rbp),%eax
add    $0xc0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getViewAxis>:
push   %rbx
sub    $0x90,%rsp
mov    0x2ea9(%rip),%rax
mov    (%rax),%edi
lea    0x50(%rsp),%rbx
mov    %rbx,%rsi
call   1050 <glGetFloatv@plt>
lea    0x10(%rsp),%rsi
mov    %rbx,%rdi
call   1030 <invert4d@plt>
movss  0x30(%rsp),%xmm0
movss  0x34(%rsp),%xmm1
movss  0x38(%rsp),%xmm2
movaps 0xe8c(%rip),%xmm3
xorps  %xmm3,%xmm0
movss  %xmm0,0x4(%rsp)
xorps  %xmm3,%xmm1
lea    0x8(%rsp),%rsi
movss  %xmm1,0x8(%rsp)
xorps  %xmm3,%xmm2
lea    0xc(%rsp),%rdx
movss  %xmm2,0xc(%rsp)
lea    0x4(%rsp),%rdi
call   1040 <normalize@plt>
movss  0xc(%rsp),%xmm4
movss  0x4(%rsp),%xmm3
movss  0x8(%rsp),%xmm0
xorps  %xmm1,%xmm1
xorps  %xmm2,%xmm2
cmpless %xmm4,%xmm2
movaps %xmm2,%xmm5
xor    %eax,%eax
ucomiss %xmm4,%xmm1
andps  %xmm4,%xmm2
movaps 0xe2e(%rip),%xmm6
xorps  %xmm6,%xmm4
andnps %xmm4,%xmm5
orps   %xmm5,%xmm2
setbe  %al
lea    (%rax,%rax,2),%eax
add    $0x1,%eax
xorps  %xmm4,%xmm4
cmpless %xmm3,%xmm4
movaps %xmm4,%xmm5
xor    %ecx,%ecx
ucomiss %xmm3,%xmm1
andps  %xmm3,%xmm4
xorps  %xmm6,%xmm3
andnps %xmm3,%xmm5
orps   %xmm5,%xmm4
setbe  %cl
ucomiss %xmm2,%xmm4
lea    0x2(%rcx,%rcx,2),%ecx
movaps %xmm2,%xmm3
cmpnless %xmm4,%xmm3
movaps %xmm3,%xmm5
andps  %xmm2,%xmm5
andnps %xmm4,%xmm3
orps   %xmm5,%xmm3
cmovb  %eax,%ecx
movaps %xmm6,%xmm5
xorps  %xmm0,%xmm5
xorps  %xmm2,%xmm2
cmpless %xmm0,%xmm2
movaps %xmm2,%xmm4
andnps %xmm5,%xmm4
andps  %xmm0,%xmm2
orps   %xmm4,%xmm2
xor    %eax,%eax
ucomiss %xmm0,%xmm1
setbe  %al
ucomiss %xmm3,%xmm2
lea    0x3(%rax,%rax,2),%eax
cmovb  %ecx,%eax
add    $0x90,%rsp
pop    %rbx
ret

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

LLVM IR (-O2):
@GL_MODELVIEW_MATRIX = global i32 0
define i32 @getViewAxis() {
%1 = alloca [3 x float]
%2 = alloca [4 x [4 x float]]
%3 = alloca [4 x [4 x float]]
%4 = bitcast [3 x float]* %1 to i8*
%5 = bitcast [4 x [4 x float]]* %2 to i8*
%6 = bitcast [4 x [4 x float]]* %3 to i8*
%7 = load i32, i32* @GL_MODELVIEW_MATRIX
%8 = bitcast [4 x [4 x float]]* %2 to i32*
%9 = call i32 @glGetFloatv(i32 %7, i32* %8)
%10 = bitcast [4 x [4 x float]]* %2 to float**
%11 = bitcast [4 x [4 x float]]* %3 to float**
%12 = call i32 @invert4d(float** %10, float** %11)
%13 = getelementptr inbounds [4 x [4 x float]], [4 x [4 x float]]* %3, i64 0, i64 2, i64 0
%14 = load float, float* %13
%15 = fneg float %14
%16 = getelementptr inbounds [3 x float], [3 x float]* %1, i64 0, i64 0
store float %15, float* %16
%17 = getelementptr inbounds [4 x [4 x float]], [4 x [4 x float]]* %3, i64 0, i64 2, i64 1
%18 = load float, float* %17
%19 = fneg float %18
%20 = getelementptr inbounds [3 x float], [3 x float]* %1, i64 0, i64 1
store float %19, float* %20
%21 = getelementptr inbounds [4 x [4 x float]], [4 x [4 x float]]* %3, i64 0, i64 2, i64 2
%22 = load float, float* %21
%23 = fneg float %22
%24 = getelementptr inbounds [3 x float], [3 x float]* %1, i64 0, i64 2
store float %23, float* %24
%25 = call i32 @normalize(float* %16, float* %20, float* %24)
%26 = load float, float* %24
%27 = load float, float* %16
%28 = load float, float* %20
%29 = fcmp oge float %26, 0.000000e+00
%30 = fneg float %26
%31 = select i1 %29, float %26, float %30
%32 = fcmp olt float %26, 0.000000e+00
%33 = select i1 %32, i32 1, i32 4
%34 = fcmp oge float %27, 0.000000e+00
%35 = fneg float %27
%36 = select i1 %34, float %27, float %35
%37 = fcmp ugt float %31, %36
%38 = fcmp olt float %27, 0.000000e+00
%39 = select i1 %38, i32 2, i32 5
%40 = select i1 %37, float %31, float %36
%41 = select i1 %37, i32 %33, i32 %39
%42 = fcmp oge float %28, 0.000000e+00
%43 = fneg float %28
%44 = select i1 %42, float %28, float %43
%45 = fcmp ugt float %40, %44
%46 = fcmp olt float %28, 0.000000e+00
%47 = select i1 %46, i32 3, i32 6
%48 = select i1 %45, i32 %41, i32 %47
ret i32 %48
}