; LLVM IR from ybj366533/YY-Camera :: yy_soundtouch/src/main/jni/SoundTouch (PeakFinder)

; 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.soundtouch::PeakFinder" = type { i32, i32 }

@.str = external hidden unnamed_addr constant [19 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [106 x i8], align 1
@__PRETTY_FUNCTION__._ZNK10soundtouch10PeakFinder17findCrossingLevelEPKffii = external hidden unnamed_addr constant [84 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

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

; Function Attrs: mustprogress nounwind uwtable
define dso_local noundef i32 @_ZNK10soundtouch10PeakFinder17findCrossingLevelEPKffii(ptr noundef nonnull align 4 dereferenceable(8) %0, ptr noundef %1, float noundef %2, i32 noundef %3, i32 noundef %4) #1 align 2 {
  %6 = alloca i32, align 4
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca float, align 4
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  %12 = alloca float, align 4
  %13 = alloca i32, align 4
  %14 = alloca i32, align 4
  store ptr %0, ptr %7, align 8, !tbaa !5
  store ptr %1, ptr %8, align 8, !tbaa !5
  store float %2, ptr %9, align 4, !tbaa !9
  store i32 %3, ptr %10, align 4, !tbaa !11
  store i32 %4, ptr %11, align 4, !tbaa !11
  %15 = load ptr, ptr %7, align 8
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #3
  %16 = load ptr, ptr %8, align 8, !tbaa !5
  %17 = load i32, ptr %10, align 4, !tbaa !11
  %18 = sext i32 %17 to i64
  %19 = getelementptr inbounds float, ptr %16, i64 %18
  %20 = load float, ptr %19, align 4, !tbaa !9
  store float %20, ptr %12, align 4, !tbaa !9
  %21 = load float, ptr %12, align 4, !tbaa !9
  %22 = load float, ptr %9, align 4, !tbaa !9
  %23 = fcmp oge float %21, %22
  br i1 %23, label %24, label %25

24:                                               ; preds = %5
  br label %27

25:                                               ; preds = %5
  call void @__assert_fail(ptr noundef @.str, ptr noundef @.str.1, i32 noundef 150, ptr noundef @__PRETTY_FUNCTION__._ZNK10soundtouch10PeakFinder17findCrossingLevelEPKffii) #4
  unreachable

26:                                               ; No predecessors!
  br label %27

27:                                               ; preds = %26, %24
  %28 = load i32, ptr %10, align 4, !tbaa !11
  store i32 %28, ptr %13, align 4, !tbaa !11
  br label %29

29:                                               ; preds = %53, %27
  %30 = load i32, ptr %13, align 4, !tbaa !11
  %31 = getelementptr inbounds %"class.soundtouch::PeakFinder", ptr %15, i32 0, i32 0
  %32 = load i32, ptr %31, align 4, !tbaa !13
  %33 = icmp sge i32 %30, %32
  br i1 %33, label %34, label %39

34:                                               ; preds = %29
  %35 = load i32, ptr %13, align 4, !tbaa !11
  %36 = getelementptr inbounds %"class.soundtouch::PeakFinder", ptr %15, i32 0, i32 1
  %37 = load i32, ptr %36, align 4, !tbaa !15
  %38 = icmp slt i32 %35, %37
  br label %39

39:                                               ; preds = %34, %29
  %40 = phi i1 [ false, %29 ], [ %38, %34 ]
  br i1 %40, label %41, label %57

41:                                               ; preds = %39
  %42 = load ptr, ptr %8, align 8, !tbaa !5
  %43 = load i32, ptr %13, align 4, !tbaa !11
  %44 = load i32, ptr %11, align 4, !tbaa !11
  %45 = add nsw i32 %43, %44
  %46 = sext i32 %45 to i64
  %47 = getelementptr inbounds float, ptr %42, i64 %46
  %48 = load float, ptr %47, align 4, !tbaa !9
  %49 = load float, ptr %9, align 4, !tbaa !9
  %50 = fcmp olt float %48, %49
  br i1 %50, label %51, label %53

51:                                               ; preds = %41
  %52 = load i32, ptr %13, align 4, !tbaa !11
  store i32 %52, ptr %6, align 4
  store i32 1, ptr %14, align 4
  br label %58

53:                                               ; preds = %41
  %54 = load i32, ptr %11, align 4, !tbaa !11
  %55 = load i32, ptr %13, align 4, !tbaa !11
  %56 = add nsw i32 %55, %54
  store i32 %56, ptr %13, align 4, !tbaa !11
  br label %29, !llvm.loop !16

57:                                               ; preds = %39
  store i32 -1, ptr %6, align 4
  store i32 1, ptr %14, align 4
  br label %58

58:                                               ; preds = %57, %51
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #3
  %59 = load i32, ptr %6, align 4
  ret i32 %59
}

; Function Attrs: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) #2

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { noreturn 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 #3 = { nounwind }
attributes #4 = { noreturn 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 = !{!"float", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = !{!14, !12, i64 0}
!14 = !{!"_ZTSN10soundtouch10PeakFinderE", !12, i64 0, !12, i64 4}
!15 = !{!14, !12, i64 4}
!16 = distinct !{!16, !17}
!17 = !{!"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 [19 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [106 x i8], align 1
@__PRETTY_FUNCTION__._ZNK10soundtouch10PeakFinder17findCrossingLevelEPKffii = external hidden unnamed_addr constant [84 x i8], align 1

; Function Attrs: mustprogress nounwind uwtable
define dso_local noundef i32 @_ZNK10soundtouch10PeakFinder17findCrossingLevelEPKffii(ptr nocapture noundef nonnull readonly align 4 dereferenceable(8) %0, ptr nocapture noundef readonly %1, float noundef %2, i32 noundef %3, i32 noundef %4) local_unnamed_addr #0 align 2 {
  %6 = sext i32 %3 to i64
  %7 = getelementptr inbounds float, ptr %1, i64 %6
  %8 = load float, ptr %7, align 4, !tbaa !5
  %9 = fcmp ult float %8, %2
  br i1 %9, label %16, label %.preheader

.preheader:                                       ; preds = %5
  %10 = load i32, ptr %0, align 4, !tbaa !9
  %11 = getelementptr inbounds i8, ptr %0, i64 4
  %12 = load i32, ptr %11, align 4
  %13 = sext i32 %4 to i64
  %14 = sext i32 %10 to i64
  %15 = sext i32 %12 to i64
  br label %17

16:                                               ; preds = %5
  tail call void @__assert_fail(ptr noundef nonnull @.str, ptr noundef nonnull @.str.1, i32 noundef 150, ptr noundef nonnull @__PRETTY_FUNCTION__._ZNK10soundtouch10PeakFinder17findCrossingLevelEPKffii) #2
  unreachable

17:                                               ; preds = %.preheader, %19
  %indvars.iv = phi i64 [ %6, %.preheader ], [ %indvars.iv.next, %19 ]
  %.not = icmp sge i64 %indvars.iv, %14
  %18 = icmp slt i64 %indvars.iv, %15
  %or.cond = select i1 %.not, i1 %18, i1 false
  br i1 %or.cond, label %19, label %.critedge

19:                                               ; preds = %17
  %indvars.iv.next = add nsw i64 %indvars.iv, %13
  %20 = getelementptr inbounds float, ptr %1, i64 %indvars.iv.next
  %21 = load float, ptr %20, align 4, !tbaa !5
  %22 = fcmp olt float %21, %2
  br i1 %22, label %.critedge.split.loop.exit20, label %17, !llvm.loop !12

.critedge.split.loop.exit20:                      ; preds = %19
  %23 = trunc nsw i64 %indvars.iv to i32
  br label %.critedge

.critedge:                                        ; preds = %17, %.critedge.split.loop.exit20
  %.015 = phi i32 [ %23, %.critedge.split.loop.exit20 ], [ -1, %17 ]
  ret i32 %.015
}

; Function Attrs: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) local_unnamed_addr #1

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 = { noreturn 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 = { noreturn 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 = !{!"float", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !11, i64 0}
!10 = !{!"_ZTSN10soundtouch10PeakFinderE", !11, i64 0, !11, i64 4}
!11 = !{!"int", !7, i64 0}
!12 = distinct !{!12, !13}
!13 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,LCSSAPass,LICMPass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass