#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 cosf(float);
float sinf(float);
void mat2_rotate(float *dst, float rad) {
  float a0 = dst[0], a1 = dst[1], a2 = dst[2], a3 = dst[3];
  float s = sinf(rad);
  float c = cosf(rad);
  dst[0] = (a0 * c) + (a2 * s);
  dst[1] = (a1 * c) + (a3 * s);
  dst[2] = (a0 * -s) + (a2 * c);
  dst[3] = (a1 * -s) + (a3 * c);
}


x86 assembly (clang, -O0):
<mat2_rotate>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
movss  %xmm0,-0xc(%rbp)
mov    -0x8(%rbp),%rax
movss  (%rax),%xmm0
movss  %xmm0,-0x10(%rbp)
mov    -0x8(%rbp),%rax
movss  0x4(%rax),%xmm0
movss  %xmm0,-0x14(%rbp)
mov    -0x8(%rbp),%rax
movss  0x8(%rax),%xmm0
movss  %xmm0,-0x18(%rbp)
mov    -0x8(%rbp),%rax
movss  0xc(%rax),%xmm0
movss  %xmm0,-0x1c(%rbp)
movss  -0xc(%rbp),%xmm0
call   1030 <sinf@plt>
movss  %xmm0,-0x20(%rbp)
movss  -0xc(%rbp),%xmm0
call   1040 <cosf@plt>
movss  %xmm0,-0x24(%rbp)
movss  -0x10(%rbp),%xmm0
movss  -0x24(%rbp),%xmm2
movss  -0x18(%rbp),%xmm1
mulss  -0x20(%rbp),%xmm1
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
mov    -0x8(%rbp),%rax
movss  %xmm0,(%rax)
movss  -0x14(%rbp),%xmm0
movss  -0x24(%rbp),%xmm2
movss  -0x1c(%rbp),%xmm1
mulss  -0x20(%rbp),%xmm1
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
mov    -0x8(%rbp),%rax
movss  %xmm0,0x4(%rax)
movss  -0x10(%rbp),%xmm0
movss  -0x20(%rbp),%xmm1
movd   %xmm1,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm2
movss  -0x18(%rbp),%xmm1
mulss  -0x24(%rbp),%xmm1
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
mov    -0x8(%rbp),%rax
movss  %xmm0,0x8(%rax)
movss  -0x14(%rbp),%xmm0
movss  -0x20(%rbp),%xmm1
movd   %xmm1,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm2
movss  -0x1c(%rbp),%xmm1
mulss  -0x24(%rbp),%xmm1
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
mov    -0x8(%rbp),%rax
movss  %xmm0,0xc(%rax)
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mat2_rotate>:
push   %rbx
sub    $0x40,%rsp
movss  %xmm0,0xc(%rsp)
mov    %rdi,%rbx
movsd  (%rdi),%xmm2
movsd  0x8(%rdi),%xmm1
movlhps %xmm2,%xmm2
movaps %xmm2,0x30(%rsp)
movlhps %xmm1,%xmm1
movaps %xmm1,0x20(%rsp)
call   1030 <sinf@plt>
movaps %xmm0,0x10(%rsp)
movss  0xc(%rsp),%xmm0
call   1040 <cosf@plt>
movaps 0xe9d(%rip),%xmm1
movaps 0x10(%rsp),%xmm2
xorps  %xmm2,%xmm1
shufps $0x0,%xmm0,%xmm2
mulps  0x20(%rsp),%xmm2
shufps $0x0,%xmm1,%xmm0
mulps  0x30(%rsp),%xmm0
addps  %xmm2,%xmm0
movups %xmm0,(%rbx)
add    $0x40,%rsp
pop    %rbx
ret

LLVM IR (-O0):
define void @mat2_rotate(float* %0, float %1) {
%3 = alloca float*
%4 = alloca float
%5 = alloca float
%6 = alloca float
%7 = alloca float
%8 = alloca float
%9 = alloca float
%10 = alloca float
store float* %0, float** %3
store float %1, float* %4
%11 = load float*, float** %3
%12 = getelementptr inbounds float, float* %11, i64 0
%13 = load float, float* %12
store float %13, float* %5
%14 = load float*, float** %3
%15 = getelementptr inbounds float, float* %14, i64 1
%16 = load float, float* %15
store float %16, float* %6
%17 = load float*, float** %3
%18 = getelementptr inbounds float, float* %17, i64 2
%19 = load float, float* %18
store float %19, float* %7
%20 = load float*, float** %3
%21 = getelementptr inbounds float, float* %20, i64 3
%22 = load float, float* %21
store float %22, float* %8
%23 = load float, float* %4
%24 = call float @sinf(float %23)
store float %24, float* %9
%25 = load float, float* %4
%26 = call float @cosf(float %25)
store float %26, float* %10
%27 = load float, float* %5
%28 = load float, float* %10
%29 = load float, float* %7
%30 = load float, float* %9
%31 = fmul float %29, %30
%32 = call float @llvm.fmuladd.f32(float %27, float %28, float %31)
%33 = load float*, float** %3
%34 = getelementptr inbounds float, float* %33, i64 0
store float %32, float* %34
%35 = load float, float* %6
%36 = load float, float* %10
%37 = load float, float* %8
%38 = load float, float* %9
%39 = fmul float %37, %38
%40 = call float @llvm.fmuladd.f32(float %35, float %36, float %39)
%41 = load float*, float** %3
%42 = getelementptr inbounds float, float* %41, i64 1
store float %40, float* %42
%43 = load float, float* %5
%44 = load float, float* %9
%45 = fneg float %44
%46 = load float, float* %7
%47 = load float, float* %10
%48 = fmul float %46, %47
%49 = call float @llvm.fmuladd.f32(float %43, float %45, float %48)
%50 = load float*, float** %3
%51 = getelementptr inbounds float, float* %50, i64 2
store float %49, float* %51
%52 = load float, float* %6
%53 = load float, float* %9
%54 = fneg float %53
%55 = load float, float* %8
%56 = load float, float* %10
%57 = fmul float %55, %56
%58 = call float @llvm.fmuladd.f32(float %52, float %54, float %57)
%59 = load float*, float** %3
%60 = getelementptr inbounds float, float* %59, i64 3
store float %58, float* %60
ret void
}

LLVM IR (-O2):
define void @mat2_rotate(float* nocapture %0, float %1) {
%3 = bitcast float* %0 to <2 x float>*
%4 = load <2 x float>, <2 x float>* %3
%5 = shufflevector <2 x float> %4, <2 x float> poison, <4 x i32> <i32 0, i32 1, i32 0, i32 1>
%6 = getelementptr inbounds float, float* %0, i64 2
%7 = bitcast float* %6 to <2 x float>*
%8 = load <2 x float>, <2 x float>* %7
%9 = shufflevector <2 x float> %8, <2 x float> poison, <4 x i32> <i32 0, i32 1, i32 0, i32 1>
%10 = tail call float @sinf(float %1)
%11 = tail call float @cosf(float %1)
%12 = fneg float %10
%13 = insertelement <4 x float> poison, float %10, i64 0
%14 = insertelement <4 x float> %13, float %11, i64 1
%15 = shufflevector <4 x float> %14, <4 x float> poison, <4 x i32> <i32 0, i32 0, i32 1, i32 1>
%16 = fmul <4 x float> %9, %15
%17 = insertelement <4 x float> poison, float %11, i64 0
%18 = insertelement <4 x float> %17, float %12, i64 1
%19 = shufflevector <4 x float> %18, <4 x float> poison, <4 x i32> <i32 0, i32 0, i32 1, i32 1>
%20 = call <4 x float> @llvm.fmuladd.v4f32(<4 x float> %5, <4 x float> %19, <4 x float> %16)
%21 = bitcast float* %0 to <4 x float>*
store <4 x float> %20, <4 x float>* %21
ret void
}