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

; 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 = external hidden unnamed_addr constant [32 x i8], align 1

; Function Attrs: mustprogress uwtable
define dso_local noundef zeroext i1 @_ZN7CxxTest19RealTestDescription5setUpEv(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
  %7 = alloca i8, align 1
  store ptr %0, ptr %3, align 8, !tbaa !5
  %8 = load ptr, ptr %3, align 8
  %9 = call noundef ptr @_ZNK7CxxTest19RealTestDescription5suiteEv(ptr noundef nonnull align 8 dereferenceable(56) %8)
  %10 = icmp ne ptr %9, null
  br i1 %10, label %12, label %11

11:                                               ; preds = %1
  store i1 false, ptr %2, align 1
  br label %61

12:                                               ; preds = %1
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #3
  %13 = call noundef ptr @_ZN7CxxTest13GlobalFixture18firstGlobalFixtureEv()
  store ptr %13, ptr %4, align 8, !tbaa !5
  br label %14

14:                                               ; preds = %40, %12
  %15 = load ptr, ptr %4, align 8, !tbaa !5
  %16 = icmp ne ptr %15, null
  br i1 %16, label %18, label %17

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

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

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

36:                                               ; preds = %18
  store i32 0, ptr %5, align 4
  br label %37

37:                                               ; preds = %36, %27
  call void @llvm.lifetime.end.p0(i64 1, ptr %6) #3
  %38 = load i32, ptr %5, align 4
  switch i32 %38, label %43 [
    i32 0, label %39
  ]

39:                                               ; preds = %37
  br label %40

40:                                               ; preds = %39
  %41 = load ptr, ptr %4, align 8, !tbaa !5
  %42 = call noundef ptr @_ZN7CxxTest13GlobalFixture17nextGlobalFixtureEv(ptr noundef nonnull align 8 dereferenceable(25) %41)
  store ptr %42, ptr %4, align 8, !tbaa !5
  br label %14, !llvm.loop !15

43:                                               ; preds = %37, %17
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #3
  %44 = load i32, ptr %5, align 4
  switch i32 %44, label %63 [
    i32 2, label %45
    i32 1, label %61
  ]

45:                                               ; preds = %43
  call void @llvm.lifetime.start.p0(i64 1, ptr %7) #3
  store i8 0, ptr %7, align 1, !tbaa !11
  %46 = call noundef ptr @_ZNK7CxxTest19RealTestDescription5suiteEv(ptr noundef nonnull align 8 dereferenceable(56) %8)
  %47 = load ptr, ptr %46, align 8, !tbaa !9
  %48 = getelementptr inbounds ptr, ptr %47, i64 2
  %49 = load ptr, ptr %48, align 8
  call void %49(ptr noundef nonnull align 8 dereferenceable(8) %46)
  store i8 1, ptr %7, align 1, !tbaa !11
  %50 = load i8, ptr %7, align 1, !tbaa !11, !range !13, !noundef !14
  %51 = trunc i8 %50 to i1
  %52 = zext i1 %51 to i32
  %53 = icmp eq i32 %52, 0
  br i1 %53, label %54, label %57

54:                                               ; preds = %45
  %55 = load i8, ptr %7, align 1, !tbaa !11, !range !13, !noundef !14
  %56 = trunc i8 %55 to i1
  store i1 %56, ptr %2, align 1
  store i32 1, ptr %5, align 4
  br label %58

57:                                               ; preds = %45
  store i32 0, ptr %5, align 4
  br label %58

58:                                               ; preds = %57, %54
  call void @llvm.lifetime.end.p0(i64 1, ptr %7) #3
  %59 = load i32, ptr %5, align 4
  switch i32 %59, label %63 [
    i32 0, label %60
    i32 1, label %61
  ]

60:                                               ; preds = %58
  store i1 true, ptr %2, align 1
  br label %61

61:                                               ; preds = %60, %58, %43, %11
  %62 = load i1, ptr %2, align 1
  ret i1 %62

63:                                               ; preds = %58, %43
  unreachable
}

; 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 noundef ptr @_ZN7CxxTest13GlobalFixture18firstGlobalFixtureEv() #2

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

declare noundef ptr @_ZN7CxxTest13GlobalFixture17nextGlobalFixtureEv(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 = external hidden unnamed_addr constant [32 x i8], align 1

; Function Attrs: mustprogress uwtable
define dso_local noundef zeroext i1 @_ZN7CxxTest19RealTestDescription5setUpEv(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 %23, label %3

3:                                                ; preds = %1
  %4 = tail call noundef ptr @_ZN7CxxTest13GlobalFixture18firstGlobalFixtureEv()
  %.not1418 = icmp eq ptr %4, null
  br i1 %.not1418, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %3, %.critedge
  %.01319 = phi ptr [ %9, %.critedge ], [ %4, %3 ]
  %5 = load ptr, ptr %.01319, align 8, !tbaa !5
  %6 = getelementptr inbounds i8, ptr %5, i64 32
  %7 = load ptr, ptr %6, align 8
  %8 = tail call noundef zeroext i1 %7(ptr noundef nonnull align 8 dereferenceable(25) %.01319)
  br i1 %8, label %.critedge, label %10

.critedge:                                        ; preds = %.lr.ph
  %9 = tail call noundef ptr @_ZN7CxxTest13GlobalFixture17nextGlobalFixtureEv(ptr noundef nonnull align 8 dereferenceable(25) %.01319)
  %.not14 = icmp eq ptr %9, null
  br i1 %.not14, label %._crit_edge, label %.lr.ph, !llvm.loop !8

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

._crit_edge:                                      ; preds = %.critedge, %3
  %19 = tail call noundef ptr @_ZNK7CxxTest19RealTestDescription5suiteEv(ptr noundef nonnull align 8 dereferenceable(56) %0)
  %20 = load ptr, ptr %19, align 8, !tbaa !5
  %21 = getelementptr inbounds i8, ptr %20, i64 16
  %22 = load ptr, ptr %21, align 8
  tail call void %22(ptr noundef nonnull align 8 dereferenceable(8) %19)
  br label %23

23:                                               ; preds = %10, %1, %._crit_edge
  %.4 = phi i1 [ false, %10 ], [ true, %._crit_edge ], [ false, %1 ]
  ret i1 %.4
}

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

declare noundef ptr @_ZN7CxxTest13GlobalFixture18firstGlobalFixtureEv() local_unnamed_addr #1

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

declare noundef ptr @_ZN7CxxTest13GlobalFixture17nextGlobalFixtureEv(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: CorrelatedValuePropagationPass,EarlyCSEPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,SROAPass,SimplifyCFGPass,TailCallElimPass