; 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::Load" = type { i32, i32, double, double, %"class.std::complex", double, double, double, double }
%"class.std::complex" = type { { double, double } }
%"class.elabtsaot::PwsSchematicModelElement" = type { %"class.elabtsaot::PwsModelElement", float, float, float, float }
%"class.elabtsaot::PwsModelElement" = type { ptr, i32, i32 }

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

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

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i32 @llvm.abs.i32(i32, i1 immarg) #2

; Function Attrs: mustprogress uwtable
define dso_local noundef i32 @_ZN9elabtsaot17PwsSchematicModel14addLoadElementENS_4LoadEbPi(ptr noundef nonnull align 8 dereferenceable(112) %0, ptr noundef byval(%"class.elabtsaot::Load") align 8 %1, i1 noundef zeroext %2, ptr noundef %3) unnamed_addr #1 align 2 {
  %5 = alloca i32, align 4
  %6 = alloca ptr, align 8
  %7 = alloca i8, align 1
  %8 = alloca ptr, align 8
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  %12 = alloca ptr, align 8
  %13 = alloca ptr, align 8
  store ptr %0, ptr %6, align 8, !tbaa !5
  %14 = zext i1 %2 to i8
  store i8 %14, ptr %7, align 1, !tbaa !9
  store ptr %3, ptr %8, align 8, !tbaa !5
  %15 = load ptr, ptr %6, align 8
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #3
  %16 = getelementptr inbounds %"class.elabtsaot::Load", ptr %1, i32 0, i32 0
  %17 = load i32, ptr %16, align 8, !tbaa !11
  %18 = load i8, ptr %7, align 1, !tbaa !9, !range !16, !noundef !17
  %19 = trunc i8 %18 to i1
  %20 = load ptr, ptr %15, align 8, !tbaa !18
  %21 = getelementptr inbounds ptr, ptr %20, i64 5
  %22 = load ptr, ptr %21, align 8
  %23 = call noundef i32 %22(ptr noundef nonnull align 8 dereferenceable(112) %15, i32 noundef 3, i32 noundef %17, i1 noundef zeroext %19, ptr noundef %9)
  store i32 %23, ptr %10, align 4, !tbaa !20
  %24 = load i32, ptr %10, align 4, !tbaa !20
  %25 = icmp ne i32 %24, 0
  br i1 %25, label %26, label %27

26:                                               ; preds = %4
  store i32 1, ptr %5, align 4
  store i32 1, ptr %11, align 4
  br label %110

27:                                               ; preds = %4
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #3
  %28 = load i32, ptr %9, align 4, !tbaa !20
  %29 = sext i32 %28 to i64
  %30 = call noundef ptr @_ZN9elabtsaot17PwsSchematicModel14elementByIndexEim(ptr noundef nonnull align 8 dereferenceable(112) %15, i32 noundef 3, i64 noundef %29)
  store ptr %30, ptr %12, align 8, !tbaa !5
  %31 = load ptr, ptr %8, align 8, !tbaa !5
  %32 = icmp ne ptr %31, null
  br i1 %32, label %33, label %36

33:                                               ; preds = %27
  %34 = load i32, ptr %9, align 4, !tbaa !20
  %35 = load ptr, ptr %8, align 8, !tbaa !5
  store i32 %34, ptr %35, align 4, !tbaa !20
  br label %36

36:                                               ; preds = %33, %27
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #3
  %37 = getelementptr inbounds %"class.elabtsaot::Load", ptr %1, i32 0, i32 1
  %38 = load i32, ptr %37, align 4, !tbaa !21
  %39 = call noundef ptr @_ZN9elabtsaot17PwsSchematicModel7elementEijPi(ptr noundef nonnull align 8 dereferenceable(112) %15, i32 noundef 0, i32 noundef %38, ptr noundef null)
  store ptr %39, ptr %13, align 8, !tbaa !5
  %40 = load ptr, ptr %13, align 8, !tbaa !5
  %41 = icmp eq ptr %40, null
  br i1 %41, label %42, label %43

42:                                               ; preds = %36
  store i32 1, ptr %5, align 4
  store i32 1, ptr %11, align 4
  br label %109

43:                                               ; preds = %36
  %44 = load ptr, ptr %13, align 8, !tbaa !5
  %45 = getelementptr inbounds %"class.elabtsaot::PwsSchematicModelElement", ptr %44, i32 0, i32 2
  %46 = load float, ptr %45, align 4, !tbaa !22
  %47 = load ptr, ptr %13, align 8, !tbaa !5
  %48 = getelementptr inbounds %"class.elabtsaot::PwsSchematicModelElement", ptr %47, i32 0, i32 4
  %49 = load float, ptr %48, align 4, !tbaa !26
  %50 = fadd float %46, %49
  %51 = fdiv float %50, 2.000000e+00
  %52 = load ptr, ptr %12, align 8, !tbaa !5
  %53 = getelementptr inbounds %"class.elabtsaot::PwsSchematicModelElement", ptr %52, i32 0, i32 2
  store float %51, ptr %53, align 4, !tbaa !22
  %54 = load ptr, ptr %13, align 8, !tbaa !5
  %55 = getelementptr inbounds %"class.elabtsaot::PwsSchematicModelElement", ptr %54, i32 0, i32 1
  %56 = load float, ptr %55, align 8, !tbaa !27
  %57 = load ptr, ptr %13, align 8, !tbaa !5
  %58 = getelementptr inbounds %"class.elabtsaot::PwsSchematicModelElement", ptr %57, i32 0, i32 3
  %59 = load float, ptr %58, align 8, !tbaa !28
  %60 = fadd float %56, %59
  %61 = fdiv float %60, 2.000000e+00
  %62 = load ptr, ptr %12, align 8, !tbaa !5
  %63 = getelementptr inbounds %"class.elabtsaot::PwsSchematicModelElement", ptr %62, i32 0, i32 1
  store float %61, ptr %63, align 8, !tbaa !27
  %64 = load ptr, ptr %13, align 8, !tbaa !5
  %65 = getelementptr inbounds %"class.elabtsaot::PwsSchematicModelElement", ptr %64, i32 0, i32 4
  %66 = load float, ptr %65, align 4, !tbaa !26
  %67 = load ptr, ptr %13, align 8, !tbaa !5
  %68 = getelementptr inbounds %"class.elabtsaot::PwsSchematicModelElement", ptr %67, i32 0, i32 2
  %69 = load float, ptr %68, align 4, !tbaa !22
  %70 = fsub float %66, %69
  %71 = fptosi float %70 to i32
  %72 = call i32 @llvm.abs.i32(i32 %71, i1 true)
  %73 = icmp eq i32 %72, 5
  br i1 %73, label %74, label %91

74:                                               ; preds = %43
  %75 = load ptr, ptr %12, align 8, !tbaa !5
  %76 = getelementptr inbounds %"class.elabtsaot::PwsSchematicModelElement", ptr %75, i32 0, i32 1
  %77 = load float, ptr %76, align 8, !tbaa !27
  %78 = fsub float %77, 1.000000e+01
  store float %78, ptr %76, align 8, !tbaa !27
  %79 = load ptr, ptr %12, align 8, !tbaa !5
  %80 = getelementptr inbounds %"class.elabtsaot::PwsSchematicModelElement", ptr %79, i32 0, i32 1
  %81 = load float, ptr %80, align 8, !tbaa !27
  %82 = fadd float %81, 2.000000e+01
  %83 = load ptr, ptr %12, align 8, !tbaa !5
  %84 = getelementptr inbounds %"class.elabtsaot::PwsSchematicModelElement", ptr %83, i32 0, i32 3
  store float %82, ptr %84, align 8, !tbaa !28
  %85 = load ptr, ptr %12, align 8, !tbaa !5
  %86 = getelementptr inbounds %"class.elabtsaot::PwsSchematicModelElement", ptr %85, i32 0, i32 2
  %87 = load float, ptr %86, align 4, !tbaa !22
  %88 = fsub float %87, 2.500000e+01
  %89 = load ptr, ptr %12, align 8, !tbaa !5
  %90 = getelementptr inbounds %"class.elabtsaot::PwsSchematicModelElement", ptr %89, i32 0, i32 4
  store float %88, ptr %90, align 4, !tbaa !26
  br label %108

91:                                               ; preds = %43
  %92 = load ptr, ptr %12, align 8, !tbaa !5
  %93 = getelementptr inbounds %"class.elabtsaot::PwsSchematicModelElement", ptr %92, i32 0, i32 2
  %94 = load float, ptr %93, align 4, !tbaa !22
  %95 = fsub float %94, 1.000000e+01
  store float %95, ptr %93, align 4, !tbaa !22
  %96 = load ptr, ptr %12, align 8, !tbaa !5
  %97 = getelementptr inbounds %"class.elabtsaot::PwsSchematicModelElement", ptr %96, i32 0, i32 1
  %98 = load float, ptr %97, align 8, !tbaa !27
  %99 = fsub float %98, 2.500000e+01
  %100 = load ptr, ptr %12, align 8, !tbaa !5
  %101 = getelementptr inbounds %"class.elabtsaot::PwsSchematicModelElement", ptr %100, i32 0, i32 3
  store float %99, ptr %101, align 8, !tbaa !28
  %102 = load ptr, ptr %12, align 8, !tbaa !5
  %103 = getelementptr inbounds %"class.elabtsaot::PwsSchematicModelElement", ptr %102, i32 0, i32 2
  %104 = load float, ptr %103, align 4, !tbaa !22
  %105 = fadd float %104, 2.000000e+01
  %106 = load ptr, ptr %12, align 8, !tbaa !5
  %107 = getelementptr inbounds %"class.elabtsaot::PwsSchematicModelElement", ptr %106, i32 0, i32 4
  store float %105, ptr %107, align 4, !tbaa !26
  br label %108

108:                                              ; preds = %91, %74
  store i32 0, ptr %5, align 4
  store i32 1, ptr %11, align 4
  br label %109

109:                                              ; preds = %108, %42
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #3
  br label %110

110:                                              ; preds = %109, %26
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #3
  %111 = load i32, ptr %5, align 4
  ret i32 %111
}

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 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
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 = !{!12, !13, i64 0}
!12 = !{!"_ZTSN9elabtsaot4LoadE", !13, i64 0, !13, i64 4, !14, i64 8, !14, i64 16, !15, i64 24, !14, i64 40, !14, i64 48, !14, i64 56, !14, i64 64}
!13 = !{!"int", !7, i64 0}
!14 = !{!"double", !7, i64 0}
!15 = !{!"_ZTSSt7complexIdE", !7, i64 0}
!16 = !{i8 0, i8 2}
!17 = !{}
!18 = !{!19, !19, i64 0}
!19 = !{!"vtable pointer", !8, i64 0}
!20 = !{!13, !13, i64 0}
!21 = !{!12, !13, i64 4}
!22 = !{!23, !25, i64 20}
!23 = !{!"_ZTSN9elabtsaot24PwsSchematicModelElementE", !24, i64 0, !25, i64 16, !25, i64 20, !25, i64 24, !25, i64 28}
!24 = !{!"_ZTSN9elabtsaot15PwsModelElementE", !13, i64 8, !13, i64 12}
!25 = !{!"float", !7, i64 0}
!26 = !{!23, !25, i64 28}
!27 = !{!23, !25, i64 16}
!28 = !{!23, !25, i64 24}


; 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::Load" = type { i32, i32, double, double, %"class.std::complex", double, double, double, double }
%"class.std::complex" = type { { double, double } }

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

; 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
declare dso_local noundef ptr @_ZN9elabtsaot17PwsSchematicModel14elementByIndexEim(ptr noundef nonnull align 8 dereferenceable(112), i32 noundef, i64 noundef) local_unnamed_addr #1 align 2

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

; Function Attrs: mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i32 @llvm.abs.i32(i32, i1 immarg) #2

; Function Attrs: mustprogress uwtable
define dso_local noundef range(i32 0, 2) i32 @_ZN9elabtsaot17PwsSchematicModel14addLoadElementENS_4LoadEbPi(ptr noundef nonnull align 8 dereferenceable(112) %0, ptr nocapture noundef readonly byval(%"class.elabtsaot::Load") align 8 %1, i1 noundef zeroext %2, ptr noundef writeonly %3) unnamed_addr #1 align 2 {
  %5 = alloca i32, align 4
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %5) #3
  %6 = load i32, ptr %1, align 8, !tbaa !5
  %7 = load ptr, ptr %0, align 8, !tbaa !12
  %8 = getelementptr inbounds i8, ptr %7, i64 40
  %9 = load ptr, ptr %8, align 8
  %10 = call noundef i32 %9(ptr noundef nonnull align 8 dereferenceable(112) %0, i32 noundef 3, i32 noundef %6, i1 noundef zeroext %2, ptr noundef nonnull %5)
  %.not = icmp eq i32 %10, 0
  br i1 %.not, label %11, label %51

11:                                               ; preds = %4
  %12 = load i32, ptr %5, align 4, !tbaa !14
  %13 = sext i32 %12 to i64
  %14 = call noundef ptr @_ZN9elabtsaot17PwsSchematicModel14elementByIndexEim(ptr noundef nonnull align 8 dereferenceable(112) %0, i32 noundef 3, i64 noundef %13)
  %.not26 = icmp eq ptr %3, null
  br i1 %.not26, label %17, label %15

15:                                               ; preds = %11
  %16 = load i32, ptr %5, align 4, !tbaa !14
  store i32 %16, ptr %3, align 4, !tbaa !14
  br label %17

17:                                               ; preds = %15, %11
  %18 = getelementptr inbounds i8, ptr %1, i64 4
  %19 = load i32, ptr %18, align 4, !tbaa !15
  %20 = call noundef ptr @_ZN9elabtsaot17PwsSchematicModel7elementEijPi(ptr noundef nonnull align 8 dereferenceable(112) %0, i32 noundef 0, i32 noundef %19, ptr noundef null)
  %21 = icmp eq ptr %20, null
  br i1 %21, label %51, label %22

22:                                               ; preds = %17
  %23 = getelementptr inbounds i8, ptr %20, i64 20
  %24 = getelementptr inbounds i8, ptr %20, i64 16
  %25 = getelementptr inbounds i8, ptr %20, i64 24
  %26 = load <2 x float>, ptr %24, align 8, !tbaa !16
  %27 = load <2 x float>, ptr %25, align 8, !tbaa !16
  %28 = fadd <2 x float> %26, %27
  %29 = fmul <2 x float> %28, <float 5.000000e-01, float 5.000000e-01>
  %30 = getelementptr inbounds i8, ptr %14, i64 16
  store <2 x float> %29, ptr %30, align 8, !tbaa !16
  %31 = load float, ptr %23, align 4, !tbaa !18
  %32 = extractelement <2 x float> %27, i64 1
  %33 = fsub float %32, %31
  %34 = fptosi float %33 to i32
  %35 = call i32 @llvm.abs.i32(i32 %34, i1 true)
  %36 = icmp eq i32 %35, 5
  %37 = getelementptr inbounds i8, ptr %14, i64 28
  br i1 %36, label %38, label %45

38:                                               ; preds = %22
  %39 = getelementptr inbounds i8, ptr %14, i64 24
  %40 = extractelement <2 x float> %29, i64 0
  %41 = fadd float %40, -1.000000e+01
  store float %41, ptr %30, align 8, !tbaa !21
  %42 = fadd float %41, 2.000000e+01
  store float %42, ptr %39, align 8, !tbaa !22
  %43 = extractelement <2 x float> %29, i64 1
  %44 = fadd float %43, -2.500000e+01
  br label %.sink.split

45:                                               ; preds = %22
  %46 = getelementptr inbounds i8, ptr %14, i64 20
  %47 = fadd <2 x float> %29, <float -2.500000e+01, float -1.000000e+01>
  %48 = shufflevector <2 x float> %47, <2 x float> poison, <2 x i32> <i32 1, i32 0>
  store <2 x float> %48, ptr %46, align 4, !tbaa !16
  %49 = extractelement <2 x float> %47, i64 1
  %50 = fadd float %49, 2.000000e+01
  br label %.sink.split

.sink.split:                                      ; preds = %38, %45
  %.sink = phi float [ %50, %45 ], [ %44, %38 ]
  store float %.sink, ptr %37, align 4, !tbaa !23
  br label %51

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

attributes #0 = { mustprogress 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 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }
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, !7, i64 0}
!6 = !{!"_ZTSN9elabtsaot4LoadE", !7, i64 0, !7, i64 4, !10, i64 8, !10, i64 16, !11, i64 24, !10, i64 40, !10, i64 48, !10, i64 56, !10, i64 64}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"double", !8, i64 0}
!11 = !{!"_ZTSSt7complexIdE", !8, i64 0}
!12 = !{!13, !13, i64 0}
!13 = !{!"vtable pointer", !9, i64 0}
!14 = !{!7, !7, i64 0}
!15 = !{!6, !7, i64 4}
!16 = !{!17, !17, i64 0}
!17 = !{!"float", !8, i64 0}
!18 = !{!19, !17, i64 20}
!19 = !{!"_ZTSN9elabtsaot24PwsSchematicModelElementE", !20, i64 0, !17, i64 16, !17, i64 20, !17, i64 24, !17, i64 28}
!20 = !{!"_ZTSN9elabtsaot15PwsModelElementE", !7, i64 8, !7, i64 12}
!21 = !{!19, !17, i64 16}
!22 = !{!19, !17, i64 24}
!23 = !{!19, !17, i64 28}


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