; LLVM IR from achilles288/robot-monitor-graphics :: src/base/math/mat3.ll (ZNK3rmg4Mat3mlERKNS_4Vec3E)

; 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.rmg::Vec3" = type { %union.anon.1 }
%union.anon.1 = type { %struct.anon }
%struct.anon = type { float, float, float }
%"struct.rmg::Mat3" = type { %union.anon }
%union.anon = type { [3 x [3 x float]] }

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #0

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

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

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

; Function Attrs: mustprogress uwtable
define dso_local { <2 x float>, float } @_ZNK3rmg4Mat3mlERKNS_4Vec3E(ptr noundef nonnull align 4 dereferenceable(36) %0, ptr noundef nonnull align 4 dereferenceable(12) %1) #3 align 2 {
  %3 = alloca %"struct.rmg::Vec3", align 4
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca { <2 x float>, float }, align 8
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  %10 = load ptr, ptr %4, align 8
  call void @_ZN3rmg4Vec3C2Ev(ptr noundef nonnull align 4 dereferenceable(12) %3)
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #6
  store i32 0, ptr %6, align 4, !tbaa !9
  br label %11

11:                                               ; preds = %43, %2
  %12 = load i32, ptr %6, align 4, !tbaa !9
  %13 = icmp slt i32 %12, 3
  br i1 %13, label %15, label %14

14:                                               ; preds = %11
  store i32 2, ptr %7, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #6
  br label %46

15:                                               ; preds = %11
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #6
  store i32 0, ptr %8, align 4, !tbaa !9
  br label %16

16:                                               ; preds = %39, %15
  %17 = load i32, ptr %8, align 4, !tbaa !9
  %18 = icmp slt i32 %17, 3
  br i1 %18, label %20, label %19

19:                                               ; preds = %16
  store i32 5, ptr %7, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #6
  br label %42

20:                                               ; preds = %16
  %21 = getelementptr inbounds %"struct.rmg::Mat3", ptr %10, i32 0, i32 0
  %22 = load i32, ptr %6, align 4, !tbaa !9
  %23 = sext i32 %22 to i64
  %24 = getelementptr inbounds [3 x [3 x float]], ptr %21, i64 0, i64 %23
  %25 = load i32, ptr %8, align 4, !tbaa !9
  %26 = sext i32 %25 to i64
  %27 = getelementptr inbounds [3 x float], ptr %24, i64 0, i64 %26
  %28 = load float, ptr %27, align 4, !tbaa !11
  %29 = load ptr, ptr %5, align 8, !tbaa !5
  %30 = load i32, ptr %8, align 4, !tbaa !9
  %31 = trunc i32 %30 to i8
  %32 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNK3rmg4Vec3ixEh(ptr noundef nonnull align 4 dereferenceable(12) %29, i8 noundef zeroext %31)
  %33 = load float, ptr %32, align 4, !tbaa !12
  %34 = load i32, ptr %6, align 4, !tbaa !9
  %35 = trunc i32 %34 to i8
  %36 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZN3rmg4Vec3ixEh(ptr noundef nonnull align 4 dereferenceable(12) %3, i8 noundef zeroext %35)
  %37 = load float, ptr %36, align 4, !tbaa !12
  %38 = call float @llvm.fmuladd.f32(float %28, float %33, float %37)
  store float %38, ptr %36, align 4, !tbaa !12
  br label %39

39:                                               ; preds = %20
  %40 = load i32, ptr %8, align 4, !tbaa !9
  %41 = add nsw i32 %40, 1
  store i32 %41, ptr %8, align 4, !tbaa !9
  br label %16, !llvm.loop !14

42:                                               ; preds = %19
  br label %43

43:                                               ; preds = %42
  %44 = load i32, ptr %6, align 4, !tbaa !9
  %45 = add nsw i32 %44, 1
  store i32 %45, ptr %6, align 4, !tbaa !9
  br label %11, !llvm.loop !16

46:                                               ; preds = %14
  %47 = getelementptr inbounds %"struct.rmg::Vec3", ptr %3, i32 0, i32 0
  %48 = getelementptr inbounds %union.anon.1, ptr %47, i32 0, i32 0
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %9, ptr align 4 %48, i64 12, i1 false)
  %49 = load { <2 x float>, float }, ptr %9, align 8
  ret { <2 x float>, float } %49
}

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local void @_ZN3rmg4Vec3C2Ev(ptr noundef nonnull align 4 dereferenceable(12)) unnamed_addr #4 align 2

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef nonnull align 4 dereferenceable(4) ptr @_ZNK3rmg4Vec3ixEh(ptr noundef nonnull align 4 dereferenceable(12), i8 noundef zeroext) #5 align 2

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef nonnull align 4 dereferenceable(4) ptr @_ZN3rmg4Vec3ixEh(ptr noundef nonnull align 4 dereferenceable(12), i8 noundef zeroext) #5 align 2

attributes #0 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #3 = { 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 #4 = { inlinehint mustprogress nounwind 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 #5 = { 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 #6 = { 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, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!7, !7, i64 0}
!12 = !{!13, !13, i64 0}
!13 = !{!"float", !7, i64 0}
!14 = distinct !{!14, !15}
!15 = !{!"llvm.loop.mustprogress"}
!16 = distinct !{!16, !15}


; 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.rmg::Vec3" = type { %union.anon.1 }
%union.anon.1 = type { %struct.anon }
%struct.anon = type { float, float, float }

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

; Function Attrs: mustprogress uwtable
define dso_local { <2 x float>, float } @_ZNK3rmg4Mat3mlERKNS_4Vec3E(ptr nocapture noundef nonnull readonly align 4 dereferenceable(36) %0, ptr noundef nonnull align 4 dereferenceable(12) %1) local_unnamed_addr #1 align 2 {
.preheader:
  %2 = alloca %"struct.rmg::Vec3", align 8
  call void @_ZN3rmg4Vec3C2Ev(ptr noundef nonnull align 4 dereferenceable(12) %2)
  %3 = load float, ptr %0, align 4, !tbaa !5
  %4 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNK3rmg4Vec3ixEh(ptr noundef nonnull align 4 dereferenceable(12) %1, i8 noundef zeroext 0)
  %5 = load float, ptr %4, align 4, !tbaa !8
  %6 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZN3rmg4Vec3ixEh(ptr noundef nonnull align 4 dereferenceable(12) %2, i8 noundef zeroext 0)
  %7 = load float, ptr %6, align 4, !tbaa !8
  %8 = call float @llvm.fmuladd.f32(float %3, float %5, float %7)
  store float %8, ptr %6, align 4, !tbaa !8
  %9 = getelementptr inbounds i8, ptr %0, i64 4
  %10 = load float, ptr %9, align 4, !tbaa !5
  %11 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNK3rmg4Vec3ixEh(ptr noundef nonnull align 4 dereferenceable(12) %1, i8 noundef zeroext 1)
  %12 = load float, ptr %11, align 4, !tbaa !8
  %13 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZN3rmg4Vec3ixEh(ptr noundef nonnull align 4 dereferenceable(12) %2, i8 noundef zeroext 0)
  %14 = load float, ptr %13, align 4, !tbaa !8
  %15 = call float @llvm.fmuladd.f32(float %10, float %12, float %14)
  store float %15, ptr %13, align 4, !tbaa !8
  %16 = getelementptr inbounds i8, ptr %0, i64 8
  %17 = load float, ptr %16, align 4, !tbaa !5
  %18 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNK3rmg4Vec3ixEh(ptr noundef nonnull align 4 dereferenceable(12) %1, i8 noundef zeroext 2)
  %19 = load float, ptr %18, align 4, !tbaa !8
  %20 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZN3rmg4Vec3ixEh(ptr noundef nonnull align 4 dereferenceable(12) %2, i8 noundef zeroext 0)
  %21 = load float, ptr %20, align 4, !tbaa !8
  %22 = call float @llvm.fmuladd.f32(float %17, float %19, float %21)
  store float %22, ptr %20, align 4, !tbaa !8
  %23 = getelementptr inbounds i8, ptr %0, i64 12
  %24 = load float, ptr %23, align 4, !tbaa !5
  %25 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNK3rmg4Vec3ixEh(ptr noundef nonnull align 4 dereferenceable(12) %1, i8 noundef zeroext 0)
  %26 = load float, ptr %25, align 4, !tbaa !8
  %27 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZN3rmg4Vec3ixEh(ptr noundef nonnull align 4 dereferenceable(12) %2, i8 noundef zeroext 1)
  %28 = load float, ptr %27, align 4, !tbaa !8
  %29 = call float @llvm.fmuladd.f32(float %24, float %26, float %28)
  store float %29, ptr %27, align 4, !tbaa !8
  %30 = getelementptr inbounds i8, ptr %0, i64 16
  %31 = load float, ptr %30, align 4, !tbaa !5
  %32 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNK3rmg4Vec3ixEh(ptr noundef nonnull align 4 dereferenceable(12) %1, i8 noundef zeroext 1)
  %33 = load float, ptr %32, align 4, !tbaa !8
  %34 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZN3rmg4Vec3ixEh(ptr noundef nonnull align 4 dereferenceable(12) %2, i8 noundef zeroext 1)
  %35 = load float, ptr %34, align 4, !tbaa !8
  %36 = call float @llvm.fmuladd.f32(float %31, float %33, float %35)
  store float %36, ptr %34, align 4, !tbaa !8
  %37 = getelementptr inbounds i8, ptr %0, i64 20
  %38 = load float, ptr %37, align 4, !tbaa !5
  %39 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNK3rmg4Vec3ixEh(ptr noundef nonnull align 4 dereferenceable(12) %1, i8 noundef zeroext 2)
  %40 = load float, ptr %39, align 4, !tbaa !8
  %41 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZN3rmg4Vec3ixEh(ptr noundef nonnull align 4 dereferenceable(12) %2, i8 noundef zeroext 1)
  %42 = load float, ptr %41, align 4, !tbaa !8
  %43 = call float @llvm.fmuladd.f32(float %38, float %40, float %42)
  store float %43, ptr %41, align 4, !tbaa !8
  %44 = getelementptr inbounds i8, ptr %0, i64 24
  %45 = load float, ptr %44, align 4, !tbaa !5
  %46 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNK3rmg4Vec3ixEh(ptr noundef nonnull align 4 dereferenceable(12) %1, i8 noundef zeroext 0)
  %47 = load float, ptr %46, align 4, !tbaa !8
  %48 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZN3rmg4Vec3ixEh(ptr noundef nonnull align 4 dereferenceable(12) %2, i8 noundef zeroext 2)
  %49 = load float, ptr %48, align 4, !tbaa !8
  %50 = call float @llvm.fmuladd.f32(float %45, float %47, float %49)
  store float %50, ptr %48, align 4, !tbaa !8
  %51 = getelementptr inbounds i8, ptr %0, i64 28
  %52 = load float, ptr %51, align 4, !tbaa !5
  %53 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNK3rmg4Vec3ixEh(ptr noundef nonnull align 4 dereferenceable(12) %1, i8 noundef zeroext 1)
  %54 = load float, ptr %53, align 4, !tbaa !8
  %55 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZN3rmg4Vec3ixEh(ptr noundef nonnull align 4 dereferenceable(12) %2, i8 noundef zeroext 2)
  %56 = load float, ptr %55, align 4, !tbaa !8
  %57 = call float @llvm.fmuladd.f32(float %52, float %54, float %56)
  store float %57, ptr %55, align 4, !tbaa !8
  %58 = getelementptr inbounds i8, ptr %0, i64 32
  %59 = load float, ptr %58, align 4, !tbaa !5
  %60 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNK3rmg4Vec3ixEh(ptr noundef nonnull align 4 dereferenceable(12) %1, i8 noundef zeroext 2)
  %61 = load float, ptr %60, align 4, !tbaa !8
  %62 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZN3rmg4Vec3ixEh(ptr noundef nonnull align 4 dereferenceable(12) %2, i8 noundef zeroext 2)
  %63 = load float, ptr %62, align 4, !tbaa !8
  %64 = call float @llvm.fmuladd.f32(float %59, float %61, float %63)
  store float %64, ptr %62, align 4, !tbaa !8
  %.sroa.0.0.copyload = load <2 x float>, ptr %2, align 8
  %.sroa.2.0..sroa_idx = getelementptr inbounds i8, ptr %2, i64 8
  %.sroa.2.0.copyload = load float, ptr %.sroa.2.0..sroa_idx, align 8
  %.fca.0.insert = insertvalue { <2 x float>, float } poison, <2 x float> %.sroa.0.0.copyload, 0
  %.fca.1.insert = insertvalue { <2 x float>, float } %.fca.0.insert, float %.sroa.2.0.copyload, 1
  ret { <2 x float>, float } %.fca.1.insert
}

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local void @_ZN3rmg4Vec3C2Ev(ptr noundef nonnull align 4 dereferenceable(12)) unnamed_addr #2 align 2

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef nonnull align 4 dereferenceable(4) ptr @_ZNK3rmg4Vec3ixEh(ptr noundef nonnull align 4 dereferenceable(12), i8 noundef zeroext) local_unnamed_addr #3 align 2

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef nonnull align 4 dereferenceable(4) ptr @_ZN3rmg4Vec3ixEh(ptr noundef nonnull align 4 dereferenceable(12), i8 noundef zeroext) local_unnamed_addr #3 align 2

attributes #0 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }
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 = { inlinehint mustprogress nounwind 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 = { 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" }

!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 = !{!"omnipotent char", !7, i64 0}
!7 = !{!"Simple C++ TBAA"}
!8 = !{!9, !9, i64 0}
!9 = !{!"float", !6, i64 0}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IndVarSimplifyPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,LICMPass,LoopRotatePass,LoopSimplifyPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass