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

; 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.cfg::InstructionIteratorImpl.433" = type { ptr, %"struct.std::_Rb_tree_const_iterator", %"class.ir_list::InstructionIteratorImpl.62" }
%"struct.std::_Rb_tree_const_iterator" = type { ptr }
%"class.ir_list::InstructionIteratorImpl.62" = type { %"class.boost::intrusive::list_iterator.38", %"class.boost::intrusive::list_iterator.38" }
%"class.boost::intrusive::list_iterator.38" = type { %"struct.boost::intrusive::iiterator_members" }
%"struct.boost::intrusive::iiterator_members" = type { ptr }
%"class.cfg::InstructionIterableImpl" = type { ptr }
%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 noundef zeroext i1 @_ZNK13IRInstruction8has_destEv(ptr noundef nonnull align 8 dereferenceable(32)) #1 align 2

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

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

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN3cfg23InstructionIterableImplILb1EE5beginEv(ptr dead_on_unwind noalias writable sret(%"class.cfg::InstructionIteratorImpl.433") align 8, ptr noundef nonnull align 8 dereferenceable(8)) #1 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN3cfg23InstructionIterableImplILb1EE3endEv(ptr dead_on_unwind noalias writable sret(%"class.cfg::InstructionIteratorImpl.433") align 8, ptr noundef nonnull align 8 dereferenceable(8)) #1 align 2

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

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

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

; Function Attrs: mustprogress uwtable
define dso_local noundef i32 @_ZNK3cfg16ControlFlowGraph22compute_registers_sizeEv(ptr noundef nonnull align 8 dereferenceable(160) %0) #1 align 2 {
  %2 = alloca ptr, align 8
  %3 = alloca i32, align 4
  %4 = alloca ptr, align 8
  %5 = alloca %"class.cfg::InstructionIterableImpl", align 8
  %6 = alloca %"class.cfg::InstructionIteratorImpl.433", align 8
  %7 = alloca %"class.cfg::InstructionIteratorImpl.433", align 8
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  %10 = alloca i32, align 4
  store ptr %0, ptr %2, align 8, !tbaa !5
  %11 = load ptr, ptr %2, align 8
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #4
  store i32 0, ptr %3, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #4
  call void @_ZN3cfg23InstructionIterableImplILb1EEC2ERKNS_16ControlFlowGraphE(ptr noundef nonnull align 8 dereferenceable(8) %5, ptr noundef nonnull align 8 dereferenceable(160) %11)
  store ptr %5, ptr %4, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 32, ptr %6) #4
  %12 = load ptr, ptr %4, align 8, !tbaa !5
  call void @_ZN3cfg23InstructionIterableImplILb1EE5beginEv(ptr dead_on_unwind writable sret(%"class.cfg::InstructionIteratorImpl.433") align 8 %6, ptr noundef nonnull align 8 dereferenceable(8) %12)
  call void @llvm.lifetime.start.p0(i64 32, ptr %7) #4
  %13 = load ptr, ptr %4, align 8, !tbaa !5
  call void @_ZN3cfg23InstructionIterableImplILb1EE3endEv(ptr dead_on_unwind writable sret(%"class.cfg::InstructionIteratorImpl.433") align 8 %7, ptr noundef nonnull align 8 dereferenceable(8) %13)
  br label %14

14:                                               ; preds = %35, %1
  %15 = call noundef zeroext i1 @_ZNK3cfg23InstructionIteratorImplILb1EEneERKS1_(ptr noundef nonnull align 8 dereferenceable(32) %6, ptr noundef nonnull align 8 dereferenceable(32) %7)
  br i1 %15, label %17, label %16

16:                                               ; preds = %14
  call void @llvm.lifetime.end.p0(i64 32, ptr %7) #4
  call void @llvm.lifetime.end.p0(i64 32, ptr %6) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #4
  br label %37

17:                                               ; preds = %14
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #4
  %18 = call noundef nonnull align 8 dereferenceable(32) ptr @_ZNK3cfg23InstructionIteratorImplILb1EEdeEv(ptr noundef nonnull align 8 dereferenceable(32) %6)
  store ptr %18, ptr %8, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #4
  %19 = load ptr, ptr %8, align 8, !tbaa !5
  %20 = getelementptr inbounds %struct.MethodItemEntry, ptr %19, i32 0, i32 2
  %21 = load ptr, ptr %20, align 8, !tbaa !11
  store ptr %21, ptr %9, align 8, !tbaa !5
  %22 = load ptr, ptr %9, align 8, !tbaa !5
  %23 = call noundef zeroext i1 @_ZNK13IRInstruction8has_destEv(ptr noundef nonnull align 8 dereferenceable(32) %22)
  br i1 %23, label %24, label %34

24:                                               ; preds = %17
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #4
  %25 = load ptr, ptr %9, align 8, !tbaa !5
  %26 = call noundef i32 @_ZNK13IRInstruction4destEv(ptr noundef nonnull align 8 dereferenceable(32) %25)
  %27 = load ptr, ptr %9, align 8, !tbaa !5
  %28 = call noundef zeroext i1 @_ZNK13IRInstruction12dest_is_wideEv(ptr noundef nonnull align 8 dereferenceable(32) %27)
  %29 = zext i1 %28 to i32
  %30 = add i32 %26, %29
  %31 = add i32 %30, 1
  store i32 %31, ptr %10, align 4, !tbaa !9
  %32 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3maxIjERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) %10, ptr noundef nonnull align 4 dereferenceable(4) %3)
  %33 = load i32, ptr %32, align 4, !tbaa !9
  store i32 %33, ptr %3, align 4, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #4
  br label %34

34:                                               ; preds = %24, %17
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #4
  br label %35

35:                                               ; preds = %34
  %36 = call noundef nonnull align 8 dereferenceable(32) ptr @_ZN3cfg23InstructionIteratorImplILb1EEppEv(ptr noundef nonnull align 8 dereferenceable(32) %6)
  br label %14

37:                                               ; preds = %16
  %38 = load i32, ptr %3, align 4, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #4
  ret i32 %38
}

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3maxIjERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4), ptr noundef nonnull align 4 dereferenceable(4)) #3

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 = { 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 #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, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!7, !7, 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.cfg::InstructionIteratorImpl.433" = type { ptr, %"struct.std::_Rb_tree_const_iterator", %"class.ir_list::InstructionIteratorImpl.62" }
%"struct.std::_Rb_tree_const_iterator" = type { ptr }
%"class.ir_list::InstructionIteratorImpl.62" = type { %"class.boost::intrusive::list_iterator.38", %"class.boost::intrusive::list_iterator.38" }
%"class.boost::intrusive::list_iterator.38" = type { %"struct.boost::intrusive::iiterator_members" }
%"struct.boost::intrusive::iiterator_members" = type { ptr }
%"class.cfg::InstructionIterableImpl" = type { ptr }

; 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 noundef zeroext i1 @_ZNK13IRInstruction8has_destEv(ptr noundef nonnull align 8 dereferenceable(32)) local_unnamed_addr #1 align 2

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

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

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN3cfg23InstructionIterableImplILb1EE5beginEv(ptr dead_on_unwind noalias writable sret(%"class.cfg::InstructionIteratorImpl.433") align 8, ptr noundef nonnull align 8 dereferenceable(8)) local_unnamed_addr #1 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN3cfg23InstructionIterableImplILb1EE3endEv(ptr dead_on_unwind noalias writable sret(%"class.cfg::InstructionIteratorImpl.433") align 8, ptr noundef nonnull align 8 dereferenceable(8)) local_unnamed_addr #1 align 2

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

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

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

; Function Attrs: mustprogress uwtable
define dso_local noundef i32 @_ZNK3cfg16ControlFlowGraph22compute_registers_sizeEv(ptr noundef nonnull align 8 dereferenceable(160) %0) local_unnamed_addr #1 align 2 {
  %2 = alloca i32, align 4
  %3 = alloca %"class.cfg::InstructionIterableImpl", align 8
  %4 = alloca %"class.cfg::InstructionIteratorImpl.433", align 8
  %5 = alloca %"class.cfg::InstructionIteratorImpl.433", align 8
  %6 = alloca i32, align 4
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %2) #4
  store i32 0, ptr %2, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %3) #4
  call void @_ZN3cfg23InstructionIterableImplILb1EEC2ERKNS_16ControlFlowGraphE(ptr noundef nonnull align 8 dereferenceable(8) %3, ptr noundef nonnull align 8 dereferenceable(160) %0)
  call void @llvm.lifetime.start.p0(i64 32, ptr nonnull %4) #4
  call void @_ZN3cfg23InstructionIterableImplILb1EE5beginEv(ptr dead_on_unwind nonnull writable sret(%"class.cfg::InstructionIteratorImpl.433") align 8 %4, ptr noundef nonnull align 8 dereferenceable(8) %3)
  call void @llvm.lifetime.start.p0(i64 32, ptr nonnull %5) #4
  call void @_ZN3cfg23InstructionIterableImplILb1EE3endEv(ptr dead_on_unwind nonnull writable sret(%"class.cfg::InstructionIteratorImpl.433") align 8 %5, ptr noundef nonnull align 8 dereferenceable(8) %3)
  %7 = call noundef zeroext i1 @_ZNK3cfg23InstructionIteratorImplILb1EEneERKS1_(ptr noundef nonnull align 8 dereferenceable(32) %4, ptr noundef nonnull align 8 dereferenceable(32) %5)
  br i1 %7, label %.lr.ph, label %._crit_edge

._crit_edge.loopexit:                             ; preds = %21
  %.pre = load i32, ptr %2, align 4, !tbaa !5
  br label %._crit_edge

._crit_edge:                                      ; preds = %._crit_edge.loopexit, %1
  %8 = phi i32 [ %.pre, %._crit_edge.loopexit ], [ 0, %1 ]
  call void @llvm.lifetime.end.p0(i64 32, ptr nonnull %5) #4
  call void @llvm.lifetime.end.p0(i64 32, ptr nonnull %4) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %3) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %2) #4
  ret i32 %8

.lr.ph:                                           ; preds = %1, %21
  %9 = call noundef nonnull align 8 dereferenceable(32) ptr @_ZNK3cfg23InstructionIteratorImplILb1EEdeEv(ptr noundef nonnull align 8 dereferenceable(32) %4)
  %10 = getelementptr inbounds i8, ptr %9, i64 24
  %11 = load ptr, ptr %10, align 8, !tbaa !9
  %12 = call noundef zeroext i1 @_ZNK13IRInstruction8has_destEv(ptr noundef nonnull align 8 dereferenceable(32) %11)
  br i1 %12, label %13, label %21

13:                                               ; preds = %.lr.ph
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %6) #4
  %14 = call noundef i32 @_ZNK13IRInstruction4destEv(ptr noundef nonnull align 8 dereferenceable(32) %11)
  %15 = call noundef zeroext i1 @_ZNK13IRInstruction12dest_is_wideEv(ptr noundef nonnull align 8 dereferenceable(32) %11)
  %16 = zext i1 %15 to i32
  %17 = add i32 %14, 1
  %18 = add i32 %17, %16
  store i32 %18, ptr %6, align 4, !tbaa !5
  %19 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3maxIjERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) %6, ptr noundef nonnull align 4 dereferenceable(4) %2)
  %20 = load i32, ptr %19, align 4, !tbaa !5
  store i32 %20, ptr %2, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %6) #4
  br label %21

21:                                               ; preds = %13, %.lr.ph
  %22 = call noundef nonnull align 8 dereferenceable(32) ptr @_ZN3cfg23InstructionIteratorImplILb1EEppEv(ptr noundef nonnull align 8 dereferenceable(32) %4)
  %23 = call noundef zeroext i1 @_ZNK3cfg23InstructionIteratorImplILb1EEneERKS1_(ptr noundef nonnull align 8 dereferenceable(32) %4, ptr noundef nonnull align 8 dereferenceable(32) %5)
  br i1 %23, label %.lr.ph, label %._crit_edge.loopexit
}

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3maxIjERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4), ptr noundef nonnull align 4 dereferenceable(4)) local_unnamed_addr #3

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


; Effective O3 passes: GVNPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,ReassociatePass,SROAPass,SimplifyCFGPass