; LLVM IR from glaretechnologies/substrata :: opus/opus-1.3.1/silk/float (LTP_scale_ctrl_FLP)

; 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_encoder_state_FLP = type { %struct.silk_encoder_state, %struct.silk_shape_state_FLP, [720 x float], float }
%struct.silk_encoder_state = type { [2 x i32], i32, i32, %struct.silk_LP_state, %struct.silk_VAD_state, %struct.silk_nsq_state, [16 x i16], i32, i32, i8, i8, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, ptr, ptr, ptr, [4 x i32], i32, i32, [3 x i8], i8, [3 x i32], %struct.SideInfoIndices, [320 x i8], i32, [322 x i16], i32, i32, i32, i32, i32, i32, i32, i32, i16, %struct._silk_resampler_state_struct, i32, i32, i32, i32, i32, i32, [3 x %struct.SideInfoIndices], [3 x [320 x i8]] }
%struct.silk_LP_state = type { [2 x i32], i32, i32, i32 }
%struct.silk_VAD_state = type { [2 x i32], [2 x i32], [2 x i32], [4 x i32], [4 x i32], i16, [4 x i32], [4 x i32], [4 x i32], i32 }
%struct.silk_nsq_state = type { [640 x i16], [640 x i32], [96 x i32], [24 x i32], i32, i32, i32, i32, i32, i32, i32, i32 }
%struct.SideInfoIndices = type { [4 x i8], [4 x i8], [17 x i8], i16, i8, i8, i8, i8, i8, i8, i8 }
%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] }
%struct.silk_shape_state_FLP = type { i8, float, float }
%struct.silk_encoder_control_FLP = type { [4 x float], [2 x [16 x float]], [20 x float], float, [4 x i32], [96 x float], [4 x float], [4 x float], [4 x float], [4 x float], float, float, float, float, float, [4 x float], [4 x i32], i8 }

@silk_LTPScales_table_Q14 = external constant [3 x i16], align 2

; Function Attrs: nounwind uwtable
define dso_local void @silk_LTP_scale_ctrl_FLP(ptr noundef %0, ptr noundef %1, i32 noundef %2) #0 {
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  store i32 %2, ptr %6, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #2
  %8 = load i32, ptr %6, align 4, !tbaa !9
  %9 = icmp eq i32 %8, 0
  br i1 %9, label %10, label %56

10:                                               ; preds = %3
  %11 = load ptr, ptr %4, align 8, !tbaa !5
  %12 = getelementptr inbounds %struct.silk_encoder_state_FLP, ptr %11, i32 0, i32 0
  %13 = getelementptr inbounds %struct.silk_encoder_state, ptr %12, i32 0, i32 29
  %14 = load i32, ptr %13, align 8, !tbaa !11
  %15 = load ptr, ptr %4, align 8, !tbaa !5
  %16 = getelementptr inbounds %struct.silk_encoder_state_FLP, ptr %15, i32 0, i32 0
  %17 = getelementptr inbounds %struct.silk_encoder_state, ptr %16, i32 0, i32 60
  %18 = load i32, ptr %17, align 8, !tbaa !22
  %19 = add nsw i32 %14, %18
  store i32 %19, ptr %7, align 4, !tbaa !9
  %20 = load i32, ptr %7, align 4, !tbaa !9
  %21 = sitofp i32 %20 to float
  %22 = load ptr, ptr %5, align 8, !tbaa !5
  %23 = getelementptr inbounds %struct.silk_encoder_control_FLP, ptr %22, i32 0, i32 14
  %24 = load float, ptr %23, align 4, !tbaa !23
  %25 = fmul float %21, %24
  %26 = fmul float %25, 0x3FB99999A0000000
  %27 = fcmp ogt float %26, 2.000000e+00
  br i1 %27, label %28, label %29

28:                                               ; preds = %10
  br label %49

29:                                               ; preds = %10
  %30 = load i32, ptr %7, align 4, !tbaa !9
  %31 = sitofp i32 %30 to float
  %32 = load ptr, ptr %5, align 8, !tbaa !5
  %33 = getelementptr inbounds %struct.silk_encoder_control_FLP, ptr %32, i32 0, i32 14
  %34 = load float, ptr %33, align 4, !tbaa !23
  %35 = fmul float %31, %34
  %36 = fmul float %35, 0x3FB99999A0000000
  %37 = fcmp olt float %36, 0.000000e+00
  br i1 %37, label %38, label %39

38:                                               ; preds = %29
  br label %47

39:                                               ; preds = %29
  %40 = load i32, ptr %7, align 4, !tbaa !9
  %41 = sitofp i32 %40 to float
  %42 = load ptr, ptr %5, align 8, !tbaa !5
  %43 = getelementptr inbounds %struct.silk_encoder_control_FLP, ptr %42, i32 0, i32 14
  %44 = load float, ptr %43, align 4, !tbaa !23
  %45 = fmul float %41, %44
  %46 = fmul float %45, 0x3FB99999A0000000
  br label %47

47:                                               ; preds = %39, %38
  %48 = phi float [ 0.000000e+00, %38 ], [ %46, %39 ]
  br label %49

49:                                               ; preds = %47, %28
  %50 = phi float [ 2.000000e+00, %28 ], [ %48, %47 ]
  %51 = fptosi float %50 to i8
  %52 = load ptr, ptr %4, align 8, !tbaa !5
  %53 = getelementptr inbounds %struct.silk_encoder_state_FLP, ptr %52, i32 0, i32 0
  %54 = getelementptr inbounds %struct.silk_encoder_state, ptr %53, i32 0, i32 55
  %55 = getelementptr inbounds %struct.SideInfoIndices, ptr %54, i32 0, i32 9
  store i8 %51, ptr %55, align 1, !tbaa !25
  br label %61

56:                                               ; preds = %3
  %57 = load ptr, ptr %4, align 8, !tbaa !5
  %58 = getelementptr inbounds %struct.silk_encoder_state_FLP, ptr %57, i32 0, i32 0
  %59 = getelementptr inbounds %struct.silk_encoder_state, ptr %58, i32 0, i32 55
  %60 = getelementptr inbounds %struct.SideInfoIndices, ptr %59, i32 0, i32 9
  store i8 0, ptr %60, align 1, !tbaa !25
  br label %61

61:                                               ; preds = %56, %49
  %62 = load ptr, ptr %4, align 8, !tbaa !5
  %63 = getelementptr inbounds %struct.silk_encoder_state_FLP, ptr %62, i32 0, i32 0
  %64 = getelementptr inbounds %struct.silk_encoder_state, ptr %63, i32 0, i32 55
  %65 = getelementptr inbounds %struct.SideInfoIndices, ptr %64, i32 0, i32 9
  %66 = load i8, ptr %65, align 1, !tbaa !25
  %67 = sext i8 %66 to i64
  %68 = getelementptr inbounds [3 x i16], ptr @silk_LTPScales_table_Q14, i64 0, i64 %67
  %69 = load i16, ptr %68, align 2, !tbaa !26
  %70 = sitofp i16 %69 to float
  %71 = fdiv float %70, 1.638400e+04
  %72 = load ptr, ptr %5, align 8, !tbaa !5
  %73 = getelementptr inbounds %struct.silk_encoder_control_FLP, ptr %72, i32 0, i32 3
  store float %71, ptr %73, align 4, !tbaa !27
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #2
  ret void
}

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

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

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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { 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 4616}
!12 = !{!"", !13, i64 0, !20, i64 7192, !7, i64 7204, !21, i64 10084}
!13 = !{!"", !7, i64 0, !10, i64 8, !10, i64 12, !14, i64 16, !15, i64 36, !17, i64 148, !7, i64 4500, !10, i64 4532, !10, i64 4536, !7, i64 4540, !7, i64 4541, !10, i64 4544, !10, i64 4548, !10, i64 4552, !10, i64 4556, !10, i64 4560, !10, i64 4564, !10, i64 4568, !10, i64 4572, !10, i64 4576, !10, i64 4580, !10, i64 4584, !10, i64 4588, !10, i64 4592, !10, i64 4596, !10, i64 4600, !10, i64 4604, !10, i64 4608, !10, i64 4612, !10, i64 4616, !10, i64 4620, !10, i64 4624, !10, i64 4628, !10, i64 4632, !10, i64 4636, !10, i64 4640, !10, i64 4644, !10, i64 4648, !10, i64 4652, !10, i64 4656, !10, i64 4660, !10, i64 4664, !10, i64 4668, !10, i64 4672, !10, i64 4676, !10, i64 4680, !6, i64 4688, !6, i64 4696, !6, i64 4704, !7, i64 4712, !10, i64 4728, !10, i64 4732, !7, i64 4736, !7, i64 4739, !7, i64 4740, !18, i64 4752, !7, i64 4788, !10, i64 5108, !7, i64 5112, !10, i64 5756, !10, i64 5760, !10, i64 5764, !10, i64 5768, !10, i64 5772, !10, i64 5776, !10, i64 5780, !10, i64 5784, !16, i64 5788, !19, i64 5792, !10, i64 6096, !10, i64 6100, !10, i64 6104, !10, i64 6108, !10, i64 6112, !10, i64 6116, !7, i64 6120, !7, i64 6228}
!14 = !{!"", !7, i64 0, !10, i64 8, !10, i64 12, !10, i64 16}
!15 = !{!"", !7, i64 0, !7, i64 8, !7, i64 16, !7, i64 24, !7, i64 40, !16, i64 56, !7, i64 60, !7, i64 76, !7, i64 92, !10, i64 108}
!16 = !{!"short", !7, i64 0}
!17 = !{!"", !7, i64 0, !7, i64 1280, !7, i64 3840, !7, i64 4224, !10, i64 4320, !10, i64 4324, !10, i64 4328, !10, i64 4332, !10, i64 4336, !10, i64 4340, !10, i64 4344, !10, i64 4348}
!18 = !{!"", !7, i64 0, !7, i64 4, !7, i64 8, !16, i64 26, !7, i64 28, !7, i64 29, !7, i64 30, !7, i64 31, !7, i64 32, !7, i64 33, !7, i64 34}
!19 = !{!"_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}
!20 = !{!"", !7, i64 0, !21, i64 4, !21, i64 8}
!21 = !{!"float", !7, i64 0}
!22 = !{!12, !10, i64 5760}
!23 = !{!24, !21, i64 708}
!24 = !{!"", !7, i64 0, !7, i64 16, !7, i64 144, !21, i64 224, !7, i64 228, !7, i64 244, !7, i64 628, !7, i64 644, !7, i64 660, !7, i64 676, !21, i64 692, !21, i64 696, !21, i64 700, !21, i64 704, !21, i64 708, !7, i64 712, !7, i64 728, !7, i64 744}
!25 = !{!12, !7, i64 4785}
!26 = !{!16, !16, i64 0}
!27 = !{!24, !21, i64 224}


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

@silk_LTPScales_table_Q14 = external local_unnamed_addr constant [3 x i16], align 2

; Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: readwrite) uwtable
define dso_local void @silk_LTP_scale_ctrl_FLP(ptr nocapture noundef %0, ptr nocapture noundef %1, i32 noundef %2) local_unnamed_addr #0 {
  %4 = icmp eq i32 %2, 0
  br i1 %4, label %5, label %25

5:                                                ; preds = %3
  %6 = getelementptr inbounds i8, ptr %0, i64 4616
  %7 = load i32, ptr %6, align 8, !tbaa !5
  %8 = getelementptr inbounds i8, ptr %0, i64 5760
  %9 = load i32, ptr %8, align 8, !tbaa !20
  %10 = add nsw i32 %9, %7
  %11 = sitofp i32 %10 to float
  %12 = getelementptr inbounds i8, ptr %1, i64 708
  %13 = load float, ptr %12, align 4, !tbaa !21
  %14 = fmul float %13, %11
  %15 = fmul float %14, 0x3FB99999A0000000
  %16 = fcmp ogt float %15, 2.000000e+00
  br i1 %16, label %21, label %17

17:                                               ; preds = %5
  %18 = fcmp olt float %15, 0.000000e+00
  br i1 %18, label %21, label %19

19:                                               ; preds = %17
  %20 = fptosi float %15 to i8
  br label %21

21:                                               ; preds = %19, %17, %5
  %22 = phi i8 [ 2, %5 ], [ %20, %19 ], [ 0, %17 ]
  %23 = getelementptr inbounds i8, ptr %0, i64 4785
  store i8 %22, ptr %23, align 1, !tbaa !23
  %24 = sext i8 %22 to i64
  br label %27

25:                                               ; preds = %3
  %26 = getelementptr inbounds i8, ptr %0, i64 4785
  store i8 0, ptr %26, align 1, !tbaa !23
  br label %27

27:                                               ; preds = %25, %21
  %28 = phi i64 [ 0, %25 ], [ %24, %21 ]
  %29 = getelementptr inbounds [3 x i16], ptr @silk_LTPScales_table_Q14, i64 0, i64 %28
  %30 = load i16, ptr %29, align 2, !tbaa !24
  %31 = sitofp i16 %30 to float
  %32 = fmul float %31, 0x3F10000000000000
  %33 = getelementptr inbounds i8, ptr %1, i64 224
  store float %32, ptr %33, align 4, !tbaa !25
  ret void
}

attributes #0 = { mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: 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" }

!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 4616}
!6 = !{!"", !7, i64 0, !18, i64 7192, !8, i64 7204, !19, i64 10084}
!7 = !{!"", !8, i64 0, !10, i64 8, !10, i64 12, !11, i64 16, !12, i64 36, !14, i64 148, !8, i64 4500, !10, i64 4532, !10, i64 4536, !8, i64 4540, !8, i64 4541, !10, i64 4544, !10, i64 4548, !10, i64 4552, !10, i64 4556, !10, i64 4560, !10, i64 4564, !10, i64 4568, !10, i64 4572, !10, i64 4576, !10, i64 4580, !10, i64 4584, !10, i64 4588, !10, i64 4592, !10, i64 4596, !10, i64 4600, !10, i64 4604, !10, i64 4608, !10, i64 4612, !10, i64 4616, !10, i64 4620, !10, i64 4624, !10, i64 4628, !10, i64 4632, !10, i64 4636, !10, i64 4640, !10, i64 4644, !10, i64 4648, !10, i64 4652, !10, i64 4656, !10, i64 4660, !10, i64 4664, !10, i64 4668, !10, i64 4672, !10, i64 4676, !10, i64 4680, !15, i64 4688, !15, i64 4696, !15, i64 4704, !8, i64 4712, !10, i64 4728, !10, i64 4732, !8, i64 4736, !8, i64 4739, !8, i64 4740, !16, i64 4752, !8, i64 4788, !10, i64 5108, !8, i64 5112, !10, i64 5756, !10, i64 5760, !10, i64 5764, !10, i64 5768, !10, i64 5772, !10, i64 5776, !10, i64 5780, !10, i64 5784, !13, i64 5788, !17, i64 5792, !10, i64 6096, !10, i64 6100, !10, i64 6104, !10, i64 6108, !10, i64 6112, !10, i64 6116, !8, i64 6120, !8, i64 6228}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"int", !8, i64 0}
!11 = !{!"", !8, i64 0, !10, i64 8, !10, i64 12, !10, i64 16}
!12 = !{!"", !8, i64 0, !8, i64 8, !8, i64 16, !8, i64 24, !8, i64 40, !13, i64 56, !8, i64 60, !8, i64 76, !8, i64 92, !10, i64 108}
!13 = !{!"short", !8, i64 0}
!14 = !{!"", !8, i64 0, !8, i64 1280, !8, i64 3840, !8, i64 4224, !10, i64 4320, !10, i64 4324, !10, i64 4328, !10, i64 4332, !10, i64 4336, !10, i64 4340, !10, i64 4344, !10, i64 4348}
!15 = !{!"any pointer", !8, i64 0}
!16 = !{!"", !8, i64 0, !8, i64 4, !8, i64 8, !13, i64 26, !8, i64 28, !8, i64 29, !8, i64 30, !8, i64 31, !8, i64 32, !8, i64 33, !8, i64 34}
!17 = !{!"_silk_resampler_state_struct", !8, i64 0, !8, i64 24, !8, 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, !15, i64 296}
!18 = !{!"", !8, i64 0, !19, i64 4, !19, i64 8}
!19 = !{!"float", !8, i64 0}
!20 = !{!6, !10, i64 5760}
!21 = !{!22, !19, i64 708}
!22 = !{!"", !8, i64 0, !8, i64 16, !8, i64 144, !19, i64 224, !8, i64 228, !8, i64 244, !8, i64 628, !8, i64 644, !8, i64 660, !8, i64 676, !19, i64 692, !19, i64 696, !19, i64 700, !19, i64 704, !19, i64 708, !8, i64 712, !8, i64 728, !8, i64 744}
!23 = !{!6, !8, i64 4785}
!24 = !{!13, !13, i64 0}
!25 = !{!22, !19, i64 224}


; Effective O3 passes: BDCEPass,EarlyCSEPass,GVNPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,SimplifyCFGPass