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

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

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

declare noundef ptr @_ZN7CxxTest13GlobalFixture18firstGlobalFixtureEv() #1

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

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

; Function Attrs: mustprogress uwtable
define dso_local noundef zeroext i1 @_ZN7CxxTest20RealWorldDescription5setUpEv(ptr noundef nonnull align 8 dereferenceable(25) %0) #2 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
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #4
  %8 = call noundef ptr @_ZN7CxxTest13GlobalFixture18firstGlobalFixtureEv()
  store ptr %8, ptr %4, align 8, !tbaa !5
  br label %9

9:                                                ; preds = %32, %1
  %10 = load ptr, ptr %4, align 8, !tbaa !5
  %11 = icmp ne ptr %10, null
  br i1 %11, label %13, label %12

12:                                               ; preds = %9
  store i32 2, ptr %5, align 4
  br label %35

13:                                               ; preds = %9
  call void @llvm.lifetime.start.p0(i64 1, ptr %6) #4
  %14 = load ptr, ptr %4, align 8, !tbaa !5
  %15 = load ptr, ptr %14, align 8, !tbaa !9
  %16 = getelementptr inbounds ptr, ptr %15, i64 2
  %17 = load ptr, ptr %16, align 8
  %18 = call noundef zeroext i1 %17(ptr noundef nonnull align 8 dereferenceable(25) %14)
  %19 = zext i1 %18 to i8
  store i8 %19, ptr %6, align 1, !tbaa !11
  %20 = call noundef nonnull align 8 dereferenceable(176) ptr @_ZN7CxxTest7trackerEv()
  %21 = call noundef zeroext i1 @_ZNK7CxxTest11TestTracker10testFailedEv(ptr noundef nonnull align 8 dereferenceable(176) %20)
  br i1 %21, label %22, label %24

22:                                               ; preds = %13
  %23 = call noundef nonnull align 8 dereferenceable(176) ptr @_ZN7CxxTest7trackerEv()
  call void @_ZN7CxxTest11TestTracker10initializeEv(ptr noundef nonnull align 8 dereferenceable(176) %23)
  store i8 0, ptr %6, align 1, !tbaa !11
  br label %24

24:                                               ; preds = %22, %13
  %25 = load i8, ptr %6, align 1, !tbaa !11, !range !13, !noundef !14
  %26 = trunc i8 %25 to i1
  br i1 %26, label %28, label %27

27:                                               ; preds = %24
  call void @_ZN7CxxTest20RealWorldDescription11reportErrorEPKc(ptr noundef @.str.2)
  store i1 false, ptr %2, align 1
  store i32 1, ptr %5, align 4
  br label %29

28:                                               ; preds = %24
  store i32 0, ptr %5, align 4
  br label %29

29:                                               ; preds = %28, %27
  call void @llvm.lifetime.end.p0(i64 1, ptr %6) #4
  %30 = load i32, ptr %5, align 4
  switch i32 %30, label %35 [
    i32 0, label %31
  ]

31:                                               ; preds = %29
  br label %32

32:                                               ; preds = %31
  %33 = load ptr, ptr %4, align 8, !tbaa !5
  %34 = call noundef ptr @_ZN7CxxTest13GlobalFixture17nextGlobalFixtureEv(ptr noundef nonnull align 8 dereferenceable(25) %33)
  store ptr %34, ptr %4, align 8, !tbaa !5
  br label %9, !llvm.loop !15

35:                                               ; preds = %29, %12
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #4
  %36 = load i32, ptr %5, align 4
  switch i32 %36, label %40 [
    i32 2, label %37
    i32 1, label %38
  ]

37:                                               ; preds = %35
  store i1 true, ptr %2, align 1
  br label %38

38:                                               ; preds = %37, %35
  %39 = load i1, ptr %2, align 1
  ret i1 %39

40:                                               ; preds = %35
  unreachable
}

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef nonnull align 8 dereferenceable(176) ptr @_ZN7CxxTest7trackerEv() #3

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

declare void @_ZN7CxxTest11TestTracker10initializeEv(ptr noundef nonnull align 8 dereferenceable(176)) #1

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN7CxxTest20RealWorldDescription11reportErrorEPKc(ptr noundef) #2 align 2

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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" }
attributes #2 = { 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 #3 = { inlinehint 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 #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 = !{!"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.2 = external hidden unnamed_addr constant [23 x i8], align 1

declare noundef ptr @_ZN7CxxTest13GlobalFixture18firstGlobalFixtureEv() local_unnamed_addr #0

declare noundef ptr @_ZN7CxxTest13GlobalFixture17nextGlobalFixtureEv(ptr noundef nonnull align 8 dereferenceable(25)) local_unnamed_addr #0

; Function Attrs: mustprogress uwtable
define dso_local noundef zeroext i1 @_ZN7CxxTest20RealWorldDescription5setUpEv(ptr nocapture noundef nonnull readnone align 8 dereferenceable(25) %0) local_unnamed_addr #1 align 2 {
  %2 = tail call noundef ptr @_ZN7CxxTest13GlobalFixture18firstGlobalFixtureEv()
  %.not18 = icmp eq ptr %2, null
  br i1 %.not18, label %.loopexit, label %.lr.ph

.lr.ph:                                           ; preds = %1, %.critedge
  %.0819 = phi ptr [ %11, %.critedge ], [ %2, %1 ]
  %3 = load ptr, ptr %.0819, align 8, !tbaa !5
  %4 = getelementptr inbounds i8, ptr %3, i64 16
  %5 = load ptr, ptr %4, align 8
  %6 = tail call noundef zeroext i1 %5(ptr noundef nonnull align 8 dereferenceable(25) %.0819)
  %7 = tail call noundef nonnull align 8 dereferenceable(176) ptr @_ZN7CxxTest7trackerEv()
  %8 = tail call noundef zeroext i1 @_ZNK7CxxTest11TestTracker10testFailedEv(ptr noundef nonnull align 8 dereferenceable(176) %7)
  br i1 %8, label %.critedge12, label %10

.critedge12:                                      ; preds = %.lr.ph
  %9 = tail call noundef nonnull align 8 dereferenceable(176) ptr @_ZN7CxxTest7trackerEv()
  tail call void @_ZN7CxxTest11TestTracker10initializeEv(ptr noundef nonnull align 8 dereferenceable(176) %9)
  br label %.loopexit13

10:                                               ; preds = %.lr.ph
  br i1 %6, label %.critedge, label %.loopexit13

.loopexit13:                                      ; preds = %10, %.critedge12
  tail call void @_ZN7CxxTest20RealWorldDescription11reportErrorEPKc(ptr noundef nonnull @.str.2)
  br label %.loopexit

.critedge:                                        ; preds = %10
  %11 = tail call noundef ptr @_ZN7CxxTest13GlobalFixture17nextGlobalFixtureEv(ptr noundef nonnull align 8 dereferenceable(25) %.0819)
  %.not = icmp eq ptr %11, null
  br i1 %.not, label %.loopexit, label %.lr.ph, !llvm.loop !8

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

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef nonnull align 8 dereferenceable(176) ptr @_ZN7CxxTest7trackerEv() local_unnamed_addr #2

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

declare void @_ZN7CxxTest11TestTracker10initializeEv(ptr noundef nonnull align 8 dereferenceable(176)) local_unnamed_addr #0

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN7CxxTest20RealWorldDescription11reportErrorEPKc(ptr noundef) local_unnamed_addr #1 align 2

attributes #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 = { 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 = { inlinehint 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" }

!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,GVNPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LCSSAPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass