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

; 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::ZeroCrossingAnalysis" = type <{ ptr, i32, i8, [3 x i8] }>
%"class.sptk::ZeroCrossingAnalysis::Buffer" = type { ptr, i8, double }

; Function Attrs: mustprogress uwtable
define dso_local noundef zeroext i1 @_ZNK4sptk20ZeroCrossingAnalysis3RunERKSt6vectorIdSaIdEEPiPNS0_6BufferE(ptr noundef nonnull align 8 dereferenceable(13) %0, ptr noundef nonnull align 8 dereferenceable(24) %1, ptr noundef %2, ptr noundef %3) #0 align 2 {
  %5 = alloca i1, align 1
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  %10 = alloca ptr, align 8
  %11 = alloca i32, align 4
  %12 = alloca i32, align 4
  store ptr %0, ptr %6, align 8, !tbaa !5
  store ptr %1, ptr %7, align 8, !tbaa !5
  store ptr %2, ptr %8, align 8, !tbaa !5
  store ptr %3, ptr %9, align 8, !tbaa !5
  %13 = load ptr, ptr %6, align 8
  %14 = getelementptr inbounds %"class.sptk::ZeroCrossingAnalysis", ptr %13, i32 0, i32 2
  %15 = load i8, ptr %14, align 4, !tbaa !9, !range !13, !noundef !14
  %16 = trunc i8 %15 to i1
  br i1 %16, label %17, label %30

17:                                               ; preds = %4
  %18 = load ptr, ptr %7, align 8, !tbaa !5
  %19 = call noundef i64 @_ZNKSt6vectorIdSaIdEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %18) #3
  %20 = getelementptr inbounds %"class.sptk::ZeroCrossingAnalysis", ptr %13, i32 0, i32 1
  %21 = load i32, ptr %20, align 8, !tbaa !15
  %22 = sext i32 %21 to i64
  %23 = icmp ne i64 %19, %22
  br i1 %23, label %30, label %24

24:                                               ; preds = %17
  %25 = load ptr, ptr %8, align 8, !tbaa !5
  %26 = icmp eq ptr null, %25
  br i1 %26, label %30, label %27

27:                                               ; preds = %24
  %28 = load ptr, ptr %9, align 8, !tbaa !5
  %29 = icmp eq ptr null, %28
  br i1 %29, label %30, label %31

30:                                               ; preds = %27, %24, %17, %4
  store i1 false, ptr %5, align 1
  br label %96

31:                                               ; preds = %27
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #3
  %32 = load ptr, ptr %7, align 8, !tbaa !5
  %33 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNKSt6vectorIdSaIdEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %32, i64 noundef 0) #3
  store ptr %33, ptr %10, align 8, !tbaa !5
  %34 = load ptr, ptr %9, align 8, !tbaa !5
  %35 = getelementptr inbounds %"class.sptk::ZeroCrossingAnalysis::Buffer", ptr %34, i32 0, i32 1
  %36 = load i8, ptr %35, align 8, !tbaa !16, !range !13, !noundef !14
  %37 = trunc i8 %36 to i1
  br i1 %37, label %38, label %46

38:                                               ; preds = %31
  %39 = load ptr, ptr %10, align 8, !tbaa !5
  %40 = getelementptr inbounds double, ptr %39, i64 0
  %41 = load double, ptr %40, align 8, !tbaa !19
  %42 = load ptr, ptr %9, align 8, !tbaa !5
  %43 = getelementptr inbounds %"class.sptk::ZeroCrossingAnalysis::Buffer", ptr %42, i32 0, i32 2
  store double %41, ptr %43, align 8, !tbaa !20
  %44 = load ptr, ptr %9, align 8, !tbaa !5
  %45 = getelementptr inbounds %"class.sptk::ZeroCrossingAnalysis::Buffer", ptr %44, i32 0, i32 1
  store i8 0, ptr %45, align 8, !tbaa !16
  br label %46

46:                                               ; preds = %38, %31
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #3
  store i32 0, ptr %11, align 4, !tbaa !21
  %47 = load ptr, ptr %9, align 8, !tbaa !5
  %48 = getelementptr inbounds %"class.sptk::ZeroCrossingAnalysis::Buffer", ptr %47, i32 0, i32 2
  %49 = load double, ptr %48, align 8, !tbaa !20
  %50 = load ptr, ptr %10, align 8, !tbaa !5
  %51 = getelementptr inbounds double, ptr %50, i64 0
  %52 = load double, ptr %51, align 8, !tbaa !19
  %53 = call noundef zeroext i1 @_ZN12_GLOBAL__N_19IsCrossedEdd(double noundef %49, double noundef %52)
  br i1 %53, label %54, label %57

54:                                               ; preds = %46
  %55 = load i32, ptr %11, align 4, !tbaa !21
  %56 = add nsw i32 %55, 1
  store i32 %56, ptr %11, align 4, !tbaa !21
  br label %57

57:                                               ; preds = %54, %46
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #3
  store i32 1, ptr %12, align 4, !tbaa !21
  br label %58

58:                                               ; preds = %81, %57
  %59 = load i32, ptr %12, align 4, !tbaa !21
  %60 = getelementptr inbounds %"class.sptk::ZeroCrossingAnalysis", ptr %13, i32 0, i32 1
  %61 = load i32, ptr %60, align 8, !tbaa !15
  %62 = icmp slt i32 %59, %61
  br i1 %62, label %64, label %63

63:                                               ; preds = %58
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #3
  br label %84

64:                                               ; preds = %58
  %65 = load ptr, ptr %10, align 8, !tbaa !5
  %66 = load i32, ptr %12, align 4, !tbaa !21
  %67 = sub nsw i32 %66, 1
  %68 = sext i32 %67 to i64
  %69 = getelementptr inbounds double, ptr %65, i64 %68
  %70 = load double, ptr %69, align 8, !tbaa !19
  %71 = load ptr, ptr %10, align 8, !tbaa !5
  %72 = load i32, ptr %12, align 4, !tbaa !21
  %73 = sext i32 %72 to i64
  %74 = getelementptr inbounds double, ptr %71, i64 %73
  %75 = load double, ptr %74, align 8, !tbaa !19
  %76 = call noundef zeroext i1 @_ZN12_GLOBAL__N_19IsCrossedEdd(double noundef %70, double noundef %75)
  br i1 %76, label %77, label %80

77:                                               ; preds = %64
  %78 = load i32, ptr %11, align 4, !tbaa !21
  %79 = add nsw i32 %78, 1
  store i32 %79, ptr %11, align 4, !tbaa !21
  br label %80

80:                                               ; preds = %77, %64
  br label %81

81:                                               ; preds = %80
  %82 = load i32, ptr %12, align 4, !tbaa !21
  %83 = add nsw i32 %82, 1
  store i32 %83, ptr %12, align 4, !tbaa !21
  br label %58, !llvm.loop !22

84:                                               ; preds = %63
  %85 = load ptr, ptr %10, align 8, !tbaa !5
  %86 = getelementptr inbounds %"class.sptk::ZeroCrossingAnalysis", ptr %13, i32 0, i32 1
  %87 = load i32, ptr %86, align 8, !tbaa !15
  %88 = sub nsw i32 %87, 1
  %89 = sext i32 %88 to i64
  %90 = getelementptr inbounds double, ptr %85, i64 %89
  %91 = load double, ptr %90, align 8, !tbaa !19
  %92 = load ptr, ptr %9, align 8, !tbaa !5
  %93 = getelementptr inbounds %"class.sptk::ZeroCrossingAnalysis::Buffer", ptr %92, i32 0, i32 2
  store double %91, ptr %93, align 8, !tbaa !20
  %94 = load i32, ptr %11, align 4, !tbaa !21
  %95 = load ptr, ptr %8, align 8, !tbaa !5
  store i32 %94, ptr %95, align 4, !tbaa !21
  store i1 true, ptr %5, align 1
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #3
  br label %96

96:                                               ; preds = %84, %30
  %97 = load i1, ptr %5, align 1
  ret i1 %97
}

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i64 @_ZNKSt6vectorIdSaIdEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24)) #1 align 2

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(8) ptr @_ZNKSt6vectorIdSaIdEEixEm(ptr noundef nonnull align 8 dereferenceable(24), i64 noundef) #1 align 2

; Function Attrs: mustprogress nounwind uwtable
declare hidden noundef zeroext i1 @_ZN12_GLOBAL__N_19IsCrossedEdd(double noundef, double noundef) #1

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #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 = { 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 #2 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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, !12, i64 12}
!10 = !{!"_ZTSN4sptk20ZeroCrossingAnalysisE", !11, i64 8, !12, i64 12}
!11 = !{!"int", !7, i64 0}
!12 = !{!"bool", !7, i64 0}
!13 = !{i8 0, i8 2}
!14 = !{}
!15 = !{!10, !11, i64 8}
!16 = !{!17, !12, i64 8}
!17 = !{!"_ZTSN4sptk20ZeroCrossingAnalysis6BufferE", !12, i64 8, !18, i64 16}
!18 = !{!"double", !7, i64 0}
!19 = !{!18, !18, i64 0}
!20 = !{!17, !18, i64 16}
!21 = !{!11, !11, i64 0}
!22 = distinct !{!22, !23}
!23 = !{!"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"

; Function Attrs: mustprogress nounwind uwtable
define dso_local noundef zeroext i1 @_ZNK4sptk20ZeroCrossingAnalysis3RunERKSt6vectorIdSaIdEEPiPNS0_6BufferE(ptr nocapture noundef nonnull readonly align 8 dereferenceable(13) %0, ptr noundef nonnull align 8 dereferenceable(24) %1, ptr noundef writeonly %2, ptr noundef %3) local_unnamed_addr #0 align 2 {
  %5 = getelementptr inbounds i8, ptr %0, i64 12
  %6 = load i8, ptr %5, align 4, !tbaa !5, !range !11, !noundef !12
  %7 = trunc nuw i8 %6 to i1
  br i1 %7, label %8, label %43

8:                                                ; preds = %4
  %9 = tail call noundef i64 @_ZNKSt6vectorIdSaIdEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %1) #1
  %10 = getelementptr inbounds i8, ptr %0, i64 8
  %11 = load i32, ptr %10, align 8, !tbaa !13
  %12 = sext i32 %11 to i64
  %13 = icmp ne i64 %9, %12
  %14 = icmp eq ptr %2, null
  %or.cond = or i1 %14, %13
  %15 = icmp eq ptr %3, null
  %or.cond3 = or i1 %15, %or.cond
  br i1 %or.cond3, label %43, label %16

16:                                               ; preds = %8
  %17 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZNKSt6vectorIdSaIdEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %1, i64 noundef 0) #1
  %18 = getelementptr inbounds i8, ptr %3, i64 8
  %19 = load i8, ptr %18, align 8, !tbaa !14, !range !11, !noundef !12
  %20 = trunc nuw i8 %19 to i1
  br i1 %20, label %21, label %._crit_edge37

._crit_edge37:                                    ; preds = %16
  %.phi.trans.insert = getelementptr inbounds i8, ptr %3, i64 16
  %.pre = load double, ptr %.phi.trans.insert, align 8, !tbaa !17
  %.pre38 = load double, ptr %17, align 8, !tbaa !18
  br label %24

21:                                               ; preds = %16
  %22 = load double, ptr %17, align 8, !tbaa !18
  %23 = getelementptr inbounds i8, ptr %3, i64 16
  store double %22, ptr %23, align 8, !tbaa !17
  store i8 0, ptr %18, align 8, !tbaa !14
  br label %24

24:                                               ; preds = %._crit_edge37, %21
  %25 = phi double [ %.pre38, %._crit_edge37 ], [ %22, %21 ]
  %26 = phi double [ %.pre, %._crit_edge37 ], [ %22, %21 ]
  %27 = getelementptr inbounds i8, ptr %3, i64 16
  %28 = tail call noundef zeroext i1 @_ZN12_GLOBAL__N_19IsCrossedEdd(double noundef %26, double noundef %25)
  %spec.select = zext i1 %28 to i32
  %29 = load i32, ptr %10, align 8, !tbaa !13
  %30 = icmp sgt i32 %29, 1
  br i1 %30, label %.lr.ph, label %.._crit_edge_crit_edge

.._crit_edge_crit_edge:                           ; preds = %24
  %.pre39 = sext i32 %29 to i64
  br label %._crit_edge

._crit_edge:                                      ; preds = %.lr.ph, %.._crit_edge_crit_edge
  %.pre-phi = phi i64 [ %.pre39, %.._crit_edge_crit_edge ], [ %41, %.lr.ph ]
  %.1.lcssa = phi i32 [ %spec.select, %.._crit_edge_crit_edge ], [ %spec.select31, %.lr.ph ]
  %31 = getelementptr double, ptr %17, i64 %.pre-phi
  %32 = getelementptr i8, ptr %31, i64 -8
  %33 = load double, ptr %32, align 8, !tbaa !18
  store double %33, ptr %27, align 8, !tbaa !17
  store i32 %.1.lcssa, ptr %2, align 4, !tbaa !19
  br label %43

.lr.ph:                                           ; preds = %24, %.lr.ph
  %indvars.iv = phi i64 [ %indvars.iv.next, %.lr.ph ], [ 1, %24 ]
  %.132 = phi i32 [ %spec.select31, %.lr.ph ], [ %spec.select, %24 ]
  %34 = getelementptr double, ptr %17, i64 %indvars.iv
  %35 = getelementptr i8, ptr %34, i64 -8
  %36 = load double, ptr %35, align 8, !tbaa !18
  %37 = load double, ptr %34, align 8, !tbaa !18
  %38 = tail call noundef zeroext i1 @_ZN12_GLOBAL__N_19IsCrossedEdd(double noundef %36, double noundef %37)
  %39 = zext i1 %38 to i32
  %spec.select31 = add nuw nsw i32 %.132, %39
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %40 = load i32, ptr %10, align 8, !tbaa !13
  %41 = sext i32 %40 to i64
  %42 = icmp slt i64 %indvars.iv.next, %41
  br i1 %42, label %.lr.ph, label %._crit_edge, !llvm.loop !20

43:                                               ; preds = %4, %8, %._crit_edge
  %.027 = phi i1 [ true, %._crit_edge ], [ false, %8 ], [ false, %4 ]
  ret i1 %.027
}

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i64 @_ZNKSt6vectorIdSaIdEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24)) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(8) ptr @_ZNKSt6vectorIdSaIdEEixEm(ptr noundef nonnull align 8 dereferenceable(24), i64 noundef) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress nounwind uwtable
declare hidden noundef zeroext i1 @_ZN12_GLOBAL__N_19IsCrossedEdd(double noundef, double noundef) local_unnamed_addr #0

attributes #0 = { 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 #1 = { 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, !10, i64 12}
!6 = !{!"_ZTSN4sptk20ZeroCrossingAnalysisE", !7, i64 8, !10, i64 12}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"bool", !8, i64 0}
!11 = !{i8 0, i8 2}
!12 = !{}
!13 = !{!6, !7, i64 8}
!14 = !{!15, !10, i64 8}
!15 = !{!"_ZTSN4sptk20ZeroCrossingAnalysis6BufferE", !10, i64 8, !16, i64 16}
!16 = !{!"double", !8, i64 0}
!17 = !{!15, !16, i64 16}
!18 = !{!16, !16, i64 0}
!19 = !{!7, !7, i64 0}
!20 = distinct !{!20, !21}
!21 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: BDCEPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass