; LLVM IR from Compaile/ctrack :: examples/complex_multithreaded_puzzle.ll (Z14recursive_worki)

; 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.ctrack::vCTRACK_VERSION_MAJOR_CTRACK_VERSION_MINOR_CTRACK_VERSION_PATCH::EventHandler" = type <{ %"class.std::chrono::time_point", i32, i32, %"class.std::basic_string_view", %"class.std::basic_string_view", i32, i32, i32, [4 x i8] }>
%"class.std::chrono::time_point" = type { %"class.std::chrono::duration" }
%"class.std::chrono::duration" = type { i64 }
%"class.std::basic_string_view" = type { i64, ptr }

@.str.19 = external hidden unnamed_addr constant [91 x i8], align 1
@.str.21 = external hidden unnamed_addr constant [15 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 i32 @__gxx_personality_v0(...)

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

; Function Attrs: nounwind
declare i64 @_ZNSt6chrono3_V212system_clock3nowEv() #1

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z15sleepy_functioni(i32 noundef) #2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN6ctrack63vCTRACK_VERSION_MAJOR_CTRACK_VERSION_MINOR_CTRACK_VERSION_PATCH12EventHandlerC2EiPKcS3_NSt6chrono10time_pointINS4_3_V212system_clockENS4_8durationIlSt5ratioILl1ELl1000000000EEEEEE(ptr noundef nonnull align 8 dereferenceable(60), i32 noundef, ptr noundef, ptr noundef, i64) unnamed_addr #2 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN6ctrack63vCTRACK_VERSION_MAJOR_CTRACK_VERSION_MINOR_CTRACK_VERSION_PATCH12EventHandlerD2Ev(ptr noundef nonnull align 8 dereferenceable(60)) unnamed_addr #3 align 2

; Function Attrs: mustprogress uwtable
define dso_local noundef i32 @_Z14recursive_worki(i32 noundef %0) #2 personality ptr @__gxx_personality_v0 {
  %2 = alloca i32, align 4
  %3 = alloca i32, align 4
  %4 = alloca %"class.ctrack::vCTRACK_VERSION_MAJOR_CTRACK_VERSION_MINOR_CTRACK_VERSION_PATCH::EventHandler", align 8
  %5 = alloca %"class.std::chrono::time_point", align 8
  %6 = alloca i32, align 4
  %7 = alloca ptr, align 8
  %8 = alloca i32, align 4
  store i32 %0, ptr %3, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 64, ptr %4) #4
  %9 = call i64 @_ZNSt6chrono3_V212system_clock3nowEv() #4
  %10 = getelementptr inbounds %"class.std::chrono::time_point", ptr %5, i32 0, i32 0
  %11 = getelementptr inbounds %"class.std::chrono::duration", ptr %10, i32 0, i32 0
  store i64 %9, ptr %11, align 8
  %12 = getelementptr inbounds %"class.std::chrono::time_point", ptr %5, i32 0, i32 0
  %13 = getelementptr inbounds %"class.std::chrono::duration", ptr %12, i32 0, i32 0
  %14 = load i64, ptr %13, align 8
  call void @_ZN6ctrack63vCTRACK_VERSION_MAJOR_CTRACK_VERSION_MINOR_CTRACK_VERSION_PATCH12EventHandlerC2EiPKcS3_NSt6chrono10time_pointINS4_3_V212system_clockENS4_8durationIlSt5ratioILl1ELl1000000000EEEEEE(ptr noundef nonnull align 8 dereferenceable(60) %4, i32 noundef 19, ptr noundef @.str.19, ptr noundef @.str.21, i64 %14)
  %15 = load i32, ptr %3, align 4, !tbaa !5
  %16 = icmp sle i32 %15, 1
  br i1 %16, label %17, label %18

17:                                               ; preds = %1
  store i32 1, ptr %2, align 4
  store i32 1, ptr %6, align 4
  br label %33

18:                                               ; preds = %1
  invoke void @_Z15sleepy_functioni(i32 noundef 1)
          to label %19 unwind label %29

19:                                               ; preds = %18
  %20 = load i32, ptr %3, align 4, !tbaa !5
  %21 = sub nsw i32 %20, 1
  %22 = invoke noundef i32 @_Z14recursive_worki(i32 noundef %21)
          to label %23 unwind label %29

23:                                               ; preds = %19
  %24 = load i32, ptr %3, align 4, !tbaa !5
  %25 = sub nsw i32 %24, 2
  %26 = invoke noundef i32 @_Z14recursive_worki(i32 noundef %25)
          to label %27 unwind label %29

27:                                               ; preds = %23
  %28 = add nsw i32 %22, %26
  store i32 %28, ptr %2, align 4
  store i32 1, ptr %6, align 4
  br label %33

29:                                               ; preds = %23, %19, %18
  %30 = landingpad { ptr, i32 }
          cleanup
  %31 = extractvalue { ptr, i32 } %30, 0
  store ptr %31, ptr %7, align 8
  %32 = extractvalue { ptr, i32 } %30, 1
  store i32 %32, ptr %8, align 4
  call void @_ZN6ctrack63vCTRACK_VERSION_MAJOR_CTRACK_VERSION_MINOR_CTRACK_VERSION_PATCH12EventHandlerD2Ev(ptr noundef nonnull align 8 dereferenceable(60) %4) #4
  call void @llvm.lifetime.end.p0(i64 64, ptr %4) #4
  br label %35

33:                                               ; preds = %27, %17
  call void @_ZN6ctrack63vCTRACK_VERSION_MAJOR_CTRACK_VERSION_MINOR_CTRACK_VERSION_PATCH12EventHandlerD2Ev(ptr noundef nonnull align 8 dereferenceable(60) %4) #4
  call void @llvm.lifetime.end.p0(i64 64, ptr %4) #4
  %34 = load i32, ptr %2, align 4
  ret i32 %34

35:                                               ; preds = %29
  %36 = load ptr, ptr %7, align 8
  %37 = load i32, ptr %8, align 4
  %38 = insertvalue { ptr, i32 } poison, ptr %36, 0
  %39 = insertvalue { ptr, i32 } %38, i32 %37, 1
  resume { ptr, i32 } %39
}

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


; 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.ctrack::vCTRACK_VERSION_MAJOR_CTRACK_VERSION_MINOR_CTRACK_VERSION_PATCH::EventHandler" = type <{ %"class.std::chrono::time_point", i32, i32, %"class.std::basic_string_view", %"class.std::basic_string_view", i32, i32, i32, [4 x i8] }>
%"class.std::chrono::time_point" = type { %"class.std::chrono::duration" }
%"class.std::chrono::duration" = type { i64 }
%"class.std::basic_string_view" = type { i64, ptr }

@.str.19 = external hidden unnamed_addr constant [91 x i8], align 1
@.str.21 = external hidden unnamed_addr constant [15 x i8], align 1

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

declare i32 @__gxx_personality_v0(...)

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

; Function Attrs: nounwind
declare i64 @_ZNSt6chrono3_V212system_clock3nowEv() local_unnamed_addr #1

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z15sleepy_functioni(i32 noundef) local_unnamed_addr #2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN6ctrack63vCTRACK_VERSION_MAJOR_CTRACK_VERSION_MINOR_CTRACK_VERSION_PATCH12EventHandlerC2EiPKcS3_NSt6chrono10time_pointINS4_3_V212system_clockENS4_8durationIlSt5ratioILl1ELl1000000000EEEEEE(ptr noundef nonnull align 8 dereferenceable(60), i32 noundef, ptr noundef, ptr noundef, i64) unnamed_addr #2 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN6ctrack63vCTRACK_VERSION_MAJOR_CTRACK_VERSION_MINOR_CTRACK_VERSION_PATCH12EventHandlerD2Ev(ptr noundef nonnull align 8 dereferenceable(60)) unnamed_addr #3 align 2

; Function Attrs: mustprogress uwtable
define dso_local noundef i32 @_Z14recursive_worki(i32 noundef %0) local_unnamed_addr #2 personality ptr @__gxx_personality_v0 {
  %2 = alloca %"class.ctrack::vCTRACK_VERSION_MAJOR_CTRACK_VERSION_MINOR_CTRACK_VERSION_PATCH::EventHandler", align 8
  call void @llvm.lifetime.start.p0(i64 64, ptr nonnull %2) #4
  %3 = tail call i64 @_ZNSt6chrono3_V212system_clock3nowEv() #4
  call void @_ZN6ctrack63vCTRACK_VERSION_MAJOR_CTRACK_VERSION_MINOR_CTRACK_VERSION_PATCH12EventHandlerC2EiPKcS3_NSt6chrono10time_pointINS4_3_V212system_clockENS4_8durationIlSt5ratioILl1ELl1000000000EEEEEE(ptr noundef nonnull align 8 dereferenceable(60) %2, i32 noundef 19, ptr noundef nonnull @.str.19, ptr noundef nonnull @.str.21, i64 %3)
  %4 = icmp slt i32 %0, 2
  br i1 %4, label %16, label %5

5:                                                ; preds = %1
  invoke void @_Z15sleepy_functioni(i32 noundef 1)
          to label %6 unwind label %14

6:                                                ; preds = %5
  %7 = add nsw i32 %0, -1
  %8 = invoke noundef i32 @_Z14recursive_worki(i32 noundef %7)
          to label %9 unwind label %14

9:                                                ; preds = %6
  %10 = add nsw i32 %0, -2
  %11 = invoke noundef i32 @_Z14recursive_worki(i32 noundef %10)
          to label %12 unwind label %14

12:                                               ; preds = %9
  %13 = add nsw i32 %11, %8
  br label %16

14:                                               ; preds = %9, %6, %5
  %15 = landingpad { ptr, i32 }
          cleanup
  call void @_ZN6ctrack63vCTRACK_VERSION_MAJOR_CTRACK_VERSION_MINOR_CTRACK_VERSION_PATCH12EventHandlerD2Ev(ptr noundef nonnull align 8 dereferenceable(60) %2) #4
  call void @llvm.lifetime.end.p0(i64 64, ptr nonnull %2) #4
  resume { ptr, i32 } %15

16:                                               ; preds = %1, %12
  %.0 = phi i32 [ %13, %12 ], [ 1, %1 ]
  call void @_ZN6ctrack63vCTRACK_VERSION_MAJOR_CTRACK_VERSION_MINOR_CTRACK_VERSION_PATCH12EventHandlerD2Ev(ptr noundef nonnull align 8 dereferenceable(60) %2) #4
  call void @llvm.lifetime.end.p0(i64 64, ptr nonnull %2) #4
  ret i32 %.0
}

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


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass