; LLVM IR from ThePhysicsGuys/Physics3D :: Physics3D/math/linalg/trigonometry.ll (ZN3P3D5orthoEffffff)

; 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"

%"class.P3D::Matrix" = type { [16 x float] }
%"class.std::initializer_list" = type { ptr, i64 }

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

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

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZN3P3D6MatrixIfLm4ELm4EEC2ESt16initializer_listIfE(ptr noundef nonnull align 4 dereferenceable(64), ptr, i64) unnamed_addr #2 align 2

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

attributes #0 = { 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 #1 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { inlinehint 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 #3 = { 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 = !{!"float", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !11, i64 0}
!10 = !{!"_ZTSSt16initializer_listIfE", !11, i64 0, !12, i64 8}
!11 = !{!"any pointer", !7, i64 0}
!12 = !{!"long", !7, i64 0}
!13 = !{!10, !12, 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"

%"class.P3D::Matrix" = type { [16 x float] }

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN3P3D5orthoEffffff(ptr dead_on_unwind noalias nonnull writable sret(%"class.P3D::Matrix") align 4 %0, float noundef %1, float noundef %2, float noundef %3, float noundef %4, float noundef %5, float noundef %6) local_unnamed_addr #0 {
  %8 = alloca [16 x float], align 4
  %9 = fsub float %2, %1
  %10 = fdiv float 2.000000e+00, %9
  %11 = fsub float %4, %3
  %12 = fdiv float 2.000000e+00, %11
  %13 = insertelement <2 x float> poison, float %5, i64 0
  %14 = insertelement <2 x float> %13, float %6, i64 1
  %15 = shufflevector <2 x float> %14, <2 x float> poison, <2 x i32> <i32 1, i32 0>
  %16 = fsub <2 x float> %14, %15
  %17 = fadd float %1, %2
  %18 = fsub float %1, %2
  %19 = fdiv float %17, %18
  %20 = fadd float %3, %4
  %21 = fsub float %3, %4
  %22 = fdiv float %20, %21
  %23 = fadd float %5, %6
  call void @llvm.lifetime.start.p0(i64 64, ptr nonnull %8) #3
  store float %10, ptr %8, align 4, !tbaa !5
  %24 = getelementptr inbounds i8, ptr %8, i64 4
  store <2 x float> zeroinitializer, ptr %24, align 4, !tbaa !5
  %25 = getelementptr inbounds i8, ptr %8, i64 12
  store float %19, ptr %25, align 4, !tbaa !5
  %26 = getelementptr inbounds i8, ptr %8, i64 16
  store float 0.000000e+00, ptr %26, align 4, !tbaa !5
  %27 = getelementptr inbounds i8, ptr %8, i64 20
  store float %12, ptr %27, align 4, !tbaa !5
  %28 = getelementptr inbounds i8, ptr %8, i64 24
  store float 0.000000e+00, ptr %28, align 4, !tbaa !5
  %29 = getelementptr inbounds i8, ptr %8, i64 28
  store float %22, ptr %29, align 4, !tbaa !5
  %30 = getelementptr inbounds i8, ptr %8, i64 32
  store <2 x float> zeroinitializer, ptr %30, align 4, !tbaa !5
  %31 = getelementptr inbounds i8, ptr %8, i64 40
  %32 = insertelement <2 x float> <float poison, float -2.000000e+00>, float %23, i64 0
  %33 = fdiv <2 x float> %32, %16
  %34 = shufflevector <2 x float> %33, <2 x float> poison, <2 x i32> <i32 1, i32 0>
  store <2 x float> %34, ptr %31, align 4, !tbaa !5
  %35 = getelementptr inbounds i8, ptr %8, i64 48
  store <4 x float> <float 0.000000e+00, float 0.000000e+00, float 0.000000e+00, float 1.000000e+00>, ptr %35, align 4, !tbaa !5
  call void @_ZN3P3D6MatrixIfLm4ELm4EEC2ESt16initializer_listIfE(ptr noundef nonnull align 4 dereferenceable(64) %0, ptr nonnull %8, i64 16)
  call void @llvm.lifetime.end.p0(i64 64, ptr nonnull %8) #3
  ret void
}

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

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZN3P3D6MatrixIfLm4ELm4EEC2ESt16initializer_listIfE(ptr noundef nonnull align 4 dereferenceable(64), ptr, i64) unnamed_addr #2 align 2

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

attributes #0 = { 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 #1 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { inlinehint 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 #3 = { 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 = !{!"float", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}


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