; LLVM IR from turi-code/SFrame :: cxxtest/cxxtest/RealDescriptions.ll (ZN7CxxTest19RealTestDescription8tearDownEv)

; 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"

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

; Function Attrs: mustprogress uwtable
declare dso_local noundef ptr @_ZNK7CxxTest19RealTestDescription5suiteEv(ptr noundef nonnull align 8 dereferenceable(56)) #0 align 2

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

declare void @_ZN7CxxTest10doFailTestEPKciS1_(ptr noundef, i32 noundef, ptr noundef) #2

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

; Function Attrs: mustprogress uwtable
define dso_local noundef zeroext i1 @_ZN7CxxTest19RealTestDescription8tearDownEv(ptr noundef nonnull align 8 dereferenceable(56) %0) unnamed_addr #0 align 2 {
  %2 = alloca i1, align 1
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca i32, align 4
  %6 = alloca i8, align 1
  store ptr %0, ptr %3, align 8, !tbaa !5
  %7 = load ptr, ptr %3, align 8
  %8 = call noundef ptr @_ZNK7CxxTest19RealTestDescription5suiteEv(ptr noundef nonnull align 8 dereferenceable(56) %7)
  %9 = icmp ne ptr %8, null
  br i1 %9, label %11, label %10

10:                                               ; preds = %1
  store i1 false, ptr %2, align 1
  br label %49

11:                                               ; preds = %1
  %12 = call noundef ptr @_ZNK7CxxTest19RealTestDescription5suiteEv(ptr noundef nonnull align 8 dereferenceable(56) %7)
  %13 = load ptr, ptr %12, align 8, !tbaa !9
  %14 = getelementptr inbounds ptr, ptr %13, i64 3
  %15 = load ptr, ptr %14, align 8
  call void %15(ptr noundef nonnull align 8 dereferenceable(8) %12)
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #3
  %16 = call noundef ptr @_ZN7CxxTest13GlobalFixture17lastGlobalFixtureEv()
  store ptr %16, ptr %4, align 8, !tbaa !5
  br label %17

17:                                               ; preds = %43, %11
  %18 = load ptr, ptr %4, align 8, !tbaa !5
  %19 = icmp ne ptr %18, null
  br i1 %19, label %21, label %20

20:                                               ; preds = %17
  store i32 2, ptr %5, align 4
  br label %46

21:                                               ; preds = %17
  call void @llvm.lifetime.start.p0(i64 1, ptr %6) #3
  %22 = load ptr, ptr %4, align 8, !tbaa !5
  %23 = load ptr, ptr %22, align 8, !tbaa !9
  %24 = getelementptr inbounds ptr, ptr %23, i64 5
  %25 = load ptr, ptr %24, align 8
  %26 = call noundef zeroext i1 %25(ptr noundef nonnull align 8 dereferenceable(25) %22)
  %27 = zext i1 %26 to i8
  store i8 %27, ptr %6, align 1, !tbaa !11
  %28 = load i8, ptr %6, align 1, !tbaa !11, !range !13, !noundef !14
  %29 = trunc i8 %28 to i1
  br i1 %29, label %39, label %30

30:                                               ; preds = %21
  %31 = load ptr, ptr %7, align 8, !tbaa !9
  %32 = getelementptr inbounds ptr, ptr %31, i64 2
  %33 = load ptr, ptr %32, align 8
  %34 = call noundef ptr %33(ptr noundef nonnull align 8 dereferenceable(56) %7)
  %35 = load ptr, ptr %7, align 8, !tbaa !9
  %36 = getelementptr inbounds ptr, ptr %35, i64 3
  %37 = load ptr, ptr %36, align 8
  %38 = call noundef i32 %37(ptr noundef nonnull align 8 dereferenceable(56) %7)
  call void @_ZN7CxxTest10doFailTestEPKciS1_(ptr noundef %34, i32 noundef %38, ptr noundef @.str.1)
  store i1 false, ptr %2, align 1
  store i32 1, ptr %5, align 4
  br label %40

39:                                               ; preds = %21
  store i32 0, ptr %5, align 4
  br label %40

40:                                               ; preds = %39, %30
  call void @llvm.lifetime.end.p0(i64 1, ptr %6) #3
  %41 = load i32, ptr %5, align 4
  switch i32 %41, label %46 [
    i32 0, label %42
  ]

42:                                               ; preds = %40
  br label %43

43:                                               ; preds = %42
  %44 = load ptr, ptr %4, align 8, !tbaa !5
  %45 = call noundef ptr @_ZN7CxxTest13GlobalFixture17prevGlobalFixtureEv(ptr noundef nonnull align 8 dereferenceable(25) %44)
  store ptr %45, ptr %4, align 8, !tbaa !5
  br label %17, !llvm.loop !15

