; LLVM IR from thekyria/elabtsaot2 :: emulator_hw/hardware_model/slicedigital.ll (ZN9elabtsaot12SliceDigital5resetEv)

; 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::SliceDigital" = type { %"class.elabtsaot::GPFPQPipeline", %"class.elabtsaot::GPFSlackPipeline", %"class.elabtsaot::TDGeneratorPipeline", %"class.elabtsaot::TDConstZLoadPipeline", %"class.elabtsaot::TDConstILoadPipeline", %"class.elabtsaot::TDConstPLoadPipeline", [4 x [6 x i32]], [4 x [6 x double]], [4 x [6 x double]] }
%"class.elabtsaot::GPFPQPipeline" = type { %"class.elabtsaot::Pipeline", %"class.std::vector.5", %"class.std::vector.5" }
%"class.elabtsaot::Pipeline" = type { ptr, %"class.std::vector", i64, i64, i64, i64, %"class.std::vector.0" }
%"class.std::vector" = type { %"struct.std::_Vector_base" }
%"struct.std::_Vector_base" = type { %"struct.std::_Vector_base<std::__cxx11::basic_string<char>, std::allocator<std::__cxx11::basic_string<char>>>::_Vector_impl" }
%"struct.std::_Vector_base<std::__cxx11::basic_string<char>, std::allocator<std::__cxx11::basic_string<char>>>::_Vector_impl" = type { %"struct.std::_Vector_base<std::__cxx11::basic_string<char>, std::allocator<std::__cxx11::basic_string<char>>>::_Vector_impl_data" }
%"struct.std::_Vector_base<std::__cxx11::basic_string<char>, std::allocator<std::__cxx11::basic_string<char>>>::_Vector_impl_data" = type { ptr, ptr, ptr }
%"class.std::vector.0" = type { %"struct.std::_Vector_base.1" }
%"struct.std::_Vector_base.1" = type { %"struct.std::_Vector_base<std::pair<int, int>, std::allocator<std::pair<int, int>>>::_Vector_impl" }
%"struct.std::_Vector_base<std::pair<int, int>, std::allocator<std::pair<int, int>>>::_Vector_impl" = type { %"struct.std::_Vector_base<std::pair<int, int>, std::allocator<std::pair<int, int>>>::_Vector_impl_data" }
%"struct.std::_Vector_base<std::pair<int, int>, std::allocator<std::pair<int, int>>>::_Vector_impl_data" = type { ptr, ptr, ptr }
%"class.std::vector.5" = type { %"struct.std::_Vector_base.6" }
%"struct.std::_Vector_base.6" = type { %"struct.std::_Vector_base<std::complex<double>, std::allocator<std::complex<double>>>::_Vector_impl" }
%"struct.std::_Vector_base<std::complex<double>, std::allocator<std::complex<double>>>::_Vector_impl" = type { %"struct.std::_Vector_base<std::complex<double>, std::allocator<std::complex<double>>>::_Vector_impl_data" }
%"struct.std::_Vector_base<std::complex<double>, std::allocator<std::complex<double>>>::_Vector_impl_data" = type { ptr, ptr, ptr }
%"class.elabtsaot::GPFSlackPipeline" = type { %"class.elabtsaot::Pipeline", %"class.std::vector.5" }
%"class.elabtsaot::TDGeneratorPipeline" = type { %"class.elabtsaot::Pipeline", %"class.std::vector.10", %"class.std::vector.5", %"class.std::vector.10", %"class.std::vector.10", %"class.std::vector.10", %"class.std::vector.10", %"class.std::vector.10", %"class.std::vector.10", %"class.std::vector.10", %"class.std::vector.10", %"class.std::vector.10", %"class.std::vector.10" }
%"class.std::vector.10" = type { %"struct.std::_Vector_base.11" }
%"struct.std::_Vector_base.11" = type { %"struct.std::_Vector_base<double, std::allocator<double>>::_Vector_impl" }
%"struct.std::_Vector_base<double, std::allocator<double>>::_Vector_impl" = type { %"struct.std::_Vector_base<double, std::allocator<double>>::_Vector_impl_data" }
%"struct.std::_Vector_base<double, std::allocator<double>>::_Vector_impl_data" = type { ptr, ptr, ptr }
%"class.elabtsaot::TDConstZLoadPipeline" = type { %"class.elabtsaot::Pipeline", %"class.std::vector.5", %"class.std::vector.5" }
%"class.elabtsaot::TDConstILoadPipeline" = type { %"class.elabtsaot::Pipeline", %"class.std::vector.5" }
%"class.elabtsaot::TDConstPLoadPipeline" = type { %"class.elabtsaot::Pipeline", %"class.std::vector.5", %"class.std::vector.5" }

; 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 uwtable
define dso_local void @_ZN9elabtsaot12SliceDigital5resetEv(ptr noundef nonnull align 8 dereferenceable(1488) %0) #1 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.elabtsaot::SliceDigital", ptr %6, i32 0, i32 0
  call void @_ZN9elabtsaot13GPFPQPipeline5resetEv(ptr noundef nonnull align 8 dereferenceable(136) %7)
  %8 = getelementptr inbounds %"class.elabtsaot::SliceDigital", ptr %6, i32 0, i32 1
  call void @_ZN9elabtsaot16GPFSlackPipeline5resetEv(ptr noundef nonnull align 8 dereferenceable(112) %8)
  %9 = getelementptr inbounds %"class.elabtsaot::SliceDigital", ptr %6, i32 0, i32 2
  call void @_ZN9elabtsaot19TDGeneratorPipeline5resetEv(ptr noundef nonnull align 8 dereferenceable(376) %9)
  %10 = getelementptr inbounds %"class.elabtsaot::SliceDigital", ptr %6, i32 0, i32 3
  call void @_ZN9elabtsaot20TDConstZLoadPipeline5resetEv(ptr noundef nonnull align 8 dereferenceable(136) %10)
  %11 = getelementptr inbounds %"class.elabtsaot::SliceDigital", ptr %6, i32 0, i32 4
  call void @_ZN9elabtsaot20TDConstILoadPipeline5resetEv(ptr noundef nonnull align 8 dereferenceable(112) %11)
  %12 = getelementptr inbounds %"class.elabtsaot::SliceDigital", ptr %6, i32 0, i32 5
  call void @_ZN9elabtsaot20TDConstPLoadPipeline5resetEv(ptr noundef nonnull align 8 dereferenceable(136) %12)
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #3
  store i64 0, ptr %3, align 8, !tbaa !9
  br label %13

13:                                               ; preds = %42, %1
  %14 = load i64, ptr %3, align 8, !tbaa !9
  %15 = icmp ne i64 %14, 4
  br i1 %15, label %17, label %16

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

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

18:                                               ; preds = %38, %17
  %19 = load i64, ptr %5, align 8, !tbaa !9
  %20 = icmp ne i64 %19, 6
  br i1 %20, label %22, label %21

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

22:                                               ; preds = %18
  %23 = getelementptr inbounds %"class.elabtsaot::SliceDigital", ptr %6, i32 0, i32 6
  %24 = load i64, ptr %3, align 8, !tbaa !9
  %25 = getelementptr inbounds [4 x [6 x i32]], ptr %23, i64 0, i64 %24
  %26 = load i64, ptr %5, align 8, !tbaa !9
  %27 = getelementptr inbounds [6 x i32], ptr %25, i64 0, i64 %26
  store i32 0, ptr %27, align 4, !tbaa !11
  %28 = getelementptr inbounds %"class.elabtsaot::SliceDigital", ptr %6, i32 0, i32 7
  %29 = load i64, ptr %3, align 8, !tbaa !9
  %30 = getelementptr inbounds [4 x [6 x double]], ptr %28, i64 0, i64 %29
  %31 = load i64, ptr %5, align 8, !tbaa !9
  %32 = getelementptr inbounds [6 x double], ptr %30, i64 0, i64 %31
  store double 0.000000e+00, ptr %32, align 8, !tbaa !13
  %33 = getelementptr inbounds %"class.elabtsaot::SliceDigital", ptr %6, i32 0, i32 8
  %34 = load i64, ptr %3, align 8, !tbaa !9
  %35 = getelementptr inbounds [4 x [6 x double]], ptr %33, i64 0, i64 %34
  %36 = load i64, ptr %5, align 8, !tbaa !9
  %37 = getelementptr inbounds [6 x double], ptr %35, i64 0, i64 %36
  store double 0.000000e+00, ptr %37, align 8, !tbaa !13
  br label %38

38:                                               ; preds = %22
  %39 = load i64, ptr %5, align 8, !tbaa !9
  %40 = add i64 %39, 1
  store i64 %40, ptr %5, align 8, !tbaa !9
  br label %18, !llvm.loop !15

41:                                               ; preds = %21
  br label %42

42:                                               ; preds = %41
  %43 = load i64, ptr %3, align 8, !tbaa !9
  %44 = add i64 %43, 1
  store i64 %44, ptr %3, align 8, !tbaa !9
  br label %13, !llvm.loop !17

45:                                               ; preds = %16
  ret void
}

declare void @_ZN9elabtsaot13GPFPQPipeline5resetEv(ptr noundef nonnull align 8 dereferenceable(136)) unnamed_addr #2

declare void @_ZN9elabtsaot16GPFSlackPipeline5resetEv(ptr noundef nonnull align 8 dereferenceable(112)) unnamed_addr #2

declare void @_ZN9elabtsaot19TDGeneratorPipeline5resetEv(ptr noundef nonnull align 8 dereferenceable(376)) unnamed_addr #2

declare void @_ZN9elabtsaot20TDConstZLoadPipeline5resetEv(ptr noundef nonnull align 8 dereferenceable(136)) unnamed_addr #2

declare void @_ZN9elabtsaot20TDConstILoadPipeline5resetEv(ptr noundef nonnull align 8 dereferenceable(112)) unnamed_addr #2

declare void @_ZN9elabtsaot20TDConstPLoadPipeline5resetEv(ptr noundef nonnull align 8 dereferenceable(136)) unnamed_addr #2

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = !{!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, !12, i64 0}
!12 = !{!"_ZTS17NodeInjectionType", !7, i64 0}
!13 = !{!14, !14, i64 0}
!14 = !{!"double", !7, i64 0}
!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 @_ZN9elabtsaot12SliceDigital5resetEv(ptr noundef nonnull align 8 dereferenceable(1488) %0) local_unnamed_addr #0 align 2 {
.preheader:
  tail call void @_ZN9elabtsaot13GPFPQPipeline5resetEv(ptr noundef nonnull align 8 dereferenceable(136) %0)
  %1 = getelementptr inbounds i8, ptr %0, i64 136
  tail call void @_ZN9elabtsaot16GPFSlackPipeline5resetEv(ptr noundef nonnull align 8 dereferenceable(112) %1)
  %2 = getelementptr inbounds i8, ptr %0, i64 248
  tail call void @_ZN9elabtsaot19TDGeneratorPipeline5resetEv(ptr noundef nonnull align 8 dereferenceable(376) %2)
  %3 = getelementptr inbounds i8, ptr %0, i64 624
  tail call void @_ZN9elabtsaot20TDConstZLoadPipeline5resetEv(ptr noundef nonnull align 8 dereferenceable(136) %3)
  %4 = getelementptr inbounds i8, ptr %0, i64 760
  tail call void @_ZN9elabtsaot20TDConstILoadPipeline5resetEv(ptr noundef nonnull align 8 dereferenceable(112) %4)
  %5 = getelementptr inbounds i8, ptr %0, i64 872
  tail call void @_ZN9elabtsaot20TDConstPLoadPipeline5resetEv(ptr noundef nonnull align 8 dereferenceable(136) %5)
  %6 = getelementptr inbounds i8, ptr %0, i64 1008
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(480) %6, i8 0, i64 480, i1 false)
  ret void
}

declare void @_ZN9elabtsaot13GPFPQPipeline5resetEv(ptr noundef nonnull align 8 dereferenceable(136)) unnamed_addr #1

declare void @_ZN9elabtsaot16GPFSlackPipeline5resetEv(ptr noundef nonnull align 8 dereferenceable(112)) unnamed_addr #1

declare void @_ZN9elabtsaot19TDGeneratorPipeline5resetEv(ptr noundef nonnull align 8 dereferenceable(376)) unnamed_addr #1

declare void @_ZN9elabtsaot20TDConstZLoadPipeline5resetEv(ptr noundef nonnull align 8 dereferenceable(136)) unnamed_addr #1

declare void @_ZN9elabtsaot20TDConstILoadPipeline5resetEv(ptr noundef nonnull align 8 dereferenceable(112)) unnamed_addr #1

declare void @_ZN9elabtsaot20TDConstPLoadPipeline5resetEv(ptr noundef nonnull align 8 dereferenceable(136)) 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)"}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,LICMPass,LoopRotatePass,LoopSimplifyPass,MemCpyOptPass,SROAPass,SimplifyCFGPass,TailCallElimPass