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

/* Variables and functions */
int /*<<< orphan*/ GL_MODELVIEW_MATRIX;
int atan2(float, float);
int /*<<< orphan*/ buildRot(int, int /*<<< orphan*/, int, int /*<<< orphan*/,
                            float *);
int /*<<< orphan*/ glGetFloatv(int /*<<< orphan*/, float *);
int /*<<< orphan*/ glMultMatrixf(float *);
void calcMatrix(void) {
  float mat[16];
  glGetFloatv(GL_MODELVIEW_MATRIX, mat);
  buildRot(-180 * atan2(mat[8], mat[10]) / 3.14159265358979323846, 0, 1, 0,
           mat);
  glMultMatrixf(mat);
}


x86 assembly (clang, -O0):
<calcMatrix>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    0x2e99(%rip),%rax
mov    (%rax),%edi
lea    -0x40(%rbp),%rsi
call   1060 <glGetFloatv@plt>
movss  -0x20(%rbp),%xmm0
movss  -0x18(%rbp),%xmm1
call   1030 <atan2@plt>
imul   $0xffffff4c,%eax,%eax
cvtsi2sd %eax,%xmm0
movsd  0xe85(%rip),%xmm1
divsd  %xmm1,%xmm0
cvttsd2si %xmm0,%edi
lea    -0x40(%rbp),%r8
xor    %ecx,%ecx
mov    $0x1,%edx
mov    %ecx,%esi
call   1050 <buildRot@plt>
lea    -0x40(%rbp),%rdi
call   1040 <glMultMatrixf@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<calcMatrix>:
push   %rbx
sub    $0x40,%rsp
mov    0x2e9c(%rip),%rax
mov    (%rax),%edi
mov    %rsp,%rbx
mov    %rbx,%rsi
call   1060 <glGetFloatv@plt>
movss  0x20(%rsp),%xmm0
movss  0x28(%rsp),%xmm1
call   1030 <atan2@plt>
imul   $0xffffff4c,%eax,%eax
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
divsd  0xe81(%rip),%xmm0
cvttsd2si %xmm0,%edi
xor    %esi,%esi
mov    $0x1,%edx
xor    %ecx,%ecx
mov    %rbx,%r8
call   1050 <buildRot@plt>
mov    %rbx,%rdi
call   1040 <glMultMatrixf@plt>
add    $0x40,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@GL_MODELVIEW_MATRIX = global i32 0
define void @calcMatrix() {
%1 = alloca [16 x float]
%2 = load i32, i32* @GL_MODELVIEW_MATRIX
%3 = getelementptr inbounds [16 x float], [16 x float]* %1, i64 0, i64 0
%4 = call i32 @glGetFloatv(i32 %2, float* %3)
%5 = getelementptr inbounds [16 x float], [16 x float]* %1, i64 0, i64 8
%6 = load float, float* %5
%7 = getelementptr inbounds [16 x float], [16 x float]* %1, i64 0, i64 10
%8 = load float, float* %7
%9 = call i32 @atan2(float %6, float %8)
%10 = mul nsw i32 -180, %9
%11 = sitofp i32 %10 to double
%12 = fdiv double %11, 0x400921FB54442D18
%13 = fptosi double %12 to i32
%14 = getelementptr inbounds [16 x float], [16 x float]* %1, i64 0, i64 0
%15 = call i32 @buildRot(i32 %13, i32 0, i32 1, i32 0, float* %14)
%16 = getelementptr inbounds [16 x float], [16 x float]* %1, i64 0, i64 0
%17 = call i32 @glMultMatrixf(float* %16)
ret void
}

LLVM IR (-O2):
@GL_MODELVIEW_MATRIX = global i32 0
define void @calcMatrix() {
%1 = alloca [16 x float]
%2 = bitcast [16 x float]* %1 to i8*
%3 = load i32, i32* @GL_MODELVIEW_MATRIX
%4 = getelementptr inbounds [16 x float], [16 x float]* %1, i64 0, i64 0
%5 = call i32 @glGetFloatv(i32 %3, float* %4)
%6 = getelementptr inbounds [16 x float], [16 x float]* %1, i64 0, i64 8
%7 = load float, float* %6
%8 = getelementptr inbounds [16 x float], [16 x float]* %1, i64 0, i64 10
%9 = load float, float* %8
%10 = call i32 @atan2(float %7, float %9)
%11 = mul nsw i32 %10, -180
%12 = sitofp i32 %11 to double
%13 = fdiv double %12, 0x400921FB54442D18
%14 = fptosi double %13 to i32
%15 = call i32 @buildRot(i32 %14, i32 0, i32 1, i32 0, float* %4)
%16 = call i32 @glMultMatrixf(float* %4)
ret void
}