; LLVM IR from facebook/redex :: libredex/ControlFlow.ll (ZN3cfg5Block13get_last_insnEv)

; 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.boost::intrusive::list_iterator" = type { %"struct.boost::intrusive::iiterator_members" }
%"struct.boost::intrusive::iiterator_members" = type { ptr }
%"class.boost::intrusive::reverse_iterator" = type { %"class.boost::intrusive::list_iterator" }
%struct.MethodItemEntry = type { %"class.boost::intrusive::list_member_hook", i32, %union.anon.16 }
%"class.boost::intrusive::list_member_hook" = type { %"class.boost::intrusive::generic_hook" }
%"class.boost::intrusive::generic_hook" = type { %"struct.boost::intrusive::list_node" }
%"struct.boost::intrusive::list_node" = type { ptr, ptr }
%union.anon.16 = type { ptr }

; 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 void @_ZN3cfg5Block3endEv(ptr dead_on_unwind noalias writable sret(%"class.boost::intrusive::list_iterator") align 8, ptr noundef nonnull align 8 dereferenceable(104)) #1 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN3cfg5Block6rbeginEv(ptr dead_on_unwind noalias writable sret(%"class.boost::intrusive::reverse_iterator") align 8, ptr noundef nonnull align 8 dereferenceable(104)) #1 align 2

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN3cfg5Block4rendEv(ptr dead_on_unwind noalias writable sret(%"class.boost::intrusive::reverse_iterator") align 8, ptr noundef nonnull align 8 dereferenceable(104)) #1 align 2

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

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZSt4prevIN5boost9intrusive13list_iteratorINS1_8mhtraitsI15MethodItemEntryNS1_16list_member_hookIJEEEXadL_ZNS4_10list_hook_EEEEELb0EEEET_S9_NSt15iterator_traitsIS9_E15difference_typeE(ptr dead_on_unwind noalias writable sret(%"class.boost::intrusive::list_iterator") align 8, ptr noundef, i64 noundef) #2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNK5boost9intrusive16reverse_iteratorINS0_13list_iteratorINS0_8mhtraitsI15MethodItemEntryNS0_16list_member_hookIJEEEXadL_ZNS4_10list_hook_EEEEELb0EEEE4baseEv(ptr dead_on_unwind noalias writable sret(%"class.boost::intrusive::list_iterator") align 8, ptr noundef nonnull align 8 dereferenceable(8)) #1 align 2

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

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN3cfg5Block13get_last_insnEv(ptr dead_on_unwind noalias writable sret(%"class.boost::intrusive::list_iterator") align 8 %0, ptr noundef nonnull align 8 dereferenceable(104) %1) #1 align 2 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca %"class.boost::intrusive::reverse_iterator", align 8
  %6 = alloca %"class.boost::intrusive::reverse_iterator", align 8
  %7 = alloca i32, align 4
  %8 = alloca %"class.boost::intrusive::list_iterator", align 8
  store ptr %0, ptr %3, align 8
  store ptr %1, ptr %4, align 8, !tbaa !5
  %9 = load ptr, ptr %4, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #4
  call void @_ZN3cfg5Block6rbeginEv(ptr dead_on_unwind writable sret(%"class.boost::intrusive::reverse_iterator") align 8 %5, ptr noundef nonnull align 8 dereferenceable(104) %9)
  br label %10

10:                                               ; preds = %20, %2
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #4
  call void @_ZN3cfg5Block4rendEv(ptr dead_on_unwind writable sret(%"class.boost::intrusive::reverse_iterator") align 8 %6, ptr noundef nonnull align 8 dereferenceable(104) %9)
  %11 = call noundef zeroext i1 @_ZN5boost9intrusiveneERKNS0_16reverse_iteratorINS0_13list_iteratorINS0_8mhtraitsI15MethodItemEntryNS0_16list_member_hookIJEEEXadL_ZNS4_10list_hook_EEEEELb0EEEEESB_(ptr noundef nonnull align 8 dereferenceable(8) %5, ptr noundef nonnull align 8 dereferenceable(8) %6)
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #4
  br i1 %11, label %13, label %12

12:                                               ; preds = %10
  store i32 2, ptr %7, align 4
  br label %22

13:                                               ; preds = %10
  %14 = call noundef ptr @_ZNK5boost9intrusive16reverse_iteratorINS0_13list_iteratorINS0_8mhtraitsI15MethodItemEntryNS0_16list_member_hookIJEEEXadL_ZNS4_10list_hook_EEEEELb0EEEEptEv(ptr noundef nonnull align 8 dereferenceable(8) %5)
  %15 = getelementptr inbounds %struct.MethodItemEntry, ptr %14, i32 0, i32 1
  %16 = load i32, ptr %15, align 8, !tbaa !9
  %17 = icmp eq i32 %16, 2
  br i1 %17, label %18, label %19

18:                                               ; preds = %13
  call void @_ZNK5boost9intrusive16reverse_iteratorINS0_13list_iteratorINS0_8mhtraitsI15MethodItemEntryNS0_16list_member_hookIJEEEXadL_ZNS4_10list_hook_EEEEELb0EEEE4baseEv(ptr dead_on_unwind writable sret(%"class.boost::intrusive::list_iterator") align 8 %8, ptr noundef nonnull align 8 dereferenceable(8) %5)
  call void @_ZSt4prevIN5boost9intrusive13list_iteratorINS1_8mhtraitsI15MethodItemEntryNS1_16list_member_hookIJEEEXadL_ZNS4_10list_hook_EEEEELb0EEEET_S9_NSt15iterator_traitsIS9_E15difference_typeE(ptr dead_on_unwind writable sret(%"class.boost::intrusive::list_iterator") align 8 %0, ptr noundef %8, i64 noundef 1)
  store i32 1, ptr %7, align 4
  br label %22

19:                                               ; preds = %13
  br label %20

20:                                               ; preds = %19
  %21 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZN5boost9intrusive16reverse_iteratorINS0_13list_iteratorINS0_8mhtraitsI15MethodItemEntryNS0_16list_member_hookIJEEEXadL_ZNS4_10list_hook_EEEEELb0EEEEppEv(ptr noundef nonnull align 8 dereferenceable(8) %5)
  br label %10, !llvm.loop !15

22:                                               ; preds = %18, %12
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #4
  %23 = load i32, ptr %7, align 4
  switch i32 %23, label %26 [
    i32 2, label %24
    i32 1, label %25
  ]

24:                                               ; preds = %22
  call void @_ZN3cfg5Block3endEv(ptr dead_on_unwind writable sret(%"class.boost::intrusive::list_iterator") align 8 %0, ptr noundef nonnull align 8 dereferenceable(104) %9)
  br label %25

25:                                               ; preds = %24, %22
  ret void

26:                                               ; preds = %22
  unreachable
}

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 = { 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, !14, i64 16}
!10 = !{!"_ZTS15MethodItemEntry", !11, i64 0, !14, i64 16, !7, i64 24}
!11 = !{!"_ZTSN5boost9intrusive16list_member_hookIJEEE", !12, i64 0}
!12 = !{!"_ZTSN5boost9intrusive12generic_hookILNS0_10algo_typesE0ENS0_16list_node_traitsIPvEENS0_10member_tagELNS0_14link_mode_typeE1ELNS0_14base_hook_typeE0EEE", !13, i64 0}
!13 = !{!"_ZTSN5boost9intrusive9list_nodeIPvEE", !6, i64 0, !6, i64 8}
!14 = !{!"_ZTS14MethodItemType", !7, i64 0}
!15 = distinct !{!15, !16}
!16 = !{!"llvm.loop.mustprogress"}


; 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.boost::intrusive::list_iterator" = type { %"struct.boost::intrusive::iiterator_members" }
%"struct.boost::intrusive::iiterator_members" = type { ptr }
%"class.boost::intrusive::reverse_iterator" = type { %"class.boost::intrusive::list_iterator" }

; 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 void @_ZN3cfg5Block3endEv(ptr dead_on_unwind noalias writable sret(%"class.boost::intrusive::list_iterator") align 8, ptr noundef nonnull align 8 dereferenceable(104)) local_unnamed_addr #1 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN3cfg5Block6rbeginEv(ptr dead_on_unwind noalias writable sret(%"class.boost::intrusive::reverse_iterator") align 8, ptr noundef nonnull align 8 dereferenceable(104)) local_unnamed_addr #1 align 2

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN3cfg5Block4rendEv(ptr dead_on_unwind noalias writable sret(%"class.boost::intrusive::reverse_iterator") align 8, ptr noundef nonnull align 8 dereferenceable(104)) local_unnamed_addr #1 align 2

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

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZSt4prevIN5boost9intrusive13list_iteratorINS1_8mhtraitsI15MethodItemEntryNS1_16list_member_hookIJEEEXadL_ZNS4_10list_hook_EEEEELb0EEEET_S9_NSt15iterator_traitsIS9_E15difference_typeE(ptr dead_on_unwind noalias writable sret(%"class.boost::intrusive::list_iterator") align 8, ptr noundef, i64 noundef) local_unnamed_addr #2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNK5boost9intrusive16reverse_iteratorINS0_13list_iteratorINS0_8mhtraitsI15MethodItemEntryNS0_16list_member_hookIJEEEXadL_ZNS4_10list_hook_EEEEELb0EEEE4baseEv(ptr dead_on_unwind noalias writable sret(%"class.boost::intrusive::list_iterator") align 8, ptr noundef nonnull align 8 dereferenceable(8)) local_unnamed_addr #1 align 2

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

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN3cfg5Block13get_last_insnEv(ptr dead_on_unwind noalias writable sret(%"class.boost::intrusive::list_iterator") align 8 %0, ptr noundef nonnull align 8 dereferenceable(104) %1) local_unnamed_addr #1 align 2 {
  %3 = alloca %"class.boost::intrusive::reverse_iterator", align 8
  %4 = alloca %"class.boost::intrusive::reverse_iterator", align 8
  %5 = alloca %"class.boost::intrusive::list_iterator", align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %3) #4
  call void @_ZN3cfg5Block6rbeginEv(ptr dead_on_unwind nonnull writable sret(%"class.boost::intrusive::reverse_iterator") align 8 %3, ptr noundef nonnull align 8 dereferenceable(104) %1)
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %4) #4
  call void @_ZN3cfg5Block4rendEv(ptr dead_on_unwind nonnull writable sret(%"class.boost::intrusive::reverse_iterator") align 8 %4, ptr noundef nonnull align 8 dereferenceable(104) %1)
  %6 = call noundef zeroext i1 @_ZN5boost9intrusiveneERKNS0_16reverse_iteratorINS0_13list_iteratorINS0_8mhtraitsI15MethodItemEntryNS0_16list_member_hookIJEEEXadL_ZNS4_10list_hook_EEEEELb0EEEEESB_(ptr noundef nonnull align 8 dereferenceable(8) %3, ptr noundef nonnull align 8 dereferenceable(8) %4)
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %4) #4
  br i1 %6, label %.lr.ph, label %._crit_edge

.lr.ph:                                           ; preds = %2, %11
  %7 = call noundef ptr @_ZNK5boost9intrusive16reverse_iteratorINS0_13list_iteratorINS0_8mhtraitsI15MethodItemEntryNS0_16list_member_hookIJEEEXadL_ZNS4_10list_hook_EEEEELb0EEEEptEv(ptr noundef nonnull align 8 dereferenceable(8) %3)
  %8 = getelementptr inbounds i8, ptr %7, i64 16
  %9 = load i32, ptr %8, align 8, !tbaa !5
  %10 = icmp eq i32 %9, 2
  br i1 %10, label %14, label %11

11:                                               ; preds = %.lr.ph
  %12 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZN5boost9intrusive16reverse_iteratorINS0_13list_iteratorINS0_8mhtraitsI15MethodItemEntryNS0_16list_member_hookIJEEEXadL_ZNS4_10list_hook_EEEEELb0EEEEppEv(ptr noundef nonnull align 8 dereferenceable(8) %3)
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %4) #4
  call void @_ZN3cfg5Block4rendEv(ptr dead_on_unwind nonnull writable sret(%"class.boost::intrusive::reverse_iterator") align 8 %4, ptr noundef nonnull align 8 dereferenceable(104) %1)
  %13 = call noundef zeroext i1 @_ZN5boost9intrusiveneERKNS0_16reverse_iteratorINS0_13list_iteratorINS0_8mhtraitsI15MethodItemEntryNS0_16list_member_hookIJEEEXadL_ZNS4_10list_hook_EEEEELb0EEEEESB_(ptr noundef nonnull align 8 dereferenceable(8) %3, ptr noundef nonnull align 8 dereferenceable(8) %4)
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %4) #4
  br i1 %13, label %.lr.ph, label %._crit_edge, !llvm.loop !14

14:                                               ; preds = %.lr.ph
  call void @_ZNK5boost9intrusive16reverse_iteratorINS0_13list_iteratorINS0_8mhtraitsI15MethodItemEntryNS0_16list_member_hookIJEEEXadL_ZNS4_10list_hook_EEEEELb0EEEE4baseEv(ptr dead_on_unwind nonnull writable sret(%"class.boost::intrusive::list_iterator") align 8 %5, ptr noundef nonnull align 8 dereferenceable(8) %3)
  call void @_ZSt4prevIN5boost9intrusive13list_iteratorINS1_8mhtraitsI15MethodItemEntryNS1_16list_member_hookIJEEEXadL_ZNS4_10list_hook_EEEEELb0EEEET_S9_NSt15iterator_traitsIS9_E15difference_typeE(ptr dead_on_unwind writable sret(%"class.boost::intrusive::list_iterator") align 8 %0, ptr noundef nonnull %5, i64 noundef 1)
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %3) #4
  br label %15

._crit_edge:                                      ; preds = %11, %2
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %3) #4
  call void @_ZN3cfg5Block3endEv(ptr dead_on_unwind writable sret(%"class.boost::intrusive::list_iterator") align 8 %0, ptr noundef nonnull align 8 dereferenceable(104) %1)
  br label %15

15:                                               ; preds = %14, %._crit_edge
  ret void
}

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 = { 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, !13, i64 16}
!6 = !{!"_ZTS15MethodItemEntry", !7, i64 0, !13, i64 16, !11, i64 24}
!7 = !{!"_ZTSN5boost9intrusive16list_member_hookIJEEE", !8, i64 0}
!8 = !{!"_ZTSN5boost9intrusive12generic_hookILNS0_10algo_typesE0ENS0_16list_node_traitsIPvEENS0_10member_tagELNS0_14link_mode_typeE1ELNS0_14base_hook_typeE0EEE", !9, i64 0}
!9 = !{!"_ZTSN5boost9intrusive9list_nodeIPvEE", !10, i64 0, !10, i64 8}
!10 = !{!"any pointer", !11, i64 0}
!11 = !{!"omnipotent char", !12, i64 0}
!12 = !{!"Simple C++ TBAA"}
!13 = !{!"_ZTS14MethodItemType", !11, i64 0}
!14 = distinct !{!14, !15}
!15 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: CorrelatedValuePropagationPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,SROAPass,SimplifyCFGPass