; LLVM IR from thepowersgang/mrustc :: src/ast/expr.ll (ZNK3AST14ExprNode_Index5cloneEv)

; 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.AST::ExprNodeP" = type { ptr }
%"struct.AST::ExprNode_Index" = type { %"class.AST::ExprNode", %"class.AST::ExprNodeP", %"class.AST::ExprNodeP" }
%"class.AST::ExprNode" = type { ptr, %"class.AST::AttributeList", %struct.Span }
%"class.AST::AttributeList" = type { %"class.std::vector" }
%"class.std::vector" = type { %"struct.std::_Vector_base" }
%"struct.std::_Vector_base" = type { %"struct.std::_Vector_base<AST::Attribute, std::allocator<AST::Attribute>>::_Vector_impl" }
%"struct.std::_Vector_base<AST::Attribute, std::allocator<AST::Attribute>>::_Vector_impl" = type { %"struct.std::_Vector_base<AST::Attribute, std::allocator<AST::Attribute>>::_Vector_impl_data" }
%"struct.std::_Vector_base<AST::Attribute, std::allocator<AST::Attribute>>::_Vector_impl_data" = type { ptr, ptr, ptr }
%struct.Span = type { ptr }

declare i32 @__gxx_personality_v0(...)

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

; Function Attrs: inlinehint mustprogress uwtable
declare hidden void @_ZN3AST12_GLOBAL__N_112mk_exprnodepERK4SpanPNS_8ExprNodeE(ptr dead_on_unwind noalias writable sret(%"class.AST::ExprNodeP") align 8, ptr noundef nonnull align 8 dereferenceable(8), ptr noundef) #1

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(8) ptr @_ZNK3AST8ExprNode4spanEv(ptr noundef nonnull align 8 dereferenceable(40)) #0 align 2

; Function Attrs: nobuiltin allocsize(0)
declare noundef nonnull ptr @_Znwm(i64 noundef) #2

; Function Attrs: nobuiltin nounwind
declare void @_ZdlPvm(ptr noundef, i64 noundef) #3

; Function Attrs: mustprogress uwtable
define dso_local void @_ZNK3AST14ExprNode_Index5cloneEv(ptr dead_on_unwind noalias writable sret(%"class.AST::ExprNodeP") align 8 %0, ptr noundef nonnull align 8 dereferenceable(56) %1) unnamed_addr #4 align 2 personality ptr @__gxx_personality_v0 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca %"class.AST::ExprNodeP", align 8
  %6 = alloca ptr, align 8
  %7 = alloca i32, align 4
  %8 = alloca %"class.AST::ExprNodeP", align 8
  %9 = alloca i1, align 1
  store ptr %0, ptr %3, align 8
  store ptr %1, ptr %4, align 8, !tbaa !5
  %10 = load ptr, ptr %4, align 8
  %11 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNK3AST8ExprNode4spanEv(ptr noundef nonnull align 8 dereferenceable(40) %10)
  %12 = call noalias noundef nonnull ptr @_Znwm(i64 noundef 56) #5
  store i1 true, ptr %9, align 1
  %13 = getelementptr inbounds %"struct.AST::ExprNode_Index", ptr %10, i32 0, i32 1
  %14 = invoke noundef ptr @_ZNK3AST9ExprNodePptEv(ptr noundef nonnull align 8 dereferenceable(8) %13)
          to label %15 unwind label %29

15:                                               ; preds = %2
  %16 = load ptr, ptr %14, align 8, !tbaa !9
  %17 = getelementptr inbounds ptr, ptr %16, i64 4
  %18 = load ptr, ptr %17, align 8
  invoke void %18(ptr dead_on_unwind writable sret(%"class.AST::ExprNodeP") align 8 %5, ptr noundef nonnull align 8 dereferenceable(40) %14)
          to label %19 unwind label %29

19:                                               ; preds = %15
  %20 = getelementptr inbounds %"struct.AST::ExprNode_Index", ptr %10, i32 0, i32 2
  %21 = invoke noundef ptr @_ZNK3AST9ExprNodePptEv(ptr noundef nonnull align 8 dereferenceable(8) %20)
          to label %22 unwind label %33

22:                                               ; preds = %19
  %23 = load ptr, ptr %21, align 8, !tbaa !9
  %24 = getelementptr inbounds ptr, ptr %23, i64 4
  %25 = load ptr, ptr %24, align 8
  invoke void %25(ptr dead_on_unwind writable sret(%"class.AST::ExprNodeP") align 8 %8, ptr noundef nonnull align 8 dereferenceable(40) %21)
          to label %26 unwind label %33

26:                                               ; preds = %22
  invoke void @_ZN3AST14ExprNode_IndexC2ENS_9ExprNodePES1_(ptr noundef nonnull align 8 dereferenceable(56) %12, ptr noundef %5, ptr noundef %8)
          to label %27 unwind label %37

27:                                               ; preds = %26
  store i1 false, ptr %9, align 1
  invoke void @_ZN3AST12_GLOBAL__N_112mk_exprnodepERK4SpanPNS_8ExprNodeE(ptr dead_on_unwind writable sret(%"class.AST::ExprNodeP") align 8 %0, ptr noundef nonnull align 8 dereferenceable(8) %11, ptr noundef %12)
          to label %28 unwind label %37

28:                                               ; preds = %27
  call void @_ZN3AST9ExprNodePD1Ev(ptr noundef nonnull align 8 dereferenceable(8) %8) #6
  call void @_ZN3AST9ExprNodePD1Ev(ptr noundef nonnull align 8 dereferenceable(8) %5) #6
  ret void

29:                                               ; preds = %15, %2
  %30 = landingpad { ptr, i32 }
          cleanup
  %31 = extractvalue { ptr, i32 } %30, 0
  store ptr %31, ptr %6, align 8
  %32 = extractvalue { ptr, i32 } %30, 1
  store i32 %32, ptr %7, align 4
  br label %42

33:                                               ; preds = %22, %19
  %34 = landingpad { ptr, i32 }
          cleanup
  %35 = extractvalue { ptr, i32 } %34, 0
  store ptr %35, ptr %6, align 8
  %36 = extractvalue { ptr, i32 } %34, 1
  store i32 %36, ptr %7, align 4
  br label %41

37:                                               ; preds = %27, %26
  %38 = landingpad { ptr, i32 }
          cleanup
  %39 = extractvalue { ptr, i32 } %38, 0
  store ptr %39, ptr %6, align 8
  %40 = extractvalue { ptr, i32 } %38, 1
  store i32 %40, ptr %7, align 4
  call void @_ZN3AST9ExprNodePD1Ev(ptr noundef nonnull align 8 dereferenceable(8) %8) #6
  br label %41

41:                                               ; preds = %37, %33
  call void @_ZN3AST9ExprNodePD1Ev(ptr noundef nonnull align 8 dereferenceable(8) %5) #6
  br label %42

42:                                               ; preds = %41, %29
  %43 = load i1, ptr %9, align 1
  br i1 %43, label %44, label %45

44:                                               ; preds = %42
  call void @_ZdlPvm(ptr noundef %12, i64 noundef 56) #7
  br label %45

45:                                               ; preds = %44, %42
  br label %46

46:                                               ; preds = %45
  %47 = load ptr, ptr %6, align 8
  %48 = load i32, ptr %7, align 4
  %49 = insertvalue { ptr, i32 } poison, ptr %47, 0
  %50 = insertvalue { ptr, i32 } %49, i32 %48, 1
  resume { ptr, i32 } %50
}

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN3AST14ExprNode_IndexC2ENS_9ExprNodePES1_(ptr noundef nonnull align 8 dereferenceable(56), ptr noundef, ptr noundef) unnamed_addr #4 align 2

declare void @_ZN3AST9ExprNodePD1Ev(ptr)

attributes #0 = { 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 = { 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 = { nobuiltin allocsize(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 = { nobuiltin nounwind "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 = { 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 #5 = { builtin allocsize(0) }
attributes #6 = { nounwind }
attributes #7 = { builtin 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 = !{!"vtable pointer", !8, 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"

%"class.AST::ExprNodeP" = type { ptr }

declare i32 @__gxx_personality_v0(...)

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

; Function Attrs: inlinehint mustprogress uwtable
declare hidden void @_ZN3AST12_GLOBAL__N_112mk_exprnodepERK4SpanPNS_8ExprNodeE(ptr dead_on_unwind noalias writable sret(%"class.AST::ExprNodeP") align 8, ptr noundef nonnull align 8 dereferenceable(8), ptr noundef) local_unnamed_addr #1

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(8) ptr @_ZNK3AST8ExprNode4spanEv(ptr noundef nonnull align 8 dereferenceable(40)) local_unnamed_addr #0 align 2

; Function Attrs: nobuiltin allocsize(0)
declare noundef nonnull ptr @_Znwm(i64 noundef) local_unnamed_addr #2

; Function Attrs: nobuiltin nounwind
declare void @_ZdlPvm(ptr noundef, i64 noundef) local_unnamed_addr #3

; Function Attrs: mustprogress uwtable
define dso_local void @_ZNK3AST14ExprNode_Index5cloneEv(ptr dead_on_unwind noalias writable sret(%"class.AST::ExprNodeP") align 8 %0, ptr noundef nonnull align 8 dereferenceable(56) %1) unnamed_addr #4 align 2 personality ptr @__gxx_personality_v0 {
  %3 = alloca %"class.AST::ExprNodeP", align 8
  %4 = alloca %"class.AST::ExprNodeP", align 8
  %5 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZNK3AST8ExprNode4spanEv(ptr noundef nonnull align 8 dereferenceable(40) %1)
  %6 = tail call noalias noundef nonnull dereferenceable(56) ptr @_Znwm(i64 noundef 56) #5
  %7 = getelementptr inbounds i8, ptr %1, i64 40
  %8 = tail call noundef ptr @_ZNK3AST9ExprNodePptEv(ptr noundef nonnull align 8 dereferenceable(8) %7)
  %9 = load ptr, ptr %8, align 8, !tbaa !5
  %10 = getelementptr inbounds i8, ptr %9, i64 32
  %11 = load ptr, ptr %10, align 8
  invoke void %11(ptr dead_on_unwind nonnull writable sret(%"class.AST::ExprNodeP") align 8 %3, ptr noundef nonnull align 8 dereferenceable(40) %8)
          to label %12 unwind label %.thread

12:                                               ; preds = %2
  %13 = getelementptr inbounds i8, ptr %1, i64 48
  %14 = call noundef ptr @_ZNK3AST9ExprNodePptEv(ptr noundef nonnull align 8 dereferenceable(8) %13)
  %15 = load ptr, ptr %14, align 8, !tbaa !5
  %16 = getelementptr inbounds i8, ptr %15, i64 32
  %17 = load ptr, ptr %16, align 8
  invoke void %17(ptr dead_on_unwind nonnull writable sret(%"class.AST::ExprNodeP") align 8 %4, ptr noundef nonnull align 8 dereferenceable(40) %14)
          to label %18 unwind label %.thread13

18:                                               ; preds = %12
  invoke void @_ZN3AST14ExprNode_IndexC2ENS_9ExprNodePES1_(ptr noundef nonnull align 8 dereferenceable(56) %6, ptr noundef nonnull %3, ptr noundef nonnull %4)
          to label %19 unwind label %23

19:                                               ; preds = %18
  invoke void @_ZN3AST12_GLOBAL__N_112mk_exprnodepERK4SpanPNS_8ExprNodeE(ptr dead_on_unwind writable sret(%"class.AST::ExprNodeP") align 8 %0, ptr noundef nonnull align 8 dereferenceable(8) %5, ptr noundef nonnull %6)
          to label %20 unwind label %23

20:                                               ; preds = %19
  call void @_ZN3AST9ExprNodePD1Ev(ptr noundef nonnull align 8 dereferenceable(8) %4) #6
  call void @_ZN3AST9ExprNodePD1Ev(ptr noundef nonnull align 8 dereferenceable(8) %3) #6
  ret void

.thread:                                          ; preds = %2
  %21 = landingpad { ptr, i32 }
          cleanup
  br label %25

.thread13:                                        ; preds = %12
  %22 = landingpad { ptr, i32 }
          cleanup
  call void @_ZN3AST9ExprNodePD1Ev(ptr noundef nonnull align 8 dereferenceable(8) %3) #6
  br label %25

23:                                               ; preds = %18, %19
  %.0 = phi i1 [ false, %19 ], [ true, %18 ]
  %24 = landingpad { ptr, i32 }
          cleanup
  call void @_ZN3AST9ExprNodePD1Ev(ptr noundef nonnull align 8 dereferenceable(8) %4) #6
  call void @_ZN3AST9ExprNodePD1Ev(ptr noundef nonnull align 8 dereferenceable(8) %3) #6
  br i1 %.0, label %25, label %26

25:                                               ; preds = %.thread13, %.thread, %23
  %.pn.pn12 = phi { ptr, i32 } [ %21, %.thread ], [ %24, %23 ], [ %22, %.thread13 ]
  call void @_ZdlPvm(ptr noundef nonnull %6, i64 noundef 56) #7
  br label %26

26:                                               ; preds = %23, %25
  %.pn.pn11 = phi { ptr, i32 } [ %24, %23 ], [ %.pn.pn12, %25 ]
  resume { ptr, i32 } %.pn.pn11
}

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN3AST14ExprNode_IndexC2ENS_9ExprNodePES1_(ptr noundef nonnull align 8 dereferenceable(56), ptr noundef, ptr noundef) unnamed_addr #4 align 2

declare void @_ZN3AST9ExprNodePD1Ev(ptr) local_unnamed_addr

attributes #0 = { 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 = { 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 = { nobuiltin allocsize(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 = { nobuiltin nounwind "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 = { 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 #5 = { builtin allocsize(0) }
attributes #6 = { nounwind }
attributes #7 = { builtin 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"}


; Effective O3 passes: CorrelatedValuePropagationPass,GlobalOptPass,InstCombinePass,JumpThreadingPass,SROAPass,SimplifyCFGPass,TailCallElimPass