; LLVM IR from thekyria/elabtsaot2 :: emulator_hw/hardware_model/sliceanalog.ll (ZNK9elabtsaot11SliceAnalog12getEmbrCountEv)

; 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.elabtsaot::SliceAnalog" = type { double, double, %"class.elabtsaot::DAC", %"class.elabtsaot::DAC", %"class.std::vector" }
%"class.elabtsaot::DAC" = type <{ double, double, i32, i32, i32, [4 x i8], double, double, double, double, i32, [4 x i8] }>
%"class.std::vector" = type { %"struct.std::_Vector_base" }
%"struct.std::_Vector_base" = type { %"struct.std::_Vector_base<std::vector<elabtsaot::Atom>, std::allocator<std::vector<elabtsaot::Atom>>>::_Vector_impl" }
%"struct.std::_Vector_base<std::vector<elabtsaot::Atom>, std::allocator<std::vector<elabtsaot::Atom>>>::_Vector_impl" = type { %"struct.std::_Vector_base<std::vector<elabtsaot::Atom>, std::allocator<std::vector<elabtsaot::Atom>>>::_Vector_impl_data" }
%"struct.std::_Vector_base<std::vector<elabtsaot::Atom>, std::allocator<std::vector<elabtsaot::Atom>>>::_Vector_impl_data" = type { ptr, ptr, ptr }

; 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
declare dso_local noundef i64 @_ZNKSt6vectorIS_IN9elabtsaot4AtomESaIS1_EESaIS3_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24)) #1 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i64 @_ZNKSt6vectorIN9elabtsaot4AtomESaIS1_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24)) #1 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(24) ptr @_ZNKSt6vectorIS_IN9elabtsaot4AtomESaIS1_EESaIS3_EEixEm(ptr noundef nonnull align 8 dereferenceable(24), i64 noundef) #1 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(392) ptr @_ZNKSt6vectorIN9elabtsaot4AtomESaIS1_EEixEm(ptr noundef nonnull align 8 dereferenceable(24), i64 noundef) #1 align 2

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

8:                                                ; preds = %36, %1
  %9 = load i64, ptr %4, align 8, !tbaa !9
  %10 = getelementptr inbounds %"class.elabtsaot::SliceAnalog", ptr %7, i32 0, i32 4
  %11 = call noundef i64 @_ZNKSt6vectorIS_IN9elabtsaot4AtomESaIS1_EESaIS3_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %10) #4
  %12 = icmp ne i64 %9, %11
  br i1 %12, label %14, label %13

13:                                               ; preds = %8
  store i32 2, ptr %5, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #4
  br label %39

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

15:                                               ; preds = %32, %14
  %16 = load i64, ptr %6, align 8, !tbaa !9
  %17 = getelementptr inbounds %"class.elabtsaot::SliceAnalog", ptr %7, i32 0, i32 4
  %18 = load i64, ptr %4, align 8, !tbaa !9
  %19 = call noundef nonnull align 8 dereferenceable(24) ptr @_ZNKSt6vectorIS_IN9elabtsaot4AtomESaIS1_EESaIS3_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %17, i64 noundef %18) #4
  %20 = call noundef i64 @_ZNKSt6vectorIN9elabtsaot4AtomESaIS1_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %19) #4
  %21 = icmp ne i64 %16, %20
  br i1 %21, label %23, label %22

22:                                               ; preds = %15
  store i32 5, ptr %5, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #4
  br label %35

23:                                               ; preds = %15
  %24 = getelementptr inbounds %"class.elabtsaot::SliceAnalog", ptr %7, i32 0, i32 4
  %25 = load i64, ptr %4, align 8, !tbaa !9
  %26 = call noundef nonnull align 8 dereferenceable(24) ptr @_ZNKSt6vectorIS_IN9elabtsaot4AtomESaIS1_EESaIS3_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %24, i64 noundef %25) #4
  %27 = load i64, ptr %6, align 8, !tbaa !9
  %28 = call noundef nonnull align 8 dereferenceable(392) ptr @_ZNKSt6vectorIN9elabtsaot4AtomESaIS1_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %26, i64 noundef %27) #4
  %29 = call noundef i64 @_ZNK9elabtsaot4Atom12getEmbrCountEv(ptr noundef nonnull align 8 dereferenceable(392) %28)
  %30 = load i64, ptr %3, align 8, !tbaa !9
  %31 = add i64 %30, %29
  store i64 %31, ptr %3, align 8, !tbaa !9
  br label %32

32:                                               ; preds = %23
  %33 = load i64, ptr %6, align 8, !tbaa !9
  %34 = add i64 %33, 1
  store i64 %34, ptr %6, align 8, !tbaa !9
  br label %15, !llvm.loop !11

35:                                               ; preds = %22
  br label %36

36:                                               ; preds = %35
  %37 = load i64, ptr %4, align 8, !tbaa !9
  %38 = add i64 %37, 1
  store i64 %38, ptr %4, align 8, !tbaa !9
  br label %8, !llvm.loop !13

39:                                               ; preds = %13
  %40 = load i64, ptr %3, align 8, !tbaa !9
  store i32 1, ptr %5, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #4
  ret i64 %40
}

declare noundef i64 @_ZNK9elabtsaot4Atom12getEmbrCountEv(ptr noundef nonnull align 8 dereferenceable(392)) #3

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 = { "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 = 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"

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i64 @_ZNKSt6vectorIS_IN9elabtsaot4AtomESaIS1_EESaIS3_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24)) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i64 @_ZNKSt6vectorIN9elabtsaot4AtomESaIS1_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24)) local_unnamed_addr #0 align 2

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(392) ptr @_ZNKSt6vectorIN9elabtsaot4AtomESaIS1_EEixEm(ptr noundef nonnull align 8 dereferenceable(24), i64 noundef) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress uwtable
define dso_local noundef i64 @_ZNK9elabtsaot11SliceAnalog12getEmbrCountEv(ptr noundef nonnull align 8 dereferenceable(184) %0) local_unnamed_addr #1 align 2 {
  %2 = getelementptr inbounds i8, ptr %0, i64 160
  %3 = tail call noundef i64 @_ZNKSt6vectorIS_IN9elabtsaot4AtomESaIS1_EESaIS3_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %2) #3
  %.not15 = icmp eq i64 %3, 0
  br i1 %.not15, label %._crit_edge18, label %.preheader

.preheader:                                       ; preds = %1, %._crit_edge
  %.0917 = phi i64 [ %6, %._crit_edge ], [ 0, %1 ]
  %.01016 = phi i64 [ %.1.lcssa, %._crit_edge ], [ 0, %1 ]
  %4 = tail call noundef nonnull align 8 dereferenceable(24) ptr @_ZNKSt6vectorIS_IN9elabtsaot4AtomESaIS1_EESaIS3_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %2, i64 noundef %.0917) #3
  %5 = tail call noundef i64 @_ZNKSt6vectorIN9elabtsaot4AtomESaIS1_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %4) #3
  %.not1112 = icmp eq i64 %5, 0
  br i1 %.not1112, label %._crit_edge, label %.lr.ph

._crit_edge18:                                    ; preds = %._crit_edge, %1
  %.010.lcssa = phi i64 [ 0, %1 ], [ %.1.lcssa, %._crit_edge ]
  ret i64 %.010.lcssa

._crit_edge:                                      ; preds = %.lr.ph, %.preheader
  %.1.lcssa = phi i64 [ %.01016, %.preheader ], [ %11, %.lr.ph ]
  %6 = add i64 %.0917, 1
  %7 = tail call noundef i64 @_ZNKSt6vectorIS_IN9elabtsaot4AtomESaIS1_EESaIS3_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %2) #3
  %.not = icmp eq i64 %6, %7
  br i1 %.not, label %._crit_edge18, label %.preheader, !llvm.loop !5

.lr.ph:                                           ; preds = %.preheader, %.lr.ph
  %.014 = phi i64 [ %12, %.lr.ph ], [ 0, %.preheader ]
  %.113 = phi i64 [ %11, %.lr.ph ], [ %.01016, %.preheader ]
  %8 = tail call noundef nonnull align 8 dereferenceable(24) ptr @_ZNKSt6vectorIS_IN9elabtsaot4AtomESaIS1_EESaIS3_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %2, i64 noundef %.0917) #3
  %9 = tail call noundef nonnull align 8 dereferenceable(392) ptr @_ZNKSt6vectorIN9elabtsaot4AtomESaIS1_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %8, i64 noundef %.014) #3
  %10 = tail call noundef i64 @_ZNK9elabtsaot4Atom12getEmbrCountEv(ptr noundef nonnull align 8 dereferenceable(392) %9)
  %11 = add i64 %10, %.113
  %12 = add i64 %.014, 1
  %13 = tail call noundef nonnull align 8 dereferenceable(24) ptr @_ZNKSt6vectorIS_IN9elabtsaot4AtomESaIS1_EESaIS3_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %2, i64 noundef %.0917) #3
  %14 = tail call noundef i64 @_ZNKSt6vectorIN9elabtsaot4AtomESaIS1_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %13) #3
  %.not11 = icmp eq i64 %12, %14
  br i1 %.not11, label %._crit_edge, label %.lr.ph, !llvm.loop !7
}

declare noundef i64 @_ZNK9elabtsaot4Atom12getEmbrCountEv(ptr noundef nonnull align 8 dereferenceable(392)) local_unnamed_addr #2

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" }
attributes #1 = { 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" }
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 = distinct !{!5, !6}
!6 = !{!"llvm.loop.mustprogress"}
!7 = distinct !{!7, !6}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass