; LLVM IR from facebook/redex :: libredex/PointsToSemantics.ll (ZNK16PointsToVariable9to_s_exprEv)

; 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.sparta::s_expr" = type { %"class.boost::intrusive_ptr" }
%"class.boost::intrusive_ptr" = type { ptr }
%"class.std::initializer_list" = type { ptr, i64 }
%class.PointsToVariable = type { i32 }

@.str.8 = external hidden unnamed_addr constant [2 x i8], align 1

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: 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 void @_ZNK16PointsToVariable9to_s_exprEv(ptr dead_on_unwind noalias writable sret(%"class.sparta::s_expr") align 8 %0, ptr noundef nonnull align 4 dereferenceable(4) %1) #1 align 2 personality ptr @__gxx_personality_v0 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca %"class.std::initializer_list", align 8
  %6 = alloca [2 x %"class.sparta::s_expr"], align 8
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca i32, align 4
  store ptr %0, ptr %3, align 8
  store ptr %1, ptr %4, align 8, !tbaa !5
  %10 = load ptr, ptr %4, align 8
  call void @llvm.lifetime.start.p0(i64 16, ptr %6) #4
  store ptr %6, ptr %7, align 8
  invoke void @_ZN6sparta6s_exprC2EPKc(ptr noundef nonnull align 8 dereferenceable(8) %6, ptr noundef @.str.8)
          to label %11 unwind label %30

11:                                               ; preds = %2
  %12 = getelementptr inbounds %"class.sparta::s_expr", ptr %6, i64 1
  store ptr %12, ptr %7, align 8
  %13 = getelementptr inbounds %class.PointsToVariable, ptr %10, i32 0, i32 0
  %14 = load i32, ptr %13, align 4, !tbaa !9
  invoke void @_ZN6sparta6s_exprC2Ei(ptr noundef nonnull align 8 dereferenceable(8) %12, i32 noundef %14)
          to label %15 unwind label %30

15:                                               ; preds = %11
  %16 = getelementptr inbounds %"class.std::initializer_list", ptr %5, i32 0, i32 0
  store ptr %6, ptr %16, align 8, !tbaa !12
  %17 = getelementptr inbounds %"class.std::initializer_list", ptr %5, i32 0, i32 1
  store i64 2, ptr %17, align 8, !tbaa !15
  %18 = getelementptr inbounds { ptr, i64 }, ptr %5, i32 0, i32 0
  %19 = load ptr, ptr %18, align 8
  %20 = getelementptr inbounds { ptr, i64 }, ptr %5, i32 0, i32 1
  %21 = load i64, ptr %20, align 8
  invoke void @_ZN6sparta6s_exprC2ESt16initializer_listIS0_E(ptr noundef nonnull align 8 dereferenceable(8) %0, ptr %19, i64 %21)
          to label %22 unwind label %41

22:                                               ; preds = %15
  %23 = getelementptr inbounds [2 x %"class.sparta::s_expr"], ptr %6, i32 0, i32 0
  %24 = getelementptr inbounds %"class.sparta::s_expr", ptr %23, i64 2
  br label %25

25:                                               ; preds = %25, %22
  %26 = phi ptr [ %24, %22 ], [ %27, %25 ]
  %27 = getelementptr inbounds %"class.sparta::s_expr", ptr %26, i64 -1
  call void @_ZN6sparta6s_exprD2Ev(ptr noundef nonnull align 8 dereferenceable(8) %27) #4
  %28 = icmp eq ptr %27, %23
  br i1 %28, label %29, label %25

29:                                               ; preds = %25
  call void @llvm.lifetime.end.p0(i64 16, ptr %6) #4
  ret void

30:                                               ; preds = %11, %2
  %31 = landingpad { ptr, i32 }
          cleanup
  %32 = extractvalue { ptr, i32 } %31, 0
  store ptr %32, ptr %8, align 8
  %33 = extractvalue { ptr, i32 } %31, 1
  store i32 %33, ptr %9, align 4
  %34 = load ptr, ptr %7, align 8
  %35 = icmp eq ptr %6, %34
  br i1 %35, label %40, label %36

36:                                               ; preds = %36, %30
  %37 = phi ptr [ %34, %30 ], [ %38, %36 ]
  %38 = getelementptr inbounds %"class.sparta::s_expr", ptr %37, i64 -1
  call void @_ZN6sparta6s_exprD2Ev(ptr noundef nonnull align 8 dereferenceable(8) %38) #4
  %39 = icmp eq ptr %38, %6
  br i1 %39, label %40, label %36

40:                                               ; preds = %36, %30
  br label %52

41:                                               ; preds = %15
  %42 = landingpad { ptr, i32 }
          cleanup
  %43 = extractvalue { ptr, i32 } %42, 0
  store ptr %43, ptr %8, align 8
  %44 = extractvalue { ptr, i32 } %42, 1
  store i32 %44, ptr %9, align 4
  %45 = getelementptr inbounds [2 x %"class.sparta::s_expr"], ptr %6, i32 0, i32 0
  %46 = getelementptr inbounds %"class.sparta::s_expr", ptr %45, i64 2
  br label %47

47:                                               ; preds = %47, %41
  %48 = phi ptr [ %46, %41 ], [ %49, %47 ]
  %49 = getelementptr inbounds %"class.sparta::s_expr", ptr %48, i64 -1
  call void @_ZN6sparta6s_exprD2Ev(ptr noundef nonnull align 8 dereferenceable(8) %49) #4
  %50 = icmp eq ptr %49, %45
  br i1 %50, label %51, label %47

51:                                               ; preds = %47
  br label %52

52:                                               ; preds = %51, %40
  call void @llvm.lifetime.end.p0(i64 16, ptr %6) #4
  br label %53

53:                                               ; preds = %52
  %54 = load ptr, ptr %8, align 8
  %55 = load i32, ptr %9, align 4
  %56 = insertvalue { ptr, i32 } poison, ptr %54, 0
  %57 = insertvalue { ptr, i32 } %56, i32 %55, 1
  resume { ptr, i32 } %57
}

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

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

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

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

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 = { 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 #3 = { 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 #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, !11, i64 0}
!10 = !{!"_ZTS16PointsToVariable", !11, i64 0}
!11 = !{!"int", !7, i64 0}
!12 = !{!13, !6, i64 0}
!13 = !{!"_ZTSSt16initializer_listIN6sparta6s_exprEE", !6, i64 0, !14, i64 8}
!14 = !{!"long", !7, i64 0}
!15 = !{!13, !14, i64 8}


; 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.sparta::s_expr" = type { %"class.boost::intrusive_ptr" }
%"class.boost::intrusive_ptr" = type { ptr }

@.str.8 = external hidden unnamed_addr constant [2 x i8], align 1

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: 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 void @_ZNK16PointsToVariable9to_s_exprEv(ptr dead_on_unwind noalias writable sret(%"class.sparta::s_expr") align 8 %0, ptr nocapture noundef nonnull readonly align 4 dereferenceable(4) %1) local_unnamed_addr #1 align 2 personality ptr @__gxx_personality_v0 {
  %3 = alloca [2 x %"class.sparta::s_expr"], align 8
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %3) #4
  call void @_ZN6sparta6s_exprC2EPKc(ptr noundef nonnull align 8 dereferenceable(8) %3, ptr noundef nonnull @.str.8)
  %4 = getelementptr inbounds i8, ptr %3, i64 8
  %5 = load i32, ptr %1, align 4, !tbaa !5
  invoke void @_ZN6sparta6s_exprC2Ei(ptr noundef nonnull align 8 dereferenceable(8) %4, i32 noundef %5)
          to label %6 unwind label %.loopexit.loopexit9

6:                                                ; preds = %2
  invoke void @_ZN6sparta6s_exprC2ESt16initializer_listIS0_E(ptr noundef nonnull align 8 dereferenceable(8) %0, ptr nonnull %3, i64 2)
          to label %7 unwind label %.loopexit.loopexit

7:                                                ; preds = %6
  %8 = getelementptr inbounds i8, ptr %3, i64 8
  call void @_ZN6sparta6s_exprD2Ev(ptr noundef nonnull align 8 dereferenceable(8) %8) #4
  call void @_ZN6sparta6s_exprD2Ev(ptr noundef nonnull align 8 dereferenceable(8) %3) #4
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %3) #4
  ret void

.loopexit.loopexit9:                              ; preds = %2
  %9 = landingpad { ptr, i32 }
          cleanup
  br label %.loopexit

.loopexit.loopexit:                               ; preds = %6
  %10 = landingpad { ptr, i32 }
          cleanup
  %11 = getelementptr inbounds i8, ptr %3, i64 8
  call void @_ZN6sparta6s_exprD2Ev(ptr noundef nonnull align 8 dereferenceable(8) %11) #4
  br label %.loopexit

.loopexit:                                        ; preds = %.loopexit.loopexit9, %.loopexit.loopexit
  %.pn = phi { ptr, i32 } [ %10, %.loopexit.loopexit ], [ %9, %.loopexit.loopexit9 ]
  call void @_ZN6sparta6s_exprD2Ev(ptr noundef nonnull align 8 dereferenceable(8) %3) #4
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %3) #4
  resume { ptr, i32 } %.pn
}

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

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

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

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

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 = { 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 #3 = { 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 #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 = !{!"_ZTS16PointsToVariable", !7, i64 0}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LoopSimplifyPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass