; LLVM IR from ASDAlexander77/TypeScriptCompiler :: tsc/tsc-new-parser (parenthesizer_rules)

; 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.ptr.102 = type { %"class.std::shared_ptr.103" }
%"class.std::shared_ptr.103" = type { %"class.std::__shared_ptr.104" }
%"class.std::__shared_ptr.104" = type { ptr, %"class.std::__shared_count" }
%"class.std::__shared_count" = type { ptr }
%struct.ptr.97 = type { %"class.std::shared_ptr.98" }
%"class.std::shared_ptr.98" = type { %"class.std::__shared_ptr.99" }
%"class.std::__shared_ptr.99" = type { ptr, %"class.std::__shared_count" }
%"struct.ts::ParenthesizerRules" = type { ptr }

declare i32 @__gxx_personality_v0(...)

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local void @_ZN3ptrIN2ts4data8TypeNodeEEC2ERKS3_(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef nonnull align 8 dereferenceable(16)) unnamed_addr #0 align 2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZN3ptrIN2ts4data8TypeNodeEEcv10SyntaxKindEv(ptr noundef nonnull align 8 dereferenceable(16)) #0 align 2

declare void @_ZN2ts11NodeFactory23createParenthesizedTypeE3ptrINS_4data8TypeNodeEE(ptr dead_on_unwind writable sret(%struct.ptr.102) align 8, ptr noundef nonnull align 8 dereferenceable(232), ptr noundef) #1

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN3ptrIN2ts4data8TypeNodeEEC2INS1_21ParenthesizedTypeNodeEEES_IT_E(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef) unnamed_addr #2 align 2

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

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN2ts18ParenthesizerRules45parenthesizeConstituentTypeOfIntersectionTypeE3ptrINS_4data8TypeNodeEE(ptr dead_on_unwind noalias writable sret(%struct.ptr.97) align 8, ptr noundef nonnull align 8 dereferenceable(8), ptr noundef) #3 align 2

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN2ts18ParenthesizerRules33parenthesizeOperandOfTypeOperatorE3ptrINS_4data8TypeNodeEE(ptr dead_on_unwind noalias writable sret(%struct.ptr.97) align 8 %0, ptr noundef nonnull align 8 dereferenceable(8) %1, ptr noundef %2) #3 align 2 personality ptr @__gxx_personality_v0 {
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca %struct.ptr.102, align 8
  %8 = alloca %struct.ptr.97, align 8
  %9 = alloca ptr, align 8
  %10 = alloca i32, align 4
  %11 = alloca %struct.ptr.97, align 8
  store ptr %0, ptr %4, align 8
  store ptr %1, ptr %5, align 8, !tbaa !5
  store ptr %2, ptr %6, align 8, !tbaa !5
  %12 = load ptr, ptr %5, align 8
  %13 = call noundef i32 @_ZN3ptrIN2ts4data8TypeNodeEEcv10SyntaxKindEv(ptr noundef nonnull align 8 dereferenceable(16) %2)
  switch i32 %13, label %28 [
    i32 193, label %14
  ]

14:                                               ; preds = %3
  %15 = getelementptr inbounds %"struct.ts::ParenthesizerRules", ptr %12, i32 0, i32 0
  %16 = load ptr, ptr %15, align 8, !tbaa !9
  call void @_ZN3ptrIN2ts4data8TypeNodeEEC2ERKS3_(ptr noundef nonnull align 8 dereferenceable(16) %8, ptr noundef nonnull align 8 dereferenceable(16) %2) #4
  invoke void @_ZN2ts11NodeFactory23createParenthesizedTypeE3ptrINS_4data8TypeNodeEE(ptr dead_on_unwind writable sret(%struct.ptr.102) align 8 %7, ptr noundef nonnull align 8 dereferenceable(232) %16, ptr noundef %8)
          to label %17 unwind label %19

17:                                               ; preds = %14
  invoke void @_ZN3ptrIN2ts4data8TypeNodeEEC2INS1_21ParenthesizedTypeNodeEEES_IT_E(ptr noundef nonnull align 8 dereferenceable(16) %0, ptr noundef %7)
          to label %18 unwind label %23

18:                                               ; preds = %17
  call void @_ZN3ptrIN2ts4data21ParenthesizedTypeNodeEED2Ev(ptr noundef nonnull align 8 dereferenceable(16) %7) #4
  call void @_ZN3ptrIN2ts4data8TypeNodeEED2Ev(ptr noundef nonnull align 8 dereferenceable(16) %8) #4
  br label %34

19:                                               ; preds = %14
  %20 = landingpad { ptr, i32 }
          cleanup
  %21 = extractvalue { ptr, i32 } %20, 0
  store ptr %21, ptr %9, align 8
  %22 = extractvalue { ptr, i32 } %20, 1
  store i32 %22, ptr %10, align 4
  br label %27

23:                                               ; preds = %17
  %24 = landingpad { ptr, i32 }
          cleanup
  %25 = extractvalue { ptr, i32 } %24, 0
  store ptr %25, ptr %9, align 8
  %26 = extractvalue { ptr, i32 } %24, 1
  store i32 %26, ptr %10, align 4
  call void @_ZN3ptrIN2ts4data21ParenthesizedTypeNodeEED2Ev(ptr noundef nonnull align 8 dereferenceable(16) %7) #4
  br label %27

27:                                               ; preds = %23, %19
  call void @_ZN3ptrIN2ts4data8TypeNodeEED2Ev(ptr noundef nonnull align 8 dereferenceable(16) %8) #4
  br label %35

28:                                               ; preds = %3
  call void @_ZN3ptrIN2ts4data8TypeNodeEEC2ERKS3_(ptr noundef nonnull align 8 dereferenceable(16) %11, ptr noundef nonnull align 8 dereferenceable(16) %2) #4
  invoke void @_ZN2ts18ParenthesizerRules45parenthesizeConstituentTypeOfIntersectionTypeE3ptrINS_4data8TypeNodeEE(ptr dead_on_unwind writable sret(%struct.ptr.97) align 8 %0, ptr noundef nonnull align 8 dereferenceable(8) %12, ptr noundef %11)
          to label %29 unwind label %30

29:                                               ; preds = %28
  call void @_ZN3ptrIN2ts4data8TypeNodeEED2Ev(ptr noundef nonnull align 8 dereferenceable(16) %11) #4
  br label %34

30:                                               ; preds = %28
  %31 = landingpad { ptr, i32 }
          cleanup
  %32 = extractvalue { ptr, i32 } %31, 0
  store ptr %32, ptr %9, align 8
  %33 = extractvalue { ptr, i32 } %31, 1
  store i32 %33, ptr %10, align 4
  call void @_ZN3ptrIN2ts4data8TypeNodeEED2Ev(ptr noundef nonnull align 8 dereferenceable(16) %11) #4
  br label %35

34:                                               ; preds = %29, %18
  ret void

35:                                               ; preds = %30, %27
  %36 = load ptr, ptr %9, align 8
  %37 = load i32, ptr %10, align 4
  %38 = insertvalue { ptr, i32 } poison, ptr %36, 0
  %39 = insertvalue { ptr, i32 } %38, i32 %37, 1
  resume { ptr, i32 } %39
}

attributes #0 = { 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 #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 = { 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, !6, i64 0}
!10 = !{!"_ZTSN2ts18ParenthesizerRulesE", !6, 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"

%struct.ptr.102 = type { %"class.std::shared_ptr.103" }
%"class.std::shared_ptr.103" = type { %"class.std::__shared_ptr.104" }
%"class.std::__shared_ptr.104" = type { ptr, %"class.std::__shared_count" }
%"class.std::__shared_count" = type { ptr }
%struct.ptr.97 = type { %"class.std::shared_ptr.98" }
%"class.std::shared_ptr.98" = type { %"class.std::__shared_ptr.99" }
%"class.std::__shared_ptr.99" = type { ptr, %"class.std::__shared_count" }

declare i32 @__gxx_personality_v0(...)

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local void @_ZN3ptrIN2ts4data8TypeNodeEEC2ERKS3_(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef nonnull align 8 dereferenceable(16)) unnamed_addr #0 align 2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZN3ptrIN2ts4data8TypeNodeEEcv10SyntaxKindEv(ptr noundef nonnull align 8 dereferenceable(16)) local_unnamed_addr #0 align 2

declare void @_ZN2ts11NodeFactory23createParenthesizedTypeE3ptrINS_4data8TypeNodeEE(ptr dead_on_unwind writable sret(%struct.ptr.102) align 8, ptr noundef nonnull align 8 dereferenceable(232), ptr noundef) local_unnamed_addr #1

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN3ptrIN2ts4data8TypeNodeEEC2INS1_21ParenthesizedTypeNodeEEES_IT_E(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef) unnamed_addr #2 align 2

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

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN2ts18ParenthesizerRules45parenthesizeConstituentTypeOfIntersectionTypeE3ptrINS_4data8TypeNodeEE(ptr dead_on_unwind noalias writable sret(%struct.ptr.97) align 8, ptr noundef nonnull align 8 dereferenceable(8), ptr noundef) local_unnamed_addr #3 align 2

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN2ts18ParenthesizerRules33parenthesizeOperandOfTypeOperatorE3ptrINS_4data8TypeNodeEE(ptr dead_on_unwind noalias writable sret(%struct.ptr.97) align 8 %0, ptr noundef nonnull align 8 dereferenceable(8) %1, ptr noundef nonnull %2) local_unnamed_addr #3 align 2 personality ptr @__gxx_personality_v0 {
  %4 = alloca %struct.ptr.102, align 8
  %5 = alloca %struct.ptr.97, align 8
  %6 = alloca %struct.ptr.97, align 8
  %7 = tail call noundef i32 @_ZN3ptrIN2ts4data8TypeNodeEEcv10SyntaxKindEv(ptr noundef nonnull align 8 dereferenceable(16) %2)
  %cond = icmp eq i32 %7, 193
  br i1 %cond, label %8, label %13

8:                                                ; preds = %3
  %9 = load ptr, ptr %1, align 8, !tbaa !5
  call void @_ZN3ptrIN2ts4data8TypeNodeEEC2ERKS3_(ptr noundef nonnull align 8 dereferenceable(16) %5, ptr noundef nonnull align 8 dereferenceable(16) %2) #4
  invoke void @_ZN2ts11NodeFactory23createParenthesizedTypeE3ptrINS_4data8TypeNodeEE(ptr dead_on_unwind nonnull writable sret(%struct.ptr.102) align 8 %4, ptr noundef nonnull align 8 dereferenceable(232) %9, ptr noundef nonnull %5)
          to label %10 unwind label %11

10:                                               ; preds = %8
  call void @_ZN3ptrIN2ts4data8TypeNodeEEC2INS1_21ParenthesizedTypeNodeEEES_IT_E(ptr noundef nonnull align 8 dereferenceable(16) %0, ptr noundef nonnull %4)
  call void @_ZN3ptrIN2ts4data21ParenthesizedTypeNodeEED2Ev(ptr noundef nonnull align 8 dereferenceable(16) %4) #4
  br label %16

11:                                               ; preds = %8
  %12 = landingpad { ptr, i32 }
          cleanup
  br label %17

13:                                               ; preds = %3
  call void @_ZN3ptrIN2ts4data8TypeNodeEEC2ERKS3_(ptr noundef nonnull align 8 dereferenceable(16) %6, ptr noundef nonnull align 8 dereferenceable(16) %2) #4
  invoke void @_ZN2ts18ParenthesizerRules45parenthesizeConstituentTypeOfIntersectionTypeE3ptrINS_4data8TypeNodeEE(ptr dead_on_unwind writable sret(%struct.ptr.97) align 8 %0, ptr noundef nonnull align 8 dereferenceable(8) %1, ptr noundef nonnull %6)
          to label %16 unwind label %14

14:                                               ; preds = %13
  %15 = landingpad { ptr, i32 }
          cleanup
  br label %17

16:                                               ; preds = %13, %10
  %.sink = phi ptr [ %5, %10 ], [ %6, %13 ]
  call void @_ZN3ptrIN2ts4data8TypeNodeEED2Ev(ptr noundef nonnull align 8 dereferenceable(16) %.sink) #4
  ret void

17:                                               ; preds = %14, %11
  %.sink4 = phi ptr [ %6, %14 ], [ %5, %11 ]
  %.pn = phi { ptr, i32 } [ %15, %14 ], [ %12, %11 ]
  call void @_ZN3ptrIN2ts4data8TypeNodeEED2Ev(ptr noundef nonnull align 8 dereferenceable(16) %.sink4) #4
  resume { ptr, i32 } %.pn
}

attributes #0 = { 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 #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 = { 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, !7, i64 0}
!6 = !{!"_ZTSN2ts18ParenthesizerRulesE", !7, i64 0}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,InstCombinePass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass