; LLVM IR from TobiasKozel/VAE :: external/portaudio/qa/loopback/src (audio_analyzer)

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

%struct.PaQaAnalysisResult_s = type { i32, double, double, double, double, double, double, double, double }

@.str.1 = external hidden unnamed_addr constant [101 x i8], align 1
@g_testsFailed = external global i32, align 4
@g_testsPassed = external global i32, align 4
@.str.11 = external hidden unnamed_addr constant [41 x i8], align 1
@.str.13 = external hidden unnamed_addr constant [20 x i8], align 1
@.str.14 = external hidden unnamed_addr constant [11 x i8], align 1
@.str.15 = external hidden unnamed_addr constant [19 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

declare i32 @printf(ptr noundef, ...) #1

; Function Attrs: nounwind uwtable
declare dso_local i32 @PaQa_MeasureLatency(ptr noundef, ptr noundef, ptr noundef) #2

; Function Attrs: nounwind uwtable
declare dso_local i32 @PaQa_DetectPop(ptr noundef, ptr noundef, ptr noundef) #2

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #3

; Function Attrs: nounwind uwtable
declare dso_local i32 @PaQa_DetectPhaseError(ptr noundef, ptr noundef, ptr noundef) #2

; Function Attrs: nounwind uwtable
define dso_local i32 @PaQa_AnalyseRecording(ptr noundef %0, ptr noundef %1, ptr noundef %2) #2 {
  %4 = alloca i32, align 4
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  store ptr %0, ptr %5, align 8, !tbaa !5
  store ptr %1, ptr %6, align 8, !tbaa !5
  store ptr %2, ptr %7, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #4
  store i32 0, ptr %8, align 4, !tbaa !9
  %10 = load ptr, ptr %7, align 8, !tbaa !5
  call void @llvm.memset.p0.i64(ptr align 8 %10, i8 0, i64 72, i1 false)
  %11 = load ptr, ptr %5, align 8, !tbaa !5
  %12 = load ptr, ptr %6, align 8, !tbaa !5
  %13 = load ptr, ptr %7, align 8, !tbaa !5
  %14 = call i32 @PaQa_MeasureLatency(ptr noundef %11, ptr noundef %12, ptr noundef %13)
  store i32 %14, ptr %8, align 4, !tbaa !9
  %15 = load i32, ptr %8, align 4, !tbaa !9
  %16 = icmp ne i32 0, %15
  br i1 %16, label %17, label %22

17:                                               ; preds = %3
  %18 = load i32, ptr %8, align 4, !tbaa !9
  %19 = call i32 (ptr, ...) @printf(ptr noundef @.str.11, ptr noundef @.str.1, i32 noundef 691, ptr noundef @.str.13, i32 noundef 0, i32 noundef %18)
  %20 = load i32, ptr @g_testsFailed, align 4, !tbaa !9
  %21 = add nsw i32 %20, 1
  store i32 %21, ptr @g_testsFailed, align 4, !tbaa !9
  br label %69

22:                                               ; preds = %3
  %23 = load i32, ptr @g_testsPassed, align 4, !tbaa !9
  %24 = add nsw i32 %23, 1
  store i32 %24, ptr @g_testsPassed, align 4, !tbaa !9
  br label %25

25:                                               ; preds = %22
  %26 = load ptr, ptr %7, align 8, !tbaa !5
  %27 = getelementptr inbounds %struct.PaQaAnalysisResult_s, ptr %26, i32 0, i32 1
  %28 = load double, ptr %27, align 8, !tbaa !11
  %29 = fcmp oge double %28, 0.000000e+00
  br i1 %29, label %30, label %68

30:                                               ; preds = %25
  %31 = load ptr, ptr %7, align 8, !tbaa !5
  %32 = getelementptr inbounds %struct.PaQaAnalysisResult_s, ptr %31, i32 0, i32 2
  %33 = load double, ptr %32, align 8, !tbaa !14
  %34 = fcmp ogt double %33, 1.000000e-01
  br i1 %34, label %35, label %68

35:                                               ; preds = %30
  %36 = load ptr, ptr %7, align 8, !tbaa !5
  %37 = getelementptr inbounds %struct.PaQaAnalysisResult_s, ptr %36, i32 0, i32 0
  store i32 1, ptr %37, align 8, !tbaa !15
  %38 = load ptr, ptr %5, align 8, !tbaa !5
  %39 = load ptr, ptr %6, align 8, !tbaa !5
  %40 = load ptr, ptr %7, align 8, !tbaa !5
  %41 = call i32 @PaQa_DetectPop(ptr noundef %38, ptr noundef %39, ptr noundef %40)
  store i32 %41, ptr %8, align 4, !tbaa !9
  %42 = load i32, ptr %8, align 4, !tbaa !9
  %43 = icmp ne i32 0, %42
  br i1 %43, label %44, label %49

44:                                               ; preds = %35
  %45 = load i32, ptr %8, align 4, !tbaa !9
  %46 = call i32 (ptr, ...) @printf(ptr noundef @.str.11, ptr noundef @.str.1, i32 noundef 698, ptr noundef @.str.14, i32 noundef 0, i32 noundef %45)
  %47 = load i32, ptr @g_testsFailed, align 4, !tbaa !9
  %48 = add nsw i32 %47, 1
  store i32 %48, ptr @g_testsFailed, align 4, !tbaa !9
  br label %69

49:                                               ; preds = %35
  %50 = load i32, ptr @g_testsPassed, align 4, !tbaa !9
  %51 = add nsw i32 %50, 1
  store i32 %51, ptr @g_testsPassed, align 4, !tbaa !9
  br label %52

52:                                               ; preds = %49
  %53 = load ptr, ptr %5, align 8, !tbaa !5
  %54 = load ptr, ptr %6, align 8, !tbaa !5
  %55 = load ptr, ptr %7, align 8, !tbaa !5
  %56 = call i32 @PaQa_DetectPhaseError(ptr noundef %53, ptr noundef %54, ptr noundef %55)
  store i32 %56, ptr %8, align 4, !tbaa !9
  %57 = load i32, ptr %8, align 4, !tbaa !9
  %58 = icmp ne i32 0, %57
  br i1 %58, label %59, label %64

59:                                               ; preds = %52
  %60 = load i32, ptr %8, align 4, !tbaa !9
  %61 = call i32 (ptr, ...) @printf(ptr noundef @.str.11, ptr noundef @.str.1, i32 noundef 701, ptr noundef @.str.15, i32 noundef 0, i32 noundef %60)
  %62 = load i32, ptr @g_testsFailed, align 4, !tbaa !9
  %63 = add nsw i32 %62, 1
  store i32 %63, ptr @g_testsFailed, align 4, !tbaa !9
  br label %69

64:                                               ; preds = %52
  %65 = load i32, ptr @g_testsPassed, align 4, !tbaa !9
  %66 = add nsw i32 %65, 1
  store i32 %66, ptr @g_testsPassed, align 4, !tbaa !9
  br label %67

67:                                               ; preds = %64
  br label %68

68:                                               ; preds = %67, %30, %25
  store i32 0, ptr %4, align 4
  store i32 1, ptr %9, align 4
  br label %70

69:                                               ; preds = %59, %44, %17
  store i32 -1, ptr %4, align 4
  store i32 1, ptr %9, align 4
  br label %70

70:                                               ; preds = %69, %68
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #4
  %71 = load i32, ptr %4, align 4
  ret i32 %71
}

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 = { 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 #3 = { nocallback nofree nounwind willreturn memory(argmem: write) }
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/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!12, !13, i64 8}
!12 = !{!"PaQaAnalysisResult_s", !10, i64 0, !13, i64 8, !13, i64 16, !13, i64 24, !13, i64 32, !13, i64 40, !13, i64 48, !13, i64 56, !13, i64 64}
!13 = !{!"double", !7, i64 0}
!14 = !{!12, !13, i64 16}
!15 = !{!12, !10, i64 0}


; 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.1 = external hidden unnamed_addr constant [101 x i8], align 1
@g_testsFailed = external local_unnamed_addr global i32, align 4
@g_testsPassed = external local_unnamed_addr global i32, align 4
@.str.11 = external hidden unnamed_addr constant [41 x i8], align 1
@.str.13 = external hidden unnamed_addr constant [20 x i8], align 1
@.str.14 = external hidden unnamed_addr constant [11 x i8], align 1
@.str.15 = external hidden unnamed_addr constant [19 x i8], align 1

; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare dso_local i32 @PaQa_MeasureLatency(ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
declare dso_local i32 @PaQa_DetectPop(ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #1

; Function Attrs: mustprogress nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #2

; Function Attrs: nounwind uwtable
declare dso_local i32 @PaQa_DetectPhaseError(ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
define dso_local range(i32 -1, 1) i32 @PaQa_AnalyseRecording(ptr noundef %0, ptr noundef %1, ptr noundef %2) local_unnamed_addr #1 {
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(72) %2, i8 0, i64 72, i1 false)
  %4 = tail call i32 @PaQa_MeasureLatency(ptr noundef %0, ptr noundef %1, ptr noundef %2)
  %.not = icmp eq i32 %4, 0
  br i1 %.not, label %7, label %5

5:                                                ; preds = %3
  %6 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.11, ptr noundef nonnull @.str.1, i32 noundef 691, ptr noundef nonnull @.str.13, i32 noundef 0, i32 noundef %4)
  br label %.sink.split

7:                                                ; preds = %3
  %8 = load i32, ptr @g_testsPassed, align 4, !tbaa !5
  %9 = add nsw i32 %8, 1
  store i32 %9, ptr @g_testsPassed, align 4, !tbaa !5
  %10 = getelementptr inbounds i8, ptr %2, i64 8
  %11 = load double, ptr %10, align 8, !tbaa !9
  %12 = fcmp ult double %11, 0.000000e+00
  br i1 %12, label %29, label %13

13:                                               ; preds = %7
  %14 = getelementptr inbounds i8, ptr %2, i64 16
  %15 = load double, ptr %14, align 8, !tbaa !12
  %16 = fcmp ogt double %15, 1.000000e-01
  br i1 %16, label %17, label %29

17:                                               ; preds = %13
  store i32 1, ptr %2, align 8, !tbaa !13
  %18 = tail call i32 @PaQa_DetectPop(ptr noundef %0, ptr noundef %1, ptr noundef nonnull %2)
  %.not22 = icmp eq i32 %18, 0
  br i1 %.not22, label %21, label %19

19:                                               ; preds = %17
  %20 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.11, ptr noundef nonnull @.str.1, i32 noundef 698, ptr noundef nonnull @.str.14, i32 noundef 0, i32 noundef %18)
  br label %.sink.split

21:                                               ; preds = %17
  %22 = load i32, ptr @g_testsPassed, align 4, !tbaa !5
  %23 = add nsw i32 %22, 1
  store i32 %23, ptr @g_testsPassed, align 4, !tbaa !5
  %24 = tail call i32 @PaQa_DetectPhaseError(ptr noundef %0, ptr noundef %1, ptr noundef nonnull %2)
  %.not23 = icmp eq i32 %24, 0
  br i1 %.not23, label %.sink.split, label %25

25:                                               ; preds = %21
  %26 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.11, ptr noundef nonnull @.str.1, i32 noundef 701, ptr noundef nonnull @.str.15, i32 noundef 0, i32 noundef %24)
  br label %.sink.split

.sink.split:                                      ; preds = %21, %25, %19, %5
  %g_testsFailed.sink25 = phi ptr [ @g_testsFailed, %5 ], [ @g_testsFailed, %19 ], [ @g_testsFailed, %25 ], [ @g_testsPassed, %21 ]
  %.0.ph = phi i32 [ -1, %5 ], [ -1, %19 ], [ -1, %25 ], [ 0, %21 ]
  %27 = load i32, ptr %g_testsFailed.sink25, align 4, !tbaa !5
  %28 = add nsw i32 %27, 1
  store i32 %28, ptr %g_testsFailed.sink25, align 4, !tbaa !5
  br label %29

29:                                               ; preds = %.sink.split, %7, %13
  %.0 = phi i32 [ 0, %13 ], [ 0, %7 ], [ %.0.ph, %.sink.split ]
  ret i32 %.0
}

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

!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/C++ TBAA"}
!9 = !{!10, !11, i64 8}
!10 = !{!"PaQaAnalysisResult_s", !6, i64 0, !11, i64 8, !11, i64 16, !11, i64 24, !11, i64 32, !11, i64 40, !11, i64 48, !11, i64 56, !11, i64 64}
!11 = !{!"double", !7, i64 0}
!12 = !{!10, !11, i64 16}
!13 = !{!10, !6, i64 0}


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