#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 */
scalar_t__ cos(float);
int /*<<< orphan*/ memset(float *, int /*<<< orphan*/, int);
scalar_t__ sin(float);
void matrixRotate(float matrix[], char m, float Deg) {
  char m1, m2;
  float c, s;
  Deg *= 3.141592653589f / 180.0f;
  memset(matrix, 0, sizeof(float) * 16);
  matrix[((m - 1) << 2) + m - 1] = matrix[15] = 1.0f;
  m1 = (m % 3);
  m2 = ((m1 + 1) % 3);
  c = (float)cos(Deg);
  s = (float)sin(Deg);
  matrix[(m1 << 2) + m1] = c;
  matrix[(m1 << 2) + m2] = s;
  matrix[(m2 << 2) + m2] = c;
  matrix[(m2 << 2) + m1] = -s;
}


x86 assembly (clang, -O0):
<matrixRotate>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %sil,%al
mov    %rdi,-0x8(%rbp)
mov    %al,-0x9(%rbp)
movss  %xmm0,-0x10(%rbp)
movss  0xeb5(%rip),%xmm0
mulss  -0x10(%rbp),%xmm0
movss  %xmm0,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
xor    %esi,%esi
mov    $0x40,%edx
call   1030 <memset@plt>
mov    -0x8(%rbp),%rax
movss  0xe8b(%rip),%xmm0
movss  %xmm0,0x3c(%rax)
mov    -0x8(%rbp),%rax
movsbl -0x9(%rbp),%ecx
sub    $0x1,%ecx
shl    $0x2,%ecx
movsbl -0x9(%rbp),%edx
add    %edx,%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movss  0xe64(%rip),%xmm0
movss  %xmm0,(%rax,%rcx,4)
movsbl -0x9(%rbp),%eax
mov    $0x3,%ecx
cltd
idiv   %ecx
mov    %dl,%al
mov    %al,-0x11(%rbp)
movsbl -0x11(%rbp),%eax
add    $0x1,%eax
mov    $0x3,%ecx
cltd
idiv   %ecx
mov    %dl,%al
mov    %al,-0x12(%rbp)
movss  -0x10(%rbp),%xmm0
call   1050 <cos@plt>
cvtsi2ss %rax,%xmm0
movss  %xmm0,-0x18(%rbp)
movss  -0x10(%rbp),%xmm0
call   1040 <sin@plt>
cvtsi2ss %rax,%xmm0
movss  %xmm0,-0x1c(%rbp)
movss  -0x18(%rbp),%xmm0
mov    -0x8(%rbp),%rax
movsbl -0x11(%rbp),%ecx
shl    $0x2,%ecx
movsbl -0x11(%rbp),%edx
add    %edx,%ecx
movslq %ecx,%rcx
movss  %xmm0,(%rax,%rcx,4)
movss  -0x1c(%rbp),%xmm0
mov    -0x8(%rbp),%rax
movsbl -0x11(%rbp),%ecx
shl    $0x2,%ecx
movsbl -0x12(%rbp),%edx
add    %edx,%ecx
movslq %ecx,%rcx
movss  %xmm0,(%rax,%rcx,4)
movss  -0x18(%rbp),%xmm0
mov    -0x8(%rbp),%rax
movsbl -0x12(%rbp),%ecx
shl    $0x2,%ecx
movsbl -0x12(%rbp),%edx
add    %edx,%ecx
movslq %ecx,%rcx
movss  %xmm0,(%rax,%rcx,4)
movss  -0x1c(%rbp),%xmm0
movd   %xmm0,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm0
mov    -0x8(%rbp),%rax
movsbl -0x12(%rbp),%ecx
shl    $0x2,%ecx
movsbl -0x11(%rbp),%edx
add    %edx,%ecx
movslq %ecx,%rcx
movss  %xmm0,(%rax,%rcx,4)
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<matrixRotate>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %esi,%ebx
mov    %rdi,%r14
mulss  0xeba(%rip),%xmm0
movss  %xmm0,0x8(%rsp)
xor    %esi,%esi
mov    $0x40,%edx
call   1030 <memset@plt>
movl   $0x3f800000,0x3c(%r14)
3f
lea    (%rbx,%rbx,4),%eax
add    $0xfffffffb,%eax
cltq
movl   $0x3f800000,(%r14,%rax,4)
3f
imul   $0x56,%ebx,%eax
movzwl %ax,%eax
mov    %eax,%ecx
shr    $0xf,%ecx
shr    $0x8,%eax
add    %cl,%al
movzbl %al,%eax
lea    (%rax,%rax,2),%eax
sub    %al,%bl
movsbl %bl,%r15d
lea    0x1(%r15),%eax
movsbl %al,%eax
imul   $0x56,%eax,%ecx
movzwl %cx,%ecx
mov    %ecx,%edx
shr    $0xf,%edx
shr    $0x8,%ecx
add    %dl,%cl
movzbl %cl,%ecx
lea    (%rcx,%rcx,2),%ecx
sub    %cl,%al
movsbl %al,%ebx
movss  0x8(%rsp),%xmm0
call   1050 <cos@plt>
xorps  %xmm0,%xmm0
cvtsi2ss %rax,%xmm0
movss  %xmm0,0xc(%rsp)
movss  0x8(%rsp),%xmm0
call   1040 <sin@plt>
xorps  %xmm0,%xmm0
cvtsi2ss %rax,%xmm0
lea    (%r15,%r15,4),%eax
cltq
movss  0xc(%rsp),%xmm1
movss  %xmm1,(%r14,%rax,4)
lea    (%rbx,%r15,4),%eax
cltq
movss  %xmm0,(%r14,%rax,4)
lea    (%rbx,%rbx,4),%eax
cltq
xorps  0xe0c(%rip),%xmm0
movss  %xmm1,(%r14,%rax,4)
lea    (%r15,%rbx,4),%eax
cltq
movss  %xmm0,(%r14,%rax,4)
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define void @matrixRotate(float* %0, i8 signext %1, float %2) {
%4 = alloca float*
%5 = alloca i8
%6 = alloca float
%7 = alloca i8
%8 = alloca i8
%9 = alloca float
%10 = alloca float
store float* %0, float** %4
store i8 %1, i8* %5
store float %2, float* %6
%11 = load float, float* %6
%12 = fmul float %11, 0x3F91DF46A0000000
store float %12, float* %6
%13 = load float*, float** %4
%14 = call i32 @memset(float* %13, i32 0, i32 64)
%15 = load float*, float** %4
%16 = getelementptr inbounds float, float* %15, i64 15
store float 1.000000e+00, float* %16
%17 = load float*, float** %4
%18 = load i8, i8* %5
%19 = sext i8 %18 to i32
%20 = sub nsw i32 %19, 1
%21 = shl i32 %20, 2
%22 = load i8, i8* %5
%23 = sext i8 %22 to i32
%24 = add nsw i32 %21, %23
%25 = sub nsw i32 %24, 1
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds float, float* %17, i64 %26
store float 1.000000e+00, float* %27
%28 = load i8, i8* %5
%29 = sext i8 %28 to i32
%30 = srem i32 %29, 3
%31 = trunc i32 %30 to i8
store i8 %31, i8* %7
%32 = load i8, i8* %7
%33 = sext i8 %32 to i32
%34 = add nsw i32 %33, 1
%35 = srem i32 %34, 3
%36 = trunc i32 %35 to i8
store i8 %36, i8* %8
%37 = load float, float* %6
%38 = call i64 @cos(float %37)
%39 = sitofp i64 %38 to float
store float %39, float* %9
%40 = load float, float* %6
%41 = call i64 @sin(float %40)
%42 = sitofp i64 %41 to float
store float %42, float* %10
%43 = load float, float* %9
%44 = load float*, float** %4
%45 = load i8, i8* %7
%46 = sext i8 %45 to i32
%47 = shl i32 %46, 2
%48 = load i8, i8* %7
%49 = sext i8 %48 to i32
%50 = add nsw i32 %47, %49
%51 = sext i32 %50 to i64
%52 = getelementptr inbounds float, float* %44, i64 %51
store float %43, float* %52
%53 = load float, float* %10
%54 = load float*, float** %4
%55 = load i8, i8* %7
%56 = sext i8 %55 to i32
%57 = shl i32 %56, 2
%58 = load i8, i8* %8
%59 = sext i8 %58 to i32
%60 = add nsw i32 %57, %59
%61 = sext i32 %60 to i64
%62 = getelementptr inbounds float, float* %54, i64 %61
store float %53, float* %62
%63 = load float, float* %9
%64 = load float*, float** %4
%65 = load i8, i8* %8
%66 = sext i8 %65 to i32
%67 = shl i32 %66, 2
%68 = load i8, i8* %8
%69 = sext i8 %68 to i32
%70 = add nsw i32 %67, %69
%71 = sext i32 %70 to i64
%72 = getelementptr inbounds float, float* %64, i64 %71
store float %63, float* %72
%73 = load float, float* %10
%74 = fneg float %73
%75 = load float*, float** %4
%76 = load i8, i8* %8
%77 = sext i8 %76 to i32
%78 = shl i32 %77, 2
%79 = load i8, i8* %7
%80 = sext i8 %79 to i32
%81 = add nsw i32 %78, %80
%82 = sext i32 %81 to i64
%83 = getelementptr inbounds float, float* %75, i64 %82
store float %74, float* %83
ret void
}

LLVM IR (-O2):
define void @matrixRotate(float* %0, i8 signext %1, float %2) {
%4 = fmul float %2, 0x3F91DF46A0000000
%5 = tail call i32 @memset(float* %0, i32 0, i32 64)
%6 = getelementptr inbounds float, float* %0, i64 15
store float 1.000000e+00, float* %6
%7 = sext i8 %1 to i32
%8 = shl nsw i32 %7, 2
%9 = add nsw i32 %7, -5
%10 = add nsw i32 %9, %8
%11 = sext i32 %10 to i64
%12 = getelementptr inbounds float, float* %0, i64 %11
store float 1.000000e+00, float* %12
%13 = srem i8 %1, 3
%14 = sext i8 %13 to i32
%15 = add nsw i8 %13, 1
%16 = srem i8 %15, 3
%17 = sext i8 %16 to i32
%18 = tail call i64 @cos(float %4)
%19 = sitofp i64 %18 to float
%20 = tail call i64 @sin(float %4)
%21 = sitofp i64 %20 to float
%22 = shl nsw i32 %14, 2
%23 = mul nsw i32 %14, 5
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds float, float* %0, i64 %24
store float %19, float* %25
%26 = add nsw i32 %22, %17
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds float, float* %0, i64 %27
store float %21, float* %28
%29 = shl nsw i32 %17, 2
%30 = mul nsw i32 %17, 5
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds float, float* %0, i64 %31
store float %19, float* %32
%33 = fneg float %21
%34 = add nsw i32 %29, %14
%35 = sext i32 %34 to i64
%36 = getelementptr inbounds float, float* %0, i64 %35
store float %33, float* %36
ret void
}