; LLVM IR from reworks-org/galaxy :: deps/sfml_deps/vorbis-src/vq (vqgen)

; 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.quant_meta = type { i64, i64, i32, i32 }
%struct.vqgen = type { i32, i32, i32, i32, i32, float, i32, ptr, i64, i64, ptr, ptr, ptr, i64, ptr, ptr, ptr, ptr }

; 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: inlinehint nounwind uwtable
declare hidden ptr @_now(ptr noundef, i64 noundef) #1

declare float @_float32_unpack(i64 noundef) #2

; Function Attrs: nounwind uwtable
define dso_local void @vqgen_unquantize(ptr noundef %0, ptr noundef %1) #3 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca i64, align 8
  %6 = alloca i64, align 8
  %7 = alloca float, align 4
  %8 = alloca float, align 4
  %9 = alloca float, align 4
  %10 = alloca float, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  store ptr %1, ptr %4, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #5
  %11 = load ptr, ptr %4, align 8, !tbaa !5
  %12 = getelementptr inbounds %struct.quant_meta, ptr %11, i32 0, i32 0
  %13 = load i64, ptr %12, align 8, !tbaa !9
  %14 = call float @_float32_unpack(i64 noundef %13)
  store float %14, ptr %7, align 4, !tbaa !13
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #5
  %15 = load ptr, ptr %4, align 8, !tbaa !5
  %16 = getelementptr inbounds %struct.quant_meta, ptr %15, i32 0, i32 1
  %17 = load i64, ptr %16, align 8, !tbaa !15
  %18 = call float @_float32_unpack(i64 noundef %17)
  store float %18, ptr %8, align 4, !tbaa !13
  store i64 0, ptr %5, align 8, !tbaa !16
  br label %19

19:                                               ; preds = %69, %2
  %20 = load i64, ptr %5, align 8, !tbaa !16
  %21 = load ptr, ptr %3, align 8, !tbaa !5
  %22 = getelementptr inbounds %struct.vqgen, ptr %21, i32 0, i32 13
  %23 = load i64, ptr %22, align 8, !tbaa !17
  %24 = icmp slt i64 %20, %23
  br i1 %24, label %25, label %72

25:                                               ; preds = %19
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #5
  store float 0.000000e+00, ptr %9, align 4, !tbaa !13
  store i64 0, ptr %6, align 8, !tbaa !16
  br label %26

26:                                               ; preds = %65, %25
  %27 = load i64, ptr %6, align 8, !tbaa !16
  %28 = load ptr, ptr %3, align 8, !tbaa !5
  %29 = getelementptr inbounds %struct.vqgen, ptr %28, i32 0, i32 3
  %30 = load i32, ptr %29, align 4, !tbaa !19
  %31 = sext i32 %30 to i64
  %32 = icmp slt i64 %27, %31
  br i1 %32, label %33, label %68

33:                                               ; preds = %26
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #5
  %34 = load ptr, ptr %3, align 8, !tbaa !5
  %35 = load i64, ptr %5, align 8, !tbaa !16
  %36 = call ptr @_now(ptr noundef %34, i64 noundef %35)
  %37 = load i64, ptr %6, align 8, !tbaa !16
  %38 = getelementptr inbounds float, ptr %36, i64 %37
  %39 = load float, ptr %38, align 4, !tbaa !13
  store float %39, ptr %10, align 4, !tbaa !13
  %40 = load float, ptr %10, align 4, !tbaa !13
  %41 = fpext float %40 to double
  %42 = call double @llvm.fabs.f64(double %41)
  %43 = load float, ptr %8, align 4, !tbaa !13
  %44 = fpext float %43 to double
  %45 = load float, ptr %9, align 4, !tbaa !13
  %46 = fpext float %45 to double
  %47 = call double @llvm.fmuladd.f64(double %42, double %44, double %46)
  %48 = load float, ptr %7, align 4, !tbaa !13
  %49 = fpext float %48 to double
  %50 = fadd double %47, %49
  %51 = fptrunc double %50 to float
  store float %51, ptr %10, align 4, !tbaa !13
  %52 = load ptr, ptr %4, align 8, !tbaa !5
  %53 = getelementptr inbounds %struct.quant_meta, ptr %52, i32 0, i32 3
  %54 = load i32, ptr %53, align 4, !tbaa !20
  %55 = icmp ne i32 %54, 0
  br i1 %55, label %56, label %58

56:                                               ; preds = %33
  %57 = load float, ptr %10, align 4, !tbaa !13
  store float %57, ptr %9, align 4, !tbaa !13
  br label %58

58:                                               ; preds = %56, %33
  %59 = load float, ptr %10, align 4, !tbaa !13
  %60 = load ptr, ptr %3, align 8, !tbaa !5
  %61 = load i64, ptr %5, align 8, !tbaa !16
  %62 = call ptr @_now(ptr noundef %60, i64 noundef %61)
  %63 = load i64, ptr %6, align 8, !tbaa !16
  %64 = getelementptr inbounds float, ptr %62, i64 %63
  store float %59, ptr %64, align 4, !tbaa !13
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #5
  br label %65

65:                                               ; preds = %58
  %66 = load i64, ptr %6, align 8, !tbaa !16
  %67 = add nsw i64 %66, 1
  store i64 %67, ptr %6, align 8, !tbaa !16
  br label %26, !llvm.loop !21

68:                                               ; preds = %26
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #5
  br label %69

69:                                               ; preds = %68
  %70 = load i64, ptr %5, align 8, !tbaa !16
  %71 = add nsw i64 %70, 1
  store i64 %71, ptr %5, align 8, !tbaa !16
  br label %19, !llvm.loop !23

72:                                               ; preds = %19
  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 8, ptr %6) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #5
  ret void
}

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare double @llvm.fabs.f64(double) #4

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

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { inlinehint 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 = { "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 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 #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, !11, i64 0}
!10 = !{!"", !11, i64 0, !11, i64 8, !12, i64 16, !12, i64 20}
!11 = !{!"long", !7, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = !{!14, !14, i64 0}
!14 = !{!"float", !7, i64 0}
!15 = !{!10, !11, i64 8}
!16 = !{!11, !11, i64 0}
!17 = !{!18, !11, i64 80}
!18 = !{!"vqgen", !12, i64 0, !12, i64 4, !12, i64 8, !12, i64 12, !12, i64 16, !14, i64 20, !12, i64 24, !6, i64 32, !11, i64 40, !11, i64 48, !6, i64 56, !6, i64 64, !6, i64 72, !11, i64 80, !6, i64 88, !6, i64 96, !6, i64 104, !6, i64 112}
!19 = !{!18, !12, i64 12}
!20 = !{!10, !12, i64 20}
!21 = distinct !{!21, !22}
!22 = !{!"llvm.loop.mustprogress"}
!23 = distinct !{!23, !22}


; 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: inlinehint nounwind uwtable
declare hidden ptr @_now(ptr noundef, i64 noundef) local_unnamed_addr #0

declare float @_float32_unpack(i64 noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
define dso_local void @vqgen_unquantize(ptr noundef %0, ptr nocapture noundef readonly %1) local_unnamed_addr #2 {
  %3 = load i64, ptr %1, align 8, !tbaa !5
  %4 = tail call float @_float32_unpack(i64 noundef %3) #5
  %5 = getelementptr inbounds i8, ptr %1, i64 8
  %6 = load i64, ptr %5, align 8, !tbaa !11
  %7 = tail call float @_float32_unpack(i64 noundef %6) #5
  %8 = getelementptr inbounds i8, ptr %0, i64 80
  %9 = load i64, ptr %8, align 8, !tbaa !12
  %10 = icmp sgt i64 %9, 0
  br i1 %10, label %.preheader.lr.ph, label %._crit_edge25

.preheader.lr.ph:                                 ; preds = %2
  %11 = getelementptr inbounds i8, ptr %0, i64 12
  %12 = fpext float %7 to double
  %13 = fpext float %4 to double
  %14 = getelementptr inbounds i8, ptr %1, i64 20
  %.pre = load i32, ptr %11, align 4, !tbaa !16
  br label %.preheader

.preheader:                                       ; preds = %.preheader.lr.ph, %._crit_edge
  %15 = phi i64 [ %9, %.preheader.lr.ph ], [ %34, %._crit_edge ]
  %16 = phi i32 [ %.pre, %.preheader.lr.ph ], [ %35, %._crit_edge ]
  %.02024 = phi i64 [ 0, %.preheader.lr.ph ], [ %36, %._crit_edge ]
  %17 = icmp sgt i32 %16, 0
  br i1 %17, label %.lr.ph, label %._crit_edge

.lr.ph:                                           ; preds = %.preheader, %.lr.ph
  %.023 = phi float [ %.1, %.lr.ph ], [ 0.000000e+00, %.preheader ]
  %.02122 = phi i64 [ %30, %.lr.ph ], [ 0, %.preheader ]
  %18 = tail call ptr @_now(ptr noundef nonnull %0, i64 noundef %.02024)
  %19 = getelementptr inbounds float, ptr %18, i64 %.02122
  %20 = load float, ptr %19, align 4, !tbaa !17
  %21 = tail call float @llvm.fabs.f32(float %20)
  %22 = fpext float %21 to double
  %23 = fpext float %.023 to double
  %24 = tail call double @llvm.fmuladd.f64(double %22, double %12, double %23)
  %25 = fadd double %24, %13
  %26 = fptrunc double %25 to float
  %27 = load i32, ptr %14, align 4, !tbaa !18
  %.not = icmp eq i32 %27, 0
  %.1 = select i1 %.not, float %.023, float %26
  %28 = tail call ptr @_now(ptr noundef nonnull %0, i64 noundef %.02024)
  %29 = getelementptr inbounds float, ptr %28, i64 %.02122
  store float %26, ptr %29, align 4, !tbaa !17
  %30 = add nuw nsw i64 %.02122, 1
  %31 = load i32, ptr %11, align 4, !tbaa !16
  %32 = sext i32 %31 to i64
  %33 = icmp slt i64 %30, %32
  br i1 %33, label %.lr.ph, label %._crit_edge.loopexit, !llvm.loop !19

._crit_edge.loopexit:                             ; preds = %.lr.ph
  %.pre26 = load i64, ptr %8, align 8, !tbaa !12
  br label %._crit_edge

._crit_edge:                                      ; preds = %._crit_edge.loopexit, %.preheader
  %34 = phi i64 [ %.pre26, %._crit_edge.loopexit ], [ %15, %.preheader ]
  %35 = phi i32 [ %31, %._crit_edge.loopexit ], [ %16, %.preheader ]
  %36 = add nuw nsw i64 %.02024, 1
  %37 = icmp slt i64 %36, %34
  br i1 %37, label %.preheader, label %._crit_edge25, !llvm.loop !21

._crit_edge25:                                    ; preds = %._crit_edge, %2
  ret void
}

; Function Attrs: mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare double @llvm.fmuladd.f64(double, double, double) #3

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

attributes #0 = { inlinehint 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 = { "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 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }
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, !7, i64 0}
!6 = !{!"", !7, i64 0, !7, i64 8, !10, i64 16, !10, i64 20}
!7 = !{!"long", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"int", !8, i64 0}
!11 = !{!6, !7, i64 8}
!12 = !{!13, !7, i64 80}
!13 = !{!"vqgen", !10, i64 0, !10, i64 4, !10, i64 8, !10, i64 12, !10, i64 16, !14, i64 20, !10, i64 24, !15, i64 32, !7, i64 40, !7, i64 48, !15, i64 56, !15, i64 64, !15, i64 72, !7, i64 80, !15, i64 88, !15, i64 96, !15, i64 104, !15, i64 112}
!14 = !{!"float", !8, i64 0}
!15 = !{!"any pointer", !8, i64 0}
!16 = !{!13, !10, i64 12}
!17 = !{!14, !14, i64 0}
!18 = !{!6, !10, i64 20}
!19 = distinct !{!19, !20}
!20 = !{!"llvm.loop.mustprogress"}
!21 = distinct !{!21, !20}


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