; LLVM IR from sp-nitech/SPTK :: src/analysis (aperiodicity_extraction)

; 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.sptk::AperiodicityExtraction" = type { ptr, ptr }

@_ZTVN4sptk22AperiodicityExtractionE = external dso_local unnamed_addr constant { [4 x ptr] }, align 8

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN4sptk22AperiodicityExtractionC2EiidNS0_10AlgorithmsE(ptr noundef nonnull align 8 dereferenceable(16) %0, i32 noundef %1, i32 noundef %2, double noundef %3, i32 noundef %4) unnamed_addr #0 align 2 personality ptr @__gxx_personality_v0 {
  %6 = alloca ptr, align 8
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca double, align 8
  %10 = alloca i32, align 4
  %11 = alloca ptr, align 8
  %12 = alloca i32, align 4
  store ptr %0, ptr %6, align 8, !tbaa !5
  store i32 %1, ptr %7, align 4, !tbaa !9
  store i32 %2, ptr %8, align 4, !tbaa !9
  store double %3, ptr %9, align 8, !tbaa !11
  store i32 %4, ptr %10, align 4, !tbaa !13
  %13 = load ptr, ptr %6, align 8
  store ptr getelementptr inbounds inrange(-16, 16) ({ [4 x ptr] }, ptr @_ZTVN4sptk22AperiodicityExtractionE, i32 0, i32 0, i32 2), ptr %13, align 8, !tbaa !15
  %14 = load i32, ptr %10, align 4, !tbaa !13
  switch i32 %14, label %37 [
    i32 0, label %15
    i32 1, label %26
  ]

15:                                               ; preds = %5
  %16 = call noalias noundef nonnull ptr @_Znwm(i64 noundef 32) #4
  %17 = load i32, ptr %7, align 4, !tbaa !9
  %18 = load i32, ptr %8, align 4, !tbaa !9
  %19 = load double, ptr %9, align 8, !tbaa !11
  invoke void @_ZN4sptk30AperiodicityExtractionByTandemC1Eiid(ptr noundef nonnull align 8 dereferenceable(25) %16, i32 noundef %17, i32 noundef %18, double noundef %19)
          to label %20 unwind label %22

20:                                               ; preds = %15
  %21 = getelementptr inbounds %"class.sptk::AperiodicityExtraction", ptr %13, i32 0, i32 1
  store ptr %16, ptr %21, align 8, !tbaa !17
  br label %39

22:                                               ; preds = %15
  %23 = landingpad { ptr, i32 }
          cleanup
  %24 = extractvalue { ptr, i32 } %23, 0
  store ptr %24, ptr %11, align 8
  %25 = extractvalue { ptr, i32 } %23, 1
  store i32 %25, ptr %12, align 4
  call void @_ZdlPvm(ptr noundef %16, i64 noundef 32) #5
  br label %40

26:                                               ; preds = %5
  %27 = call noalias noundef nonnull ptr @_Znwm(i64 noundef 32) #4
  %28 = load i32, ptr %7, align 4, !tbaa !9
  %29 = load i32, ptr %8, align 4, !tbaa !9
  %30 = load double, ptr %9, align 8, !tbaa !11
  invoke void @_ZN4sptk29AperiodicityExtractionByWorldC1Eiid(ptr noundef nonnull align 8 dereferenceable(25) %27, i32 noundef %28, i32 noundef %29, double noundef %30)
          to label %31 unwind label %33

31:                                               ; preds = %26
  %32 = getelementptr inbounds %"class.sptk::AperiodicityExtraction", ptr %13, i32 0, i32 1
  store ptr %27, ptr %32, align 8, !tbaa !17
  br label %39

33:                                               ; preds = %26
  %34 = landingpad { ptr, i32 }
          cleanup
  %35 = extractvalue { ptr, i32 } %34, 0
  store ptr %35, ptr %11, align 8
  %36 = extractvalue { ptr, i32 } %34, 1
  store i32 %36, ptr %12, align 4
  call void @_ZdlPvm(ptr noundef %27, i64 noundef 32) #5
  br label %40

37:                                               ; preds = %5
  %38 = getelementptr inbounds %"class.sptk::AperiodicityExtraction", ptr %13, i32 0, i32 1
  store ptr null, ptr %38, align 8, !tbaa !17
  br label %39

39:                                               ; preds = %37, %31, %20
  ret void

40:                                               ; preds = %33, %22
  %41 = load ptr, ptr %11, align 8
  %42 = load i32, ptr %12, align 4
  %43 = insertvalue { ptr, i32 } poison, ptr %41, 0
  %44 = insertvalue { ptr, i32 } %43, i32 %42, 1
  resume { ptr, i32 } %44
}

; Function Attrs: nobuiltin allocsize(0)
declare noundef nonnull ptr @_Znwm(i64 noundef) #1

declare void @_ZN4sptk30AperiodicityExtractionByTandemC1Eiid(ptr noundef nonnull align 8 dereferenceable(25), i32 noundef, i32 noundef, double noundef) unnamed_addr #2

declare i32 @__gxx_personality_v0(...)

; Function Attrs: nobuiltin nounwind
declare void @_ZdlPvm(ptr noundef, i64 noundef) #3

declare void @_ZN4sptk29AperiodicityExtractionByWorldC1Eiid(ptr noundef nonnull align 8 dereferenceable(25), i32 noundef, i32 noundef, double noundef) unnamed_addr #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 = { nobuiltin allocsize(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 = { "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 = { nobuiltin 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 #4 = { builtin allocsize(0) }
attributes #5 = { builtin 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, !12, i64 0}
!12 = !{!"double", !7, i64 0}
!13 = !{!14, !14, i64 0}
!14 = !{!"_ZTSN4sptk22AperiodicityExtraction10AlgorithmsE", !7, i64 0}
!15 = !{!16, !16, i64 0}
!16 = !{!"vtable pointer", !8, i64 0}
!17 = !{!18, !6, i64 8}
!18 = !{!"_ZTSN4sptk22AperiodicityExtractionE", !6, i64 8}


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

@_ZTVN4sptk22AperiodicityExtractionE = external dso_local unnamed_addr constant { [4 x ptr] }, align 8

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN4sptk22AperiodicityExtractionC2EiidNS0_10AlgorithmsE(ptr nocapture noundef nonnull writeonly align 8 dereferenceable(16) %0, i32 noundef %1, i32 noundef %2, double noundef %3, i32 noundef %4) unnamed_addr #0 align 2 personality ptr @__gxx_personality_v0 {
  store ptr getelementptr inbounds inrange(-16, 16) (i8, ptr @_ZTVN4sptk22AperiodicityExtractionE, i64 16), ptr %0, align 8, !tbaa !5
  switch i32 %4, label %14 [
    i32 0, label %6
    i32 1, label %10
  ]

6:                                                ; preds = %5
  %7 = tail call noalias noundef nonnull dereferenceable(32) ptr @_Znwm(i64 noundef 32) #4
  invoke void @_ZN4sptk30AperiodicityExtractionByTandemC1Eiid(ptr noundef nonnull align 8 dereferenceable(25) %7, i32 noundef %1, i32 noundef %2, double noundef %3)
          to label %14 unwind label %8

8:                                                ; preds = %6
  %9 = landingpad { ptr, i32 }
          cleanup
  br label %16

10:                                               ; preds = %5
  %11 = tail call noalias noundef nonnull dereferenceable(32) ptr @_Znwm(i64 noundef 32) #4
  invoke void @_ZN4sptk29AperiodicityExtractionByWorldC1Eiid(ptr noundef nonnull align 8 dereferenceable(25) %11, i32 noundef %1, i32 noundef %2, double noundef %3)
          to label %14 unwind label %12

12:                                               ; preds = %10
  %13 = landingpad { ptr, i32 }
          cleanup
  br label %16

14:                                               ; preds = %5, %10, %6
  %.sink = phi ptr [ %7, %6 ], [ %11, %10 ], [ null, %5 ]
  %15 = getelementptr inbounds i8, ptr %0, i64 8
  store ptr %.sink, ptr %15, align 8, !tbaa !8
  ret void

16:                                               ; preds = %12, %8
  %.sink12 = phi ptr [ %11, %12 ], [ %7, %8 ]
  %.pn = phi { ptr, i32 } [ %13, %12 ], [ %9, %8 ]
  tail call void @_ZdlPvm(ptr noundef nonnull %.sink12, i64 noundef 32) #5
  resume { ptr, i32 } %.pn
}

; Function Attrs: nobuiltin allocsize(0)
declare noundef nonnull ptr @_Znwm(i64 noundef) local_unnamed_addr #1

declare void @_ZN4sptk30AperiodicityExtractionByTandemC1Eiid(ptr noundef nonnull align 8 dereferenceable(25), i32 noundef, i32 noundef, double noundef) unnamed_addr #2

declare i32 @__gxx_personality_v0(...)

; Function Attrs: nobuiltin nounwind
declare void @_ZdlPvm(ptr noundef, i64 noundef) local_unnamed_addr #3

declare void @_ZN4sptk29AperiodicityExtractionByWorldC1Eiid(ptr noundef nonnull align 8 dereferenceable(25), i32 noundef, i32 noundef, double noundef) unnamed_addr #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 = { nobuiltin allocsize(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 = { "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 = { nobuiltin 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 #4 = { builtin allocsize(0) }
attributes #5 = { builtin 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 = !{!"vtable pointer", !7, i64 0}
!7 = !{!"Simple C++ TBAA"}
!8 = !{!9, !10, i64 8}
!9 = !{!"_ZTSN4sptk22AperiodicityExtractionE", !10, i64 8}
!10 = !{!"any pointer", !11, i64 0}
!11 = !{!"omnipotent char", !7, i64 0}


; Effective O3 passes: CorrelatedValuePropagationPass,GlobalOptPass,InstCombinePass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass