; LLVM IR from PaddlePaddle/Paddle :: paddle/pir/src/core (block_operand)

; 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.pir::BlockOperand" = type { ptr }
%"class.pir::detail::BlockOperandImpl" = type { %"class.pir::BlockOperand", ptr, ptr, ptr }

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

; Function Attrs: mustprogress uwtable
declare dso_local noundef zeroext i1 @_ZNK3pir12BlockOperandcvbEv(ptr noundef nonnull align 8 dereferenceable(8)) #1 align 2

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

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

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN3pir6detail16BlockOperandImpl17RemoveFromUdChainEv(ptr noundef nonnull align 8 dereferenceable(32) %0) #1 align 2 {
  %2 = alloca ptr, align 8
  %3 = alloca %"class.pir::BlockOperand", align 8
  %4 = alloca %"class.pir::BlockOperand", align 8
  store ptr %0, ptr %2, align 8, !tbaa !5
  %5 = load ptr, ptr %2, align 8
  %6 = getelementptr inbounds %"class.pir::detail::BlockOperandImpl", ptr %5, i32 0, i32 2
  %7 = load ptr, ptr %6, align 8, !tbaa !9
  %8 = icmp ne ptr %7, null
  br i1 %8, label %10, label %9

9:                                                ; preds = %1
  br label %47

10:                                               ; preds = %1
  %11 = getelementptr inbounds %"class.pir::detail::BlockOperandImpl", ptr %5, i32 0, i32 1
  %12 = load ptr, ptr %11, align 8, !tbaa !12
  %13 = icmp ne ptr %12, null
  br i1 %13, label %15, label %14

14:                                               ; preds = %10
  br label %47

15:                                               ; preds = %10
  %16 = getelementptr inbounds %"class.pir::detail::BlockOperandImpl", ptr %5, i32 0, i32 1
  %17 = load ptr, ptr %16, align 8, !tbaa !12
  %18 = getelementptr inbounds %"class.pir::detail::BlockOperandImpl", ptr %5, i32 0, i32 2
  %19 = load ptr, ptr %18, align 8, !tbaa !9
  %20 = call noundef ptr @_ZN3pir5Block14first_use_addrEv(ptr noundef nonnull align 8 dereferenceable(120) %19)
  %21 = icmp eq ptr %17, %20
  br i1 %21, label %22, label %28

22:                                               ; preds = %15
  %23 = getelementptr inbounds %"class.pir::detail::BlockOperandImpl", ptr %5, i32 0, i32 2
  %24 = load ptr, ptr %23, align 8, !tbaa !9
  %25 = getelementptr inbounds %"class.pir::detail::BlockOperandImpl", ptr %5, i32 0, i32 0
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %3, ptr align 8 %25, i64 8, i1 false), !tbaa.struct !13
  %26 = getelementptr inbounds %"class.pir::BlockOperand", ptr %3, i32 0, i32 0
  %27 = load ptr, ptr %26, align 8
  call void @_ZN3pir5Block13set_first_useENS_12BlockOperandE(ptr noundef nonnull align 8 dereferenceable(120) %24, ptr %27)
  br label %33

28:                                               ; preds = %15
  %29 = getelementptr inbounds %"class.pir::detail::BlockOperandImpl", ptr %5, i32 0, i32 0
  %30 = getelementptr inbounds %"class.pir::detail::BlockOperandImpl", ptr %5, i32 0, i32 1
  %31 = load ptr, ptr %30, align 8, !tbaa !12
  %32 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZN3pir12BlockOperandaSERKS0_(ptr noundef nonnull align 8 dereferenceable(8) %31, ptr noundef nonnull align 8 dereferenceable(8) %29)
  br label %33

33:                                               ; preds = %28, %22
  %34 = getelementptr inbounds %"class.pir::detail::BlockOperandImpl", ptr %5, i32 0, i32 0
  %35 = call noundef zeroext i1 @_ZNK3pir12BlockOperandcvbEv(ptr noundef nonnull align 8 dereferenceable(8) %34)
  br i1 %35, label %36, label %42

36:                                               ; preds = %33
  %37 = getelementptr inbounds %"class.pir::detail::BlockOperandImpl", ptr %5, i32 0, i32 1
  %38 = load ptr, ptr %37, align 8, !tbaa !12
  %39 = getelementptr inbounds %"class.pir::detail::BlockOperandImpl", ptr %5, i32 0, i32 0
  %40 = call noundef ptr @_ZNK3pir12BlockOperand4implEv(ptr noundef nonnull align 8 dereferenceable(8) %39)
  %41 = getelementptr inbounds %"class.pir::detail::BlockOperandImpl", ptr %40, i32 0, i32 1
  store ptr %38, ptr %41, align 8, !tbaa !12
  br label %42

42:                                               ; preds = %36, %33
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #4
  call void @_ZN3pir12BlockOperandC2EPNS_6detail16BlockOperandImplE(ptr noundef nonnull align 8 dereferenceable(8) %4, ptr noundef null)
  %43 = getelementptr inbounds %"class.pir::detail::BlockOperandImpl", ptr %5, i32 0, i32 0
  %44 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZN3pir12BlockOperandaSERKS0_(ptr noundef nonnull align 8 dereferenceable(8) %43, ptr noundef nonnull align 8 dereferenceable(8) %4)
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #4
  %45 = getelementptr inbounds %"class.pir::detail::BlockOperandImpl", ptr %5, i32 0, i32 1
  store ptr null, ptr %45, align 8, !tbaa !12
  %46 = getelementptr inbounds %"class.pir::detail::BlockOperandImpl", ptr %5, i32 0, i32 2
  store ptr null, ptr %46, align 8, !tbaa !9
  br label %47

47:                                               ; preds = %42, %14, %9
  ret void
}

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #3

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

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

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

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

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 = { 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 willreturn memory(argmem: readwrite) }
attributes #3 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
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 16}
!10 = !{!"_ZTSN3pir6detail16BlockOperandImplE", !11, i64 0, !6, i64 8, !6, i64 16, !6, i64 24}
!11 = !{!"_ZTSN3pir12BlockOperandE", !6, i64 0}
!12 = !{!10, !6, i64 8}
!13 = !{i64 0, i64 8, !5}


; 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.pir::BlockOperand" = type { ptr }

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

; Function Attrs: mustprogress uwtable
declare dso_local noundef zeroext i1 @_ZNK3pir12BlockOperandcvbEv(ptr noundef nonnull align 8 dereferenceable(8)) local_unnamed_addr #1 align 2

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

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

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN3pir6detail16BlockOperandImpl17RemoveFromUdChainEv(ptr noundef nonnull align 8 dereferenceable(32) %0) local_unnamed_addr #1 align 2 {
  %2 = alloca %"class.pir::BlockOperand", align 8
  %3 = getelementptr inbounds i8, ptr %0, i64 16
  %4 = load ptr, ptr %3, align 8, !tbaa !5
  %.not = icmp eq ptr %4, null
  br i1 %.not, label %24, label %5

5:                                                ; preds = %1
  %6 = getelementptr inbounds i8, ptr %0, i64 8
  %7 = load ptr, ptr %6, align 8, !tbaa !11
  %.not2 = icmp eq ptr %7, null
  br i1 %.not2, label %24, label %8

8:                                                ; preds = %5
  %9 = tail call noundef ptr @_ZN3pir5Block14first_use_addrEv(ptr noundef nonnull align 8 dereferenceable(120) %4)
  %10 = icmp eq ptr %7, %9
  br i1 %10, label %11, label %13

11:                                               ; preds = %8
  %12 = load ptr, ptr %3, align 8, !tbaa !5
  %.sroa.0.0.copyload = load ptr, ptr %0, align 8, !tbaa !12
  tail call void @_ZN3pir5Block13set_first_useENS_12BlockOperandE(ptr noundef nonnull align 8 dereferenceable(120) %12, ptr %.sroa.0.0.copyload)
  br label %16

13:                                               ; preds = %8
  %14 = load ptr, ptr %6, align 8, !tbaa !11
  %15 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZN3pir12BlockOperandaSERKS0_(ptr noundef nonnull align 8 dereferenceable(8) %14, ptr noundef nonnull align 8 dereferenceable(8) %0)
  br label %16

16:                                               ; preds = %13, %11
  %17 = tail call noundef zeroext i1 @_ZNK3pir12BlockOperandcvbEv(ptr noundef nonnull align 8 dereferenceable(8) %0)
  br i1 %17, label %18, label %22

18:                                               ; preds = %16
  %19 = load ptr, ptr %6, align 8, !tbaa !11
  %20 = tail call noundef ptr @_ZNK3pir12BlockOperand4implEv(ptr noundef nonnull align 8 dereferenceable(8) %0)
  %21 = getelementptr inbounds i8, ptr %20, i64 8
  store ptr %19, ptr %21, align 8, !tbaa !11
  br label %22

22:                                               ; preds = %18, %16
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %2) #4
  call void @_ZN3pir12BlockOperandC2EPNS_6detail16BlockOperandImplE(ptr noundef nonnull align 8 dereferenceable(8) %2, ptr noundef null)
  %23 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZN3pir12BlockOperandaSERKS0_(ptr noundef nonnull align 8 dereferenceable(8) %0, ptr noundef nonnull align 8 dereferenceable(8) %2)
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %2) #4
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(16) %6, i8 0, i64 16, i1 false)
  br label %24

24:                                               ; preds = %5, %1, %22
  ret void
}

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

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

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

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

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #3

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 = { 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 willreturn memory(argmem: readwrite) }
attributes #3 = { nocallback nofree nounwind willreturn memory(argmem: write) }
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, !8, i64 16}
!6 = !{!"_ZTSN3pir6detail16BlockOperandImplE", !7, i64 0, !8, i64 8, !8, i64 16, !8, i64 24}
!7 = !{!"_ZTSN3pir12BlockOperandE", !8, i64 0}
!8 = !{!"any pointer", !9, i64 0}
!9 = !{!"omnipotent char", !10, i64 0}
!10 = !{!"Simple C++ TBAA"}
!11 = !{!6, !8, i64 8}
!12 = !{!8, !8, i64 0}


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