; LLVM IR from glaretechnologies/substrata :: opus/opus-1.3.1/silk (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"

%struct._silk_resampler_state_struct = type { [6 x i32], %union.anon, [48 x i16], i32, i32, i32, i32, i32, i32, i32, i32, ptr }
%union.anon = type { [36 x i32] }

; 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 i32 @silk_resampler(ptr noundef %0, ptr noundef %1, ptr noundef %2, i32 noundef %3) #1 {
  %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
  store i32 %3, ptr %8, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #4
  %10 = load ptr, ptr %5, align 8, !tbaa !5
  %11 = getelementptr inbounds %struct._silk_resampler_state_struct, ptr %10, i32 0, i32 8
  %12 = load i32, ptr %11, align 4, !tbaa !11
  %13 = load ptr, ptr %5, align 8, !tbaa !5
  %14 = getelementptr inbounds %struct._silk_resampler_state_struct, ptr %13, i32 0, i32 10
  %15 = load i32, ptr %14, align 4, !tbaa !13
  %16 = sub nsw i32 %12, %15
  store i32 %16, ptr %9, align 4, !tbaa !9
  %17 = load ptr, ptr %5, align 8, !tbaa !5
  %18 = getelementptr inbounds %struct._silk_resampler_state_struct, ptr %17, i32 0, i32 2
  %19 = load ptr, ptr %5, align 8, !tbaa !5
  %20 = getelementptr inbounds %struct._silk_resampler_state_struct, ptr %19, i32 0, i32 10
  %21 = load i32, ptr %20, align 4, !tbaa !13
  %22 = sext i32 %21 to i64
  %23 = getelementptr inbounds [48 x i16], ptr %18, i64 0, i64 %22
  %24 = load ptr, ptr %7, align 8, !tbaa !5
  %25 = load i32, ptr %9, align 4, !tbaa !9
  %26 = sext i32 %25 to i64
  %27 = mul i64 %26, 2
  call void @llvm.memcpy.p0.p0.i64(ptr align 2 %23, ptr align 2 %24, i64 %27, i1 false)
  %28 = load ptr, ptr %5, align 8, !tbaa !5
  %29 = getelementptr inbounds %struct._silk_resampler_state_struct, ptr %28, i32 0, i32 3
  %30 = load i32, ptr %29, align 8, !tbaa !14
  switch i32 %30, label %106 [
    i32 1, label %31
    i32 2, label %56
    i32 3, label %81
  ]

31:                                               ; preds = %4
  %32 = load ptr, ptr %5, align 8, !tbaa !5
  %33 = load ptr, ptr %6, align 8, !tbaa !5
  %34 = load ptr, ptr %5, align 8, !tbaa !5
  %35 = getelementptr inbounds %struct._silk_resampler_state_struct, ptr %34, i32 0, i32 2
  %36 = getelementptr inbounds [48 x i16], ptr %35, i64 0, i64 0
  %37 = load ptr, ptr %5, align 8, !tbaa !5
  %38 = getelementptr inbounds %struct._silk_resampler_state_struct, ptr %37, i32 0, i32 8
  %39 = load i32, ptr %38, align 4, !tbaa !11
  call void @silk_resampler_private_up2_HQ_wrapper(ptr noundef %32, ptr noundef %33, ptr noundef %36, i32 noundef %39)
  %40 = load ptr, ptr %5, align 8, !tbaa !5
  %41 = load ptr, ptr %6, align 8, !tbaa !5
  %42 = load ptr, ptr %5, align 8, !tbaa !5
  %43 = getelementptr inbounds %struct._silk_resampler_state_struct, ptr %42, i32 0, i32 9
  %44 = load i32, ptr %43, align 8, !tbaa !15
  %45 = sext i32 %44 to i64
  %46 = getelementptr inbounds i16, ptr %41, i64 %45
  %47 = load ptr, ptr %7, align 8, !tbaa !5
  %48 = load i32, ptr %9, align 4, !tbaa !9
  %49 = sext i32 %48 to i64
  %50 = getelementptr inbounds i16, ptr %47, i64 %49
  %51 = load i32, ptr %8, align 4, !tbaa !9
  %52 = load ptr, ptr %5, align 8, !tbaa !5
  %53 = getelementptr inbounds %struct._silk_resampler_state_struct, ptr %52, i32 0, i32 8
  %54 = load i32, ptr %53, align 4, !tbaa !11
  %55 = sub nsw i32 %51, %54
  call void @silk_resampler_private_up2_HQ_wrapper(ptr noundef %40, ptr noundef %46, ptr noundef %50, i32 noundef %55)
  br label %133

56:                                               ; preds = %4
  %57 = load ptr, ptr %5, align 8, !tbaa !5
  %58 = load ptr, ptr %6, align 8, !tbaa !5
  %59 = load ptr, ptr %5, align 8, !tbaa !5
  %60 = getelementptr inbounds %struct._silk_resampler_state_struct, ptr %59, i32 0, i32 2
  %61 = getelementptr inbounds [48 x i16], ptr %60, i64 0, i64 0
  %62 = load ptr, ptr %5, align 8, !tbaa !5
  %63 = getelementptr inbounds %struct._silk_resampler_state_struct, ptr %62, i32 0, i32 8
  %64 = load i32, ptr %63, align 4, !tbaa !11
  call void @silk_resampler_private_IIR_FIR(ptr noundef %57, ptr noundef %58, ptr noundef %61, i32 noundef %64)
  %65 = load ptr, ptr %5, align 8, !tbaa !5
  %66 = load ptr, ptr %6, align 8, !tbaa !5
  %67 = load ptr, ptr %5, align 8, !tbaa !5
  %68 = getelementptr inbounds %struct._silk_resampler_state_struct, ptr %67, i32 0, i32 9
  %69 = load i32, ptr %68, align 8, !tbaa !15
  %70 = sext i32 %69 to i64
  %71 = getelementptr inbounds i16, ptr %66, i64 %70
  %72 = load ptr, ptr %7, align 8, !tbaa !5
  %73 = load i32, ptr %9, align 4, !tbaa !9
  %74 = sext i32 %73 to i64
  %75 = getelementptr inbounds i16, ptr %72, i64 %74
  %76 = load i32, ptr %8, align 4, !tbaa !9
  %77 = load ptr, ptr %5, align 8, !tbaa !5
  %78 = getelementptr inbounds %struct._silk_resampler_state_struct, ptr %77, i32 0, i32 8
  %79 = load i32, ptr %78, align 4, !tbaa !11
  %80 = sub nsw i32 %76, %79
  call void @silk_resampler_private_IIR_FIR(ptr noundef %65, ptr noundef %71, ptr noundef %75, i32 noundef %80)
  br label %133

81:                                               ; preds = %4
  %82 = load ptr, ptr %5, align 8, !tbaa !5
  %83 = load ptr, ptr %6, align 8, !tbaa !5
  %84 = load ptr, ptr %5, align 8, !tbaa !5
  %85 = getelementptr inbounds %struct._silk_resampler_state_struct, ptr %84, i32 0, i32 2
  %86 = getelementptr inbounds [48 x i16], ptr %85, i64 0, i64 0
  %87 = load ptr, ptr %5, align 8, !tbaa !5
  %88 = getelementptr inbounds %struct._silk_resampler_state_struct, ptr %87, i32 0, i32 8
  %89 = load i32, ptr %88, align 4, !tbaa !11
  call void @silk_resampler_private_down_FIR(ptr noundef %82, ptr noundef %83, ptr noundef %86, i32 noundef %89)
  %90 = load ptr, ptr %5, align 8, !tbaa !5
  %91 = load ptr, ptr %6, align 8, !tbaa !5
  %92 = load ptr, ptr %5, align 8, !tbaa !5
  %93 = getelementptr inbounds %struct._silk_resampler_state_struct, ptr %92, i32 0, i32 9
  %94 = load i32, ptr %93, align 8, !tbaa !15
  %95 = sext i32 %94 to i64
  %96 = getelementptr inbounds i16, ptr %91, i64 %95
  %97 = load ptr, ptr %7, align 8, !tbaa !5
  %98 = load i32, ptr %9, align 4, !tbaa !9
  %99 = sext i32 %98 to i64
  %100 = getelementptr inbounds i16, ptr %97, i64 %99
  %101 = load i32, ptr %8, align 4, !tbaa !9
  %102 = load ptr, ptr %5, align 8, !tbaa !5
  %103 = getelementptr inbounds %struct._silk_resampler_state_struct, ptr %102, i32 0, i32 8
  %104 = load i32, ptr %103, align 4, !tbaa !11
  %105 = sub nsw i32 %101, %104
  call void @silk_resampler_private_down_FIR(ptr noundef %90, ptr noundef %96, ptr noundef %100, i32 noundef %105)
  br label %133

106:                                              ; preds = %4
  %107 = load ptr, ptr %6, align 8, !tbaa !5
  %108 = load ptr, ptr %5, align 8, !tbaa !5
  %109 = getelementptr inbounds %struct._silk_resampler_state_struct, ptr %108, i32 0, i32 2
  %110 = getelementptr inbounds [48 x i16], ptr %109, i64 0, i64 0
  %111 = load ptr, ptr %5, align 8, !tbaa !5
  %112 = getelementptr inbounds %struct._silk_resampler_state_struct, ptr %111, i32 0, i32 8
  %113 = load i32, ptr %112, align 4, !tbaa !11
  %114 = sext i32 %113 to i64
  %115 = mul i64 %114, 2
  call void @llvm.memcpy.p0.p0.i64(ptr align 2 %107, ptr align 8 %110, i64 %115, i1 false)
  %116 = load ptr, ptr %6, align 8, !tbaa !5
  %117 = load ptr, ptr %5, align 8, !tbaa !5
  %118 = getelementptr inbounds %struct._silk_resampler_state_struct, ptr %117, i32 0, i32 9
  %119 = load i32, ptr %118, align 8, !tbaa !15
  %120 = sext i32 %119 to i64
  %121 = getelementptr inbounds i16, ptr %116, i64 %120
  %122 = load ptr, ptr %7, align 8, !tbaa !5
  %123 = load i32, ptr %9, align 4, !tbaa !9
  %124 = sext i32 %123 to i64
  %125 = getelementptr inbounds i16, ptr %122, i64 %124
  %126 = load i32, ptr %8, align 4, !tbaa !9
  %127 = load ptr, ptr %5, align 8, !tbaa !5
  %128 = getelementptr inbounds %struct._silk_resampler_state_struct, ptr %127, i32 0, i32 8
  %129 = load i32, ptr %128, align 4, !tbaa !11
  %130 = sub nsw i32 %126, %129
  %131 = sext i32 %130 to i64
  %132 = mul i64 %131, 2
  call void @llvm.memcpy.p0.p0.i64(ptr align 2 %121, ptr align 2 %125, i64 %132, i1 false)
  br label %133

133:                                              ; preds = %106, %81, %56, %31
  %134 = load ptr, ptr %5, align 8, !tbaa !5
  %135 = getelementptr inbounds %struct._silk_resampler_state_struct, ptr %134, i32 0, i32 2
  %136 = getelementptr inbounds [48 x i16], ptr %135, i64 0, i64 0
  %137 = load ptr, ptr %7, align 8, !tbaa !5
  %138 = load i32, ptr %8, align 4, !tbaa !9
  %139 = load ptr, ptr %5, align 8, !tbaa !5
  %140 = getelementptr inbounds %struct._silk_resampler_state_struct, ptr %139, i32 0, i32 10
  %141 = load i32, ptr %140, align 4, !tbaa !13
  %142 = sub nsw i32 %138, %141
  %143 = sext i32 %142 to i64
  %144 = getelementptr inbounds i16, ptr %137, i64 %143
  %145 = load ptr, ptr %5, align 8, !tbaa !5
  %146 = getelementptr inbounds %struct._silk_resampler_state_struct, ptr %145, i32 0, i32 10
  %147 = load i32, ptr %146, align 4, !tbaa !13
  %148 = sext i32 %147 to i64
  %149 = mul i64 %148, 2
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %136, ptr align 2 %144, i64 %149, i1 false)
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #4
  ret i32 0
}

; 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

declare void @silk_resampler_private_up2_HQ_wrapper(ptr noundef, ptr noundef, ptr noundef, i32 noundef) #3

declare void @silk_resampler_private_IIR_FIR(ptr noundef, ptr noundef, ptr noundef, i32 noundef) #3

declare void @silk_resampler_private_down_FIR(ptr noundef, ptr noundef, ptr noundef, i32 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 = { "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 }

!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, !10, i64 284}
!12 = !{!"_silk_resampler_state_struct", !7, i64 0, !7, i64 24, !7, i64 168, !10, i64 264, !10, i64 268, !10, i64 272, !10, i64 276, !10, i64 280, !10, i64 284, !10, i64 288, !10, i64 292, !6, i64 296}
!13 = !{!12, !10, i64 292}
!14 = !{!12, !10, i64 264}
!15 = !{!12, !10, i64 288}


; 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: nounwind uwtable
define dso_local noundef i32 @silk_resampler(ptr noundef %0, ptr noundef %1, ptr noundef %2, i32 noundef %3) local_unnamed_addr #0 {
  %5 = getelementptr inbounds i8, ptr %0, i64 284
  %6 = load i32, ptr %5, align 4, !tbaa !5
  %7 = getelementptr inbounds i8, ptr %0, i64 292
  %8 = load i32, ptr %7, align 4, !tbaa !11
  %9 = sub nsw i32 %6, %8
  %10 = getelementptr inbounds i8, ptr %0, i64 168
  %11 = sext i32 %8 to i64
  %12 = getelementptr inbounds [48 x i16], ptr %10, i64 0, i64 %11
  %13 = sext i32 %9 to i64
  %14 = shl nsw i64 %13, 1
  tail call void @llvm.memcpy.p0.p0.i64(ptr nonnull align 2 %12, ptr align 2 %2, i64 %14, i1 false)
  %15 = getelementptr inbounds i8, ptr %0, i64 264
  %16 = load i32, ptr %15, align 8, !tbaa !12
  %17 = load i32, ptr %5, align 4, !tbaa !5
  switch i32 %16, label %42 [
    i32 1, label %18
    i32 2, label %26
    i32 3, label %34
  ]

18:                                               ; preds = %4
  tail call void @silk_resampler_private_up2_HQ_wrapper(ptr noundef nonnull %0, ptr noundef %1, ptr noundef nonnull %10, i32 noundef %17) #3
  %19 = getelementptr inbounds i8, ptr %0, i64 288
  %20 = load i32, ptr %19, align 8, !tbaa !13
  %21 = sext i32 %20 to i64
  %22 = getelementptr inbounds i16, ptr %1, i64 %21
  %23 = getelementptr inbounds i16, ptr %2, i64 %13
  %24 = load i32, ptr %5, align 4, !tbaa !5
  %25 = sub nsw i32 %3, %24
  tail call void @silk_resampler_private_up2_HQ_wrapper(ptr noundef nonnull %0, ptr noundef %22, ptr noundef %23, i32 noundef %25) #3
  br label %54

26:                                               ; preds = %4
  tail call void @silk_resampler_private_IIR_FIR(ptr noundef nonnull %0, ptr noundef %1, ptr noundef nonnull %10, i32 noundef %17) #3
  %27 = getelementptr inbounds i8, ptr %0, i64 288
  %28 = load i32, ptr %27, align 8, !tbaa !13
  %29 = sext i32 %28 to i64
  %30 = getelementptr inbounds i16, ptr %1, i64 %29
  %31 = getelementptr inbounds i16, ptr %2, i64 %13
  %32 = load i32, ptr %5, align 4, !tbaa !5
  %33 = sub nsw i32 %3, %32
  tail call void @silk_resampler_private_IIR_FIR(ptr noundef nonnull %0, ptr noundef %30, ptr noundef %31, i32 noundef %33) #3
  br label %54

34:                                               ; preds = %4
  tail call void @silk_resampler_private_down_FIR(ptr noundef nonnull %0, ptr noundef %1, ptr noundef nonnull %10, i32 noundef %17) #3
  %35 = getelementptr inbounds i8, ptr %0, i64 288
  %36 = load i32, ptr %35, align 8, !tbaa !13
  %37 = sext i32 %36 to i64
  %38 = getelementptr inbounds i16, ptr %1, i64 %37
  %39 = getelementptr inbounds i16, ptr %2, i64 %13
  %40 = load i32, ptr %5, align 4, !tbaa !5
  %41 = sub nsw i32 %3, %40
  tail call void @silk_resampler_private_down_FIR(ptr noundef nonnull %0, ptr noundef %38, ptr noundef %39, i32 noundef %41) #3
  br label %54

42:                                               ; preds = %4
  %43 = sext i32 %17 to i64
  %44 = shl nsw i64 %43, 1
  tail call void @llvm.memcpy.p0.p0.i64(ptr align 2 %1, ptr nonnull align 8 %10, i64 %44, i1 false)
  %45 = getelementptr inbounds i8, ptr %0, i64 288
  %46 = load i32, ptr %45, align 8, !tbaa !13
  %47 = sext i32 %46 to i64
  %48 = getelementptr inbounds i16, ptr %1, i64 %47
  %49 = getelementptr inbounds i16, ptr %2, i64 %13
  %50 = load i32, ptr %5, align 4, !tbaa !5
  %51 = sub nsw i32 %3, %50
  %52 = sext i32 %51 to i64
  %53 = shl nsw i64 %52, 1
  tail call void @llvm.memcpy.p0.p0.i64(ptr align 2 %48, ptr align 2 %49, i64 %53, i1 false)
  br label %54

54:                                               ; preds = %42, %34, %26, %18
  %55 = load i32, ptr %7, align 4, !tbaa !11
  %56 = sub nsw i32 %3, %55
  %57 = sext i32 %56 to i64
  %58 = getelementptr inbounds i16, ptr %2, i64 %57
  %59 = sext i32 %55 to i64
  %60 = shl nsw i64 %59, 1
  tail call void @llvm.memcpy.p0.p0.i64(ptr nonnull align 8 %10, ptr align 2 %58, i64 %60, i1 false)
  ret i32 0
}

; 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) #1

declare void @silk_resampler_private_up2_HQ_wrapper(ptr noundef, ptr noundef, ptr noundef, i32 noundef) local_unnamed_addr #2

declare void @silk_resampler_private_IIR_FIR(ptr noundef, ptr noundef, ptr noundef, i32 noundef) local_unnamed_addr #2

declare void @silk_resampler_private_down_FIR(ptr noundef, ptr noundef, ptr noundef, i32 noundef) local_unnamed_addr #2

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

!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, !9, i64 284}
!6 = !{!"_silk_resampler_state_struct", !7, i64 0, !7, i64 24, !7, i64 168, !9, i64 264, !9, i64 268, !9, i64 272, !9, i64 276, !9, i64 280, !9, i64 284, !9, i64 288, !9, i64 292, !10, i64 296}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!"int", !7, i64 0}
!10 = !{!"any pointer", !7, i64 0}
!11 = !{!6, !9, i64 292}
!12 = !{!6, !9, i64 264}
!13 = !{!6, !9, i64 288}


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