; LLVM IR from facebookresearch/habitat-sim :: src/deps/basis-universal/encoder (basisu_resampler)

; 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.basisu::Resampler" = type <{ i32, i32, i32, i32, i32, i32, i32, [4 x i8], ptr, ptr, ptr, ptr, i8, i8, i8, [5 x i8], ptr, ptr, ptr, i32, i32, i32, float, float, [4 x i8] }>
%"struct.basisu::Resampler::Contrib_List" = type { i16, ptr }
%"struct.basisu::Resampler::Contrib" = type { float, i16 }

@.str.1 = external hidden unnamed_addr constant [116 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [5 x i8], align 1
@__PRETTY_FUNCTION__._ZN6basisu9Resampler10resample_xEPfPKf = external hidden unnamed_addr constant [61 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [5 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: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) #1

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @_ZN6basisu9Resampler10resample_xEPfPKf(ptr noundef nonnull align 8 dereferenceable(116) %0, ptr noundef %1, ptr noundef %2) #2 align 2 {
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca float, align 4
  %10 = alloca ptr, align 8
  %11 = alloca ptr, align 8
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  store ptr %2, ptr %6, align 8, !tbaa !5
  %12 = load ptr, ptr %4, align 8
  %13 = load ptr, ptr %5, align 8, !tbaa !5
  %14 = icmp ne ptr %13, null
  br i1 %14, label %15, label %16

15:                                               ; preds = %3
  br label %18

16:                                               ; preds = %3
  call void @__assert_fail(ptr noundef @.str.2, ptr noundef @.str.1, i32 noundef 352, ptr noundef @__PRETTY_FUNCTION__._ZN6basisu9Resampler10resample_xEPfPKf) #4
  unreachable

17:                                               ; No predecessors!
  br label %18

18:                                               ; preds = %17, %15
  %19 = load ptr, ptr %6, align 8, !tbaa !5
  %20 = icmp ne ptr %19, null
  br i1 %20, label %21, label %22

21:                                               ; preds = %18
  br label %24

22:                                               ; preds = %18
  call void @__assert_fail(ptr noundef @.str.3, ptr noundef @.str.1, i32 noundef 353, ptr noundef @__PRETTY_FUNCTION__._ZN6basisu9Resampler10resample_xEPfPKf) #4
  unreachable

23:                                               ; No predecessors!
  br label %24

24:                                               ; preds = %23, %21
  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
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #5
  %25 = getelementptr inbounds %"class.basisu::Resampler", ptr %12, i32 0, i32 10
  %26 = load ptr, ptr %25, align 8, !tbaa !9
  store ptr %26, ptr %10, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #5
  %27 = getelementptr inbounds %"class.basisu::Resampler", ptr %12, i32 0, i32 4
  %28 = load i32, ptr %27, align 8, !tbaa !16
  store i32 %28, ptr %7, align 4, !tbaa !17
  br label %29

29:                                               ; preds = %65, %24
  %30 = load i32, ptr %7, align 4, !tbaa !17
  %31 = icmp sgt i32 %30, 0
  br i1 %31, label %32, label %70

32:                                               ; preds = %29
  %33 = load ptr, ptr %10, align 8, !tbaa !5
  %34 = getelementptr inbounds %"struct.basisu::Resampler::Contrib_List", ptr %33, i32 0, i32 0
  %35 = load i16, ptr %34, align 8, !tbaa !18
  %36 = zext i16 %35 to i32
  store i32 %36, ptr %8, align 4, !tbaa !17
  %37 = load ptr, ptr %10, align 8, !tbaa !5
  %38 = getelementptr inbounds %"struct.basisu::Resampler::Contrib_List", ptr %37, i32 0, i32 1
  %39 = load ptr, ptr %38, align 8, !tbaa !21
  store ptr %39, ptr %11, align 8, !tbaa !5
  store float 0.000000e+00, ptr %9, align 4, !tbaa !22
  br label %40

40:                                               ; preds = %56, %32
  %41 = load i32, ptr %8, align 4, !tbaa !17
  %42 = icmp sgt i32 %41, 0
  br i1 %42, label %43, label %61

43:                                               ; preds = %40
  %44 = load ptr, ptr %6, align 8, !tbaa !5
  %45 = load ptr, ptr %11, align 8, !tbaa !5
  %46 = getelementptr inbounds %"struct.basisu::Resampler::Contrib", ptr %45, i32 0, i32 1
  %47 = load i16, ptr %46, align 4, !tbaa !23
  %48 = zext i16 %47 to i64
  %49 = getelementptr inbounds float, ptr %44, i64 %48
  %50 = load float, ptr %49, align 4, !tbaa !22
  %51 = load ptr, ptr %11, align 8, !tbaa !5
  %52 = getelementptr inbounds %"struct.basisu::Resampler::Contrib", ptr %51, i32 0, i32 0
  %53 = load float, ptr %52, align 4, !tbaa !25
  %54 = load float, ptr %9, align 4, !tbaa !22
  %55 = call float @llvm.fmuladd.f32(float %50, float %53, float %54)
  store float %55, ptr %9, align 4, !tbaa !22
  br label %56

56:                                               ; preds = %43
  %57 = load i32, ptr %8, align 4, !tbaa !17
  %58 = add nsw i32 %57, -1
  store i32 %58, ptr %8, align 4, !tbaa !17
  %59 = load ptr, ptr %11, align 8, !tbaa !5
  %60 = getelementptr inbounds %"struct.basisu::Resampler::Contrib", ptr %59, i32 1
  store ptr %60, ptr %11, align 8, !tbaa !5
  br label %40, !llvm.loop !26

61:                                               ; preds = %40
  %62 = load float, ptr %9, align 4, !tbaa !22
  %63 = load ptr, ptr %5, align 8, !tbaa !5
  %64 = getelementptr inbounds float, ptr %63, i32 1
  store ptr %64, ptr %5, align 8, !tbaa !5
  store float %62, ptr %63, align 4, !tbaa !22
  br label %65

65:                                               ; preds = %61
  %66 = load i32, ptr %7, align 4, !tbaa !17
  %67 = add nsw i32 %66, -1
  store i32 %67, ptr %7, align 4, !tbaa !17
  %68 = load ptr, ptr %10, align 8, !tbaa !5
  %69 = getelementptr inbounds %"struct.basisu::Resampler::Contrib_List", ptr %68, i32 1
  store ptr %69, ptr %10, align 8, !tbaa !5
  br label %29, !llvm.loop !28

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

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

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { 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 #3 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
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, !6, i64 0}
!6 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !6, i64 48}
!10 = !{!"_ZTSN6basisu9ResamplerE", !11, i64 0, !11, i64 4, !11, i64 8, !11, i64 12, !11, i64 16, !11, i64 20, !12, i64 24, !6, i64 32, !6, i64 40, !6, i64 48, !6, i64 56, !13, i64 64, !13, i64 65, !13, i64 66, !6, i64 72, !6, i64 80, !6, i64 88, !11, i64 96, !11, i64 100, !14, i64 104, !15, i64 108, !15, i64 112}
!11 = !{!"int", !7, i64 0}
!12 = !{!"_ZTSN6basisu9Resampler11Boundary_OpE", !7, i64 0}
!13 = !{!"bool", !7, i64 0}
!14 = !{!"_ZTSN6basisu9Resampler6StatusE", !7, i64 0}
!15 = !{!"float", !7, i64 0}
!16 = !{!10, !11, i64 16}
!17 = !{!11, !11, i64 0}
!18 = !{!19, !20, i64 0}
!19 = !{!"_ZTSN6basisu9Resampler12Contrib_ListE", !20, i64 0, !6, i64 8}
!20 = !{!"short", !7, i64 0}
!21 = !{!19, !6, i64 8}
!22 = !{!15, !15, i64 0}
!23 = !{!24, !20, i64 4}
!24 = !{!"_ZTSN6basisu9Resampler7ContribE", !15, i64 0, !20, i64 4}
!25 = !{!24, !15, i64 0}
!26 = distinct !{!26, !27}
!27 = !{!"llvm.loop.mustprogress"}
!28 = distinct !{!28, !27}


; 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 [116 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [5 x i8], align 1
@__PRETTY_FUNCTION__._ZN6basisu9Resampler10resample_xEPfPKf = external hidden unnamed_addr constant [61 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [5 x i8], align 1

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

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @_ZN6basisu9Resampler10resample_xEPfPKf(ptr nocapture noundef nonnull readonly align 8 dereferenceable(116) %0, ptr noundef writeonly %1, ptr noundef readonly %2) local_unnamed_addr #1 align 2 {
  %.not = icmp eq ptr %1, null
  br i1 %.not, label %4, label %5

4:                                                ; preds = %3
  tail call void @__assert_fail(ptr noundef nonnull @.str.2, ptr noundef nonnull @.str.1, i32 noundef 352, ptr noundef nonnull @__PRETTY_FUNCTION__._ZN6basisu9Resampler10resample_xEPfPKf) #3
  unreachable

5:                                                ; preds = %3
  %.not23 = icmp eq ptr %2, null
  br i1 %.not23, label %6, label %7

6:                                                ; preds = %5
  tail call void @__assert_fail(ptr noundef nonnull @.str.3, ptr noundef nonnull @.str.1, i32 noundef 353, ptr noundef nonnull @__PRETTY_FUNCTION__._ZN6basisu9Resampler10resample_xEPfPKf) #3
  unreachable

7:                                                ; preds = %5
  %8 = getelementptr inbounds i8, ptr %0, i64 16
  %9 = load i32, ptr %8, align 8, !tbaa !5
  %10 = icmp sgt i32 %9, 0
  br i1 %10, label %.lr.ph31.preheader, label %._crit_edge32

.lr.ph31.preheader:                               ; preds = %7
  %11 = getelementptr inbounds i8, ptr %0, i64 48
  %12 = load ptr, ptr %11, align 8, !tbaa !15
  br label %.lr.ph31

.lr.ph31:                                         ; preds = %.lr.ph31.preheader, %._crit_edge
  %.01629 = phi ptr [ %64, %._crit_edge ], [ %12, %.lr.ph31.preheader ]
  %.01928 = phi i32 [ %63, %._crit_edge ], [ %9, %.lr.ph31.preheader ]
  %.02027 = phi ptr [ %62, %._crit_edge ], [ %1, %.lr.ph31.preheader ]
  %13 = load i16, ptr %.01629, align 8, !tbaa !16
  %.not33 = icmp eq i16 %13, 0
  br i1 %.not33, label %._crit_edge, label %.lr.ph.preheader

.lr.ph.preheader:                                 ; preds = %.lr.ph31
  %14 = getelementptr inbounds i8, ptr %.01629, i64 8
  %15 = load ptr, ptr %14, align 8, !tbaa !19
  %16 = zext i16 %13 to i32
  %xtraiter = and i32 %16, 3
  %lcmp.mod.not = icmp eq i32 %xtraiter, 0
  br i1 %lcmp.mod.not, label %.lr.ph.prol.loopexit, label %.lr.ph.prol

.lr.ph.prol:                                      ; preds = %.lr.ph.preheader, %.lr.ph.prol
  %.026.prol = phi ptr [ %25, %.lr.ph.prol ], [ %15, %.lr.ph.preheader ]
  %.01725.prol = phi float [ %23, %.lr.ph.prol ], [ 0.000000e+00, %.lr.ph.preheader ]
  %.01824.prol = phi i32 [ %24, %.lr.ph.prol ], [ %16, %.lr.ph.preheader ]
  %prol.iter = phi i32 [ %prol.iter.next, %.lr.ph.prol ], [ 0, %.lr.ph.preheader ]
  %17 = getelementptr inbounds i8, ptr %.026.prol, i64 4
  %18 = load i16, ptr %17, align 4, !tbaa !20
  %19 = zext i16 %18 to i64
  %20 = getelementptr inbounds float, ptr %2, i64 %19
  %21 = load float, ptr %20, align 4, !tbaa !22
  %22 = load float, ptr %.026.prol, align 4, !tbaa !23
  %23 = tail call float @llvm.fmuladd.f32(float %21, float %22, float %.01725.prol)
  %24 = add nsw i32 %.01824.prol, -1
  %25 = getelementptr inbounds i8, ptr %.026.prol, i64 8
  %prol.iter.next = add i32 %prol.iter, 1
  %prol.iter.cmp.not = icmp eq i32 %prol.iter.next, %xtraiter
  br i1 %prol.iter.cmp.not, label %.lr.ph.prol.loopexit, label %.lr.ph.prol, !llvm.loop !24

.lr.ph.prol.loopexit:                             ; preds = %.lr.ph.prol, %.lr.ph.preheader
  %.026.unr = phi ptr [ %15, %.lr.ph.preheader ], [ %25, %.lr.ph.prol ]
  %.01725.unr = phi float [ 0.000000e+00, %.lr.ph.preheader ], [ %23, %.lr.ph.prol ]
  %.01824.unr = phi i32 [ %16, %.lr.ph.preheader ], [ %24, %.lr.ph.prol ]
  %.lcssa.unr = phi float [ poison, %.lr.ph.preheader ], [ %23, %.lr.ph.prol ]
  %26 = icmp ult i16 %13, 4
  br i1 %26, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %.lr.ph.prol.loopexit, %.lr.ph
  %.026 = phi ptr [ %59, %.lr.ph ], [ %.026.unr, %.lr.ph.prol.loopexit ]
  %.01725 = phi float [ %57, %.lr.ph ], [ %.01725.unr, %.lr.ph.prol.loopexit ]
  %.01824 = phi i32 [ %58, %.lr.ph ], [ %.01824.unr, %.lr.ph.prol.loopexit ]
  %27 = getelementptr inbounds i8, ptr %.026, i64 4
  %28 = load i16, ptr %27, align 4, !tbaa !20
  %29 = zext i16 %28 to i64
  %30 = getelementptr inbounds float, ptr %2, i64 %29
  %31 = load float, ptr %30, align 4, !tbaa !22
  %32 = load float, ptr %.026, align 4, !tbaa !23
  %33 = tail call float @llvm.fmuladd.f32(float %31, float %32, float %.01725)
  %34 = getelementptr inbounds i8, ptr %.026, i64 8
  %35 = getelementptr inbounds i8, ptr %.026, i64 12
  %36 = load i16, ptr %35, align 4, !tbaa !20
  %37 = zext i16 %36 to i64
  %38 = getelementptr inbounds float, ptr %2, i64 %37
  %39 = load float, ptr %38, align 4, !tbaa !22
  %40 = load float, ptr %34, align 4, !tbaa !23
  %41 = tail call float @llvm.fmuladd.f32(float %39, float %40, float %33)
  %42 = getelementptr inbounds i8, ptr %.026, i64 16
  %43 = getelementptr inbounds i8, ptr %.026, i64 20
  %44 = load i16, ptr %43, align 4, !tbaa !20
  %45 = zext i16 %44 to i64
  %46 = getelementptr inbounds float, ptr %2, i64 %45
  %47 = load float, ptr %46, align 4, !tbaa !22
  %48 = load float, ptr %42, align 4, !tbaa !23
  %49 = tail call float @llvm.fmuladd.f32(float %47, float %48, float %41)
  %50 = getelementptr inbounds i8, ptr %.026, i64 24
  %51 = getelementptr inbounds i8, ptr %.026, i64 28
  %52 = load i16, ptr %51, align 4, !tbaa !20
  %53 = zext i16 %52 to i64
  %54 = getelementptr inbounds float, ptr %2, i64 %53
  %55 = load float, ptr %54, align 4, !tbaa !22
  %56 = load float, ptr %50, align 4, !tbaa !23
  %57 = tail call float @llvm.fmuladd.f32(float %55, float %56, float %49)
  %58 = add nsw i32 %.01824, -4
  %59 = getelementptr inbounds i8, ptr %.026, i64 32
  %60 = add i32 %.01824, -5
  %61 = icmp ult i32 %60, -2
  br i1 %61, label %.lr.ph, label %._crit_edge, !llvm.loop !26

._crit_edge:                                      ; preds = %.lr.ph.prol.loopexit, %.lr.ph, %.lr.ph31
  %.017.lcssa = phi float [ 0.000000e+00, %.lr.ph31 ], [ %.lcssa.unr, %.lr.ph.prol.loopexit ], [ %57, %.lr.ph ]
  %62 = getelementptr inbounds i8, ptr %.02027, i64 4
  store float %.017.lcssa, ptr %.02027, align 4, !tbaa !22
  %63 = add nsw i32 %.01928, -1
  %64 = getelementptr inbounds i8, ptr %.01629, i64 16
  %65 = icmp sgt i32 %.01928, 1
  br i1 %65, label %.lr.ph31, label %._crit_edge32, !llvm.loop !28

._crit_edge32:                                    ; preds = %._crit_edge, %7
  ret void
}

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

attributes #0 = { 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 #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 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #3 = { 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, !7, i64 16}
!6 = !{!"_ZTSN6basisu9ResamplerE", !7, i64 0, !7, i64 4, !7, i64 8, !7, i64 12, !7, i64 16, !7, i64 20, !10, i64 24, !11, i64 32, !11, i64 40, !11, i64 48, !11, i64 56, !12, i64 64, !12, i64 65, !12, i64 66, !11, i64 72, !11, i64 80, !11, i64 88, !7, i64 96, !7, i64 100, !13, i64 104, !14, i64 108, !14, i64 112}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"_ZTSN6basisu9Resampler11Boundary_OpE", !8, i64 0}
!11 = !{!"any pointer", !8, i64 0}
!12 = !{!"bool", !8, i64 0}
!13 = !{!"_ZTSN6basisu9Resampler6StatusE", !8, i64 0}
!14 = !{!"float", !8, i64 0}
!15 = !{!6, !11, i64 48}
!16 = !{!17, !18, i64 0}
!17 = !{!"_ZTSN6basisu9Resampler12Contrib_ListE", !18, i64 0, !11, i64 8}
!18 = !{!"short", !8, i64 0}
!19 = !{!17, !11, i64 8}
!20 = !{!21, !18, i64 4}
!21 = !{!"_ZTSN6basisu9Resampler7ContribE", !14, i64 0, !18, i64 4}
!22 = !{!14, !14, i64 0}
!23 = !{!21, !14, i64 0}
!24 = distinct !{!24, !25}
!25 = !{!"llvm.loop.unroll.disable"}
!26 = distinct !{!26, !27}
!27 = !{!"llvm.loop.mustprogress"}
!28 = distinct !{!28, !27}


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