; LLVM IR from thekyria/elabtsaot2 :: emulator_hw/hardware_model/slice.ll (ZN9elabtsaot5Slice5resetEb)

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

%"struct.elabtsaot::Slice" = type <{ %"class.elabtsaot::SliceAnalog", %"class.elabtsaot::SliceDigital", i32, [4 x i8] }>
%"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 }
%"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.10", %"class.std::vector.10" }
%"class.elabtsaot::Pipeline" = type { ptr, %"class.std::vector.0", i64, i64, i64, i64, %"class.std::vector.5" }
%"class.std::vector.0" = type { %"struct.std::_Vector_base.1" }
%"struct.std::_Vector_base.1" = 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.5" = type { %"struct.std::_Vector_base.6" }
%"struct.std::_Vector_base.6" = 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.10" = type { %"struct.std::_Vector_base.11" }
%"struct.std::_Vector_base.11" = 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.10" }
%"class.elabtsaot::TDGeneratorPipeline" = type { %"class.elabtsaot::Pipeline", %"class.std::vector.15", %"class.std::vector.10", %"class.std::vector.15", %"class.std::vector.15", %"class.std::vector.15", %"class.std::vector.15", %"class.std::vector.15", %"class.std::vector.15", %"class.std::vector.15", %"class.std::vector.15", %"class.std::vector.15", %"class.std::vector.15" }
%"class.std::vector.15" = type { %"struct.std::_Vector_base.16" }
%"struct.std::_Vector_base.16" = 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.10", %"class.std::vector.10" }
%"class.elabtsaot::TDConstILoadPipeline" = type { %"class.elabtsaot::Pipeline", %"class.std::vector.10" }
%"class.elabtsaot::TDConstPLoadPipeline" = type { %"class.elabtsaot::Pipeline", %"class.std::vector.10", %"class.std::vector.10" }

; Function Attrs: mustprogress uwtable
define dso_local noundef i32 @_ZN9elabtsaot5Slice5resetEb(ptr noundef nonnull align 8 dereferenceable(1676) %0, i1 noundef zeroext %1) #0 align 2 {
  %3 = alloca i32, align 4
  %4 = alloca ptr, align 8
  %5 = alloca i8, align 1
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  %8 = zext i1 %1 to i8
  store i8 %8, ptr %5, align 1, !tbaa !9
  %9 = load ptr, ptr %4, align 8
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #3
  %10 = getelementptr inbounds %"struct.elabtsaot::Slice", ptr %9, i32 0, i32 0
  %11 = load i8, ptr %5, align 1, !tbaa !9, !range !11, !noundef !12
  %12 = trunc i8 %11 to i1
  %13 = call noundef i32 @_ZN9elabtsaot11SliceAnalog5resetEb(ptr noundef nonnull align 8 dereferenceable(184) %10, i1 noundef zeroext %12)
  store i32 %13, ptr %6, align 4, !tbaa !13
  %14 = load i32, ptr %6, align 4, !tbaa !13
  %15 = icmp ne i32 %14, 0
  br i1 %15, label %16, label %18

16:                                               ; preds = %2
  %17 = load i32, ptr %6, align 4, !tbaa !13
  store i32 %17, ptr %3, align 4
  store i32 1, ptr %7, align 4
  br label %19

18:                                               ; preds = %2
  store i32 0, ptr %7, align 4
  br label %19

19:                                               ; preds = %18, %16
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #3
  %20 = load i32, ptr %7, align 4
  switch i32 %20, label %25 [
    i32 0, label %21
    i32 1, label %23
  ]

21:                                               ; preds = %19
  %22 = getelementptr inbounds %"struct.elabtsaot::Slice", ptr %9, i32 0, i32 1
  call void @_ZN9elabtsaot12SliceDigital5resetEv(ptr noundef nonnull align 8 dereferenceable(1488) %22)
  store i32 0, ptr %3, align 4
  br label %23

23:                                               ; preds = %21, %19
  %24 = load i32, ptr %3, align 4
  ret i32 %24

25:                                               ; preds = %19
  unreachable
}

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

declare noundef i32 @_ZN9elabtsaot11SliceAnalog5resetEb(ptr noundef nonnull align 8 dereferenceable(184), i1 noundef zeroext) #2

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

declare void @_ZN9elabtsaot12SliceDigital5resetEv(ptr noundef nonnull align 8 dereferenceable(1488)) #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 = { 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 = !{!"bool", !7, i64 0}
!11 = !{i8 0, i8 2}
!12 = !{}
!13 = !{!14, !14, i64 0}
!14 = !{!"int", !7, 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 noundef i32 @_ZN9elabtsaot5Slice5resetEb(ptr noundef nonnull align 8 dereferenceable(1676) %0, i1 noundef zeroext %1) local_unnamed_addr #0 align 2 {
  %3 = tail call noundef i32 @_ZN9elabtsaot11SliceAnalog5resetEb(ptr noundef nonnull align 8 dereferenceable(184) %0, i1 noundef zeroext %1)
  %.not.not = icmp eq i32 %3, 0
  br i1 %.not.not, label %4, label %6

4:                                                ; preds = %2
  %5 = getelementptr inbounds i8, ptr %0, i64 184
  tail call void @_ZN9elabtsaot12SliceDigital5resetEv(ptr noundef nonnull align 8 dereferenceable(1488) %5)
  br label %6

6:                                                ; preds = %2, %4
  ret i32 %3
}

declare noundef i32 @_ZN9elabtsaot11SliceAnalog5resetEb(ptr noundef nonnull align 8 dereferenceable(184), i1 noundef zeroext) local_unnamed_addr #1

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


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,SROAPass,SimplifyCFGPass,TailCallElimPass