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

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

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN10meshloader25MeshBuildingDataCollector15createDataStoreEv(ptr noundef nonnull align 8 dereferenceable(56) %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
  %7 = getelementptr inbounds %"class.meshloader::MeshBuildingDataCollector", ptr %6, i32 0, i32 1
  %8 = load ptr, ptr %7, align 8, !tbaa !9
  %9 = call noundef i64 @_ZNK10meshloader10NumsMatrix13getColsAmountEv(ptr noundef nonnull align 8 dereferenceable(40) %8)
  %10 = sub i64 %9, 2
  %11 = getelementptr inbounds %"class.meshloader::MeshBuildingDataCollector", ptr %6, i32 0, i32 3
  store i64 %10, ptr %11, align 8, !tbaa !12
  %12 = getelementptr inbounds %"class.meshloader::MeshBuildingDataCollector", ptr %6, i32 0, i32 1
  %13 = load ptr, ptr %12, align 8, !tbaa !9
  %14 = call noundef i64 @_ZNK10meshloader10NumsMatrix13getRowsAmountEv(ptr noundef nonnull align 8 dereferenceable(40) %13)
  %15 = sub i64 %14, 2
  %16 = getelementptr inbounds %"class.meshloader::MeshBuildingDataCollector", ptr %6, i32 0, i32 4
  store i64 %15, ptr %16, align 8, !tbaa !13
  %17 = getelementptr inbounds %"class.meshloader::MeshBuildingDataCollector", ptr %6, i32 0, i32 5
  store i64 0, ptr %17, align 8, !tbaa !14
  %18 = getelementptr inbounds %"class.meshloader::MeshBuildingDataCollector", ptr %6, i32 0, i32 6
  store i64 0, ptr %18, align 8, !tbaa !15
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #3
  store i64 0, ptr %3, align 8, !tbaa !16
  br label %19

19:                                               ; preds = %56, %1
  %20 = load i64, ptr %3, align 8, !tbaa !16
  %21 = getelementptr inbounds %"class.meshloader::MeshBuildingDataCollector", ptr %6, i32 0, i32 4
  %22 = load i64, ptr %21, align 8, !tbaa !13
  %23 = icmp ult i64 %20, %22
  br i1 %23, label %25, label %24

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

25:                                               ; preds = %19
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #3
  store i64 0, ptr %5, align 8, !tbaa !16
  br label %26

26:                                               ; preds = %52, %25
  %27 = load i64, ptr %5, align 8, !tbaa !16
  %28 = getelementptr inbounds %"class.meshloader::MeshBuildingDataCollector", ptr %6, i32 0, i32 3
  %29 = load i64, ptr %28, align 8, !tbaa !12
  %30 = icmp ult i64 %27, %29
  br i1 %30, label %32, label %31

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

32:                                               ; preds = %26
  %33 = load i64, ptr %3, align 8, !tbaa !16
  %34 = load i64, ptr %5, align 8, !tbaa !16
  %35 = call noundef i64 @_ZN10meshloader25MeshBuildingDataCollector14getInteriorNumEmm(ptr noundef nonnull align 8 dereferenceable(56) %6, i64 noundef %33, i64 noundef %34)
  %36 = icmp ne i64 0, %35
  br i1 %36, label %37, label %41

37:                                               ; preds = %32
  %38 = getelementptr inbounds %"class.meshloader::MeshBuildingDataCollector", ptr %6, i32 0, i32 5
  %39 = load i64, ptr %38, align 8, !tbaa !14
  %40 = add i64 %39, 1
  store i64 %40, ptr %38, align 8, !tbaa !14
  br label %51

41:                                               ; preds = %32
  %42 = load i64, ptr %3, align 8, !tbaa !16
  %43 = load i64, ptr %5, align 8, !tbaa !16
  %44 = call noundef i64 @_ZN10meshloader25MeshBuildingDataCollector14getInteriorNumEmm(ptr noundef nonnull align 8 dereferenceable(56) %6, i64 noundef %42, i64 noundef %43)
  %45 = icmp eq i64 0, %44
  br i1 %45, label %46, label %50

46:                                               ; preds = %41
  %47 = getelementptr inbounds %"class.meshloader::MeshBuildingDataCollector", ptr %6, i32 0, i32 6
  %48 = load i64, ptr %47, align 8, !tbaa !15
  %49 = add i64 %48, 1
  store i64 %49, ptr %47, align 8, !tbaa !15
  br label %50

50:                                               ; preds = %46, %41
  br label %51

51:                                               ; preds = %50, %37
  br label %52

52:                                               ; preds = %51
  %53 = load i64, ptr %5, align 8, !tbaa !16
  %54 = add i64 %53, 1
  store i64 %54, ptr %5, align 8, !tbaa !16
  br label %26, !llvm.loop !17

55:                                               ; preds = %31
  br label %56

56:                                               ; preds = %55
  %57 = load i64, ptr %3, align 8, !tbaa !16
  %58 = add i64 %57, 1
  store i64 %58, ptr %3, align 8, !tbaa !16
  br label %19, !llvm.loop !19

59:                                               ; preds = %24
  %60 = getelementptr inbounds %"class.meshloader::MeshBuildingDataCollector", ptr %6, i32 0, i32 0
  %61 = load ptr, ptr %60, align 8, !tbaa !20
  %62 = getelementptr inbounds %"class.meshloader::MeshBuildingDataCollector", ptr %6, i32 0, i32 5
  %63 = load i64, ptr %62, align 8, !tbaa !14
  %64 = getelementptr inbounds %"class.meshloader::MeshBuildingDataCollector", ptr %6, i32 0, i32 6
  %65 = load i64, ptr %64, align 8, !tbaa !15
  call void @_ZN10meshloader16MeshBuildingMask12createArraysEmm(ptr noundef nonnull align 8 dereferenceable(8) %61, i64 noundef %63, i64 noundef %65)
  ret void
}

declare noundef i64 @_ZNK10meshloader10NumsMatrix13getColsAmountEv(ptr noundef nonnull align 8 dereferenceable(40)) #1

declare noundef i64 @_ZNK10meshloader10NumsMatrix13getRowsAmountEv(ptr noundef nonnull align 8 dereferenceable(40)) #1

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

; Function Attrs: mustprogress uwtable
declare dso_local noundef i64 @_ZN10meshloader25MeshBuildingDataCollector14getInteriorNumEmm(ptr noundef nonnull align 8 dereferenceable(56), i64 noundef, i64 noundef) #0 align 2

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

declare void @_ZN10meshloader16MeshBuildingMask12createArraysEmm(ptr noundef nonnull align 8 dereferenceable(8), i64 noundef, i64 noundef) #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" }
attributes #2 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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, !6, i64 8}
!10 = !{!"_ZTSN10meshloader25MeshBuildingDataCollectorE", !6, i64 0, !6, i64 8, !6, i64 16, !11, i64 24, !11, i64 32, !11, i64 40, !11, i64 48}
!11 = !{!"long", !7, i64 0}
!12 = !{!10, !11, i64 24}
!13 = !{!10, !11, i64 32}
!14 = !{!10, !11, i64 40}
!15 = !{!10, !11, i64 48}
!16 = !{!11, !11, i64 0}
!17 = distinct !{!17, !18}
!18 = !{!"llvm.loop.mustprogress"}
!19 = distinct !{!19, !18}
!20 = !{!10, !6, i64 0}


; 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 @_ZN10meshloader25MeshBuildingDataCollector15createDataStoreEv(ptr noundef nonnull align 8 dereferenceable(56) %0) local_unnamed_addr #0 align 2 {
  %2 = getelementptr inbounds i8, ptr %0, i64 8
  %3 = load ptr, ptr %2, align 8, !tbaa !5
  %4 = tail call noundef i64 @_ZNK10meshloader10NumsMatrix13getColsAmountEv(ptr noundef nonnull align 8 dereferenceable(40) %3)
  %5 = add i64 %4, -2
  %6 = getelementptr inbounds i8, ptr %0, i64 24
  store i64 %5, ptr %6, align 8, !tbaa !11
  %7 = load ptr, ptr %2, align 8, !tbaa !5
  %8 = tail call noundef i64 @_ZNK10meshloader10NumsMatrix13getRowsAmountEv(ptr noundef nonnull align 8 dereferenceable(40) %7)
  %9 = add i64 %8, -2
  %10 = getelementptr inbounds i8, ptr %0, i64 32
  store i64 %9, ptr %10, align 8, !tbaa !12
  %11 = getelementptr inbounds i8, ptr %0, i64 40
  %12 = getelementptr inbounds i8, ptr %0, i64 48
  %.not12 = icmp eq i64 %9, 0
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(16) %11, i8 0, i64 16, i1 false)
  %13 = load i64, ptr %6, align 8
  %.not13 = icmp eq i64 %13, 0
  %or.cond = select i1 %.not12, i1 true, i1 %.not13
  br i1 %or.cond, label %._crit_edge11, label %.preheader

.preheader:                                       ; preds = %1, %._crit_edge
  %14 = phi i64 [ %19, %._crit_edge ], [ %9, %1 ]
  %15 = phi i64 [ %20, %._crit_edge ], [ 1, %1 ]
  %.0810 = phi i64 [ %21, %._crit_edge ], [ 0, %1 ]
  %.not14 = icmp eq i64 %15, 0
  br i1 %.not14, label %._crit_edge, label %.lr.ph

._crit_edge11.loopexit15:                         ; preds = %._crit_edge
  %.pre16 = load i64, ptr %11, align 8, !tbaa !13
  %.pre17 = load i64, ptr %12, align 8, !tbaa !14
  br label %._crit_edge11

._crit_edge11:                                    ; preds = %._crit_edge11.loopexit15, %1
  %16 = phi i64 [ %.pre17, %._crit_edge11.loopexit15 ], [ 0, %1 ]
  %17 = phi i64 [ %.pre16, %._crit_edge11.loopexit15 ], [ 0, %1 ]
  %18 = load ptr, ptr %0, align 8, !tbaa !15
  tail call void @_ZN10meshloader16MeshBuildingMask12createArraysEmm(ptr noundef nonnull align 8 dereferenceable(8) %18, i64 noundef %17, i64 noundef %16)
  ret void

._crit_edge.loopexit:                             ; preds = %29
  %.pre = load i64, ptr %10, align 8, !tbaa !12
  br label %._crit_edge

._crit_edge:                                      ; preds = %._crit_edge.loopexit, %.preheader
  %19 = phi i64 [ %.pre, %._crit_edge.loopexit ], [ %14, %.preheader ]
  %20 = phi i64 [ %31, %._crit_edge.loopexit ], [ 0, %.preheader ]
  %21 = add nuw i64 %.0810, 1
  %22 = icmp ult i64 %21, %19
  br i1 %22, label %.preheader, label %._crit_edge11.loopexit15, !llvm.loop !16

.lr.ph:                                           ; preds = %.preheader, %29
  %.09 = phi i64 [ %30, %29 ], [ 0, %.preheader ]
  %23 = tail call noundef i64 @_ZN10meshloader25MeshBuildingDataCollector14getInteriorNumEmm(ptr noundef nonnull align 8 dereferenceable(56) %0, i64 noundef %.0810, i64 noundef %.09)
  %.not = icmp eq i64 %23, 0
  br i1 %.not, label %24, label %.sink.split

24:                                               ; preds = %.lr.ph
  %25 = tail call noundef i64 @_ZN10meshloader25MeshBuildingDataCollector14getInteriorNumEmm(ptr noundef nonnull align 8 dereferenceable(56) %0, i64 noundef %.0810, i64 noundef %.09)
  %26 = icmp eq i64 %25, 0
  br i1 %26, label %.sink.split, label %29

.sink.split:                                      ; preds = %24, %.lr.ph
  %.sink = phi ptr [ %11, %.lr.ph ], [ %12, %24 ]
  %27 = load i64, ptr %.sink, align 8, !tbaa !19
  %28 = add i64 %27, 1
  store i64 %28, ptr %.sink, align 8, !tbaa !19
  br label %29

29:                                               ; preds = %.sink.split, %24
  %30 = add nuw i64 %.09, 1
  %31 = load i64, ptr %6, align 8, !tbaa !11
  %32 = icmp ult i64 %30, %31
  br i1 %32, label %.lr.ph, label %._crit_edge.loopexit, !llvm.loop !20
}

declare noundef i64 @_ZNK10meshloader10NumsMatrix13getColsAmountEv(ptr noundef nonnull align 8 dereferenceable(40)) local_unnamed_addr #1

declare noundef i64 @_ZNK10meshloader10NumsMatrix13getRowsAmountEv(ptr noundef nonnull align 8 dereferenceable(40)) local_unnamed_addr #1

; Function Attrs: mustprogress uwtable
declare dso_local noundef i64 @_ZN10meshloader25MeshBuildingDataCollector14getInteriorNumEmm(ptr noundef nonnull align 8 dereferenceable(56), i64 noundef, i64 noundef) local_unnamed_addr #0 align 2

declare void @_ZN10meshloader16MeshBuildingMask12createArraysEmm(ptr noundef nonnull align 8 dereferenceable(8), i64 noundef, i64 noundef) local_unnamed_addr #1

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #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 = { nocallback nofree nounwind willreturn memory(argmem: write) }

!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, !7, i64 8}
!6 = !{!"_ZTSN10meshloader25MeshBuildingDataCollectorE", !7, i64 0, !7, i64 8, !7, i64 16, !10, i64 24, !10, i64 32, !10, i64 40, !10, i64 48}
!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 = !{!6, !10, i64 32}
!13 = !{!6, !10, i64 40}
!14 = !{!6, !10, i64 48}
!15 = !{!6, !7, i64 0}
!16 = distinct !{!16, !17, !18}
!17 = !{!"llvm.loop.mustprogress"}
!18 = !{!"llvm.loop.unswitch.partial.disable"}
!19 = !{!10, !10, i64 0}
!20 = distinct !{!20, !17}


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