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

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

@silk_stereo_pred_joint_iCDF = external constant [25 x i8], align 16
@silk_uniform3_iCDF = external constant [3 x i8], align 1
@silk_uniform5_iCDF = external constant [5 x i8], align 1
@silk_stereo_pred_quant_Q13 = external constant [16 x i16], align 16

; Function Attrs: nounwind uwtable
define dso_local void @silk_stereo_decode_pred(ptr noundef %0, ptr noundef %1) #0 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca i32, align 4
  %6 = alloca [2 x [3 x i32]], align 16
  %7 = alloca i32, align 4
  %8 = alloca i32, 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 4, ptr %5) #3
  call void @llvm.lifetime.start.p0(i64 24, ptr %6) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #3
  %9 = load ptr, ptr %3, align 8, !tbaa !5
  %10 = call i32 @ec_dec_icdf(ptr noundef %9, ptr noundef @silk_stereo_pred_joint_iCDF, i32 noundef 8)
  store i32 %10, ptr %5, align 4, !tbaa !9
  %11 = load i32, ptr %5, align 4, !tbaa !9
  %12 = sdiv i32 %11, 5
  %13 = getelementptr inbounds [2 x [3 x i32]], ptr %6, i64 0, i64 0
  %14 = getelementptr inbounds [3 x i32], ptr %13, i64 0, i64 2
  store i32 %12, ptr %14, align 8, !tbaa !9
  %15 = load i32, ptr %5, align 4, !tbaa !9
  %16 = getelementptr inbounds [2 x [3 x i32]], ptr %6, i64 0, i64 0
  %17 = getelementptr inbounds [3 x i32], ptr %16, i64 0, i64 2
  %18 = load i32, ptr %17, align 8, !tbaa !9
  %19 = mul nsw i32 5, %18
  %20 = sub nsw i32 %15, %19
  %21 = getelementptr inbounds [2 x [3 x i32]], ptr %6, i64 0, i64 1
  %22 = getelementptr inbounds [3 x i32], ptr %21, i64 0, i64 2
  store i32 %20, ptr %22, align 4, !tbaa !9
  store i32 0, ptr %5, align 4, !tbaa !9
  br label %23

23:                                               ; preds = %39, %2
  %24 = load i32, ptr %5, align 4, !tbaa !9
  %25 = icmp slt i32 %24, 2
  br i1 %25, label %26, label %42

26:                                               ; preds = %23
  %27 = load ptr, ptr %3, align 8, !tbaa !5
  %28 = call i32 @ec_dec_icdf(ptr noundef %27, ptr noundef @silk_uniform3_iCDF, i32 noundef 8)
  %29 = load i32, ptr %5, align 4, !tbaa !9
  %30 = sext i32 %29 to i64
  %31 = getelementptr inbounds [2 x [3 x i32]], ptr %6, i64 0, i64 %30
  %32 = getelementptr inbounds [3 x i32], ptr %31, i64 0, i64 0
  store i32 %28, ptr %32, align 4, !tbaa !9
  %33 = load ptr, ptr %3, align 8, !tbaa !5
  %34 = call i32 @ec_dec_icdf(ptr noundef %33, ptr noundef @silk_uniform5_iCDF, i32 noundef 8)
  %35 = load i32, ptr %5, align 4, !tbaa !9
  %36 = sext i32 %35 to i64
  %37 = getelementptr inbounds [2 x [3 x i32]], ptr %6, i64 0, i64 %36
  %38 = getelementptr inbounds [3 x i32], ptr %37, i64 0, i64 1
  store i32 %34, ptr %38, align 4, !tbaa !9
  br label %39

39:                                               ; preds = %26
  %40 = load i32, ptr %5, align 4, !tbaa !9
  %41 = add nsw i32 %40, 1
  store i32 %41, ptr %5, align 4, !tbaa !9
  br label %23, !llvm.loop !11

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

43:                                               ; preds = %103, %42
  %44 = load i32, ptr %5, align 4, !tbaa !9
  %45 = icmp slt i32 %44, 2
  br i1 %45, label %46, label %106

