; LLVM IR from zsiciarz/aquila :: lib/unittestpp/UnitTest++ (CompositeTestReporter)

; 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.UnitTest::CompositeTestReporter" = type <{ %"class.UnitTest::TestReporter", [16 x ptr], i32, [4 x i8] }>
%"class.UnitTest::TestReporter" = type { ptr }

; Function Attrs: mustprogress nounwind uwtable
define dso_local noundef zeroext i1 @_ZN8UnitTest21CompositeTestReporter14RemoveReporterEPNS_12TestReporterE(ptr noundef nonnull align 8 dereferenceable(140) %0, ptr noundef %1) #0 align 2 {
  %3 = alloca i1, align 1
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  %8 = load ptr, ptr %4, align 8
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #2
  store i32 0, ptr %6, align 4, !tbaa !9
  br label %9

9:                                                ; preds = %39, %2
  %10 = load i32, ptr %6, align 4, !tbaa !9
  %11 = getelementptr inbounds %"class.UnitTest::CompositeTestReporter", ptr %8, i32 0, i32 2
  %12 = load i32, ptr %11, align 8, !tbaa !11
  %13 = icmp slt i32 %10, %12
  br i1 %13, label %15, label %14

14:                                               ; preds = %9
  store i32 2, ptr %7, align 4
  br label %42

15:                                               ; preds = %9
  %16 = getelementptr inbounds %"class.UnitTest::CompositeTestReporter", ptr %8, i32 0, i32 1
  %17 = load i32, ptr %6, align 4, !tbaa !9
  %18 = sext i32 %17 to i64
  %19 = getelementptr inbounds [16 x ptr], ptr %16, i64 0, i64 %18
  %20 = load ptr, ptr %19, align 8, !tbaa !5
  %21 = load ptr, ptr %5, align 8, !tbaa !5
  %22 = icmp eq ptr %20, %21
  br i1 %22, label %23, label %38

23:                                               ; preds = %15
  %24 = getelementptr inbounds %"class.UnitTest::CompositeTestReporter", ptr %8, i32 0, i32 1
  %25 = getelementptr inbounds %"class.UnitTest::CompositeTestReporter", ptr %8, i32 0, i32 2
  %26 = load i32, ptr %25, align 8, !tbaa !11
  %27 = sub nsw i32 %26, 1
  %28 = sext i32 %27 to i64
  %29 = getelementptr inbounds [16 x ptr], ptr %24, i64 0, i64 %28
  %30 = load ptr, ptr %29, align 8, !tbaa !5
  %31 = getelementptr inbounds %"class.UnitTest::CompositeTestReporter", ptr %8, i32 0, i32 1
  %32 = load i32, ptr %6, align 4, !tbaa !9
  %33 = sext i32 %32 to i64
  %34 = getelementptr inbounds [16 x ptr], ptr %31, i64 0, i64 %33
  store ptr %30, ptr %34, align 8, !tbaa !5
  %35 = getelementptr inbounds %"class.UnitTest::CompositeTestReporter", ptr %8, i32 0, i32 2
  %36 = load i32, ptr %35, align 8, !tbaa !11
  %37 = add nsw i32 %36, -1
  store i32 %37, ptr %35, align 8, !tbaa !11
  store i1 true, ptr %3, align 1
  store i32 1, ptr %7, align 4
  br label %42

38:                                               ; preds = %15
  br label %39

39:                                               ; preds = %38
  %40 = load i32, ptr %6, align 4, !tbaa !9
  %41 = add nsw i32 %40, 1
  store i32 %41, ptr %6, align 4, !tbaa !9
  br label %9, !llvm.loop !14

42:                                               ; preds = %23, %14
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #2
  %43 = load i32, ptr %7, align 4
  switch i32 %43, label %47 [
    i32 2, label %44
    i32 1, label %45
  ]

44:                                               ; preds = %42
  store i1 false, ptr %3, align 1
  br label %45

45:                                               ; preds = %44, %42
  %46 = load i1, ptr %3, align 1
  ret i1 %46

47:                                               ; preds = %42
  unreachable
}

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

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

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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { 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 = !{!12, !10, i64 136}
!12 = !{!"_ZTSN8UnitTest21CompositeTestReporterE", !13, i64 0, !7, i64 8, !10, i64 136}
!13 = !{!"_ZTSN8UnitTest12TestReporterE"}
!14 = distinct !{!14, !15}
!15 = !{!"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"

; Function Attrs: mustprogress nofree norecurse nosync nounwind memory(argmem: readwrite) uwtable
define dso_local noundef zeroext i1 @_ZN8UnitTest21CompositeTestReporter14RemoveReporterEPNS_12TestReporterE(ptr nocapture noundef nonnull align 8 dereferenceable(140) %0, ptr noundef readnone %1) local_unnamed_addr #0 align 2 {
  %3 = getelementptr inbounds i8, ptr %0, i64 136
  %4 = load i32, ptr %3, align 8, !tbaa !5
  %.not18 = icmp sgt i32 %4, 0
  br i1 %.not18, label %.lr.ph, label %.loopexit

.lr.ph:                                           ; preds = %2
  %5 = getelementptr inbounds i8, ptr %0, i64 8
  %6 = zext nneg i32 %4 to i64
  %wide.trip.count = zext nneg i32 %4 to i64
  %7 = load ptr, ptr %5, align 8, !tbaa !11
  %8 = icmp eq ptr %7, %1
  br i1 %8, label %._crit_edge, label %.lr.ph28

.lr.ph28:                                         ; preds = %.lr.ph, %9
  %indvars.iv27 = phi i64 [ %indvars.iv.next, %9 ], [ 0, %.lr.ph ]
  %indvars.iv.next = add nuw nsw i64 %indvars.iv27, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next, %wide.trip.count
  br i1 %exitcond.not, label %.loopexit.loopexit, label %9, !llvm.loop !13

9:                                                ; preds = %.lr.ph28
  %10 = getelementptr inbounds [16 x ptr], ptr %5, i64 0, i64 %indvars.iv.next
  %11 = load ptr, ptr %10, align 8, !tbaa !11
  %12 = icmp eq ptr %11, %1
  br i1 %12, label %._crit_edge.loopexit, label %.lr.ph28, !llvm.loop !13

._crit_edge.loopexit:                             ; preds = %9
  %.not.le = icmp ult i64 %indvars.iv.next, %6
  br label %._crit_edge

._crit_edge:                                      ; preds = %._crit_edge.loopexit, %.lr.ph
  %indvars.iv.lcssa = phi i64 [ 0, %.lr.ph ], [ %indvars.iv.next, %._crit_edge.loopexit ]
  %.not20.lcssa = phi i1 [ true, %.lr.ph ], [ %.not.le, %._crit_edge.loopexit ]
  %13 = getelementptr inbounds [16 x ptr], ptr %5, i64 0, i64 %indvars.iv.lcssa
  %14 = add nsw i32 %4, -1
  %15 = sext i32 %14 to i64
  %16 = getelementptr inbounds [16 x ptr], ptr %5, i64 0, i64 %15
  %17 = load ptr, ptr %16, align 8, !tbaa !11
  store ptr %17, ptr %13, align 8, !tbaa !11
  store i32 %14, ptr %3, align 8, !tbaa !5
  br label %.loopexit

.loopexit.loopexit:                               ; preds = %.lr.ph28
  %.not.le34 = icmp ult i64 %indvars.iv.next, %6
  br label %.loopexit

.loopexit:                                        ; preds = %.loopexit.loopexit, %2, %._crit_edge
  %.not11 = phi i1 [ %.not20.lcssa, %._crit_edge ], [ false, %2 ], [ %.not.le34, %.loopexit.loopexit ]
  ret i1 %.not11
}

attributes #0 = { mustprogress nofree norecurse nosync nounwind memory(argmem: readwrite) 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" }

!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, !10, i64 136}
!6 = !{!"_ZTSN8UnitTest21CompositeTestReporterE", !7, i64 0, !8, i64 8, !10, i64 136}
!7 = !{!"_ZTSN8UnitTest12TestReporterE"}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"int", !8, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"any pointer", !8, i64 0}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass