#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*/ mtxLoadIdentity(float *);
int /*<<< orphan*/ mtxLoadRotate(float *, float, float, float, float);
int /*<<< orphan*/ mtxMultiply(float *, float *, float *);
int /*<<< orphan*/ mtxRotateXMatrix(float *, float);
int /*<<< orphan*/ mtxRotateYMatrix(float *, float);
int /*<<< orphan*/ mtxRotateZMatrix(float *, float);
void mtxRotateMatrix(float *mtx, float rad, float xAxis, float yAxis,
                     float zAxis) {
  if (yAxis == 0.0f && zAxis == 0.0f) {
    mtxRotateXMatrix(mtx, rad);
  } else if (xAxis == 0.0f && zAxis == 0.0f) {
    mtxRotateYMatrix(mtx, rad);
  } else if (xAxis == 0.0f && yAxis == 0.0f) {
    mtxRotateZMatrix(mtx, rad);
  } else {
    float rotMtx[16];
    mtxLoadIdentity(rotMtx);
    mtxLoadRotate(rotMtx, rad, xAxis, yAxis, zAxis);
    mtxMultiply(mtx, rotMtx, mtx);
  }
}


x86 assembly (clang, -O0):
<mtxRotateMatrix>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %rdi,-0x8(%rbp)
movss  %xmm0,-0xc(%rbp)
movss  %xmm1,-0x10(%rbp)
movss  %xmm2,-0x14(%rbp)
movss  %xmm3,-0x18(%rbp)
movss  -0x14(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomiss %xmm1,%xmm0
jne    11c1 <mtxRotateMatrix+0x61>
jp     11c1 <mtxRotateMatrix+0x61>
movss  -0x18(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomiss %xmm1,%xmm0
jne    11c1 <mtxRotateMatrix+0x61>
jp     11c1 <mtxRotateMatrix+0x61>
mov    -0x8(%rbp),%rdi
movss  -0xc(%rbp),%xmm0
call   1040 <mtxRotateXMatrix@plt>
jmp    1284 <mtxRotateMatrix+0x124>
movss  -0x10(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomiss %xmm1,%xmm0
jne    1202 <mtxRotateMatrix+0xa2>
jp     1202 <mtxRotateMatrix+0xa2>
movss  -0x18(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomiss %xmm1,%xmm0
jne    1202 <mtxRotateMatrix+0xa2>
jp     1202 <mtxRotateMatrix+0xa2>
mov    -0x8(%rbp),%rdi
movss  -0xc(%rbp),%xmm0
call   1080 <mtxRotateYMatrix@plt>
jmp    127f <mtxRotateMatrix+0x11f>
movss  -0x10(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomiss %xmm1,%xmm0
jne    1243 <mtxRotateMatrix+0xe3>
jp     1243 <mtxRotateMatrix+0xe3>
movss  -0x14(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomiss %xmm1,%xmm0
jne    1243 <mtxRotateMatrix+0xe3>
jp     1243 <mtxRotateMatrix+0xe3>
mov    -0x8(%rbp),%rdi
movss  -0xc(%rbp),%xmm0
call   1060 <mtxRotateZMatrix@plt>
jmp    127a <mtxRotateMatrix+0x11a>
lea    -0x60(%rbp),%rdi
call   1030 <mtxLoadIdentity@plt>
lea    -0x60(%rbp),%rdi
movss  -0xc(%rbp),%xmm0
movss  -0x10(%rbp),%xmm1
movss  -0x14(%rbp),%xmm2
movss  -0x18(%rbp),%xmm3
call   1070 <mtxLoadRotate@plt>
mov    -0x8(%rbp),%rdi
lea    -0x60(%rbp),%rsi
mov    -0x8(%rbp),%rdx
call   1050 <mtxMultiply@plt>
jmp    127f <mtxRotateMatrix+0x11f>
jmp    1284 <mtxRotateMatrix+0x124>
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mtxRotateMatrix>:
push   %r14
push   %rbx
sub    $0x58,%rsp
mov    %rdi,%rbx
xorps  %xmm4,%xmm4
ucomiss %xmm4,%xmm2
jne    118a <mtxRotateMatrix+0x2a>
jp     118a <mtxRotateMatrix+0x2a>
ucomiss %xmm4,%xmm3
jne    118a <mtxRotateMatrix+0x2a>
jp     118a <mtxRotateMatrix+0x2a>
mov    %rbx,%rdi
add    $0x58,%rsp
pop    %rbx
pop    %r14
jmp    1040 <mtxRotateXMatrix@plt>
ucomiss %xmm4,%xmm1
jne    11aa <mtxRotateMatrix+0x4a>
jp     11aa <mtxRotateMatrix+0x4a>
xorps  %xmm4,%xmm4
ucomiss %xmm4,%xmm3
jne    11aa <mtxRotateMatrix+0x4a>
jp     11aa <mtxRotateMatrix+0x4a>
mov    %rbx,%rdi
add    $0x58,%rsp
pop    %rbx
pop    %r14
jmp    1080 <mtxRotateYMatrix@plt>
xorps  %xmm4,%xmm4
ucomiss %xmm4,%xmm1
jne    11ca <mtxRotateMatrix+0x6a>
jp     11ca <mtxRotateMatrix+0x6a>
ucomiss %xmm4,%xmm2
jne    11ca <mtxRotateMatrix+0x6a>
jp     11ca <mtxRotateMatrix+0x6a>
mov    %rbx,%rdi
add    $0x58,%rsp
pop    %rbx
pop    %r14
jmp    1060 <mtxRotateZMatrix@plt>
lea    0x10(%rsp),%r14
mov    %r14,%rdi
movss  %xmm0,0x4(%rsp)
movss  %xmm3,0xc(%rsp)
movss  %xmm2,0x8(%rsp)
movss  %xmm1,(%rsp)
call   1030 <mtxLoadIdentity@plt>
mov    %r14,%rdi
movss  0x4(%rsp),%xmm0
movss  (%rsp),%xmm1
movss  0x8(%rsp),%xmm2
movss  0xc(%rsp),%xmm3
call   1070 <mtxLoadRotate@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
mov    %rbx,%rdx
call   1050 <mtxMultiply@plt>
add    $0x58,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define void @mtxRotateMatrix(float* %0, float %1, float %2, float %3, float %4) {
%6 = alloca float*
%7 = alloca float
%8 = alloca float
%9 = alloca float
%10 = alloca float
%11 = alloca [16 x float]
store float* %0, float** %6
store float %1, float* %7
store float %2, float* %8
store float %3, float* %9
store float %4, float* %10
%12 = load float, float* %9
%13 = fcmp oeq float %12, 0.000000e+00
br i1 %13, label %14, label %21
14: ; preds = %5
%15 = load float, float* %10
%16 = fcmp oeq float %15, 0.000000e+00
br i1 %16, label %17, label %21
17: ; preds = %14
%18 = load float*, float** %6
%19 = load float, float* %7
%20 = call i32 @mtxRotateXMatrix(float* %18, float %19)
br label %56
21: ; preds = %14, %5
%22 = load float, float* %8
%23 = fcmp oeq float %22, 0.000000e+00
br i1 %23, label %24, label %31
24: ; preds = %21
%25 = load float, float* %10
%26 = fcmp oeq float %25, 0.000000e+00
br i1 %26, label %27, label %31
27: ; preds = %24
%28 = load float*, float** %6
%29 = load float, float* %7
%30 = call i32 @mtxRotateYMatrix(float* %28, float %29)
br label %55
31: ; preds = %24, %21
%32 = load float, float* %8
%33 = fcmp oeq float %32, 0.000000e+00
br i1 %33, label %34, label %41
34: ; preds = %31
%35 = load float, float* %9
%36 = fcmp oeq float %35, 0.000000e+00
br i1 %36, label %37, label %41
37: ; preds = %34
%38 = load float*, float** %6
%39 = load float, float* %7
%40 = call i32 @mtxRotateZMatrix(float* %38, float %39)
br label %54
41: ; preds = %34, %31
%42 = getelementptr inbounds [16 x float], [16 x float]* %11, i64 0, i64 0
%43 = call i32 @mtxLoadIdentity(float* %42)
%44 = getelementptr inbounds [16 x float], [16 x float]* %11, i64 0, i64 0
%45 = load float, float* %7
%46 = load float, float* %8
%47 = load float, float* %9
%48 = load float, float* %10
%49 = call i32 @mtxLoadRotate(float* %44, float %45, float %46, float %47, float %48)
%50 = load float*, float** %6
%51 = getelementptr inbounds [16 x float], [16 x float]* %11, i64 0, i64 0
%52 = load float*, float** %6
%53 = call i32 @mtxMultiply(float* %50, float* %51, float* %52)
br label %54
54: ; preds = %41, %37
br label %55
55: ; preds = %54, %27
br label %56
56: ; preds = %55, %17
ret void
}

LLVM IR (-O2):
define void @mtxRotateMatrix(float* %0, float %1, float %2, float %3, float %4) {
%6 = alloca [16 x float]
%7 = fcmp oeq float %3, 0.000000e+00
%8 = fcmp oeq float %4, 0.000000e+00
%9 = and i1 %7, %8
br i1 %9, label %10, label %12
10: ; preds = %5
%11 = tail call i32 @mtxRotateXMatrix(float* %0, float %1)
br label %27
12: ; preds = %5
%13 = fcmp oeq float %2, 0.000000e+00
%14 = and i1 %13, %8
br i1 %14, label %15, label %17
15: ; preds = %12
%16 = tail call i32 @mtxRotateYMatrix(float* %0, float %1)
br label %27
17: ; preds = %12
%18 = and i1 %13, %7
br i1 %18, label %19, label %21
19: ; preds = %17
%20 = tail call i32 @mtxRotateZMatrix(float* %0, float %1)
br label %27
21: ; preds = %17
%22 = bitcast [16 x float]* %6 to i8*
%23 = getelementptr inbounds [16 x float], [16 x float]* %6, i64 0, i64 0
%24 = call i32 @mtxLoadIdentity(float* %23)
%25 = call i32 @mtxLoadRotate(float* %23, float %1, float %2, float %3, float %4)
%26 = call i32 @mtxMultiply(float* %0, float* %23, float* %0)
br label %27
27: ; preds = %15, %21, %19, %10
ret void
}