; LLVM IR from ysyesilyurt/ComputerGraphics :: ForwardRenderingPipeline/Matrix4.ll (ZN7Matrix4C2EPA4_d)

; 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.Matrix4 = type { [4 x [4 x double]] }

; 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 nounwind uwtable
define dso_local void @_ZN7Matrix4C2EPA4_d(ptr noundef nonnull align 8 dereferenceable(128) %0, ptr noundef %1) unnamed_addr #1 align 2 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  store ptr %1, ptr %4, align 8, !tbaa !5
  %8 = load ptr, ptr %3, align 8
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #2
  store i32 0, ptr %5, align 4, !tbaa !9
  br label %9

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

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

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

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

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

18:                                               ; preds = %14
  %19 = load ptr, ptr %4, align 8, !tbaa !5
  %20 = load i32, ptr %5, align 4, !tbaa !9
  %21 = sext i32 %20 to i64
  %22 = getelementptr inbounds [4 x double], ptr %19, i64 %21
  %23 = load i32, ptr %7, align 4, !tbaa !9
  %24 = sext i32 %23 to i64
  %25 = getelementptr inbounds [4 x double], ptr %22, i64 0, i64 %24
  %26 = load double, ptr %25, align 8, !tbaa !11
  %27 = getelementptr inbounds %class.Matrix4, ptr %8, i32 0, i32 0
  %28 = load i32, ptr %5, align 4, !tbaa !9
  %29 = sext i32 %28 to i64
  %30 = getelementptr inbounds [4 x [4 x double]], ptr %27, i64 0, i64 %29
  %31 = load i32, ptr %7, align 4, !tbaa !9
  %32 = sext i32 %31 to i64
  %33 = getelementptr inbounds [4 x double], ptr %30, i64 0, i64 %32
  store double %26, ptr %33, align 8, !tbaa !11
  br label %34

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

37:                                               ; preds = %17
  br label %38

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

41:                                               ; preds = %12
  ret void
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #2 = { 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 = !{!12, !12, i64 0}
!12 = !{!"double", !7, i64 0}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}
!15 = distinct !{!15, !14}


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

; Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: readwrite) uwtable
define dso_local void @_ZN7Matrix4C2EPA4_d(ptr nocapture noundef nonnull writeonly align 8 dereferenceable(128) %0, ptr nocapture noundef readonly %1) unnamed_addr #0 align 2 {
.preheader:
  %2 = load double, ptr %1, align 8, !tbaa !5
  store double %2, ptr %0, align 8, !tbaa !5
  %3 = getelementptr inbounds i8, ptr %1, i64 8
  %4 = load double, ptr %3, align 8, !tbaa !5
  %5 = getelementptr inbounds i8, ptr %0, i64 8
  store double %4, ptr %5, align 8, !tbaa !5
  %6 = getelementptr inbounds i8, ptr %1, i64 16
  %7 = load double, ptr %6, align 8, !tbaa !5
  %8 = getelementptr inbounds i8, ptr %0, i64 16
  store double %7, ptr %8, align 8, !tbaa !5
  %9 = getelementptr inbounds i8, ptr %1, i64 24
  %10 = load double, ptr %9, align 8, !tbaa !5
  %11 = getelementptr inbounds i8, ptr %0, i64 24
  store double %10, ptr %11, align 8, !tbaa !5
  %12 = getelementptr inbounds i8, ptr %1, i64 32
  %13 = load double, ptr %12, align 8, !tbaa !5
  %14 = getelementptr inbounds i8, ptr %0, i64 32
  store double %13, ptr %14, align 8, !tbaa !5
  %15 = getelementptr inbounds i8, ptr %1, i64 40
  %16 = load double, ptr %15, align 8, !tbaa !5
  %17 = getelementptr inbounds i8, ptr %0, i64 40
  store double %16, ptr %17, align 8, !tbaa !5
  %18 = getelementptr inbounds i8, ptr %1, i64 48
  %19 = load double, ptr %18, align 8, !tbaa !5
  %20 = getelementptr inbounds i8, ptr %0, i64 48
  store double %19, ptr %20, align 8, !tbaa !5
  %21 = getelementptr inbounds i8, ptr %1, i64 56
  %22 = load double, ptr %21, align 8, !tbaa !5
  %23 = getelementptr inbounds i8, ptr %0, i64 56
  store double %22, ptr %23, align 8, !tbaa !5
  %24 = getelementptr inbounds i8, ptr %1, i64 64
  %25 = load double, ptr %24, align 8, !tbaa !5
  %26 = getelementptr inbounds i8, ptr %0, i64 64
  store double %25, ptr %26, align 8, !tbaa !5
  %27 = getelementptr inbounds i8, ptr %1, i64 72
  %28 = load double, ptr %27, align 8, !tbaa !5
  %29 = getelementptr inbounds i8, ptr %0, i64 72
  store double %28, ptr %29, align 8, !tbaa !5
  %30 = getelementptr inbounds i8, ptr %1, i64 80
  %31 = load double, ptr %30, align 8, !tbaa !5
  %32 = getelementptr inbounds i8, ptr %0, i64 80
  store double %31, ptr %32, align 8, !tbaa !5
  %33 = getelementptr inbounds i8, ptr %1, i64 88
  %34 = load double, ptr %33, align 8, !tbaa !5
  %35 = getelementptr inbounds i8, ptr %0, i64 88
  store double %34, ptr %35, align 8, !tbaa !5
  %36 = getelementptr inbounds i8, ptr %1, i64 96
  %37 = load double, ptr %36, align 8, !tbaa !5
  %38 = getelementptr inbounds i8, ptr %0, i64 96
  store double %37, ptr %38, align 8, !tbaa !5
  %39 = getelementptr inbounds i8, ptr %1, i64 104
  %40 = load double, ptr %39, align 8, !tbaa !5
  %41 = getelementptr inbounds i8, ptr %0, i64 104
  store double %40, ptr %41, align 8, !tbaa !5
  %42 = getelementptr inbounds i8, ptr %1, i64 112
  %43 = load double, ptr %42, align 8, !tbaa !5
  %44 = getelementptr inbounds i8, ptr %0, i64 112
  store double %43, ptr %44, align 8, !tbaa !5
  %45 = getelementptr inbounds i8, ptr %1, i64 120
  %46 = load double, ptr %45, align 8, !tbaa !5
  %47 = getelementptr inbounds i8, ptr %0, i64 120
  store double %46, ptr %47, align 8, !tbaa !5
  ret void
}

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


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