46:                                               ; preds = %43
  %47 = load i32, ptr %5, align 4, !tbaa !9
  %48 = sext i32 %47 to i64
  %49 = getelementptr inbounds [2 x [3 x i32]], ptr %6, i64 0, i64 %48
  %50 = getelementptr inbounds [3 x i32], ptr %49, i64 0, i64 2
  %51 = load i32, ptr %50, align 4, !tbaa !9
  %52 = mul nsw i32 3, %51
  %53 = load i32, ptr %5, align 4, !tbaa !9
  %54 = sext i32 %53 to i64
  %55 = getelementptr inbounds [2 x [3 x i32]], ptr %6, i64 0, i64 %54
  %56 = getelementptr inbounds [3 x i32], ptr %55, i64 0, i64 0
  %57 = load i32, ptr %56, align 4, !tbaa !9
  %58 = add nsw i32 %57, %52
  store i32 %58, ptr %56, align 4, !tbaa !9
  %59 = load i32, ptr %5, align 4, !tbaa !9
  %60 = sext i32 %59 to i64
  %61 = getelementptr inbounds [2 x [3 x i32]], ptr %6, i64 0, i64 %60
  %62 = getelementptr inbounds [3 x i32], ptr %61, i64 0, i64 0
  %63 = load i32, ptr %62, align 4, !tbaa !9
  %64 = sext i32 %63 to i64
  %65 = getelementptr inbounds [16 x i16], ptr @silk_stereo_pred_quant_Q13, i64 0, i64 %64
  %66 = load i16, ptr %65, align 2, !tbaa !13
  %67 = sext i16 %66 to i32
  store i32 %67, ptr %7, align 4, !tbaa !9
  %68 = load i32, ptr %5, align 4, !tbaa !9
  %69 = sext i32 %68 to i64
  %70 = getelementptr inbounds [2 x [3 x i32]], ptr %6, i64 0, i64 %69
  %71 = getelementptr inbounds [3 x i32], ptr %70, i64 0, i64 0
  %72 = load i32, ptr %71, align 4, !tbaa !9
  %73 = add nsw i32 %72, 1
  %74 = sext i32 %73 to i64
  %75 = getelementptr inbounds [16 x i16], ptr @silk_stereo_pred_quant_Q13, i64 0, i64 %74
  %76 = load i16, ptr %75, align 2, !tbaa !13
  %77 = sext i16 %76 to i32
  %78 = load i32, ptr %7, align 4, !tbaa !9
  %79 = sub nsw i32 %77, %78
  %80 = sext i32 %79 to i64
  %81 = mul nsw i64 %80, 6554
  %82 = ashr i64 %81, 16
  %83 = trunc i64 %82 to i32
  store i32 %83, ptr %8, align 4, !tbaa !9
  %84 = load i32, ptr %7, align 4, !tbaa !9
  %85 = load i32, ptr %8, align 4, !tbaa !9
  %86 = trunc i32 %85 to i16
  %87 = sext i16 %86 to i32
  %88 = load i32, ptr %5, align 4, !tbaa !9
  %89 = sext i32 %88 to i64
  %90 = getelementptr inbounds [2 x [3 x i32]], ptr %6, i64 0, i64 %89
  %91 = getelementptr inbounds [3 x i32], ptr %90, i64 0, i64 1
  %92 = load i32, ptr %91, align 4, !tbaa !9
  %93 = mul nsw i32 2, %92
  %94 = add nsw i32 %93, 1
  %95 = trunc i32 %94 to i16
  %96 = sext i16 %95 to i32
  %97 = mul nsw i32 %87, %96
  %98 = add nsw i32 %84, %97
  %99 = load ptr, ptr %4, align 8, !tbaa !5
  %100 = load i32, ptr %5, align 4, !tbaa !9
  %101 = sext i32 %100 to i64
  %102 = getelementptr inbounds i32, ptr %99, i64 %101
  store i32 %98, ptr %102, align 4, !tbaa !9
  br label %103

103:                                              ; preds = %46
  %104 = load i32, ptr %5, align 4, !tbaa !9
  %105 = add nsw i32 %104, 1
  store i32 %105, ptr %5, align 4, !tbaa !9
  br label %43, !llvm.loop !15

106:                                              ; preds = %43
  %107 = load ptr, ptr %4, align 8, !tbaa !5
  %108 = getelementptr inbounds i32, ptr %107, i64 1
  %109 = load i32, ptr %108, align 4, !tbaa !9
  %110 = load ptr, ptr %4, align 8, !tbaa !5
  %111 = getelementptr inbounds i32, ptr %110, i64 0
  %112 = load i32, ptr %111, align 4, !tbaa !9
  %113 = sub nsw i32 %112, %109
  store i32 %113, ptr %111, align 4, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #3
  call void @llvm.lifetime.end.p0(i64 24, ptr %6) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #3
  ret void
}

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

declare i32 @ec_dec_icdf(ptr noundef, ptr noundef, i32 noundef) #2

; 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 = { "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, !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 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = !{!14, !14, i64 0}
!14 = !{!"short", !7, i64 0}
!15 = distinct !{!15, !12}


; 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_stereo_pred_joint_iCDF = external constant [25 x i8], align 16
@silk_uniform3_iCDF = external constant [3 x i8], align 1
@silk_uniform5_iCDF = external constant [5 x i8], align 1
@silk_stereo_pred_quant_Q13 = external local_unnamed_addr constant [16 x i16], align 16

; Function Attrs: nounwind uwtable
define dso_local void @silk_stereo_decode_pred(ptr noundef %0, ptr nocapture noundef writeonly %1) local_unnamed_addr #0 {
.preheader.preheader:
  %2 = tail call i32 @ec_dec_icdf(ptr noundef %0, ptr noundef nonnull @silk_stereo_pred_joint_iCDF, i32 noundef 8) #2
  %3 = sdiv i32 %2, 5
  %.neg = mul nsw i32 %3, -5
  %4 = add i32 %.neg, %2
  %5 = tail call i32 @ec_dec_icdf(ptr noundef %0, ptr noundef nonnull @silk_uniform3_iCDF, i32 noundef 8) #2
  %6 = tail call i32 @ec_dec_icdf(ptr noundef %0, ptr noundef nonnull @silk_uniform5_iCDF, i32 noundef 8) #2
  %7 = tail call i32 @ec_dec_icdf(ptr noundef %0, ptr noundef nonnull @silk_uniform3_iCDF, i32 noundef 8) #2
  %8 = tail call i32 @ec_dec_icdf(ptr noundef %0, ptr noundef nonnull @silk_uniform5_iCDF, i32 noundef 8) #2
  %9 = mul nsw i32 %3, 3
  %10 = add nsw i32 %5, %9
  %11 = sext i32 %10 to i64
  %12 = getelementptr inbounds [16 x i16], ptr @silk_stereo_pred_quant_Q13, i64 0, i64 %11
  %13 = load i16, ptr %12, align 2, !tbaa !5
  %14 = sext i16 %13 to i32
  %15 = add nsw i32 %10, 1
  %16 = sext i32 %15 to i64
  %17 = getelementptr inbounds [16 x i16], ptr @silk_stereo_pred_quant_Q13, i64 0, i64 %16
  %18 = load i16, ptr %17, align 2, !tbaa !5
  %19 = sext i16 %18 to i32
  %20 = sub nsw i32 %19, %14
  %narrow = mul nsw i32 %20, 6554
  %21 = ashr i32 %narrow, 16
  %.tr = trunc i32 %6 to i16
  %22 = shl i16 %.tr, 1
  %23 = or disjoint i16 %22, 1
  %24 = sext i16 %23 to i32
  %25 = mul nsw i32 %21, %24
  %26 = add nsw i32 %25, %14
  %27 = mul nsw i32 %4, 3
  %28 = add nsw i32 %7, %27
  %29 = sext i32 %28 to i64
  %30 = getelementptr inbounds [16 x i16], ptr @silk_stereo_pred_quant_Q13, i64 0, i64 %29
  %31 = load i16, ptr %30, align 2, !tbaa !5
  %32 = sext i16 %31 to i32
  %33 = add nsw i32 %28, 1
  %34 = sext i32 %33 to i64
  %35 = getelementptr inbounds [16 x i16], ptr @silk_stereo_pred_quant_Q13, i64 0, i64 %34
  %36 = load i16, ptr %35, align 2, !tbaa !5
  %37 = sext i16 %36 to i32
  %38 = sub nsw i32 %37, %32
  %narrow.1 = mul nsw i32 %38, 6554
  %39 = ashr i32 %narrow.1, 16
  %.tr.1 = trunc i32 %8 to i16
  %40 = shl i16 %.tr.1, 1
  %41 = or disjoint i16 %40, 1
  %42 = sext i16 %41 to i32
  %43 = mul nsw i32 %39, %42
  %44 = add nsw i32 %43, %32
  %45 = getelementptr inbounds i8, ptr %1, i64 4
  store i32 %44, ptr %45, align 4, !tbaa !9
  %46 = sub nsw i32 %26, %44
  store i32 %46, ptr %1, align 4, !tbaa !9
  ret void
}

declare i32 @ec_dec_icdf(ptr noundef, ptr noundef, i32 noundef) local_unnamed_addr #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 = { "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 }

!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 = !{!"short", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}


; Effective O3 passes: CorrelatedValuePropagationPass,DSEPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,LoopRotatePass,LoopSimplifyPass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass