; LLVM IR from artvns/SimpleFvm :: simplefvm/src/ResultsSaver/SimpleSaver (GapCellsPositionsData)

; 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.resultssaver::GapCellsPositionsData" = type { ptr, ptr }

@.str = external hidden unnamed_addr constant [16 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [2 x i8], align 1

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN12resultssaver21GapCellsPositionsData10outputDataERSt14basic_ofstreamIcSt11char_traitsIcEE(ptr noundef nonnull align 8 dereferenceable(16) %0, ptr noundef nonnull align 8 dereferenceable(248) %1) #0 align 2 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca i64, align 8
  store ptr %0, ptr %3, align 8, !tbaa !5
  store ptr %1, ptr %4, align 8, !tbaa !5
  %6 = load ptr, ptr %3, align 8
  %7 = load ptr, ptr %4, align 8, !tbaa !5
  %8 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc(ptr noundef nonnull align 8 dereferenceable(8) %7, ptr noundef @.str)
  %9 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_c(ptr noundef nonnull align 8 dereferenceable(8) %8, i8 noundef signext 10)
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #4
  store i64 0, ptr %5, align 8, !tbaa !9
  br label %10

10:                                               ; preds = %45, %2
  %11 = load i64, ptr %5, align 8, !tbaa !9
  %12 = getelementptr inbounds %"class.resultssaver::GapCellsPositionsData", ptr %6, i32 0, i32 1
  %13 = load ptr, ptr %12, align 8, !tbaa !11
  %14 = call noundef i64 @_ZNK10datastores17MeshBuildingStore17getGapCellsAmountEv(ptr noundef nonnull align 8 dereferenceable(224) %13)
  %15 = icmp ult i64 %11, %14
  br i1 %15, label %17, label %16

16:                                               ; preds = %10
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #4
  br label %48

17:                                               ; preds = %10
  %18 = load ptr, ptr %4, align 8, !tbaa !5
  %19 = getelementptr inbounds %"class.resultssaver::GapCellsPositionsData", ptr %6, i32 0, i32 1
  %20 = load ptr, ptr %19, align 8, !tbaa !11
  %21 = call noundef nonnull align 8 dereferenceable(32) ptr @_ZN10datastores17MeshBuildingStore13getGapCellNumEv(ptr noundef nonnull align 8 dereferenceable(224) %20)
  %22 = load i64, ptr %5, align 8, !tbaa !9
  %23 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZN10datastores8ArrayAdtImE8getValueEm(ptr noundef nonnull align 8 dereferenceable(32) %21, i64 noundef %22)
  %24 = load i64, ptr %23, align 8, !tbaa !9
  %25 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEm(ptr noundef nonnull align 8 dereferenceable(8) %18, i64 noundef %24)
  %26 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc(ptr noundef nonnull align 8 dereferenceable(8) %25, ptr noundef @.str.1)
  %27 = load ptr, ptr %4, align 8, !tbaa !5
  %28 = getelementptr inbounds %"class.resultssaver::GapCellsPositionsData", ptr %6, i32 0, i32 1
  %29 = load ptr, ptr %28, align 8, !tbaa !11
  %30 = call noundef nonnull align 8 dereferenceable(32) ptr @_ZN10datastores17MeshBuildingStore15getGapCell_iPosEv(ptr noundef nonnull align 8 dereferenceable(224) %29)
  %31 = load i64, ptr %5, align 8, !tbaa !9
  %32 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZN10datastores8ArrayAdtImE8getValueEm(ptr noundef nonnull align 8 dereferenceable(32) %30, i64 noundef %31)
  %33 = load i64, ptr %32, align 8, !tbaa !9
  %34 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEm(ptr noundef nonnull align 8 dereferenceable(8) %27, i64 noundef %33)
  %35 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc(ptr noundef nonnull align 8 dereferenceable(8) %34, ptr noundef @.str.1)
  %36 = load ptr, ptr %4, align 8, !tbaa !5
  %37 = getelementptr inbounds %"class.resultssaver::GapCellsPositionsData", ptr %6, i32 0, i32 1
  %38 = load ptr, ptr %37, align 8, !tbaa !11
  %39 = call noundef nonnull align 8 dereferenceable(32) ptr @_ZN10datastores17MeshBuildingStore15getGapCell_jPosEv(ptr noundef nonnull align 8 dereferenceable(224) %38)
  %40 = load i64, ptr %5, align 8, !tbaa !9
  %41 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZN10datastores8ArrayAdtImE8getValueEm(ptr noundef nonnull align 8 dereferenceable(32) %39, i64 noundef %40)
  %42 = load i64, ptr %41, align 8, !tbaa !9
  %43 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEm(ptr noundef nonnull align 8 dereferenceable(8) %36, i64 noundef %42)
  %44 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc(ptr noundef nonnull align 8 dereferenceable(8) %43, ptr noundef @.str.2)
  br label %45

45:                                               ; preds = %17
  %46 = load i64, ptr %5, align 8, !tbaa !9
  %47 = add i64 %46, 1
  store i64 %47, ptr %5, align 8, !tbaa !9
  br label %10, !llvm.loop !13

48:                                               ; preds = %16
  ret void
}

; Function Attrs: inlinehint mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_c(ptr noundef nonnull align 8 dereferenceable(8), i8 noundef signext) #1

; Function Attrs: inlinehint mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef) #1

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

declare noundef i64 @_ZNK10datastores17MeshBuildingStore17getGapCellsAmountEv(ptr noundef nonnull align 8 dereferenceable(224)) #3

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

declare noundef nonnull align 8 dereferenceable(32) ptr @_ZN10datastores17MeshBuildingStore13getGapCellNumEv(ptr noundef nonnull align 8 dereferenceable(224)) #3

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

declare noundef nonnull align 8 dereferenceable(32) ptr @_ZN10datastores17MeshBuildingStore15getGapCell_iPosEv(ptr noundef nonnull align 8 dereferenceable(224)) #3

declare noundef nonnull align 8 dereferenceable(32) ptr @_ZN10datastores17MeshBuildingStore15getGapCell_jPosEv(ptr noundef nonnull align 8 dereferenceable(224)) #3

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #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 = { 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 #2 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { "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 = !{!"long", !7, i64 0}
!11 = !{!12, !6, i64 8}
!12 = !{!"_ZTSN12resultssaver21GapCellsPositionsDataE", !6, i64 0, !6, i64 8}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}


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

@.str = external hidden unnamed_addr constant [16 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [2 x i8], align 1

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN12resultssaver21GapCellsPositionsData10outputDataERSt14basic_ofstreamIcSt11char_traitsIcEE(ptr nocapture noundef nonnull readonly align 8 dereferenceable(16) %0, ptr noundef nonnull align 8 dereferenceable(248) %1) local_unnamed_addr #0 align 2 {
  %3 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc(ptr noundef nonnull align 8 dereferenceable(8) %1, ptr noundef nonnull @.str)
  %4 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_c(ptr noundef nonnull align 8 dereferenceable(8) %3, i8 noundef signext 10)
  %5 = getelementptr inbounds i8, ptr %0, i64 8
  %6 = load ptr, ptr %5, align 8, !tbaa !5
  %7 = tail call noundef i64 @_ZNK10datastores17MeshBuildingStore17getGapCellsAmountEv(ptr noundef nonnull align 8 dereferenceable(224) %6)
  %.not = icmp eq i64 %7, 0
  br i1 %.not, label %._crit_edge, label %.lr.ph

._crit_edge:                                      ; preds = %.lr.ph, %2
  ret void

.lr.ph:                                           ; preds = %2, %.lr.ph
  %.09 = phi i64 [ %26, %.lr.ph ], [ 0, %2 ]
  %8 = load ptr, ptr %5, align 8, !tbaa !5
  %9 = tail call noundef nonnull align 8 dereferenceable(32) ptr @_ZN10datastores17MeshBuildingStore13getGapCellNumEv(ptr noundef nonnull align 8 dereferenceable(224) %8)
  %10 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZN10datastores8ArrayAdtImE8getValueEm(ptr noundef nonnull align 8 dereferenceable(32) %9, i64 noundef %.09)
  %11 = load i64, ptr %10, align 8, !tbaa !10
  %12 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEm(ptr noundef nonnull align 8 dereferenceable(8) %1, i64 noundef %11)
  %13 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc(ptr noundef nonnull align 8 dereferenceable(8) %12, ptr noundef nonnull @.str.1)
  %14 = load ptr, ptr %5, align 8, !tbaa !5
  %15 = tail call noundef nonnull align 8 dereferenceable(32) ptr @_ZN10datastores17MeshBuildingStore15getGapCell_iPosEv(ptr noundef nonnull align 8 dereferenceable(224) %14)
  %16 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZN10datastores8ArrayAdtImE8getValueEm(ptr noundef nonnull align 8 dereferenceable(32) %15, i64 noundef %.09)
  %17 = load i64, ptr %16, align 8, !tbaa !10
  %18 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEm(ptr noundef nonnull align 8 dereferenceable(8) %1, i64 noundef %17)
  %19 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc(ptr noundef nonnull align 8 dereferenceable(8) %18, ptr noundef nonnull @.str.1)
  %20 = load ptr, ptr %5, align 8, !tbaa !5
  %21 = tail call noundef nonnull align 8 dereferenceable(32) ptr @_ZN10datastores17MeshBuildingStore15getGapCell_jPosEv(ptr noundef nonnull align 8 dereferenceable(224) %20)
  %22 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZN10datastores8ArrayAdtImE8getValueEm(ptr noundef nonnull align 8 dereferenceable(32) %21, i64 noundef %.09)
  %23 = load i64, ptr %22, align 8, !tbaa !10
  %24 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEm(ptr noundef nonnull align 8 dereferenceable(8) %1, i64 noundef %23)
  %25 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc(ptr noundef nonnull align 8 dereferenceable(8) %24, ptr noundef nonnull @.str.2)
  %26 = add nuw i64 %.09, 1
  %27 = load ptr, ptr %5, align 8, !tbaa !5
  %28 = tail call noundef i64 @_ZNK10datastores17MeshBuildingStore17getGapCellsAmountEv(ptr noundef nonnull align 8 dereferenceable(224) %27)
  %29 = icmp ult i64 %26, %28
  br i1 %29, label %.lr.ph, label %._crit_edge, !llvm.loop !12
}

; Function Attrs: inlinehint mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_c(ptr noundef nonnull align 8 dereferenceable(8), i8 noundef signext) local_unnamed_addr #1

; Function Attrs: inlinehint mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef) local_unnamed_addr #1

declare noundef i64 @_ZNK10datastores17MeshBuildingStore17getGapCellsAmountEv(ptr noundef nonnull align 8 dereferenceable(224)) local_unnamed_addr #2

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

declare noundef nonnull align 8 dereferenceable(32) ptr @_ZN10datastores17MeshBuildingStore13getGapCellNumEv(ptr noundef nonnull align 8 dereferenceable(224)) local_unnamed_addr #2

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

declare noundef nonnull align 8 dereferenceable(32) ptr @_ZN10datastores17MeshBuildingStore15getGapCell_iPosEv(ptr noundef nonnull align 8 dereferenceable(224)) local_unnamed_addr #2

declare noundef nonnull align 8 dereferenceable(32) ptr @_ZN10datastores17MeshBuildingStore15getGapCell_jPosEv(ptr noundef nonnull align 8 dereferenceable(224)) local_unnamed_addr #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 = { 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 #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" }

!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 = !{!"_ZTSN12resultssaver21GapCellsPositionsDataE", !7, i64 0, !7, i64 8}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!11, !11, i64 0}
!11 = !{!"long", !8, i64 0}
!12 = distinct !{!12, !13}
!13 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass