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

; 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::Mat4" = type { %union.anon.0 }
%union.anon.0 = type { [4 x [4 x float]] }
%"struct.rmg::Mat3" = type { %union.anon }
%union.anon = type { [3 x [3 x 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 @_ZNK3rmg4Mat3cvNS_4Mat4EEv(ptr dead_on_unwind noalias writable sret(%"struct.rmg::Mat4") align 4 %0, ptr noundef nonnull align 4 dereferenceable(36) %1) #1 align 2 {
  %3 = alloca ptr, align 8
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  store ptr %1, ptr %3, align 8, !tbaa !5
  %8 = load ptr, ptr %3, align 8
  call void @_ZN3rmg4Mat4C1Ev(ptr noundef nonnull align 4 dereferenceable(64) %0)
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #4
  store i32 0, ptr %4, align 4, !tbaa !9
  br label %9

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

12:                                               ; preds = %9
  store i32 2, ptr %5, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #4
  br label %40

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

14:                                               ; preds = %33, %13
  %15 = load i32, ptr %6, align 4, !tbaa !9
  %16 = icmp slt i32 %15, 3
  br i1 %16, label %18, label %17

17:                                               ; preds = %14
  store i32 5, ptr %5, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #4
  br label %36

18:                                               ; preds = %14
  %19 = getelementptr inbounds %"struct.rmg::Mat3", ptr %8, i32 0, i32 0
  %20 = load i32, ptr %4, align 4, !tbaa !9
  %21 = sext i32 %20 to i64
  %22 = getelementptr inbounds [3 x [3 x float]], ptr %19, i64 0, i64 %21
  %23 = load i32, ptr %6, align 4, !tbaa !9
  %24 = sext i32 %23 to i64
  %25 = getelementptr inbounds [3 x float], ptr %22, i64 0, i64 %24
  %26 = load float, ptr %25, align 4, !tbaa !11
  %27 = load i32, ptr %4, align 4, !tbaa !9
  %28 = trunc i32 %27 to i8
  %29 = call noundef nonnull align 4 dereferenceable(16) ptr @_ZN3rmg4Mat4ixEh(ptr noundef nonnull align 4 dereferenceable(64) %0, i8 noundef zeroext %28)
  %30 = load i32, ptr %6, align 4, !tbaa !9
  %31 = trunc i32 %30 to i8
  %32 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZN3rmg7Mat4RowixEh(ptr noundef nonnull align 4 dereferenceable(16) %29, i8 noundef zeroext %31)
  store float %26, ptr %32, align 4, !tbaa !12
  br label %33

33:                                               ; preds = %18
  %34 = load i32, ptr %6, align 4, !tbaa !9
  %35 = add nsw i32 %34, 1
  store i32 %35, ptr %6, align 4, !tbaa !9
  br label %14, !llvm.loop !14

36:                                               ; preds = %17
  br label %37

37:                                               ; preds = %36
  %38 = load i32, ptr %4, align 4, !tbaa !9
  %39 = add nsw i32 %38, 1
  store i32 %39, ptr %4, align 4, !tbaa !9
  br label %9, !llvm.loop !16

40:                                               ; preds = %12
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #4
  store i32 0, ptr %7, align 4, !tbaa !9
  br label %41

41:                                               ; preds = %54, %40
  %42 = load i32, ptr %7, align 4, !tbaa !9
  %43 = icmp slt i32 %42, 3
  br i1 %43, label %45, label %44

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

45:                                               ; preds = %41
  %46 = load i32, ptr %7, align 4, !tbaa !9
  %47 = trunc i32 %46 to i8
  %48 = call noundef nonnull align 4 dereferenceable(16) ptr @_ZN3rmg4Mat4ixEh(ptr noundef nonnull align 4 dereferenceable(64) %0, i8 noundef zeroext %47)
  %49 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZN3rmg7Mat4RowixEh(ptr noundef nonnull align 4 dereferenceable(16) %48, i8 noundef zeroext 3)
  store float 0.000000e+00, ptr %49, align 4, !tbaa !12
  %50 = call noundef nonnull align 4 dereferenceable(16) ptr @_ZN3rmg4Mat4ixEh(ptr noundef nonnull align 4 dereferenceable(64) %0, i8 noundef zeroext 3)
  %51 = load i32, ptr %7, align 4, !tbaa !9
  %52 = trunc i32 %51 to i8
  %53 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZN3rmg7Mat4RowixEh(ptr noundef nonnull align 4 dereferenceable(16) %50, i8 noundef zeroext %52)
  store float 0.000000e+00, ptr %53, align 4, !tbaa !12
  br label %54

54:                                               ; preds = %45
  %55 = load i32, ptr %7, align 4, !tbaa !9
  %56 = add nsw i32 %55, 1
  store i32 %56, ptr %7, align 4, !tbaa !9
  br label %41, !llvm.loop !17

57:                                               ; preds = %44
  %58 = call noundef nonnull align 4 dereferenceable(16) ptr @_ZN3rmg4Mat4ixEh(ptr noundef nonnull align 4 dereferenceable(64) %0, i8 noundef zeroext 3)
  %59 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZN3rmg7Mat4RowixEh(ptr noundef nonnull align 4 dereferenceable(16) %58, i8 noundef zeroext 3)
  store float 1.000000e+00, ptr %59, align 4, !tbaa !12
  ret void
}

declare void @_ZN3rmg4Mat4C1Ev(ptr noundef nonnull align 4 dereferenceable(64)) unnamed_addr #2

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

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

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 = { "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" }
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, !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}
!17 = distinct !{!17, !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::Mat4" = type { %union.anon.0 }
%union.anon.0 = type { [4 x [4 x float]] }

; Function Attrs: mustprogress uwtable
define dso_local void @_ZNK3rmg4Mat3cvNS_4Mat4EEv(ptr dead_on_unwind noalias nonnull writable sret(%"struct.rmg::Mat4") align 4 %0, ptr nocapture noundef nonnull readonly align 4 dereferenceable(36) %1) local_unnamed_addr #0 align 2 {
.preheader14:
  tail call void @_ZN3rmg4Mat4C1Ev(ptr noundef nonnull align 4 dereferenceable(64) %0)
  %2 = load float, ptr %1, align 4, !tbaa !5
  %3 = tail call noundef nonnull align 4 dereferenceable(16) ptr @_ZN3rmg4Mat4ixEh(ptr noundef nonnull align 4 dereferenceable(64) %0, i8 noundef zeroext 0)
  %4 = tail call noundef nonnull align 4 dereferenceable(4) ptr @_ZN3rmg7Mat4RowixEh(ptr noundef nonnull align 4 dereferenceable(16) %3, i8 noundef zeroext 0)
  store float %2, ptr %4, align 4, !tbaa !8
  %5 = getelementptr inbounds i8, ptr %1, i64 4
  %6 = load float, ptr %5, align 4, !tbaa !5
  %7 = tail call noundef nonnull align 4 dereferenceable(16) ptr @_ZN3rmg4Mat4ixEh(ptr noundef nonnull align 4 dereferenceable(64) %0, i8 noundef zeroext 0)
  %8 = tail call noundef nonnull align 4 dereferenceable(4) ptr @_ZN3rmg7Mat4RowixEh(ptr noundef nonnull align 4 dereferenceable(16) %7, i8 noundef zeroext 1)
  store float %6, ptr %8, align 4, !tbaa !8
  %9 = getelementptr inbounds i8, ptr %1, i64 8
  %10 = load float, ptr %9, align 4, !tbaa !5
  %11 = tail call noundef nonnull align 4 dereferenceable(16) ptr @_ZN3rmg4Mat4ixEh(ptr noundef nonnull align 4 dereferenceable(64) %0, i8 noundef zeroext 0)
  %12 = tail call noundef nonnull align 4 dereferenceable(4) ptr @_ZN3rmg7Mat4RowixEh(ptr noundef nonnull align 4 dereferenceable(16) %11, i8 noundef zeroext 2)
  store float %10, ptr %12, align 4, !tbaa !8
  %13 = getelementptr inbounds i8, ptr %1, i64 12
  %14 = load float, ptr %13, align 4, !tbaa !5
  %15 = tail call noundef nonnull align 4 dereferenceable(16) ptr @_ZN3rmg4Mat4ixEh(ptr noundef nonnull align 4 dereferenceable(64) %0, i8 noundef zeroext 1)
  %16 = tail call noundef nonnull align 4 dereferenceable(4) ptr @_ZN3rmg7Mat4RowixEh(ptr noundef nonnull align 4 dereferenceable(16) %15, i8 noundef zeroext 0)
  store float %14, ptr %16, align 4, !tbaa !8
  %17 = getelementptr inbounds i8, ptr %1, i64 16
  %18 = load float, ptr %17, align 4, !tbaa !5
  %19 = tail call noundef nonnull align 4 dereferenceable(16) ptr @_ZN3rmg4Mat4ixEh(ptr noundef nonnull align 4 dereferenceable(64) %0, i8 noundef zeroext 1)
  %20 = tail call noundef nonnull align 4 dereferenceable(4) ptr @_ZN3rmg7Mat4RowixEh(ptr noundef nonnull align 4 dereferenceable(16) %19, i8 noundef zeroext 1)
  store float %18, ptr %20, align 4, !tbaa !8
  %21 = getelementptr inbounds i8, ptr %1, i64 20
  %22 = load float, ptr %21, align 4, !tbaa !5
  %23 = tail call noundef nonnull align 4 dereferenceable(16) ptr @_ZN3rmg4Mat4ixEh(ptr noundef nonnull align 4 dereferenceable(64) %0, i8 noundef zeroext 1)
  %24 = tail call noundef nonnull align 4 dereferenceable(4) ptr @_ZN3rmg7Mat4RowixEh(ptr noundef nonnull align 4 dereferenceable(16) %23, i8 noundef zeroext 2)
  store float %22, ptr %24, align 4, !tbaa !8
  %25 = getelementptr inbounds i8, ptr %1, i64 24
  %26 = load float, ptr %25, align 4, !tbaa !5
  %27 = tail call noundef nonnull align 4 dereferenceable(16) ptr @_ZN3rmg4Mat4ixEh(ptr noundef nonnull align 4 dereferenceable(64) %0, i8 noundef zeroext 2)
  %28 = tail call noundef nonnull align 4 dereferenceable(4) ptr @_ZN3rmg7Mat4RowixEh(ptr noundef nonnull align 4 dereferenceable(16) %27, i8 noundef zeroext 0)
  store float %26, ptr %28, align 4, !tbaa !8
  %29 = getelementptr inbounds i8, ptr %1, i64 28
  %30 = load float, ptr %29, align 4, !tbaa !5
  %31 = tail call noundef nonnull align 4 dereferenceable(16) ptr @_ZN3rmg4Mat4ixEh(ptr noundef nonnull align 4 dereferenceable(64) %0, i8 noundef zeroext 2)
  %32 = tail call noundef nonnull align 4 dereferenceable(4) ptr @_ZN3rmg7Mat4RowixEh(ptr noundef nonnull align 4 dereferenceable(16) %31, i8 noundef zeroext 1)
  store float %30, ptr %32, align 4, !tbaa !8
  %33 = getelementptr inbounds i8, ptr %1, i64 32
  %34 = load float, ptr %33, align 4, !tbaa !5
  %35 = tail call noundef nonnull align 4 dereferenceable(16) ptr @_ZN3rmg4Mat4ixEh(ptr noundef nonnull align 4 dereferenceable(64) %0, i8 noundef zeroext 2)
  %36 = tail call noundef nonnull align 4 dereferenceable(4) ptr @_ZN3rmg7Mat4RowixEh(ptr noundef nonnull align 4 dereferenceable(16) %35, i8 noundef zeroext 2)
  store float %34, ptr %36, align 4, !tbaa !8
  %37 = tail call noundef nonnull align 4 dereferenceable(16) ptr @_ZN3rmg4Mat4ixEh(ptr noundef nonnull align 4 dereferenceable(64) %0, i8 noundef zeroext 0)
  %38 = tail call noundef nonnull align 4 dereferenceable(4) ptr @_ZN3rmg7Mat4RowixEh(ptr noundef nonnull align 4 dereferenceable(16) %37, i8 noundef zeroext 3)
  store float 0.000000e+00, ptr %38, align 4, !tbaa !8
  %39 = tail call noundef nonnull align 4 dereferenceable(16) ptr @_ZN3rmg4Mat4ixEh(ptr noundef nonnull align 4 dereferenceable(64) %0, i8 noundef zeroext 3)
  %40 = tail call noundef nonnull align 4 dereferenceable(4) ptr @_ZN3rmg7Mat4RowixEh(ptr noundef nonnull align 4 dereferenceable(16) %39, i8 noundef zeroext 0)
  store float 0.000000e+00, ptr %40, align 4, !tbaa !8
  %41 = tail call noundef nonnull align 4 dereferenceable(16) ptr @_ZN3rmg4Mat4ixEh(ptr noundef nonnull align 4 dereferenceable(64) %0, i8 noundef zeroext 1)
  %42 = tail call noundef nonnull align 4 dereferenceable(4) ptr @_ZN3rmg7Mat4RowixEh(ptr noundef nonnull align 4 dereferenceable(16) %41, i8 noundef zeroext 3)
  store float 0.000000e+00, ptr %42, align 4, !tbaa !8
  %43 = tail call noundef nonnull align 4 dereferenceable(16) ptr @_ZN3rmg4Mat4ixEh(ptr noundef nonnull align 4 dereferenceable(64) %0, i8 noundef zeroext 3)
  %44 = tail call noundef nonnull align 4 dereferenceable(4) ptr @_ZN3rmg7Mat4RowixEh(ptr noundef nonnull align 4 dereferenceable(16) %43, i8 noundef zeroext 1)
  store float 0.000000e+00, ptr %44, align 4, !tbaa !8
  %45 = tail call noundef nonnull align 4 dereferenceable(16) ptr @_ZN3rmg4Mat4ixEh(ptr noundef nonnull align 4 dereferenceable(64) %0, i8 noundef zeroext 2)
  %46 = tail call noundef nonnull align 4 dereferenceable(4) ptr @_ZN3rmg7Mat4RowixEh(ptr noundef nonnull align 4 dereferenceable(16) %45, i8 noundef zeroext 3)
  store float 0.000000e+00, ptr %46, align 4, !tbaa !8
  %47 = tail call noundef nonnull align 4 dereferenceable(16) ptr @_ZN3rmg4Mat4ixEh(ptr noundef nonnull align 4 dereferenceable(64) %0, i8 noundef zeroext 3)
  %48 = tail call noundef nonnull align 4 dereferenceable(4) ptr @_ZN3rmg7Mat4RowixEh(ptr noundef nonnull align 4 dereferenceable(16) %47, i8 noundef zeroext 2)
  store float 0.000000e+00, ptr %48, align 4, !tbaa !8
  %49 = tail call noundef nonnull align 4 dereferenceable(16) ptr @_ZN3rmg4Mat4ixEh(ptr noundef nonnull align 4 dereferenceable(64) %0, i8 noundef zeroext 3)
  %50 = tail call noundef nonnull align 4 dereferenceable(4) ptr @_ZN3rmg7Mat4RowixEh(ptr noundef nonnull align 4 dereferenceable(16) %49, i8 noundef zeroext 3)
  store float 1.000000e+00, ptr %50, align 4, !tbaa !8
  ret void
}

declare void @_ZN3rmg4Mat4C1Ev(ptr noundef nonnull align 4 dereferenceable(64)) unnamed_addr #1

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

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

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 = { "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 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,InferFunctionAttrsPass,InstCombinePass,LICMPass,LoopRotatePass,LoopSimplifyPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass