; 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.PaQaRecording_s = type { i32, ptr, i32, i32 }

@.str.1 = external hidden unnamed_addr constant [101 x i8], align 1
@.str.9 = external hidden unnamed_addr constant [16 x i8], align 1
@__PRETTY_FUNCTION__.PaQa_FadeInRecording = external hidden unnamed_addr constant [53 x i8], align 1
@.str.10 = external hidden unnamed_addr constant [10 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: nounwind
declare double @cos(double noundef) #1

; Function Attrs: nounwind uwtable
define dso_local void @PaQa_FadeInRecording(ptr noundef %0, i32 noundef %1, i32 noundef %2) #2 {
  %4 = alloca ptr, align 8
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca double, align 8
  %9 = alloca double, align 8
  %10 = alloca double, align 8
  %11 = alloca double, align 8
  %12 = alloca float, align 4
  %13 = alloca float, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  store i32 %1, ptr %5, align 4, !tbaa !9
  store i32 %2, ptr %6, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #4
  store double 0x3FF921FB54442D18, ptr %8, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #4
  %14 = load i32, ptr %6, align 4, !tbaa !9
  %15 = sitofp i32 %14 to double
  %16 = fdiv double 0x3FF921FB54442D18, %15
  store double %16, ptr %9, align 8, !tbaa !11
  %17 = load i32, ptr %5, align 4, !tbaa !9
  %18 = icmp sge i32 %17, 0
  br i1 %18, label %19, label %20

19:                                               ; preds = %3
  br label %21

20:                                               ; preds = %3
  call void @__assert_fail(ptr noundef @.str.9, ptr noundef @.str.1, i32 noundef 515, ptr noundef @__PRETTY_FUNCTION__.PaQa_FadeInRecording) #5
  unreachable

21:                                               ; preds = %19
  %22 = load i32, ptr %6, align 4, !tbaa !9
  %23 = icmp sgt i32 %22, 0
  br i1 %23, label %24, label %25

24:                                               ; preds = %21
  br label %26

25:                                               ; preds = %21
  call void @__assert_fail(ptr noundef @.str.10, ptr noundef @.str.1, i32 noundef 516, ptr noundef @__PRETTY_FUNCTION__.PaQa_FadeInRecording) #5
  unreachable

26:                                               ; preds = %24
  store i32 0, ptr %7, align 4, !tbaa !9
  br label %27

27:                                               ; preds = %38, %26
  %28 = load i32, ptr %7, align 4, !tbaa !9
  %29 = load i32, ptr %5, align 4, !tbaa !9
  %30 = icmp slt i32 %28, %29
  br i1 %30, label %31, label %41

31:                                               ; preds = %27
  %32 = load ptr, ptr %4, align 8, !tbaa !5
  %33 = getelementptr inbounds %struct.PaQaRecording_s, ptr %32, i32 0, i32 1
  %34 = load ptr, ptr %33, align 8, !tbaa !13
  %35 = load i32, ptr %7, align 4, !tbaa !9
  %36 = sext i32 %35 to i64
  %37 = getelementptr inbounds float, ptr %34, i64 %36
  store float 0.000000e+00, ptr %37, align 4, !tbaa !15
  br label %38

38:                                               ; preds = %31
  %39 = load i32, ptr %7, align 4, !tbaa !9
  %40 = add nsw i32 %39, 1
  store i32 %40, ptr %7, align 4, !tbaa !9
  br label %27, !llvm.loop !17

41:                                               ; preds = %27
  store i32 0, ptr %7, align 4, !tbaa !9
  br label %42

42:                                               ; preds = %78, %41
  %43 = load i32, ptr %7, align 4, !tbaa !9
  %44 = load i32, ptr %6, align 4, !tbaa !9
  %45 = icmp slt i32 %43, %44
  br i1 %45, label %46, label %81

46:                                               ; preds = %42
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #4
  %47 = load double, ptr %8, align 8, !tbaa !11
  %48 = call double @cos(double noundef %47) #4
  store double %48, ptr %10, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #4
  %49 = load double, ptr %10, align 8, !tbaa !11
  %50 = load double, ptr %10, align 8, !tbaa !11
  %51 = fmul double %49, %50
  store double %51, ptr %11, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #4
  %52 = load ptr, ptr %4, align 8, !tbaa !5
  %53 = getelementptr inbounds %struct.PaQaRecording_s, ptr %52, i32 0, i32 1
  %54 = load ptr, ptr %53, align 8, !tbaa !13
  %55 = load i32, ptr %7, align 4, !tbaa !9
  %56 = load i32, ptr %5, align 4, !tbaa !9
  %57 = add nsw i32 %55, %56
  %58 = sext i32 %57 to i64
  %59 = getelementptr inbounds float, ptr %54, i64 %58
  %60 = load float, ptr %59, align 4, !tbaa !15
  store float %60, ptr %12, align 4, !tbaa !15
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #4
  %61 = load float, ptr %12, align 4, !tbaa !15
  %62 = fpext float %61 to double
  %63 = load double, ptr %11, align 8, !tbaa !11
  %64 = fmul double %62, %63
  %65 = fptrunc double %64 to float
  store float %65, ptr %13, align 4, !tbaa !15
  %66 = load float, ptr %13, align 4, !tbaa !15
  %67 = load ptr, ptr %4, align 8, !tbaa !5
  %68 = getelementptr inbounds %struct.PaQaRecording_s, ptr %67, i32 0, i32 1
  %69 = load ptr, ptr %68, align 8, !tbaa !13
  %70 = load i32, ptr %7, align 4, !tbaa !9
  %71 = load i32, ptr %5, align 4, !tbaa !9
  %72 = add nsw i32 %70, %71
  %73 = sext i32 %72 to i64
  %74 = getelementptr inbounds float, ptr %69, i64 %73
  store float %66, ptr %74, align 4, !tbaa !15
  %75 = load double, ptr %9, align 8, !tbaa !11
  %76 = load double, ptr %8, align 8, !tbaa !11
  %77 = fadd double %76, %75
  store double %77, ptr %8, align 8, !tbaa !11
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #4
  br label %78

78:                                               ; preds = %46
  %79 = load i32, ptr %7, align 4, !tbaa !9
  %80 = add nsw i32 %79, 1
  store i32 %80, ptr %7, align 4, !tbaa !9
  br label %42, !llvm.loop !19

81:                                               ; preds = %42
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #4
  ret void
}

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

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 = { 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 = { 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 #4 = { nounwind }
attributes #5 = { 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/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"double", !7, i64 0}
!13 = !{!14, !6, i64 8}
!14 = !{!"PaQaRecording_s", !10, i64 0, !6, i64 8, !10, i64 16, !10, i64 20}
!15 = !{!16, !16, i64 0}
!16 = !{!"float", !7, i64 0}
!17 = distinct !{!17, !18}
!18 = !{!"llvm.loop.mustprogress"}
!19 = distinct !{!19, !18}


; 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
@.str.9 = external hidden unnamed_addr constant [16 x i8], align 1
@__PRETTY_FUNCTION__.PaQa_FadeInRecording = external hidden unnamed_addr constant [53 x i8], align 1
@.str.10 = external hidden unnamed_addr constant [10 x i8], align 1

; Function Attrs: mustprogress nofree nounwind willreturn memory(write)
declare double @cos(double noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local void @PaQa_FadeInRecording(ptr nocapture noundef readonly %0, i32 noundef %1, i32 noundef %2) local_unnamed_addr #1 {
  %4 = sitofp i32 %2 to double
  %5 = fdiv double 0x3FF921FB54442D18, %4
  %6 = icmp sgt i32 %1, -1
  br i1 %6, label %8, label %7

7:                                                ; preds = %3
  tail call void @__assert_fail(ptr noundef nonnull @.str.9, ptr noundef nonnull @.str.1, i32 noundef 515, ptr noundef nonnull @__PRETTY_FUNCTION__.PaQa_FadeInRecording) #4
  unreachable

8:                                                ; preds = %3
  %9 = icmp sgt i32 %2, 0
  br i1 %9, label %.preheader27, label %14

.preheader27:                                     ; preds = %8
  %.not = icmp eq i32 %1, 0
  br i1 %.not, label %.lr.ph31, label %.lr.ph

.lr.ph:                                           ; preds = %.preheader27
  %10 = getelementptr inbounds i8, ptr %0, i64 8
  %11 = load ptr, ptr %10, align 8, !tbaa !5
  %12 = zext nneg i32 %1 to i64
  %13 = shl nuw nsw i64 %12, 2
  tail call void @llvm.memset.p0.i64(ptr align 4 %11, i8 0, i64 %13, i1 false), !tbaa !11
  br label %.lr.ph31

14:                                               ; preds = %8
  tail call void @__assert_fail(ptr noundef nonnull @.str.10, ptr noundef nonnull @.str.1, i32 noundef 516, ptr noundef nonnull @__PRETTY_FUNCTION__.PaQa_FadeInRecording) #4
  unreachable

.lr.ph31:                                         ; preds = %.preheader27, %.lr.ph
  %15 = getelementptr inbounds i8, ptr %0, i64 8
  %16 = zext nneg i32 %1 to i64
  %wide.trip.count = zext nneg i32 %2 to i64
  %xtraiter = and i64 %wide.trip.count, 1
  %17 = icmp eq i32 %2, 1
  br i1 %17, label %._crit_edge.unr-lcssa, label %.lr.ph31.new

.lr.ph31.new:                                     ; preds = %.lr.ph31
  %unroll_iter = and i64 %wide.trip.count, 2147483646
  br label %18

18:                                               ; preds = %18, %.lr.ph31.new
  %indvars.iv = phi i64 [ 0, %.lr.ph31.new ], [ %indvars.iv.next.1, %18 ]
  %.02429 = phi double [ 0x3FF921FB54442D18, %.lr.ph31.new ], [ %38, %18 ]
  %niter = phi i64 [ 0, %.lr.ph31.new ], [ %niter.next.1, %18 ]
  %19 = tail call double @cos(double noundef %.02429) #5
  %20 = fmul double %19, %19
  %21 = load ptr, ptr %15, align 8, !tbaa !5
  %22 = getelementptr inbounds float, ptr %21, i64 %indvars.iv
  %23 = getelementptr inbounds float, ptr %22, i64 %16
  %24 = load float, ptr %23, align 4, !tbaa !11
  %25 = fpext float %24 to double
  %26 = fmul double %20, %25
  %27 = fptrunc double %26 to float
  store float %27, ptr %23, align 4, !tbaa !11
  %28 = fadd double %5, %.02429
  %indvars.iv.next = or disjoint i64 %indvars.iv, 1
  %29 = tail call double @cos(double noundef %28) #5
  %30 = fmul double %29, %29
  %31 = load ptr, ptr %15, align 8, !tbaa !5
  %32 = getelementptr inbounds float, ptr %31, i64 %indvars.iv.next
  %33 = getelementptr inbounds float, ptr %32, i64 %16
  %34 = load float, ptr %33, align 4, !tbaa !11
  %35 = fpext float %34 to double
  %36 = fmul double %30, %35
  %37 = fptrunc double %36 to float
  store float %37, ptr %33, align 4, !tbaa !11
  %38 = fadd double %5, %28
  %indvars.iv.next.1 = add nuw nsw i64 %indvars.iv, 2
  %niter.next.1 = add i64 %niter, 2
  %niter.ncmp.1 = icmp eq i64 %niter.next.1, %unroll_iter
  br i1 %niter.ncmp.1, label %._crit_edge.unr-lcssa, label %18, !llvm.loop !13

._crit_edge.unr-lcssa:                            ; preds = %18, %.lr.ph31
  %indvars.iv.unr = phi i64 [ 0, %.lr.ph31 ], [ %indvars.iv.next.1, %18 ]
  %.02429.unr = phi double [ 0x3FF921FB54442D18, %.lr.ph31 ], [ %38, %18 ]
  %lcmp.mod.not = icmp eq i64 %xtraiter, 0
  br i1 %lcmp.mod.not, label %._crit_edge, label %._crit_edge.epilog-lcssa

._crit_edge.epilog-lcssa:                         ; preds = %._crit_edge.unr-lcssa
  %39 = tail call double @cos(double noundef %.02429.unr) #5
  %40 = fmul double %39, %39
  %41 = load ptr, ptr %15, align 8, !tbaa !5
  %42 = getelementptr inbounds float, ptr %41, i64 %indvars.iv.unr
  %43 = getelementptr inbounds float, ptr %42, i64 %16
  %44 = load float, ptr %43, align 4, !tbaa !11
  %45 = fpext float %44 to double
  %46 = fmul double %40, %45
  %47 = fptrunc double %46 to float
  store float %47, ptr %43, align 4, !tbaa !11
  br label %._crit_edge

._crit_edge:                                      ; preds = %._crit_edge.unr-lcssa, %._crit_edge.epilog-lcssa
  ret void
}

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

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

attributes #0 = { mustprogress nofree nounwind willreturn memory(write) "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 = { 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 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #4 = { noreturn nounwind }
attributes #5 = { 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 8}
!6 = !{!"PaQaRecording_s", !7, i64 0, !10, i64 8, !7, i64 16, !7, i64 20}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"any pointer", !8, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"float", !8, i64 0}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LICMPass,LoopIdiomRecognizePass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,ReassociatePass,SCCPPass,SROAPass,SimplifyCFGPass,TailCallElimPass