#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 */
float cos(float);
int /*<<< orphan*/ memcpy(float *, float *, int);
float sin(float);
int /*<<< orphan*/ wematIdentity(float *);
int /*<<< orphan*/ wematMult(float *, float *, float *);
int wematRotate(float polar, float azimutal, float *m) {
  float rotPole[16], rotAzi[16];
  float rotResult[16] = {0};
  float sinPolar, cosPolar;
  float sinAzi, cosAzi;
  wematIdentity(rotPole);
  wematIdentity(rotAzi);
  sinPolar = sin(polar);
  cosPolar = cos(polar);
  rotPole[5] = cosPolar;
  rotPole[6] = sinPolar;
  rotPole[9] = -sinPolar;
  rotPole[10] = cosPolar;
  sinAzi = sin(azimutal);
  cosAzi = cos(azimutal);
  rotAzi[0] = cosAzi;
  rotAzi[2] = -sinAzi;
  rotAzi[5] = 1;
  rotAzi[8] = sinAzi;
  rotAzi[10] = cosAzi;
  wematMult(rotPole, rotAzi, rotResult);
  wematMult(m, rotResult, rotPole);
  memcpy(m, rotPole, sizeof(float) * 16);
  return 0;
}


x86 assembly (clang, -O0):
<wematRotate>:
push   %rbp
mov    %rsp,%rbp
sub    $0xe0,%rsp
movss  %xmm0,-0x4(%rbp)
movss  %xmm1,-0x8(%rbp)
mov    %rdi,-0x10(%rbp)
lea    -0xd0(%rbp),%rdi
xor    %esi,%esi
mov    $0x40,%edx
call   1040 <memset@plt>
lea    -0x50(%rbp),%rdi
call   1030 <wematIdentity@plt>
lea    -0x90(%rbp),%rdi
call   1030 <wematIdentity@plt>
movss  -0x4(%rbp),%xmm0
call   1060 <sin@plt>
movss  %xmm0,-0xd4(%rbp)
ff
movss  -0x4(%rbp),%xmm0
call   1080 <cos@plt>
movss  %xmm0,-0xd8(%rbp)
ff
movss  -0xd8(%rbp),%xmm0
ff
movss  %xmm0,-0x3c(%rbp)
movss  -0xd4(%rbp),%xmm0
ff
movss  %xmm0,-0x38(%rbp)
movss  -0xd4(%rbp),%xmm0
ff
movd   %xmm0,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm0
movss  %xmm0,-0x2c(%rbp)
movss  -0xd8(%rbp),%xmm0
movss  %xmm0,-0x28(%rbp)
movss  -0x8(%rbp),%xmm0
call   1060 <sin@plt>
movss  %xmm0,-0xdc(%rbp)
ff
movss  -0x8(%rbp),%xmm0
call   1080 <cos@plt>
movss  %xmm0,-0xe0(%rbp)
ff
movss  -0xe0(%rbp),%xmm0
ff
movss  %xmm0,-0x90(%rbp)
ff
movss  -0xdc(%rbp),%xmm0
ff
movd   %xmm0,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm0
movss  %xmm0,-0x88(%rbp)
ff
movss  0xda1(%rip),%xmm0
movss  %xmm0,-0x7c(%rbp)
movss  -0xdc(%rbp),%xmm0
ff
movss  %xmm0,-0x70(%rbp)
movss  -0xe0(%rbp),%xmm0
ff
movss  %xmm0,-0x68(%rbp)
lea    -0x50(%rbp),%rdi
lea    -0x90(%rbp),%rsi
lea    -0xd0(%rbp),%rdx
call   1050 <wematMult@plt>
mov    -0x10(%rbp),%rdi
lea    -0xd0(%rbp),%rsi
lea    -0x50(%rbp),%rdx
call   1050 <wematMult@plt>
mov    -0x10(%rbp),%rdi
lea    -0x50(%rbp),%rsi
mov    $0x40,%edx
call   1070 <memcpy@plt>
xor    %eax,%eax
add    $0xe0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<wematRotate>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0xf8,%rsp
mov    %rdi,%r12
movss  %xmm1,0xc(%rsp)
movss  %xmm0,0x10(%rsp)
xorps  %xmm0,%xmm0
movaps %xmm0,0xa0(%rsp)
movaps %xmm0,0x90(%rsp)
movaps %xmm0,0x80(%rsp)
movaps %xmm0,0x70(%rsp)
lea    0xb0(%rsp),%r14
mov    %r14,%rdi
call   1030 <wematIdentity@plt>
lea    0x30(%rsp),%r15
mov    %r15,%rdi
call   1030 <wematIdentity@plt>
movss  0x10(%rsp),%xmm0
call   1050 <sin@plt>
movaps %xmm0,0x20(%rsp)
movss  0x10(%rsp),%xmm0
call   1070 <cos@plt>
movss  %xmm0,0xc4(%rsp)
movaps 0x20(%rsp),%xmm1
movss  %xmm1,0xc8(%rsp)
xorps  0xe1d(%rip),%xmm1
movss  %xmm1,0xd4(%rsp)
movss  %xmm0,0xd8(%rsp)
movss  0xc(%rsp),%xmm0
call   1050 <sin@plt>
movaps %xmm0,0x10(%rsp)
movss  0xc(%rsp),%xmm0
call   1070 <cos@plt>
movss  %xmm0,0x30(%rsp)
movaps 0xde3(%rip),%xmm1
movaps 0x10(%rsp),%xmm2
xorps  %xmm2,%xmm1
movss  %xmm1,0x38(%rsp)
movl   $0x3f800000,0x44(%rsp)
3f
movss  %xmm2,0x50(%rsp)
movss  %xmm0,0x58(%rsp)
lea    0x70(%rsp),%rbx
mov    %r14,%rdi
mov    %r15,%rsi
mov    %rbx,%rdx
call   1040 <wematMult@plt>
mov    %r12,%rdi
mov    %rbx,%rsi
mov    %r14,%rdx
call   1040 <wematMult@plt>
mov    %r12,%rdi
mov    %r14,%rsi
mov    $0x40,%edx
call   1060 <memcpy@plt>
xor    %eax,%eax
add    $0xf8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define i32 @wematRotate(float %0, float %1, float* %2) {
%4 = alloca float
%5 = alloca float
%6 = alloca float*
%7 = alloca [16 x float]
%8 = alloca [16 x float]
%9 = alloca [16 x float]
%10 = alloca float
%11 = alloca float
%12 = alloca float
%13 = alloca float
store float %0, float* %4
store float %1, float* %5
store float* %2, float** %6
%14 = bitcast [16 x float]* %9 to i8*
%15 = getelementptr inbounds [16 x float], [16 x float]* %7, i64 0, i64 0
%16 = call i32 @wematIdentity(float* %15)
%17 = getelementptr inbounds [16 x float], [16 x float]* %8, i64 0, i64 0
%18 = call i32 @wematIdentity(float* %17)
%19 = load float, float* %4
%20 = call float @sin(float %19)
store float %20, float* %10
%21 = load float, float* %4
%22 = call float @cos(float %21)
store float %22, float* %11
%23 = load float, float* %11
%24 = getelementptr inbounds [16 x float], [16 x float]* %7, i64 0, i64 5
store float %23, float* %24
%25 = load float, float* %10
%26 = getelementptr inbounds [16 x float], [16 x float]* %7, i64 0, i64 6
store float %25, float* %26
%27 = load float, float* %10
%28 = fneg float %27
%29 = getelementptr inbounds [16 x float], [16 x float]* %7, i64 0, i64 9
store float %28, float* %29
%30 = load float, float* %11
%31 = getelementptr inbounds [16 x float], [16 x float]* %7, i64 0, i64 10
store float %30, float* %31
%32 = load float, float* %5
%33 = call float @sin(float %32)
store float %33, float* %12
%34 = load float, float* %5
%35 = call float @cos(float %34)
store float %35, float* %13
%36 = load float, float* %13
%37 = getelementptr inbounds [16 x float], [16 x float]* %8, i64 0, i64 0
store float %36, float* %37
%38 = load float, float* %12
%39 = fneg float %38
%40 = getelementptr inbounds [16 x float], [16 x float]* %8, i64 0, i64 2
store float %39, float* %40
%41 = getelementptr inbounds [16 x float], [16 x float]* %8, i64 0, i64 5
store float 1.000000e+00, float* %41
%42 = load float, float* %12
%43 = getelementptr inbounds [16 x float], [16 x float]* %8, i64 0, i64 8
store float %42, float* %43
%44 = load float, float* %13
%45 = getelementptr inbounds [16 x float], [16 x float]* %8, i64 0, i64 10
store float %44, float* %45
%46 = getelementptr inbounds [16 x float], [16 x float]* %7, i64 0, i64 0
%47 = getelementptr inbounds [16 x float], [16 x float]* %8, i64 0, i64 0
%48 = getelementptr inbounds [16 x float], [16 x float]* %9, i64 0, i64 0
%49 = call i32 @wematMult(float* %46, float* %47, float* %48)
%50 = load float*, float** %6
%51 = getelementptr inbounds [16 x float], [16 x float]* %9, i64 0, i64 0
%52 = getelementptr inbounds [16 x float], [16 x float]* %7, i64 0, i64 0
%53 = call i32 @wematMult(float* %50, float* %51, float* %52)
%54 = load float*, float** %6
%55 = getelementptr inbounds [16 x float], [16 x float]* %7, i64 0, i64 0
%56 = call i32 @memcpy(float* %54, float* %55, i32 64)
ret i32 0
}

LLVM IR (-O2):
define i32 @wematRotate(float %0, float %1, float* %2) {
%4 = alloca [16 x float]
%5 = alloca [16 x float]
%6 = alloca [16 x float]
%7 = bitcast [16 x float]* %4 to i8*
%8 = bitcast [16 x float]* %5 to i8*
%9 = bitcast [16 x float]* %6 to i8*
%10 = getelementptr inbounds [16 x float], [16 x float]* %4, i64 0, i64 0
%11 = call i32 @wematIdentity(float* %10)
%12 = getelementptr inbounds [16 x float], [16 x float]* %5, i64 0, i64 0
%13 = call i32 @wematIdentity(float* %12)
%14 = call float @sin(float %0)
%15 = call float @cos(float %0)
%16 = getelementptr inbounds [16 x float], [16 x float]* %4, i64 0, i64 5
store float %15, float* %16
%17 = getelementptr inbounds [16 x float], [16 x float]* %4, i64 0, i64 6
store float %14, float* %17
%18 = fneg float %14
%19 = getelementptr inbounds [16 x float], [16 x float]* %4, i64 0, i64 9
store float %18, float* %19
%20 = getelementptr inbounds [16 x float], [16 x float]* %4, i64 0, i64 10
store float %15, float* %20
%21 = call float @sin(float %1)
%22 = call float @cos(float %1)
store float %22, float* %12
%23 = fneg float %21
%24 = getelementptr inbounds [16 x float], [16 x float]* %5, i64 0, i64 2
store float %23, float* %24
%25 = getelementptr inbounds [16 x float], [16 x float]* %5, i64 0, i64 5
store float 1.000000e+00, float* %25
%26 = getelementptr inbounds [16 x float], [16 x float]* %5, i64 0, i64 8
store float %21, float* %26
%27 = getelementptr inbounds [16 x float], [16 x float]* %5, i64 0, i64 10
store float %22, float* %27
%28 = getelementptr inbounds [16 x float], [16 x float]* %6, i64 0, i64 0
%29 = call i32 @wematMult(float* %10, float* %12, float* %28)
%30 = call i32 @wematMult(float* %2, float* %28, float* %10)
%31 = call i32 @memcpy(float* %2, float* %10, i32 64)
ret i32 0
}