; LLVM IR from thekyria/elabtsaot2 :: gui/powersystem_editor/powersystem_model (pwsschematicmodel)

; 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::Bus" = type { i32, %"class.std::__cxx11::basic_string", i32, double, double, double, double, double, double, double }
%"class.std::__cxx11::basic_string" = type { %"struct.std::__cxx11::basic_string<char>::_Alloc_hider", i64, %union.anon }
%"struct.std::__cxx11::basic_string<char>::_Alloc_hider" = type { ptr }
%union.anon = type { i64, [8 x i8] }
%"class.elabtsaot::PwsSchematicModelElement" = type { %"class.elabtsaot::PwsModelElement", float, float, float, float }
%"class.elabtsaot::PwsModelElement" = type { ptr, i32, i32 }

declare i32 @__gxx_personality_v0(...)

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

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZN9elabtsaot3BusC2ERKS0_(ptr noundef nonnull align 8 dereferenceable(104), ptr noundef nonnull align 8 dereferenceable(104)) unnamed_addr #1 align 2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local void @_ZN9elabtsaot3BusD2Ev(ptr noundef nonnull align 8 dereferenceable(104)) unnamed_addr #2 align 2

; 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 noundef i32 @_ZN9elabtsaot17PwsSchematicModel13addBusElementENS_3BusEiibbPi(ptr noundef nonnull align 8 dereferenceable(112) %0, ptr noundef %1, i32 noundef %2, i32 noundef %3, i1 noundef zeroext %4, i1 noundef zeroext %5, ptr noundef %6) #3 align 2 personality ptr @__gxx_personality_v0 {
  %8 = alloca i32, align 4
  %9 = alloca ptr, align 8
  %10 = alloca ptr, align 8
  %11 = alloca i32, align 4
  %12 = alloca i32, align 4
  %13 = alloca i8, align 1
  %14 = alloca i8, align 1
  %15 = alloca ptr, align 8
  %16 = alloca i32, align 4
  %17 = alloca i32, align 4
  %18 = alloca %"class.elabtsaot::Bus", align 8
  %19 = alloca ptr, align 8
  %20 = alloca i32, align 4
  %21 = alloca i32, align 4
  %22 = alloca ptr, align 8
  store ptr %0, ptr %9, align 8, !tbaa !5
  store ptr %1, ptr %10, align 8, !tbaa !5
  store i32 %2, ptr %11, align 4, !tbaa !9
  store i32 %3, ptr %12, align 4, !tbaa !9
  %23 = zext i1 %4 to i8
  store i8 %23, ptr %13, align 1, !tbaa !11
  %24 = zext i1 %5 to i8
  store i8 %24, ptr %14, align 1, !tbaa !11
  store ptr %6, ptr %15, align 8, !tbaa !5
  %25 = load ptr, ptr %9, align 8
  call void @llvm.lifetime.start.p0(i64 4, ptr %16) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %17) #4
  call void @_ZN9elabtsaot3BusC2ERKS0_(ptr noundef nonnull align 8 dereferenceable(104) %18, ptr noundef nonnull align 8 dereferenceable(104) %1)
  %26 = load i8, ptr %14, align 1, !tbaa !11, !range !13, !noundef !14
  %27 = trunc i8 %26 to i1
  %28 = load ptr, ptr %25, align 8, !tbaa !15
  %29 = getelementptr inbounds ptr, ptr %28, i64 6
  %30 = load ptr, ptr %29, align 8
  %31 = invoke noundef i32 %30(ptr noundef nonnull align 8 dereferenceable(112) %25, ptr noundef %18, i1 noundef zeroext %27, ptr noundef %16)
          to label %32 unwind label %36

32:                                               ; preds = %7
  call void @_ZN9elabtsaot3BusD2Ev(ptr noundef nonnull align 8 dereferenceable(104) %18) #4
  store i32 %31, ptr %17, align 4, !tbaa !9
  %33 = load i32, ptr %17, align 4, !tbaa !9
  %34 = icmp ne i32 %33, 0
  br i1 %34, label %35, label %40

35:                                               ; preds = %32
  store i32 1, ptr %8, align 4
  store i32 1, ptr %21, align 4
  br label %87

36:                                               ; preds = %7
  %37 = landingpad { ptr, i32 }
          cleanup
  %38 = extractvalue { ptr, i32 } %37, 0
  store ptr %38, ptr %19, align 8
  %39 = extractvalue { ptr, i32 } %37, 1
  store i32 %39, ptr %20, align 4
  call void @_ZN9elabtsaot3BusD2Ev(ptr noundef nonnull align 8 dereferenceable(104) %18) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %17) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %16) #4
  br label %89

40:                                               ; preds = %32
  call void @llvm.lifetime.start.p0(i64 8, ptr %22) #4
  %41 = load i32, ptr %16, align 4, !tbaa !9
  %42 = sext i32 %41 to i64
  %43 = call noundef ptr @_ZN9elabtsaot17PwsSchematicModel14elementByIndexEim(ptr noundef nonnull align 8 dereferenceable(112) %25, i32 noundef 0, i64 noundef %42)
  store ptr %43, ptr %22, align 8, !tbaa !5
  %44 = load ptr, ptr %15, align 8, !tbaa !5
  %45 = icmp ne ptr %44, null
  br i1 %45, label %46, label %49

46:                                               ; preds = %40
  %47 = load i32, ptr %16, align 4, !tbaa !9
  %48 = load ptr, ptr %15, align 8, !tbaa !5
  store i32 %47, ptr %48, align 4, !tbaa !9
  br label %49

49:                                               ; preds = %46, %40
  %50 = load i32, ptr %11, align 4, !tbaa !9
  %51 = sitofp i32 %50 to float
  %52 = load ptr, ptr %22, align 8, !tbaa !5
  %53 = getelementptr inbounds %"class.elabtsaot::PwsSchematicModelElement", ptr %52, i32 0, i32 1
  store float %51, ptr %53, align 8, !tbaa !17
  %54 = load i32, ptr %12, align 4, !tbaa !9
  %55 = sitofp i32 %54 to float
  %56 = load ptr, ptr %22, align 8, !tbaa !5
  %57 = getelementptr inbounds %"class.elabtsaot::PwsSchematicModelElement", ptr %56, i32 0, i32 2
  store float %55, ptr %57, align 4, !tbaa !21
  %58 = load i8, ptr %13, align 1, !tbaa !11, !range !13, !noundef !14
  %59 = trunc i8 %58 to i1
  br i1 %59, label %60, label %73

60:                                               ; preds = %49
  %61 = load ptr, ptr %22, align 8, !tbaa !5
  %62 = getelementptr inbounds %"class.elabtsaot::PwsSchematicModelElement", ptr %61, i32 0, i32 1
  %63 = load float, ptr %62, align 8, !tbaa !17
  %64 = fadd float %63, 3.000000e+01
  %65 = load ptr, ptr %22, align 8, !tbaa !5
  %66 = getelementptr inbounds %"class.elabtsaot::PwsSchematicModelElement", ptr %65, i32 0, i32 3
  store float %64, ptr %66, align 8, !tbaa !22
  %67 = load ptr, ptr %22, align 8, !tbaa !5
  %68 = getelementptr inbounds %"class.elabtsaot::PwsSchematicModelElement", ptr %67, i32 0, i32 2
  %69 = load float, ptr %68, align 4, !tbaa !21
  %70 = fadd float %69, 5.000000e+00
  %71 = load ptr, ptr %22, align 8, !tbaa !5
  %72 = getelementptr inbounds %"class.elabtsaot::PwsSchematicModelElement", ptr %71, i32 0, i32 4
  store float %70, ptr %72, align 4, !tbaa !23
  br label %86

73:                                               ; preds = %49
  %74 = load ptr, ptr %22, align 8, !tbaa !5
  %75 = getelementptr inbounds %"class.elabtsaot::PwsSchematicModelElement", ptr %74, i32 0, i32 1
  %76 = load float, ptr %75, align 8, !tbaa !17
  %77 = fadd float %76, 5.000000e+00
  %78 = load ptr, ptr %22, align 8, !tbaa !5
  %79 = getelementptr inbounds %"class.elabtsaot::PwsSchematicModelElement", ptr %78, i32 0, i32 3
  store float %77, ptr %79, align 8, !tbaa !22
  %80 = load ptr, ptr %22, align 8, !tbaa !5
  %81 = getelementptr inbounds %"class.elabtsaot::PwsSchematicModelElement", ptr %80, i32 0, i32 2
  %82 = load float, ptr %81, align 4, !tbaa !21
  %83 = fadd float %82, 3.000000e+01
  %84 = load ptr, ptr %22, align 8, !tbaa !5
  %85 = getelementptr inbounds %"class.elabtsaot::PwsSchematicModelElement", ptr %84, i32 0, i32 4
  store float %83, ptr %85, align 4, !tbaa !23
  br label %86

86:                                               ; preds = %73, %60
  store i32 0, ptr %8, align 4
  store i32 1, ptr %21, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %22) #4
  br label %87

87:                                               ; preds = %86, %35
  call void @llvm.lifetime.end.p0(i64 4, ptr %17) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %16) #4
  %88 = load i32, ptr %8, align 4
  ret i32 %88

89:                                               ; preds = %36
  %90 = load ptr, ptr %19, align 8
  %91 = load i32, ptr %20, align 4
  %92 = insertvalue { ptr, i32 } poison, ptr %90, 0
  %93 = insertvalue { ptr, i32 } %92, i32 %91, 1
  resume { ptr, i32 } %93
}

; Function Attrs: mustprogress uwtable
declare dso_local noundef ptr @_ZN9elabtsaot17PwsSchematicModel14elementByIndexEim(ptr noundef nonnull align 8 dereferenceable(112), i32 noundef, i64 noundef) #3 align 2

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { inlinehint 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 #3 = { 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 #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 = !{!"int", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"bool", !7, i64 0}
!13 = !{i8 0, i8 2}
!14 = !{}
!15 = !{!16, !16, i64 0}
!16 = !{!"vtable pointer", !8, i64 0}
!17 = !{!18, !20, i64 16}
!18 = !{!"_ZTSN9elabtsaot24PwsSchematicModelElementE", !19, i64 0, !20, i64 16, !20, i64 20, !20, i64 24, !20, i64 28}
!19 = !{!"_ZTSN9elabtsaot15PwsModelElementE", !10, i64 8, !10, i64 12}
!20 = !{!"float", !7, i64 0}
!21 = !{!18, !20, i64 20}
!22 = !{!18, !20, i64 24}
!23 = !{!18, !20, i64 28}


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

%"class.elabtsaot::Bus" = type { i32, %"class.std::__cxx11::basic_string", i32, double, double, double, double, double, double, double }
%"class.std::__cxx11::basic_string" = type { %"struct.std::__cxx11::basic_string<char>::_Alloc_hider", i64, %union.anon }
%"struct.std::__cxx11::basic_string<char>::_Alloc_hider" = type { ptr }
%union.anon = type { i64, [8 x i8] }

declare i32 @__gxx_personality_v0(...)

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

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZN9elabtsaot3BusC2ERKS0_(ptr noundef nonnull align 8 dereferenceable(104), ptr noundef nonnull align 8 dereferenceable(104)) unnamed_addr #1 align 2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local void @_ZN9elabtsaot3BusD2Ev(ptr noundef nonnull align 8 dereferenceable(104)) unnamed_addr #2 align 2

; Function Attrs: mustprogress 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 noundef range(i32 0, 2) i32 @_ZN9elabtsaot17PwsSchematicModel13addBusElementENS_3BusEiibbPi(ptr noundef nonnull align 8 dereferenceable(112) %0, ptr noundef nonnull %1, i32 noundef %2, i32 noundef %3, i1 noundef zeroext %4, i1 noundef zeroext %5, ptr noundef writeonly %6) local_unnamed_addr #3 align 2 personality ptr @__gxx_personality_v0 {
  %8 = alloca i32, align 4
  %9 = alloca %"class.elabtsaot::Bus", align 8
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %8) #4
  call void @_ZN9elabtsaot3BusC2ERKS0_(ptr noundef nonnull align 8 dereferenceable(104) %9, ptr noundef nonnull align 8 dereferenceable(104) %1)
  %10 = load ptr, ptr %0, align 8, !tbaa !5
  %11 = getelementptr inbounds i8, ptr %10, i64 48
  %12 = load ptr, ptr %11, align 8
  %13 = invoke noundef i32 %12(ptr noundef nonnull align 8 dereferenceable(112) %0, ptr noundef nonnull %9, i1 noundef zeroext %5, ptr noundef nonnull %8)
          to label %14 unwind label %15

14:                                               ; preds = %7
  call void @_ZN9elabtsaot3BusD2Ev(ptr noundef nonnull align 8 dereferenceable(104) %9) #4
  %.not = icmp eq i32 %13, 0
  br i1 %.not, label %17, label %32

15:                                               ; preds = %7
  %16 = landingpad { ptr, i32 }
          cleanup
  call void @_ZN9elabtsaot3BusD2Ev(ptr noundef nonnull align 8 dereferenceable(104) %9) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %8) #4
  resume { ptr, i32 } %16

17:                                               ; preds = %14
  %18 = load i32, ptr %8, align 4, !tbaa !8
  %19 = sext i32 %18 to i64
  %20 = call noundef ptr @_ZN9elabtsaot17PwsSchematicModel14elementByIndexEim(ptr noundef nonnull align 8 dereferenceable(112) %0, i32 noundef 0, i64 noundef %19)
  %.not21 = icmp eq ptr %6, null
  br i1 %.not21, label %.sink.split, label %21

21:                                               ; preds = %17
  %22 = load i32, ptr %8, align 4, !tbaa !8
  store i32 %22, ptr %6, align 4, !tbaa !8
  br label %.sink.split

.sink.split:                                      ; preds = %21, %17
  %23 = insertelement <2 x i32> poison, i32 %2, i64 0
  %24 = insertelement <2 x i32> %23, i32 %3, i64 1
  %25 = sitofp <2 x i32> %24 to <2 x float>
  %26 = getelementptr inbounds i8, ptr %20, i64 16
  store <2 x float> %25, ptr %26, align 8, !tbaa !11
  %27 = getelementptr inbounds i8, ptr %20, i64 24
  %28 = insertelement <2 x i1> poison, i1 %4, i64 0
  %29 = shufflevector <2 x i1> %28, <2 x i1> poison, <2 x i32> zeroinitializer
  %30 = select <2 x i1> %29, <2 x float> <float 3.000000e+01, float 5.000000e+00>, <2 x float> <float 5.000000e+00, float 3.000000e+01>
  %31 = fadd <2 x float> %30, %25
  store <2 x float> %31, ptr %27, align 8, !tbaa !11
  br label %32

32:                                               ; preds = %.sink.split, %14
  %.0 = phi i32 [ 1, %14 ], [ 0, %.sink.split ]
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %8) #4
  ret i32 %.0
}

; Function Attrs: mustprogress uwtable
declare dso_local noundef ptr @_ZN9elabtsaot17PwsSchematicModel14elementByIndexEim(ptr noundef nonnull align 8 dereferenceable(112), i32 noundef, i64 noundef) local_unnamed_addr #3 align 2

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { inlinehint 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 #3 = { 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 #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 = !{!"vtable pointer", !7, i64 0}
!7 = !{!"Simple C++ TBAA"}
!8 = !{!9, !9, i64 0}
!9 = !{!"int", !10, i64 0}
!10 = !{!"omnipotent char", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"float", !10, i64 0}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,PostOrderFunctionAttrsPass,SLPVectorizerPass,SROAPass,SimplifyCFGPass