46:                                               ; preds = %40, %20
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #3
  %47 = load i32, ptr %5, align 4
  switch i32 %47, label %51 [
    i32 2, label %48
    i32 1, label %49
  ]

48:                                               ; preds = %46
  store i1 true, ptr %2, align 1
  br label %49

49:                                               ; preds = %48, %46, %10
  %50 = load i1, ptr %2, align 1
  ret i1 %50

51:                                               ; preds = %46
  unreachable
}

declare noundef ptr @_ZN7CxxTest13GlobalFixture17lastGlobalFixtureEv() #2

declare noundef ptr @_ZN7CxxTest13GlobalFixture17prevGlobalFixtureEv(ptr noundef nonnull align 8 dereferenceable(25)) #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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { "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 = { 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 = !{!"vtable pointer", !8, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"bool", !7, i64 0}
!13 = !{i8 0, i8 2}
!14 = !{}
!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"

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

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

declare void @_ZN7CxxTest10doFailTestEPKciS1_(ptr noundef, i32 noundef, ptr noundef) local_unnamed_addr #1

; Function Attrs: mustprogress uwtable
define dso_local noundef zeroext i1 @_ZN7CxxTest19RealTestDescription8tearDownEv(ptr noundef nonnull align 8 dereferenceable(56) %0) unnamed_addr #0 align 2 {
  %2 = tail call noundef ptr @_ZNK7CxxTest19RealTestDescription5suiteEv(ptr noundef nonnull align 8 dereferenceable(56) %0)
  %.not = icmp eq ptr %2, null
  br i1 %.not, label %.loopexit, label %3

3:                                                ; preds = %1
  %4 = tail call noundef ptr @_ZNK7CxxTest19RealTestDescription5suiteEv(ptr noundef nonnull align 8 dereferenceable(56) %0)
  %5 = load ptr, ptr %4, align 8, !tbaa !5
  %6 = getelementptr inbounds i8, ptr %5, i64 24
  %7 = load ptr, ptr %6, align 8
  tail call void %7(ptr noundef nonnull align 8 dereferenceable(8) %4)
  %8 = tail call noundef ptr @_ZN7CxxTest13GlobalFixture17lastGlobalFixtureEv()
  %.not1012 = icmp eq ptr %8, null
  br i1 %.not1012, label %.loopexit, label %.lr.ph

.lr.ph:                                           ; preds = %3, %.critedge
  %.0913 = phi ptr [ %22, %.critedge ], [ %8, %3 ]
  %9 = load ptr, ptr %.0913, align 8, !tbaa !5
  %10 = getelementptr inbounds i8, ptr %9, i64 40
  %11 = load ptr, ptr %10, align 8
  %12 = tail call noundef zeroext i1 %11(ptr noundef nonnull align 8 dereferenceable(25) %.0913)
  br i1 %12, label %.critedge, label %13

13:                                               ; preds = %.lr.ph
  %14 = load ptr, ptr %0, align 8, !tbaa !5
  %15 = getelementptr inbounds i8, ptr %14, i64 16
  %16 = load ptr, ptr %15, align 8
  %17 = tail call noundef ptr %16(ptr noundef nonnull align 8 dereferenceable(56) %0)
  %18 = load ptr, ptr %0, align 8, !tbaa !5
  %19 = getelementptr inbounds i8, ptr %18, i64 24
  %20 = load ptr, ptr %19, align 8
  %21 = tail call noundef i32 %20(ptr noundef nonnull align 8 dereferenceable(56) %0)
  tail call void @_ZN7CxxTest10doFailTestEPKciS1_(ptr noundef %17, i32 noundef %21, ptr noundef nonnull @.str.1)
  br label %.loopexit

.critedge:                                        ; preds = %.lr.ph
  %22 = tail call noundef ptr @_ZN7CxxTest13GlobalFixture17prevGlobalFixtureEv(ptr noundef nonnull align 8 dereferenceable(25) %.0913)
  %.not10 = icmp eq ptr %22, null
  br i1 %.not10, label %.loopexit, label %.lr.ph, !llvm.loop !8

.loopexit:                                        ; preds = %.critedge, %3, %13, %1
  %.3 = phi i1 [ false, %1 ], [ false, %13 ], [ true, %3 ], [ true, %.critedge ]
  ret i1 %.3
}

declare noundef ptr @_ZN7CxxTest13GlobalFixture17lastGlobalFixtureEv() local_unnamed_addr #1

declare noundef ptr @_ZN7CxxTest13GlobalFixture17prevGlobalFixtureEv(ptr noundef nonnull align 8 dereferenceable(25)) local_unnamed_addr #1

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 = { "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, !6, i64 0}
!6 = !{!"vtable pointer", !7, i64 0}
!7 = !{!"Simple C++ TBAA"}
!8 = distinct !{!8, !9}
!9 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: ConstraintEliminationPass,CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LCSSAPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,SROAPass,SimplifyCFGPass,TailCallElimPass