; LLVM IR from drohmer/cgp :: library/cgp/09_geometric_transformation/rotation_transform (rotation_transform)

; Unoptimized IR (clang -disable-llvm-passes):
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"

%"struct.cgp::matrix_stack" = type { %"struct.cgp::numarray_stack.1" }
%"struct.cgp::numarray_stack.1" = type { %"struct.cgp::numarray_stack.0", %"struct.cgp::numarray_stack.0", %"struct.cgp::numarray_stack.0" }
%"struct.cgp::numarray_stack.0" = type { float, float, float }
%"class.std::initializer_list" = type { ptr, i64 }
%"struct.cgp::numarray_stack" = type { float, float, float, float }

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #0

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #0

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN3cgp18rotation_transform28convert_quaternion_to_matrixERKNS_10quaternionE(ptr dead_on_unwind noalias writable sret(%"struct.cgp::matrix_stack") align 4 %0, ptr noundef nonnull align 4 dereferenceable(16) %1) #1 align 2 {
  %3 = alloca ptr, align 8
  %4 = alloca float, align 4
  %5 = alloca float, align 4
  %6 = alloca float, align 4
  %7 = alloca float, align 4
  %8 = alloca %"class.std::initializer_list", align 8
  %9 = alloca [9 x float], align 4
  store ptr %1, ptr %3, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #4
  %10 = load ptr, ptr %3, align 8, !tbaa !5
  %11 = getelementptr inbounds %"struct.cgp::numarray_stack", ptr %10, i32 0, i32 0
  %12 = load float, ptr %11, align 4, !tbaa !9
  store float %12, ptr %4, align 4, !tbaa !12
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #4
  %13 = load ptr, ptr %3, align 8, !tbaa !5
  %14 = getelementptr inbounds %"struct.cgp::numarray_stack", ptr %13, i32 0, i32 1
  %15 = load float, ptr %14, align 4, !tbaa !13
  store float %15, ptr %5, align 4, !tbaa !12
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #4
  %16 = load ptr, ptr %3, align 8, !tbaa !5
  %17 = getelementptr inbounds %"struct.cgp::numarray_stack", ptr %16, i32 0, i32 2
  %18 = load float, ptr %17, align 4, !tbaa !14
  store float %18, ptr %6, align 4, !tbaa !12
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #4
  %19 = load ptr, ptr %3, align 8, !tbaa !5
  %20 = getelementptr inbounds %"struct.cgp::numarray_stack", ptr %19, i32 0, i32 3
  %21 = load float, ptr %20, align 4, !tbaa !15
  store float %21, ptr %7, align 4, !tbaa !12
  call void @llvm.lifetime.start.p0(i64 16, ptr %8) #4
  call void @llvm.lifetime.start.p0(i64 36, ptr %9) #4
  %22 = load float, ptr %5, align 4, !tbaa !12
  %23 = load float, ptr %5, align 4, !tbaa !12
  %24 = load float, ptr %6, align 4, !tbaa !12
  %25 = load float, ptr %6, align 4, !tbaa !12
  %26 = fmul float %24, %25
  %27 = call float @llvm.fmuladd.f32(float %22, float %23, float %26)
  %28 = call float @llvm.fmuladd.f32(float -2.000000e+00, float %27, float 1.000000e+00)
  store float %28, ptr %9, align 4, !tbaa !12
  %29 = getelementptr inbounds float, ptr %9, i64 1
  %30 = load float, ptr %4, align 4, !tbaa !12
  %31 = load float, ptr %5, align 4, !tbaa !12
  %32 = load float, ptr %7, align 4, !tbaa !12
  %33 = load float, ptr %6, align 4, !tbaa !12
  %34 = fmul float %32, %33
  %35 = fneg float %34
  %36 = call float @llvm.fmuladd.f32(float %30, float %31, float %35)
  %37 = fmul float 2.000000e+00, %36
  store float %37, ptr %29, align 4, !tbaa !12
  %38 = getelementptr inbounds float, ptr %9, i64 2
  %39 = load float, ptr %4, align 4, !tbaa !12
  %40 = load float, ptr %6, align 4, !tbaa !12
  %41 = load float, ptr %7, align 4, !tbaa !12
  %42 = load float, ptr %5, align 4, !tbaa !12
  %43 = fmul float %41, %42
  %44 = call float @llvm.fmuladd.f32(float %39, float %40, float %43)
  %45 = fmul float 2.000000e+00, %44
  store float %45, ptr %38, align 4, !tbaa !12
  %46 = getelementptr inbounds float, ptr %9, i64 3
  %47 = load float, ptr %4, align 4, !tbaa !12
  %48 = load float, ptr %5, align 4, !tbaa !12
  %49 = load float, ptr %7, align 4, !tbaa !12
  %50 = load float, ptr %6, align 4, !tbaa !12
  %51 = fmul float %49, %50
  %52 = call float @llvm.fmuladd.f32(float %47, float %48, float %51)
  %53 = fmul float 2.000000e+00, %52
  store float %53, ptr %46, align 4, !tbaa !12
  %54 = getelementptr inbounds float, ptr %9, i64 4
  %55 = load float, ptr %4, align 4, !tbaa !12
  %56 = load float, ptr %4, align 4, !tbaa !12
  %57 = load float, ptr %6, align 4, !tbaa !12
  %58 = load float, ptr %6, align 4, !tbaa !12
  %59 = fmul float %57, %58
  %60 = call float @llvm.fmuladd.f32(float %55, float %56, float %59)
  %61 = call float @llvm.fmuladd.f32(float -2.000000e+00, float %60, float 1.000000e+00)
  store float %61, ptr %54, align 4, !tbaa !12
  %62 = getelementptr inbounds float, ptr %9, i64 5
  %63 = load float, ptr %5, align 4, !tbaa !12
  %64 = load float, ptr %6, align 4, !tbaa !12
  %65 = load float, ptr %7, align 4, !tbaa !12
  %66 = load float, ptr %4, align 4, !tbaa !12
  %67 = fmul float %65, %66
  %68 = fneg float %67
  %69 = call float @llvm.fmuladd.f32(float %63, float %64, float %68)
  %70 = fmul float 2.000000e+00, %69
  store float %70, ptr %62, align 4, !tbaa !12
  %71 = getelementptr inbounds float, ptr %9, i64 6
  %72 = load float, ptr %4, align 4, !tbaa !12
  %73 = load float, ptr %6, align 4, !tbaa !12
  %74 = load float, ptr %7, align 4, !tbaa !12
  %75 = load float, ptr %5, align 4, !tbaa !12
  %76 = fmul float %74, %75
  %77 = fneg float %76
  %78 = call float @llvm.fmuladd.f32(float %72, float %73, float %77)
  %79 = fmul float 2.000000e+00, %78
  store float %79, ptr %71, align 4, !tbaa !12
  %80 = getelementptr inbounds float, ptr %9, i64 7
  %81 = load float, ptr %5, align 4, !tbaa !12
  %82 = load float, ptr %6, align 4, !tbaa !12
  %83 = load float, ptr %7, align 4, !tbaa !12
  %84 = load float, ptr %4, align 4, !tbaa !12
  %85 = fmul float %83, %84
  %86 = call float @llvm.fmuladd.f32(float %81, float %82, float %85)
  %87 = fmul float 2.000000e+00, %86
  store float %87, ptr %80, align 4, !tbaa !12
  %88 = getelementptr inbounds float, ptr %9, i64 8
  %89 = load float, ptr %4, align 4, !tbaa !12
  %90 = load float, ptr %4, align 4, !tbaa !12
  %91 = load float, ptr %5, align 4, !tbaa !12
  %92 = load float, ptr %5, align 4, !tbaa !12
  %93 = fmul float %91, %92
  %94 = call float @llvm.fmuladd.f32(float %89, float %90, float %93)
  %95 = call float @llvm.fmuladd.f32(float -2.000000e+00, float %94, float 1.000000e+00)
  store float %95, ptr %88, align 4, !tbaa !12
  %96 = getelementptr inbounds %"class.std::initializer_list", ptr %8, i32 0, i32 0
  store ptr %9, ptr %96, align 8, !tbaa !16
  %97 = getelementptr inbounds %"class.std::initializer_list", ptr %8, i32 0, i32 1
  store i64 9, ptr %97, align 8, !tbaa !19
  call void @_ZN3cgp12matrix_stackIfLi3ELi3EEC1ERKSt16initializer_listIfE(ptr noundef nonnull align 4 dereferenceable(36) %0, ptr noundef nonnull align 8 dereferenceable(16) %8)
  call void @llvm.lifetime.end.p0(i64 36, ptr %9) #4
  call void @llvm.lifetime.end.p0(i64 16, ptr %8) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #4
  ret void
}

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare float @llvm.fmuladd.f32(float, float, float) #2

declare void @_ZN3cgp12matrix_stackIfLi3ELi3EEC1ERKSt16initializer_listIfE(ptr noundef nonnull align 4 dereferenceable(36), ptr noundef nonnull align 8 dereferenceable(16)) unnamed_addr #3

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { mustprogress uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #2 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #3 = { "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #4 = { nounwind }

!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !11, i64 0}
!10 = !{!"_ZTSN3cgp14numarray_stackIfLi4EEE", !11, i64 0, !11, i64 4, !11, i64 8, !11, i64 12}
!11 = !{!"float", !7, i64 0}
!12 = !{!11, !11, i64 0}
!13 = !{!10, !11, i64 4}
!14 = !{!10, !11, i64 8}
!15 = !{!10, !11, i64 12}
!16 = !{!17, !6, i64 0}
!17 = !{!"_ZTSSt16initializer_listIfE", !6, i64 0, !18, i64 8}
!18 = !{!"long", !7, i64 0}
!19 = !{!17, !18, i64 8}


; Optimized IR (opt -passes='default<O3>'):
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"

%"struct.cgp::matrix_stack" = type { %"struct.cgp::numarray_stack.1" }
%"struct.cgp::numarray_stack.1" = type { %"struct.cgp::numarray_stack.0", %"struct.cgp::numarray_stack.0", %"struct.cgp::numarray_stack.0" }
%"struct.cgp::numarray_stack.0" = type { float, float, float }
%"class.std::initializer_list" = type { ptr, i64 }

; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #0

; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #0

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN3cgp18rotation_transform28convert_quaternion_to_matrixERKNS_10quaternionE(ptr dead_on_unwind noalias nonnull writable sret(%"struct.cgp::matrix_stack") align 4 %0, ptr nocapture noundef nonnull readonly align 4 dereferenceable(16) %1) local_unnamed_addr #1 align 2 {
  %3 = alloca %"class.std::initializer_list", align 8
  %4 = alloca [9 x float], align 4
  %5 = getelementptr inbounds i8, ptr %1, i64 8
  %6 = load float, ptr %5, align 4, !tbaa !5
  %7 = getelementptr inbounds i8, ptr %1, i64 12
  %8 = load float, ptr %7, align 4, !tbaa !10
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %3) #5
  call void @llvm.lifetime.start.p0(i64 36, ptr nonnull %4) #5
  %9 = fmul float %6, %6
  %10 = getelementptr inbounds i8, ptr %4, i64 4
  %11 = fmul float %6, %8
  %12 = fneg float %11
  %13 = load <2 x float>, ptr %1, align 4, !tbaa !11
  %14 = shufflevector <2 x float> %13, <2 x float> poison, <2 x i32> <i32 1, i32 0>
  %15 = extractelement <2 x float> %13, i64 1
  %16 = tail call float @llvm.fmuladd.f32(float %15, float %15, float %9)
  %17 = tail call float @llvm.fmuladd.f32(float %16, float -2.000000e+00, float 1.000000e+00)
  store float %17, ptr %4, align 4, !tbaa !11
  %18 = insertelement <2 x float> %13, float %6, i64 1
  %19 = insertelement <2 x float> poison, float %12, i64 0
  %20 = getelementptr inbounds i8, ptr %4, i64 12
  %21 = extractelement <2 x float> %13, i64 0
  %22 = tail call float @llvm.fmuladd.f32(float %21, float %15, float %11)
  %23 = fmul float %22, 2.000000e+00
  store float %23, ptr %20, align 4, !tbaa !11
  %24 = getelementptr inbounds i8, ptr %4, i64 16
  %25 = tail call float @llvm.fmuladd.f32(float %21, float %21, float %9)
  %26 = tail call float @llvm.fmuladd.f32(float %25, float -2.000000e+00, float 1.000000e+00)
  store float %26, ptr %24, align 4, !tbaa !11
  %27 = getelementptr inbounds i8, ptr %4, i64 20
  %28 = insertelement <2 x float> poison, float %8, i64 0
  %29 = shufflevector <2 x float> %28, <2 x float> poison, <2 x i32> zeroinitializer
  %30 = fmul <2 x float> %14, %29
  %31 = shufflevector <2 x float> %19, <2 x float> %30, <2 x i32> <i32 0, i32 2>
  %32 = tail call <2 x float> @llvm.fmuladd.v2f32(<2 x float> %14, <2 x float> %18, <2 x float> %31)
  %33 = fmul <2 x float> %32, <float 2.000000e+00, float 2.000000e+00>
  store <2 x float> %33, ptr %10, align 4, !tbaa !11
  %34 = shufflevector <2 x float> %30, <2 x float> poison, <2 x i32> <i32 1, i32 0>
  %35 = fneg <2 x float> %34
  %36 = insertelement <2 x float> poison, float %6, i64 0
  %37 = shufflevector <2 x float> %36, <2 x float> poison, <2 x i32> zeroinitializer
  %38 = tail call <2 x float> @llvm.fmuladd.v2f32(<2 x float> %14, <2 x float> %37, <2 x float> %35)
  %39 = fmul <2 x float> %38, <float 2.000000e+00, float 2.000000e+00>
  store <2 x float> %39, ptr %27, align 4, !tbaa !11
  %40 = getelementptr inbounds i8, ptr %4, i64 28
  %41 = extractelement <2 x float> %30, i64 1
  %42 = tail call float @llvm.fmuladd.f32(float %15, float %6, float %41)
  %43 = fmul float %42, 2.000000e+00
  store float %43, ptr %40, align 4, !tbaa !11
  %44 = getelementptr inbounds i8, ptr %4, i64 32
  %45 = fmul <2 x float> %13, %13
  %46 = extractelement <2 x float> %45, i64 1
  %47 = tail call float @llvm.fmuladd.f32(float %21, float %21, float %46)
  %48 = tail call float @llvm.fmuladd.f32(float %47, float -2.000000e+00, float 1.000000e+00)
  store float %48, ptr %44, align 4, !tbaa !11
  store ptr %4, ptr %3, align 8, !tbaa !12
  %49 = getelementptr inbounds i8, ptr %3, i64 8
  store i64 9, ptr %49, align 8, !tbaa !16
  call void @_ZN3cgp12matrix_stackIfLi3ELi3EEC1ERKSt16initializer_listIfE(ptr noundef nonnull align 4 dereferenceable(36) %0, ptr noundef nonnull align 8 dereferenceable(16) %3)
  call void @llvm.lifetime.end.p0(i64 36, ptr nonnull %4) #5
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %3) #5
  ret void
}

; Function Attrs: mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare float @llvm.fmuladd.f32(float, float, float) #2

declare void @_ZN3cgp12matrix_stackIfLi3ELi3EEC1ERKSt16initializer_listIfE(ptr noundef nonnull align 4 dereferenceable(36), ptr noundef nonnull align 8 dereferenceable(16)) unnamed_addr #3

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare <2 x float> @llvm.fmuladd.v2f32(<2 x float>, <2 x float>, <2 x float>) #4

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { mustprogress uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #2 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #3 = { "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #4 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #5 = { nounwind }

!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}
!5 = !{!6, !7, i64 8}
!6 = !{!"_ZTSN3cgp14numarray_stackIfLi4EEE", !7, i64 0, !7, i64 4, !7, i64 8, !7, i64 12}
!7 = !{!"float", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!6, !7, i64 12}
!11 = !{!7, !7, i64 0}
!12 = !{!13, !14, i64 0}
!13 = !{!"_ZTSSt16initializer_listIfE", !14, i64 0, !15, i64 8}
!14 = !{!"any pointer", !8, i64 0}
!15 = !{!"long", !8, i64 0}
!16 = !{!13, !15, i64 8}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,PostOrderFunctionAttrsPass,ReassociatePass,SLPVectorizerPass,SROAPass,TailCallElimPass,VectorCombinePass