; LLVM IR from Natrox/RaptorAudio :: RaptorAudio/src (stb_vorbis)

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

; 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 uwtable
define dso_local void @dct_iv_slow(ptr noundef %0, i32 noundef %1) #1 {
  %3 = alloca ptr, align 8
  %4 = alloca i32, align 4
  %5 = alloca [16384 x float], align 16
  %6 = alloca [2048 x float], align 16
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  %11 = alloca float, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  store i32 %1, ptr %4, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 65536, ptr %5) #5
  call void @llvm.lifetime.start.p0(i64 8192, ptr %6) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #5
  %12 = load i32, ptr %4, align 4, !tbaa !9
  %13 = ashr i32 %12, 1
  store i32 %13, ptr %9, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #5
  %14 = load i32, ptr %4, align 4, !tbaa !9
  %15 = shl i32 %14, 3
  %16 = sub nsw i32 %15, 1
  store i32 %16, ptr %10, align 4, !tbaa !9
  %17 = getelementptr inbounds [2048 x float], ptr %6, i64 0, i64 0
  %18 = load ptr, ptr %3, align 8, !tbaa !5
  %19 = load i32, ptr %4, align 4, !tbaa !9
  %20 = sext i32 %19 to i64
  %21 = mul i64 4, %20
  call void @llvm.memcpy.p0.p0.i64(ptr align 16 %17, ptr align 4 %18, i64 %21, i1 false)
  store i32 0, ptr %7, align 4, !tbaa !9
  br label %22

22:                                               ; preds = %39, %2
  %23 = load i32, ptr %7, align 4, !tbaa !9
  %24 = load i32, ptr %4, align 4, !tbaa !9
  %25 = mul nsw i32 8, %24
  %26 = icmp slt i32 %23, %25
  br i1 %26, label %27, label %42

27:                                               ; preds = %22
  %28 = load i32, ptr %7, align 4, !tbaa !9
  %29 = sitofp i32 %28 to double
  %30 = fmul double 0x3FE921FB54442D18, %29
  %31 = load i32, ptr %4, align 4, !tbaa !9
  %32 = sitofp i32 %31 to double
  %33 = fdiv double %30, %32
  %34 = call double @cos(double noundef %33) #5
  %35 = fptrunc double %34 to float
  %36 = load i32, ptr %7, align 4, !tbaa !9
  %37 = sext i32 %36 to i64
  %38 = getelementptr inbounds [16384 x float], ptr %5, i64 0, i64 %37
  store float %35, ptr %38, align 4, !tbaa !11
  br label %39

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

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

43:                                               ; preds = %80, %42
  %44 = load i32, ptr %7, align 4, !tbaa !9
  %45 = load i32, ptr %4, align 4, !tbaa !9
  %46 = icmp slt i32 %44, %45
  br i1 %46, label %47, label %83

47:                                               ; preds = %43
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #5
  store float 0.000000e+00, ptr %11, align 4, !tbaa !11
  store i32 0, ptr %8, align 4, !tbaa !9
  br label %48

48:                                               ; preds = %71, %47
  %49 = load i32, ptr %8, align 4, !tbaa !9
  %50 = load i32, ptr %4, align 4, !tbaa !9
  %51 = icmp slt i32 %49, %50
  br i1 %51, label %52, label %74

52:                                               ; preds = %48
  %53 = load i32, ptr %8, align 4, !tbaa !9
  %54 = sext i32 %53 to i64
  %55 = getelementptr inbounds [2048 x float], ptr %6, i64 0, i64 %54
  %56 = load float, ptr %55, align 4, !tbaa !11
  %57 = load i32, ptr %7, align 4, !tbaa !9
  %58 = mul nsw i32 2, %57
  %59 = add nsw i32 %58, 1
  %60 = load i32, ptr %8, align 4, !tbaa !9
  %61 = mul nsw i32 2, %60
  %62 = add nsw i32 %61, 1
  %63 = mul nsw i32 %59, %62
  %64 = load i32, ptr %10, align 4, !tbaa !9
  %65 = and i32 %63, %64
  %66 = sext i32 %65 to i64
  %67 = getelementptr inbounds [16384 x float], ptr %5, i64 0, i64 %66
  %68 = load float, ptr %67, align 4, !tbaa !11
  %69 = load float, ptr %11, align 4, !tbaa !11
  %70 = call float @llvm.fmuladd.f32(float %56, float %68, float %69)
  store float %70, ptr %11, align 4, !tbaa !11
  br label %71

71:                                               ; preds = %52
  %72 = load i32, ptr %8, align 4, !tbaa !9
  %73 = add nsw i32 %72, 1
  store i32 %73, ptr %8, align 4, !tbaa !9
  br label %48, !llvm.loop !15

74:                                               ; preds = %48
  %75 = load float, ptr %11, align 4, !tbaa !11
  %76 = load ptr, ptr %3, align 8, !tbaa !5
  %77 = load i32, ptr %7, align 4, !tbaa !9
  %78 = sext i32 %77 to i64
  %79 = getelementptr inbounds float, ptr %76, i64 %78
  store float %75, ptr %79, align 4, !tbaa !11
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #5
  br label %80

80:                                               ; preds = %74
  %81 = load i32, ptr %7, align 4, !tbaa !9
  %82 = add nsw i32 %81, 1
  store i32 %82, ptr %7, align 4, !tbaa !9
  br label %43, !llvm.loop !16

83:                                               ; preds = %43
  %84 = getelementptr inbounds [2048 x float], ptr %6, i64 0, i64 0
  call void @free(ptr noundef %84) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #5
  call void @llvm.lifetime.end.p0(i64 8192, ptr %6) #5
  call void @llvm.lifetime.end.p0(i64 65536, ptr %5) #5
  ret void
}

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #2

; Function Attrs: nounwind
declare double @cos(double noundef) #3

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare float @llvm.fmuladd.f32(float, float, float) #4

; Function Attrs: nounwind
declare void @free(ptr noundef) #3

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { 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 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
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, !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 = !{!"float", !7, i64 0}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}
!15 = distinct !{!15, !14}
!16 = distinct !{!16, !14}


; 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 nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #0

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

; Function Attrs: nounwind memory(write, argmem: readwrite, inaccessiblemem: readwrite) uwtable
define dso_local void @dct_iv_slow(ptr nocapture noundef %0, i32 noundef %1) local_unnamed_addr #1 {
  %3 = alloca [16384 x float], align 16
  %4 = alloca [2048 x float], align 16
  call void @llvm.lifetime.start.p0(i64 65536, ptr nonnull %3) #6
  call void @llvm.lifetime.start.p0(i64 8192, ptr nonnull %4) #6
  %5 = shl i32 %1, 3
  %6 = add nsw i32 %5, -1
  %7 = sext i32 %1 to i64
  %8 = shl nsw i64 %7, 2
  call void @llvm.memcpy.p0.p0.i64(ptr nonnull align 16 %4, ptr align 4 %0, i64 %8, i1 false)
  %9 = icmp sgt i32 %5, 0
  br i1 %9, label %.lr.ph, label %.preheader26

.lr.ph:                                           ; preds = %2
  %10 = sitofp i32 %1 to double
  %wide.trip.count = zext nneg i32 %5 to i64
  br label %49

.preheader26:                                     ; preds = %49, %2
  %11 = icmp sgt i32 %1, 0
  br i1 %11, label %.preheader.us.preheader, label %._crit_edge32

.preheader.us.preheader:                          ; preds = %.preheader26
  %wide.trip.count42 = zext nneg i32 %1 to i64
  %xtraiter = and i64 %wide.trip.count42, 1
  %12 = icmp eq i32 %1, 1
  %unroll_iter = and i64 %wide.trip.count42, 2147483646
  %lcmp.mod.not = icmp eq i64 %xtraiter, 0
  br label %.preheader.us

.preheader.us:                                    ; preds = %.preheader.us.preheader, %._crit_edge.us
  %indvars.iv39 = phi i64 [ 0, %.preheader.us.preheader ], [ %indvars.iv.next40, %._crit_edge.us ]
  %13 = shl nuw nsw i64 %indvars.iv39, 1
  %14 = or disjoint i64 %13, 1
  br i1 %12, label %._crit_edge.us.unr-lcssa, label %.preheader.us.new

.preheader.us.new:                                ; preds = %.preheader.us, %.preheader.us.new
  %indvars.iv34 = phi i64 [ %indvars.iv.next35.1, %.preheader.us.new ], [ 0, %.preheader.us ]
  %.029.us = phi float [ %36, %.preheader.us.new ], [ 0.000000e+00, %.preheader.us ]
  %niter = phi i64 [ %niter.next.1, %.preheader.us.new ], [ 0, %.preheader.us ]
  %15 = getelementptr inbounds [2048 x float], ptr %4, i64 0, i64 %indvars.iv34
  %16 = load float, ptr %15, align 8, !tbaa !5
  %17 = shl nuw nsw i64 %indvars.iv34, 1
  %18 = or disjoint i64 %17, 1
  %19 = mul nuw nsw i64 %18, %14
  %20 = trunc nuw i64 %19 to i32
  %21 = and i32 %6, %20
  %22 = zext nneg i32 %21 to i64
  %23 = getelementptr inbounds [16384 x float], ptr %3, i64 0, i64 %22
  %24 = load float, ptr %23, align 4, !tbaa !5
  %25 = tail call float @llvm.fmuladd.f32(float %16, float %24, float %.029.us)
  %indvars.iv.next35 = or disjoint i64 %indvars.iv34, 1
  %26 = getelementptr inbounds [2048 x float], ptr %4, i64 0, i64 %indvars.iv.next35
  %27 = load float, ptr %26, align 4, !tbaa !5
  %28 = shl nuw nsw i64 %indvars.iv.next35, 1
  %29 = or disjoint i64 %28, 1
  %30 = mul nuw nsw i64 %29, %14
  %31 = trunc nuw i64 %30 to i32
  %32 = and i32 %6, %31
  %33 = zext nneg i32 %32 to i64
  %34 = getelementptr inbounds [16384 x float], ptr %3, i64 0, i64 %33
  %35 = load float, ptr %34, align 4, !tbaa !5
  %36 = tail call float @llvm.fmuladd.f32(float %27, float %35, float %25)
  %indvars.iv.next35.1 = add nuw nsw i64 %indvars.iv34, 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.us.unr-lcssa, label %.preheader.us.new, !llvm.loop !9

._crit_edge.us.unr-lcssa:                         ; preds = %.preheader.us.new, %.preheader.us
  %.lcssa.ph = phi float [ poison, %.preheader.us ], [ %36, %.preheader.us.new ]
  %indvars.iv34.unr = phi i64 [ 0, %.preheader.us ], [ %indvars.iv.next35.1, %.preheader.us.new ]
  %.029.us.unr = phi float [ 0.000000e+00, %.preheader.us ], [ %36, %.preheader.us.new ]
  br i1 %lcmp.mod.not, label %._crit_edge.us, label %._crit_edge.us.epilog-lcssa

._crit_edge.us.epilog-lcssa:                      ; preds = %._crit_edge.us.unr-lcssa
  %37 = getelementptr inbounds [2048 x float], ptr %4, i64 0, i64 %indvars.iv34.unr
  %38 = load float, ptr %37, align 4, !tbaa !5
  %39 = shl nuw nsw i64 %indvars.iv34.unr, 1
  %40 = or disjoint i64 %39, 1
  %41 = mul nuw nsw i64 %40, %14
  %42 = trunc nuw i64 %41 to i32
  %43 = and i32 %6, %42
  %44 = zext nneg i32 %43 to i64
  %45 = getelementptr inbounds [16384 x float], ptr %3, i64 0, i64 %44
  %46 = load float, ptr %45, align 4, !tbaa !5
  %47 = tail call float @llvm.fmuladd.f32(float %38, float %46, float %.029.us.unr)
  br label %._crit_edge.us

._crit_edge.us:                                   ; preds = %._crit_edge.us.unr-lcssa, %._crit_edge.us.epilog-lcssa
  %.lcssa = phi float [ %.lcssa.ph, %._crit_edge.us.unr-lcssa ], [ %47, %._crit_edge.us.epilog-lcssa ]
  %48 = getelementptr inbounds float, ptr %0, i64 %indvars.iv39
  store float %.lcssa, ptr %48, align 4, !tbaa !5
  %indvars.iv.next40 = add nuw nsw i64 %indvars.iv39, 1
  %exitcond43.not = icmp eq i64 %indvars.iv.next40, %wide.trip.count42
  br i1 %exitcond43.not, label %._crit_edge32, label %.preheader.us, !llvm.loop !11

49:                                               ; preds = %49, %.lr.ph
  %indvars.iv = phi i64 [ 0, %.lr.ph ], [ %indvars.iv.next.1, %49 ]
  %50 = trunc nuw nsw i64 %indvars.iv to i32
  %51 = uitofp nneg i32 %50 to double
  %52 = fmul double %51, 0x3FE921FB54442D18
  %53 = fdiv double %52, %10
  %54 = tail call double @cos(double noundef %53) #6
  %55 = fptrunc double %54 to float
  %56 = getelementptr inbounds [16384 x float], ptr %3, i64 0, i64 %indvars.iv
  store float %55, ptr %56, align 8, !tbaa !5
  %indvars.iv.next = or disjoint i64 %indvars.iv, 1
  %57 = trunc nuw nsw i64 %indvars.iv.next to i32
  %58 = uitofp nneg i32 %57 to double
  %59 = fmul double %58, 0x3FE921FB54442D18
  %60 = fdiv double %59, %10
  %61 = tail call double @cos(double noundef %60) #6
  %62 = fptrunc double %61 to float
  %63 = getelementptr inbounds [16384 x float], ptr %3, i64 0, i64 %indvars.iv.next
  store float %62, ptr %63, align 4, !tbaa !5
  %indvars.iv.next.1 = add nuw nsw i64 %indvars.iv, 2
  %exitcond.not.1 = icmp eq i64 %indvars.iv.next.1, %wide.trip.count
  br i1 %exitcond.not.1, label %.preheader26, label %49, !llvm.loop !12

._crit_edge32:                                    ; preds = %._crit_edge.us, %.preheader26
  call void @free(ptr noundef nonnull %4) #6
  call void @llvm.lifetime.end.p0(i64 8192, ptr nonnull %4) #6
  call void @llvm.lifetime.end.p0(i64 65536, ptr nonnull %3) #6
  ret void
}

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

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

; Function Attrs: mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare float @llvm.fmuladd.f32(float, float, float) #4

; Function Attrs: mustprogress nounwind willreturn allockind("free") memory(argmem: readwrite, inaccessiblemem: readwrite)
declare void @free(ptr allocptr nocapture noundef) local_unnamed_addr #5

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nounwind memory(write, argmem: readwrite, inaccessiblemem: readwrite) 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: readwrite) }
attributes #3 = { 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 #4 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #5 = { mustprogress nounwind willreturn allockind("free") memory(argmem: readwrite, inaccessiblemem: readwrite) "alloc-family"="malloc" "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 #6 = { 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/C++ TBAA"}
!9 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}
!11 = distinct !{!11, !10}
!12 = distinct !{!12, !10}


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