; LLVM IR from artvns/SimpleFvm :: simplefvm/src/MeshLoader/MeshTemplates (MeshTemplateP)

; 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.meshloader::MeshTemplateP" = type { ptr, ptr, i64, i64 }

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN10meshloader13MeshTemplateP20initializeWithZeroesEv(ptr noundef nonnull align 8 dereferenceable(32) %0) #0 align 2 {
  %2 = alloca ptr, align 8
  %3 = alloca i64, align 8
  %4 = alloca i32, align 4
  %5 = alloca i64, align 8
  store ptr %0, ptr %2, align 8, !tbaa !5
  %6 = load ptr, ptr %2, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #3
  store i64 0, ptr %3, align 8, !tbaa !9
  br label %7

7:                                                ; preds = %29, %1
  %8 = load i64, ptr %3, align 8, !tbaa !9
  %9 = getelementptr inbounds %"class.meshloader::MeshTemplateP", ptr %6, i32 0, i32 2
  %10 = load i64, ptr %9, align 8, !tbaa !11
  %11 = icmp ult i64 %8, %10
  br i1 %11, label %13, label %12

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

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

14:                                               ; preds = %25, %13
  %15 = load i64, ptr %5, align 8, !tbaa !9
  %16 = getelementptr inbounds %"class.meshloader::MeshTemplateP", ptr %6, i32 0, i32 3
  %17 = load i64, ptr %16, align 8, !tbaa !13
  %18 = icmp ult i64 %15, %17
  br i1 %18, label %20, label %19

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

20:                                               ; preds = %14
  %21 = getelementptr inbounds %"class.meshloader::MeshTemplateP", ptr %6, i32 0, i32 1
  %22 = load ptr, ptr %21, align 8, !tbaa !14
  %23 = load i64, ptr %3, align 8, !tbaa !9
  %24 = load i64, ptr %5, align 8, !tbaa !9
  call void @_ZN10meshloader10BaseMatrix8setValueEmmc(ptr noundef nonnull align 8 dereferenceable(40) %22, i64 noundef %23, i64 noundef %24, i8 noundef signext 48)
  br label %25

25:                                               ; preds = %20
  %26 = load i64, ptr %5, align 8, !tbaa !9
  %27 = add i64 %26, 1
  store i64 %27, ptr %5, align 8, !tbaa !9
  br label %14, !llvm.loop !15

28:                                               ; preds = %19
  br label %29

29:                                               ; preds = %28
  %30 = load i64, ptr %3, align 8, !tbaa !9
  %31 = add i64 %30, 1
  store i64 %31, ptr %3, align 8, !tbaa !9
  br label %7, !llvm.loop !17

32:                                               ; preds = %12
  ret void
}

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

declare void @_ZN10meshloader10BaseMatrix8setValueEmmc(ptr noundef nonnull align 8 dereferenceable(40), i64 noundef, i64 noundef, i8 noundef signext) #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 = { "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 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"long", !7, i64 0}
!11 = !{!12, !10, i64 16}
!12 = !{!"_ZTSN10meshloader13MeshTemplatePE", !6, i64 0, !6, i64 8, !10, i64 16, !10, i64 24}
!13 = !{!12, !10, i64 24}
!14 = !{!12, !6, i64 8}
!15 = distinct !{!15, !16}
!16 = !{!"llvm.loop.mustprogress"}
!17 = distinct !{!17, !16}


; 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 uwtable
define dso_local void @_ZN10meshloader13MeshTemplateP20initializeWithZeroesEv(ptr nocapture noundef nonnull readonly align 8 dereferenceable(32) %0) local_unnamed_addr #0 align 2 {
  %2 = getelementptr inbounds i8, ptr %0, i64 16
  %3 = load i64, ptr %2, align 8, !tbaa !5
  %.not = icmp eq i64 %3, 0
  br i1 %.not, label %._crit_edge9, label %.preheader.lr.ph

.preheader.lr.ph:                                 ; preds = %1
  %4 = getelementptr inbounds i8, ptr %0, i64 24
  %5 = getelementptr inbounds i8, ptr %0, i64 8
  %6 = load i64, ptr %4, align 8, !tbaa !11
  %.not10 = icmp eq i64 %6, 0
  br i1 %.not10, label %._crit_edge9, label %.preheader

.preheader:                                       ; preds = %.preheader.lr.ph, %._crit_edge
  %7 = phi i64 [ %9, %._crit_edge ], [ %3, %.preheader.lr.ph ]
  %8 = phi i64 [ %10, %._crit_edge ], [ 1, %.preheader.lr.ph ]
  %.068 = phi i64 [ %11, %._crit_edge ], [ 0, %.preheader.lr.ph ]
  %.not11 = icmp eq i64 %8, 0
  br i1 %.not11, label %._crit_edge, label %.lr.ph

._crit_edge9:                                     ; preds = %._crit_edge, %.preheader.lr.ph, %1
  ret void

._crit_edge.loopexit:                             ; preds = %.lr.ph
  %.pre = load i64, ptr %2, align 8, !tbaa !5
  br label %._crit_edge

._crit_edge:                                      ; preds = %._crit_edge.loopexit, %.preheader
  %9 = phi i64 [ %.pre, %._crit_edge.loopexit ], [ %7, %.preheader ]
  %10 = phi i64 [ %15, %._crit_edge.loopexit ], [ 0, %.preheader ]
  %11 = add nuw i64 %.068, 1
  %12 = icmp ult i64 %11, %9
  br i1 %12, label %.preheader, label %._crit_edge9, !llvm.loop !12

.lr.ph:                                           ; preds = %.preheader, %.lr.ph
  %.07 = phi i64 [ %14, %.lr.ph ], [ 0, %.preheader ]
  %13 = load ptr, ptr %5, align 8, !tbaa !15
  tail call void @_ZN10meshloader10BaseMatrix8setValueEmmc(ptr noundef nonnull align 8 dereferenceable(40) %13, i64 noundef %.068, i64 noundef %.07, i8 noundef signext 48)
  %14 = add nuw i64 %.07, 1
  %15 = load i64, ptr %4, align 8, !tbaa !11
  %16 = icmp ult i64 %14, %15
  br i1 %16, label %.lr.ph, label %._crit_edge.loopexit, !llvm.loop !16
}

declare void @_ZN10meshloader10BaseMatrix8setValueEmmc(ptr noundef nonnull align 8 dereferenceable(40), i64 noundef, i64 noundef, i8 noundef signext) local_unnamed_addr #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 = { "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, !10, i64 16}
!6 = !{!"_ZTSN10meshloader13MeshTemplatePE", !7, i64 0, !7, i64 8, !10, i64 16, !10, i64 24}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"long", !8, i64 0}
!11 = !{!6, !10, i64 24}
!12 = distinct !{!12, !13, !14}
!13 = !{!"llvm.loop.mustprogress"}
!14 = !{!"llvm.loop.unswitch.partial.disable"}
!15 = !{!6, !7, i64 8}
!16 = distinct !{!16, !13}


; Effective O3 passes: CorrelatedValuePropagationPass,GVNPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LICMPass,LoopRotatePass,LoopSimplifyCFGPass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SROAPass,SimpleLoopUnswitchPass,SimplifyCFGPass,TailCallElimPass