; LLVM IR from jgaeddert/liquid-dsp :: src/fec/src (sumproduct)

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

@.str = external hidden unnamed_addr constant [79 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [51 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local i32 @fec_sumproduct(i32 noundef %0, i32 noundef %1, ptr noundef %2, ptr noundef %3, ptr noundef %4, i32 noundef %5) #0 {
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca ptr, align 8
  %11 = alloca ptr, align 8
  %12 = alloca ptr, align 8
  %13 = alloca i32, align 4
  %14 = alloca i32, align 4
  %15 = alloca ptr, align 8
  %16 = alloca i64, align 8
  %17 = alloca i64, align 8
  %18 = alloca i64, align 8
  %19 = alloca i64, align 8
  %20 = alloca i64, align 8
  %21 = alloca i32, align 4
  %22 = alloca i32, align 4
  %23 = alloca i32, align 4
  %24 = alloca i32, align 4
  store i32 %0, ptr %8, align 4, !tbaa !5
  store i32 %1, ptr %9, align 4, !tbaa !5
  store ptr %2, ptr %10, align 8, !tbaa !9
  store ptr %3, ptr %11, align 8, !tbaa !9
  store ptr %4, ptr %12, align 8, !tbaa !9
  store i32 %5, ptr %13, align 4, !tbaa !5
  %25 = load i32, ptr %9, align 4, !tbaa !5
  %26 = icmp eq i32 %25, 0
  br i1 %26, label %30, label %27

27:                                               ; preds = %6
  %28 = load i32, ptr %8, align 4, !tbaa !5
  %29 = icmp eq i32 %28, 0
  br i1 %29, label %30, label %32

30:                                               ; preds = %27, %6
  %31 = call i32 (i32, ptr, i32, ptr, ...) @liquid_error_fl(i32 noundef 3, ptr noundef @.str, i32 noundef 59, ptr noundef @.str.1)
  store i32 %31, ptr %7, align 4
  br label %131

32:                                               ; preds = %27
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #4
  store i32 0, ptr %14, align 4, !tbaa !5
  %33 = load i32, ptr %8, align 4, !tbaa !5
  %34 = load i32, ptr %9, align 4, !tbaa !5
  %35 = mul i32 %33, %34
  %36 = zext i32 %35 to i64
  %37 = call ptr @llvm.stacksave.p0()
  store ptr %37, ptr %15, align 8
  %38 = alloca float, i64 %36, align 16
  store i64 %36, ptr %16, align 8
  %39 = load i32, ptr %8, align 4, !tbaa !5
  %40 = load i32, ptr %9, align 4, !tbaa !5
  %41 = mul i32 %39, %40
  %42 = zext i32 %41 to i64
  %43 = alloca float, i64 %42, align 16
  store i64 %42, ptr %17, align 8
  %44 = load i32, ptr %9, align 4, !tbaa !5
  %45 = zext i32 %44 to i64
  %46 = alloca float, i64 %45, align 16
  store i64 %45, ptr %18, align 8
  %47 = load i32, ptr %9, align 4, !tbaa !5
  %48 = zext i32 %47 to i64
  %49 = alloca float, i64 %48, align 16
  store i64 %48, ptr %19, align 8
  %50 = load i32, ptr %8, align 4, !tbaa !5
  %51 = zext i32 %50 to i64
  %52 = alloca i8, i64 %51, align 16
  store i64 %51, ptr %20, align 8
  call void @llvm.lifetime.start.p0(i64 4, ptr %21) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %22) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %23) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %24) #4
  store i32 1, ptr %24, align 4, !tbaa !5
  store i32 0, ptr %21, align 4, !tbaa !5
  br label %53

53:                                               ; preds = %66, %32
  %54 = load i32, ptr %21, align 4, !tbaa !5
  %55 = load i32, ptr %9, align 4, !tbaa !5
  %56 = icmp ult i32 %54, %55
  br i1 %56, label %57, label %69

57:                                               ; preds = %53
  %58 = load ptr, ptr %11, align 8, !tbaa !9
  %59 = load i32, ptr %21, align 4, !tbaa !5
  %60 = zext i32 %59 to i64
  %61 = getelementptr inbounds float, ptr %58, i64 %60
  %62 = load float, ptr %61, align 4, !tbaa !11
  %63 = load i32, ptr %21, align 4, !tbaa !5
  %64 = zext i32 %63 to i64
  %65 = getelementptr inbounds float, ptr %46, i64 %64
  store float %62, ptr %65, align 4, !tbaa !11
  br label %66

66:                                               ; preds = %57
  %67 = load i32, ptr %21, align 4, !tbaa !5
  %68 = add i32 %67, 1
  store i32 %68, ptr %21, align 4, !tbaa !5
  br label %53, !llvm.loop !13

69:                                               ; preds = %53
  store i32 0, ptr %22, align 4, !tbaa !5
  br label %70

70:                                               ; preds = %105, %69
  %71 = load i32, ptr %22, align 4, !tbaa !5
  %72 = load i32, ptr %8, align 4, !tbaa !5
  %73 = icmp ult i32 %71, %72
  br i1 %73, label %74, label %108

74:                                               ; preds = %70
  store i32 0, ptr %21, align 4, !tbaa !5
  br label %75

75:                                               ; preds = %101, %74
  %76 = load i32, ptr %21, align 4, !tbaa !5
  %77 = load i32, ptr %9, align 4, !tbaa !5
  %78 = icmp ult i32 %76, %77
  br i1 %78, label %79, label %104

79:                                               ; preds = %75
  %80 = load ptr, ptr %10, align 8, !tbaa !9
  %81 = load i32, ptr %22, align 4, !tbaa !5
  %82 = load i32, ptr %21, align 4, !tbaa !5
  %83 = call zeroext i8 @smatrixb_get(ptr noundef %80, i32 noundef %81, i32 noundef %82)
  %84 = zext i8 %83 to i32
  %85 = icmp ne i32 %84, 0
  br i1 %85, label %86, label %91

86:                                               ; preds = %79
  %87 = load i32, ptr %21, align 4, !tbaa !5
  %88 = zext i32 %87 to i64
  %89 = getelementptr inbounds float, ptr %46, i64 %88
  %90 = load float, ptr %89, align 4, !tbaa !11
  br label %92

91:                                               ; preds = %79
  br label %92

92:                                               ; preds = %91, %86
  %93 = phi float [ %90, %86 ], [ 0.000000e+00, %91 ]
  %94 = load i32, ptr %22, align 4, !tbaa !5
  %95 = load i32, ptr %9, align 4, !tbaa !5
  %96 = mul i32 %94, %95
  %97 = load i32, ptr %21, align 4, !tbaa !5
  %98 = add i32 %96, %97
  %99 = zext i32 %98 to i64
  %100 = getelementptr inbounds float, ptr %38, i64 %99
  store float %93, ptr %100, align 4, !tbaa !11
  br label %101

101:                                              ; preds = %92
  %102 = load i32, ptr %21, align 4, !tbaa !5
  %103 = add i32 %102, 1
  store i32 %103, ptr %21, align 4, !tbaa !5
  br label %75, !llvm.loop !15

104:                                              ; preds = %75
  br label %105

105:                                              ; preds = %104
  %106 = load i32, ptr %22, align 4, !tbaa !5
  %107 = add i32 %106, 1
  store i32 %107, ptr %22, align 4, !tbaa !5
  br label %70, !llvm.loop !16

108:                                              ; preds = %70
  br label %109

109:                                              ; preds = %127, %108
  %110 = load i32, ptr %24, align 4, !tbaa !5
  %111 = icmp ne i32 %110, 0
  br i1 %111, label %112, label %128

112:                                              ; preds = %109
  %113 = load i32, ptr %8, align 4, !tbaa !5
  %114 = load i32, ptr %9, align 4, !tbaa !5
  %115 = load ptr, ptr %10, align 8, !tbaa !9
  %116 = load ptr, ptr %12, align 8, !tbaa !9
  %117 = call i32 @fec_sumproduct_step(i32 noundef %113, i32 noundef %114, ptr noundef %115, ptr noundef %116, ptr noundef %38, ptr noundef %43, ptr noundef %46, ptr noundef %49, ptr noundef %52)
  store i32 %117, ptr %23, align 4, !tbaa !5
  %118 = load i32, ptr %14, align 4, !tbaa !5
  %119 = add i32 %118, 1
  store i32 %119, ptr %14, align 4, !tbaa !5
  %120 = load i32, ptr %23, align 4, !tbaa !5
  %121 = icmp ne i32 %120, 0
  br i1 %121, label %126, label %122

122:                                              ; preds = %112
  %123 = load i32, ptr %14, align 4, !tbaa !5
  %124 = load i32, ptr %13, align 4, !tbaa !5
  %125 = icmp eq i32 %123, %124
  br i1 %125, label %126, label %127

126:                                              ; preds = %122, %112
  store i32 0, ptr %24, align 4, !tbaa !5
  br label %127

127:                                              ; preds = %126, %122
  br label %109, !llvm.loop !17

128:                                              ; preds = %109
  %129 = load i32, ptr %23, align 4, !tbaa !5
  store i32 %129, ptr %7, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %24) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %23) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %22) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %21) #4
  %130 = load ptr, ptr %15, align 8
  call void @llvm.stackrestore.p0(ptr %130)
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #4
  br label %131

131:                                              ; preds = %128, %30
  %132 = load i32, ptr %7, align 4
  ret i32 %132
}

declare i32 @liquid_error_fl(i32 noundef, ptr noundef, i32 noundef, ptr noundef, ...) #1

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

; Function Attrs: nocallback nofree nosync nounwind willreturn
declare ptr @llvm.stacksave.p0() #3

declare zeroext i8 @smatrixb_get(ptr noundef, i32 noundef, i32 noundef) #1

; Function Attrs: nounwind uwtable
declare dso_local i32 @fec_sumproduct_step(i32 noundef, i32 noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef) #0

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

; Function Attrs: nocallback nofree nosync nounwind willreturn
declare void @llvm.stackrestore.p0(ptr) #3

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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { nocallback nofree nosync nounwind willreturn }
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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"any pointer", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"float", !7, i64 0}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}
!15 = distinct !{!15, !14}
!16 = distinct !{!16, !14}
!17 = distinct !{!17, !14}


; 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 = external hidden unnamed_addr constant [79 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [51 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local i32 @fec_sumproduct(i32 noundef %0, i32 noundef %1, ptr noundef %2, ptr nocapture noundef readonly %3, ptr noundef %4, i32 noundef %5) local_unnamed_addr #0 {
  %7 = icmp eq i32 %1, 0
  %8 = icmp eq i32 %0, 0
  %or.cond = or i1 %8, %7
  br i1 %or.cond, label %9, label %.preheader.us.preheader

9:                                                ; preds = %6
  %10 = tail call i32 (i32, ptr, i32, ptr, ...) @liquid_error_fl(i32 noundef 3, ptr noundef nonnull @.str, i32 noundef 59, ptr noundef nonnull @.str.1) #4
  br label %39

.preheader.us.preheader:                          ; preds = %6
  %11 = mul i32 %1, %0
  %12 = zext i32 %11 to i64
  %13 = tail call ptr @llvm.stacksave.p0()
  %14 = alloca float, i64 %12, align 16
  %15 = alloca float, i64 %12, align 16
  %16 = zext i32 %1 to i64
  %17 = alloca float, i64 %16, align 16
  %18 = alloca float, i64 %16, align 16
  %19 = zext i32 %0 to i64
  %20 = alloca i8, i64 %19, align 16
  %21 = shl nuw nsw i64 %16, 2
  call void @llvm.memcpy.p0.p0.i64(ptr nonnull align 16 %17, ptr align 4 %3, i64 %21, i1 false), !tbaa !5
  br label %.preheader.us

.preheader.us:                                    ; preds = %.preheader.us.preheader, %._crit_edge.us
  %.04155.us = phi i32 [ %34, %._crit_edge.us ], [ 0, %.preheader.us.preheader ]
  %22 = mul i32 %.04155.us, %1
  br label %23

23:                                               ; preds = %.preheader.us, %29
  %indvars.iv = phi i64 [ 0, %.preheader.us ], [ %indvars.iv.next, %29 ]
  %24 = trunc nuw i64 %indvars.iv to i32
  %25 = tail call zeroext i8 @smatrixb_get(ptr noundef %2, i32 noundef %.04155.us, i32 noundef %24) #4
  %.not49.us = icmp eq i8 %25, 0
  br i1 %.not49.us, label %29, label %26

26:                                               ; preds = %23
  %27 = getelementptr inbounds float, ptr %17, i64 %indvars.iv
  %28 = load float, ptr %27, align 4, !tbaa !5
  br label %29

29:                                               ; preds = %26, %23
  %30 = phi float [ %28, %26 ], [ 0.000000e+00, %23 ]
  %31 = add i32 %22, %24
  %32 = zext i32 %31 to i64
  %33 = getelementptr inbounds float, ptr %14, i64 %32
  store float %30, ptr %33, align 4, !tbaa !5
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next, %16
  br i1 %exitcond.not, label %._crit_edge.us, label %23, !llvm.loop !9

._crit_edge.us:                                   ; preds = %29
  %34 = add nuw i32 %.04155.us, 1
  %exitcond61.not = icmp eq i32 %34, %0
  br i1 %exitcond61.not, label %select.unfold, label %.preheader.us, !llvm.loop !11

select.unfold:                                    ; preds = %._crit_edge.us, %select.unfold
  %.04556 = phi i32 [ %36, %select.unfold ], [ 0, %._crit_edge.us ]
  %35 = call i32 @fec_sumproduct_step(i32 noundef %0, i32 noundef %1, ptr noundef %2, ptr noundef %4, ptr noundef nonnull %14, ptr noundef nonnull %15, ptr noundef nonnull %17, ptr noundef nonnull %18, ptr noundef nonnull %20)
  %36 = add i32 %.04556, 1
  %.not48 = icmp ne i32 %35, 0
  %37 = icmp eq i32 %36, %5
  %or.cond50 = select i1 %.not48, i1 true, i1 %37
  br i1 %or.cond50, label %38, label %select.unfold

38:                                               ; preds = %select.unfold
  call void @llvm.stackrestore.p0(ptr %13)
  br label %39

39:                                               ; preds = %38, %9
  %.044 = phi i32 [ %10, %9 ], [ %35, %38 ]
  ret i32 %.044
}

declare i32 @liquid_error_fl(i32 noundef, ptr noundef, i32 noundef, ptr noundef, ...) local_unnamed_addr #1

; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn
declare ptr @llvm.stacksave.p0() #2

declare zeroext i8 @smatrixb_get(ptr noundef, i32 noundef, i32 noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
declare dso_local i32 @fec_sumproduct_step(i32 noundef, i32 noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #0

; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn
declare void @llvm.stackrestore.p0(ptr) #2

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

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 = { mustprogress nocallback nofree nosync nounwind willreturn }
attributes #3 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
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 = !{!"float", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}
!11 = distinct !{!11, !10}


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