; LLVM IR from Angelo1211/SoftwareRenderer :: src/matrix.ll (ZN7Matrix411makeTestMatEv)

; 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 { %"struct.std::array" }
%"struct.std::array" = type { [16 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: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 4 dereferenceable(4) ptr @_ZN7Matrix4clEmm(ptr noundef nonnull align 4 dereferenceable(64), i64 noundef, i64 noundef) #1 align 2

; 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
declare dso_local void @_ZN7Matrix4C2Ev(ptr noundef nonnull align 4 dereferenceable(64)) unnamed_addr #1 align 2

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN7Matrix411makeTestMatEv(ptr dead_on_unwind noalias writable sret(%class.Matrix4) align 4 %0) #2 align 2 {
  %2 = alloca i32, align 4
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  call void @_ZN7Matrix4C2Ev(ptr noundef nonnull align 4 dereferenceable(64) %0)
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #3
  store i32 4, ptr %2, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #3
  store i32 1, ptr %3, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #3
  store i32 0, ptr %4, align 4, !tbaa !5
  br label %7

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

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

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

13:                                               ; preds = %28, %12
  %14 = load i32, ptr %6, align 4, !tbaa !5
  %15 = load i32, ptr %2, align 4, !tbaa !5
  %16 = icmp slt i32 %14, %15
  br i1 %16, label %18, label %17

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

18:                                               ; preds = %13
  %19 = load i32, ptr %3, align 4, !tbaa !5
  %20 = sitofp i32 %19 to float
  %21 = load i32, ptr %4, align 4, !tbaa !5
  %22 = sext i32 %21 to i64
  %23 = load i32, ptr %6, align 4, !tbaa !5
  %24 = sext i32 %23 to i64
  %25 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZN7Matrix4clEmm(ptr noundef nonnull align 4 dereferenceable(64) %0, i64 noundef %22, i64 noundef %24)
  store float %20, ptr %25, align 4, !tbaa !9
  %26 = load i32, ptr %3, align 4, !tbaa !5
  %27 = add nsw i32 %26, 1
  store i32 %27, ptr %3, align 4, !tbaa !5
  br label %28

28:                                               ; preds = %18
  %29 = load i32, ptr %6, align 4, !tbaa !5
  %30 = add nsw i32 %29, 1
  store i32 %30, ptr %6, align 4, !tbaa !5
  br label %13, !llvm.loop !11

31:                                               ; preds = %17
  br label %32

32:                                               ; preds = %31
  %33 = load i32, ptr %4, align 4, !tbaa !5
  %34 = add nsw i32 %33, 1
  store i32 %34, ptr %4, align 4, !tbaa !5
  br label %7, !llvm.loop !13

35:                                               ; preds = %11
  store i32 1, ptr %5, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #3
  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 = { 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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"float", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = distinct !{!13, !12}


; 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.Matrix4 = type { %"struct.std::array" }
%"struct.std::array" = type { [16 x float] }

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 4 dereferenceable(4) ptr @_ZN7Matrix4clEmm(ptr noundef nonnull align 4 dereferenceable(64), i64 noundef, i64 noundef) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN7Matrix4C2Ev(ptr noundef nonnull align 4 dereferenceable(64)) unnamed_addr #0 align 2

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @_ZN7Matrix411makeTestMatEv(ptr dead_on_unwind noalias nonnull writable sret(%class.Matrix4) align 4 %0) local_unnamed_addr #0 align 2 {
.preheader:
  tail call void @_ZN7Matrix4C2Ev(ptr noundef nonnull align 4 dereferenceable(64) %0)
  %1 = tail call noundef nonnull align 4 dereferenceable(4) ptr @_ZN7Matrix4clEmm(ptr noundef nonnull align 4 dereferenceable(64) %0, i64 noundef 0, i64 noundef 0)
  store float 1.000000e+00, ptr %1, align 4, !tbaa !5
  %2 = tail call noundef nonnull align 4 dereferenceable(4) ptr @_ZN7Matrix4clEmm(ptr noundef nonnull align 4 dereferenceable(64) %0, i64 noundef 0, i64 noundef 1)
  store float 2.000000e+00, ptr %2, align 4, !tbaa !5
  %3 = tail call noundef nonnull align 4 dereferenceable(4) ptr @_ZN7Matrix4clEmm(ptr noundef nonnull align 4 dereferenceable(64) %0, i64 noundef 0, i64 noundef 2)
  store float 3.000000e+00, ptr %3, align 4, !tbaa !5
  %4 = tail call noundef nonnull align 4 dereferenceable(4) ptr @_ZN7Matrix4clEmm(ptr noundef nonnull align 4 dereferenceable(64) %0, i64 noundef 0, i64 noundef 3)
  store float 4.000000e+00, ptr %4, align 4, !tbaa !5
  %5 = tail call noundef nonnull align 4 dereferenceable(4) ptr @_ZN7Matrix4clEmm(ptr noundef nonnull align 4 dereferenceable(64) %0, i64 noundef 1, i64 noundef 0)
  store float 5.000000e+00, ptr %5, align 4, !tbaa !5
  %6 = tail call noundef nonnull align 4 dereferenceable(4) ptr @_ZN7Matrix4clEmm(ptr noundef nonnull align 4 dereferenceable(64) %0, i64 noundef 1, i64 noundef 1)
  store float 6.000000e+00, ptr %6, align 4, !tbaa !5
  %7 = tail call noundef nonnull align 4 dereferenceable(4) ptr @_ZN7Matrix4clEmm(ptr noundef nonnull align 4 dereferenceable(64) %0, i64 noundef 1, i64 noundef 2)
  store float 7.000000e+00, ptr %7, align 4, !tbaa !5
  %8 = tail call noundef nonnull align 4 dereferenceable(4) ptr @_ZN7Matrix4clEmm(ptr noundef nonnull align 4 dereferenceable(64) %0, i64 noundef 1, i64 noundef 3)
  store float 8.000000e+00, ptr %8, align 4, !tbaa !5
  %9 = tail call noundef nonnull align 4 dereferenceable(4) ptr @_ZN7Matrix4clEmm(ptr noundef nonnull align 4 dereferenceable(64) %0, i64 noundef 2, i64 noundef 0)
  store float 9.000000e+00, ptr %9, align 4, !tbaa !5
  %10 = tail call noundef nonnull align 4 dereferenceable(4) ptr @_ZN7Matrix4clEmm(ptr noundef nonnull align 4 dereferenceable(64) %0, i64 noundef 2, i64 noundef 1)
  store float 1.000000e+01, ptr %10, align 4, !tbaa !5
  %11 = tail call noundef nonnull align 4 dereferenceable(4) ptr @_ZN7Matrix4clEmm(ptr noundef nonnull align 4 dereferenceable(64) %0, i64 noundef 2, i64 noundef 2)
  store float 1.100000e+01, ptr %11, align 4, !tbaa !5
  %12 = tail call noundef nonnull align 4 dereferenceable(4) ptr @_ZN7Matrix4clEmm(ptr noundef nonnull align 4 dereferenceable(64) %0, i64 noundef 2, i64 noundef 3)
  store float 1.200000e+01, ptr %12, align 4, !tbaa !5
  %13 = tail call noundef nonnull align 4 dereferenceable(4) ptr @_ZN7Matrix4clEmm(ptr noundef nonnull align 4 dereferenceable(64) %0, i64 noundef 3, i64 noundef 0)
  store float 1.300000e+01, ptr %13, align 4, !tbaa !5
  %14 = tail call noundef nonnull align 4 dereferenceable(4) ptr @_ZN7Matrix4clEmm(ptr noundef nonnull align 4 dereferenceable(64) %0, i64 noundef 3, i64 noundef 1)
  store float 1.400000e+01, ptr %14, align 4, !tbaa !5
  %15 = tail call noundef nonnull align 4 dereferenceable(4) ptr @_ZN7Matrix4clEmm(ptr noundef nonnull align 4 dereferenceable(64) %0, i64 noundef 3, i64 noundef 2)
  store float 1.500000e+01, ptr %15, align 4, !tbaa !5
  %16 = tail call noundef nonnull align 4 dereferenceable(4) ptr @_ZN7Matrix4clEmm(ptr noundef nonnull align 4 dereferenceable(64) %0, i64 noundef 3, i64 noundef 3)
  store float 1.600000e+01, ptr %16, align 4, !tbaa !5
  ret void
}

attributes #0 = { 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" }

!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: GVNPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,LCSSAPass,LICMPass,LoopRotatePass,LoopSimplifyPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass