; LLVM IR from facebook/redex :: libredex/BigBlocks.ll (ZN10big_blocks8Iterator12adjust_blockEv)

; 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.big_blocks::Iterator" = type <{ ptr, %"class.boost::intrusive::list_iterator", i8, [7 x i8] }>

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN10big_blocks8Iterator12adjust_blockEv(ptr noundef nonnull align 8 dereferenceable(17) %0) #0 align 2 {
  %2 = alloca ptr, align 8
  %3 = alloca %"class.boost::intrusive::list_iterator", align 8
  %4 = alloca %"class.boost::intrusive::list_iterator", align 8
  store ptr %0, ptr %2, align 8, !tbaa !5
  %5 = load ptr, ptr %2, align 8
  br label %6

6:                                                ; preds = %39, %1
  %7 = getelementptr inbounds %"class.big_blocks::Iterator", ptr %5, i32 0, i32 0
  %8 = load ptr, ptr %7, align 8, !tbaa !9
  %9 = icmp ne ptr %8, null
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #4
  br i1 %9, label %10, label %15

10:                                               ; preds = %6
  %11 = getelementptr inbounds %"class.big_blocks::Iterator", ptr %5, i32 0, i32 1
  %12 = getelementptr inbounds %"class.big_blocks::Iterator", ptr %5, i32 0, i32 0
  %13 = load ptr, ptr %12, align 8, !tbaa !9
  call void @_ZN3cfg5Block3endEv(ptr dead_on_unwind writable sret(%"class.boost::intrusive::list_iterator") align 8 %3, ptr noundef nonnull align 8 dereferenceable(104) %13)
  %14 = call noundef zeroext i1 @_ZN5boost9intrusiveeqERKNS0_13list_iteratorINS0_8mhtraitsI15MethodItemEntryNS0_16list_member_hookIJEEEXadL_ZNS3_10list_hook_EEEEELb0EEES9_(ptr noundef nonnull align 8 dereferenceable(8) %11, ptr noundef nonnull align 8 dereferenceable(8) %3)
  br label %15

15:                                               ; preds = %10, %6
  %16 = phi i1 [ false, %6 ], [ %14, %10 ]
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #4
  br i1 %16, label %17, label %40

17:                                               ; preds = %15
  %18 = getelementptr inbounds %"class.big_blocks::Iterator", ptr %5, i32 0, i32 0
  %19 = load ptr, ptr %18, align 8, !tbaa !9
  %20 = call noundef ptr @_ZNK3cfg5Block7goes_toEv(ptr noundef nonnull align 8 dereferenceable(104) %19)
  %21 = getelementptr inbounds %"class.big_blocks::Iterator", ptr %5, i32 0, i32 0
  store ptr %20, ptr %21, align 8, !tbaa !9
  %22 = getelementptr inbounds %"class.big_blocks::Iterator", ptr %5, i32 0, i32 0
  %23 = load ptr, ptr %22, align 8, !tbaa !9
  %24 = icmp ne ptr %23, null
  br i1 %24, label %25, label %37

25:                                               ; preds = %17
  %26 = getelementptr inbounds %"class.big_blocks::Iterator", ptr %5, i32 0, i32 0
  %27 = load ptr, ptr %26, align 8, !tbaa !9
  %28 = getelementptr inbounds %"class.big_blocks::Iterator", ptr %5, i32 0, i32 2
  %29 = load i8, ptr %28, align 8, !tbaa !14, !range !15, !noundef !16
  %30 = trunc i8 %29 to i1
  %31 = call noundef zeroext i1 @_ZN12_GLOBAL__N_122is_big_block_successorEPN3cfg5BlockEb(ptr noundef %27, i1 noundef zeroext %30)
  br i1 %31, label %32, label %37

32:                                               ; preds = %25
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #4
  %33 = getelementptr inbounds %"class.big_blocks::Iterator", ptr %5, i32 0, i32 0
  %34 = load ptr, ptr %33, align 8, !tbaa !9
  call void @_ZN3cfg5Block5beginEv(ptr dead_on_unwind writable sret(%"class.boost::intrusive::list_iterator") align 8 %4, ptr noundef nonnull align 8 dereferenceable(104) %34)
  %35 = getelementptr inbounds %"class.big_blocks::Iterator", ptr %5, i32 0, i32 1
  %36 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZN5boost9intrusive13list_iteratorINS0_8mhtraitsI15MethodItemEntryNS0_16list_member_hookIJEEEXadL_ZNS3_10list_hook_EEEEELb0EEaSERKS7_(ptr noundef nonnull align 8 dereferenceable(8) %35, ptr noundef nonnull align 8 dereferenceable(8) %4)
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #4
  br label %39

37:                                               ; preds = %25, %17
  %38 = getelementptr inbounds %"class.big_blocks::Iterator", ptr %5, i32 0, i32 0
  store ptr null, ptr %38, align 8, !tbaa !9
  br label %39

39:                                               ; preds = %37, %32
  br label %6, !llvm.loop !17

40:                                               ; preds = %15
  ret void
}

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

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

declare void @_ZN3cfg5Block3endEv(ptr dead_on_unwind writable sret(%"class.boost::intrusive::list_iterator") align 8, ptr noundef nonnull align 8 dereferenceable(104)) #3

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

declare noundef ptr @_ZNK3cfg5Block7goes_toEv(ptr noundef nonnull align 8 dereferenceable(104)) #3

; Function Attrs: mustprogress uwtable
declare hidden noundef zeroext i1 @_ZN12_GLOBAL__N_122is_big_block_successorEPN3cfg5BlockEb(ptr noundef, i1 noundef zeroext) #0

declare void @_ZN3cfg5Block5beginEv(ptr dead_on_unwind writable sret(%"class.boost::intrusive::list_iterator") align 8, ptr noundef nonnull align 8 dereferenceable(104)) #3

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

attributes #0 = { 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 #1 = { 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 #2 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { "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 = !{!"_ZTSN10big_blocks8IteratorE", !6, i64 0, !11, i64 8, !13, i64 16}
!11 = !{!"_ZTSN5boost9intrusive13list_iteratorINS0_8mhtraitsI15MethodItemEntryNS0_16list_member_hookIJEEEXadL_ZNS3_10list_hook_EEEEELb0EEE", !12, i64 0}
!12 = !{!"_ZTSN5boost9intrusive17iiterator_membersIPNS0_9list_nodeIPvEEPKNS0_8mhtraitsI15MethodItemEntryNS0_16list_member_hookIJEEEXadL_ZNS7_10list_hook_EEEEELb0EEE", !6, i64 0}
!13 = !{!"bool", !7, i64 0}
!14 = !{!10, !13, i64 16}
!15 = !{i8 0, i8 2}
!16 = !{}
!17 = distinct !{!17, !18}
!18 = !{!"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 }

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN10big_blocks8Iterator12adjust_blockEv(ptr noundef nonnull align 8 dereferenceable(17) %0) local_unnamed_addr #0 align 2 {
  %2 = alloca %"class.boost::intrusive::list_iterator", align 8
  %3 = alloca %"class.boost::intrusive::list_iterator", align 8
  %4 = load ptr, ptr %0, align 8, !tbaa !5
  %.not2 = icmp eq ptr %4, null
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %2) #4
  br i1 %.not2, label %.critedge, label %.lr.ph

.lr.ph:                                           ; preds = %1
  %5 = getelementptr inbounds i8, ptr %0, i64 8
  %6 = getelementptr inbounds i8, ptr %0, i64 16
  br label %7

7:                                                ; preds = %.lr.ph, %17
  %8 = phi ptr [ %4, %.lr.ph ], [ %.pre, %17 ]
  call void @_ZN3cfg5Block3endEv(ptr dead_on_unwind nonnull writable sret(%"class.boost::intrusive::list_iterator") align 8 %2, ptr noundef nonnull align 8 dereferenceable(104) %8)
  %9 = call noundef zeroext i1 @_ZN5boost9intrusiveeqERKNS0_13list_iteratorINS0_8mhtraitsI15MethodItemEntryNS0_16list_member_hookIJEEEXadL_ZNS3_10list_hook_EEEEELb0EEES9_(ptr noundef nonnull align 8 dereferenceable(8) %5, ptr noundef nonnull align 8 dereferenceable(8) %2)
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %2) #4
  br i1 %9, label %10, label %.loopexit

10:                                               ; preds = %7
  %11 = load ptr, ptr %0, align 8, !tbaa !5
  %12 = call noundef ptr @_ZNK3cfg5Block7goes_toEv(ptr noundef nonnull align 8 dereferenceable(104) %11)
  store ptr %12, ptr %0, align 8, !tbaa !5
  %.not1 = icmp eq ptr %12, null
  br i1 %.not1, label %.thread, label %13

13:                                               ; preds = %10
  %14 = load i8, ptr %6, align 8, !tbaa !13, !range !14, !noundef !15
  %15 = trunc nuw i8 %14 to i1
  %16 = call noundef zeroext i1 @_ZN12_GLOBAL__N_122is_big_block_successorEPN3cfg5BlockEb(ptr noundef nonnull %12, i1 noundef zeroext %15)
  br i1 %16, label %17, label %.thread

.thread:                                          ; preds = %10, %13
  store ptr null, ptr %0, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %2) #4
  br label %.critedge

17:                                               ; preds = %13
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %3) #4
  %18 = load ptr, ptr %0, align 8, !tbaa !5
  call void @_ZN3cfg5Block5beginEv(ptr dead_on_unwind nonnull writable sret(%"class.boost::intrusive::list_iterator") align 8 %3, ptr noundef nonnull align 8 dereferenceable(104) %18)
  %19 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZN5boost9intrusive13list_iteratorINS0_8mhtraitsI15MethodItemEntryNS0_16list_member_hookIJEEEXadL_ZNS3_10list_hook_EEEEELb0EEaSERKS7_(ptr noundef nonnull align 8 dereferenceable(8) %5, ptr noundef nonnull align 8 dereferenceable(8) %3)
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %3) #4
  %.pre = load ptr, ptr %0, align 8, !tbaa !5
  %.not = icmp eq ptr %.pre, null
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %2) #4
  br i1 %.not, label %.critedge, label %7, !llvm.loop !16

.critedge:                                        ; preds = %17, %.thread, %1
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %2) #4
  br label %.loopexit

.loopexit:                                        ; preds = %7, %.critedge
  ret void
}

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

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

declare void @_ZN3cfg5Block3endEv(ptr dead_on_unwind writable sret(%"class.boost::intrusive::list_iterator") align 8, ptr noundef nonnull align 8 dereferenceable(104)) local_unnamed_addr #3

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

declare noundef ptr @_ZNK3cfg5Block7goes_toEv(ptr noundef nonnull align 8 dereferenceable(104)) local_unnamed_addr #3

; Function Attrs: mustprogress uwtable
declare hidden noundef zeroext i1 @_ZN12_GLOBAL__N_122is_big_block_successorEPN3cfg5BlockEb(ptr noundef, i1 noundef zeroext) local_unnamed_addr #0

declare void @_ZN3cfg5Block5beginEv(ptr dead_on_unwind writable sret(%"class.boost::intrusive::list_iterator") align 8, ptr noundef nonnull align 8 dereferenceable(104)) local_unnamed_addr #3

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

attributes #0 = { 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 #1 = { 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 #2 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { "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 = !{!"_ZTSN10big_blocks8IteratorE", !7, i64 0, !10, i64 8, !12, i64 16}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"_ZTSN5boost9intrusive13list_iteratorINS0_8mhtraitsI15MethodItemEntryNS0_16list_member_hookIJEEEXadL_ZNS3_10list_hook_EEEEELb0EEE", !11, i64 0}
!11 = !{!"_ZTSN5boost9intrusive17iiterator_membersIPNS0_9list_nodeIPvEEPKNS0_8mhtraitsI15MethodItemEntryNS0_16list_member_hookIJEEEXadL_ZNS7_10list_hook_EEEEELb0EEE", !7, i64 0}
!12 = !{!"bool", !8, i64 0}
!13 = !{!6, !12, i64 16}
!14 = !{i8 0, i8 2}
!15 = !{}
!16 = distinct !{!16, !17}
!17 = !{!"llvm.loop.mustprogress"}


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