; LLVM IR from jgaeddert/liquid-dsp :: src/matrix/src (smatrixb)

; 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.smatrixb_s = type { i32, i32, ptr, ptr, ptr, ptr, ptr, ptr, i32, 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 @smatrixb_clear(ptr noundef %0) #1 {
  %2 = alloca ptr, align 8
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  store ptr %0, ptr %2, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #2
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #2
  store i32 0, ptr %3, align 4, !tbaa !9
  br label %5

5:                                                ; preds = %37, %1
  %6 = load i32, ptr %3, align 4, !tbaa !9
  %7 = load ptr, ptr %2, align 8, !tbaa !5
  %8 = getelementptr inbounds %struct.smatrixb_s, ptr %7, i32 0, i32 0
  %9 = load i32, ptr %8, align 8, !tbaa !11
  %10 = icmp ult i32 %6, %9
  br i1 %10, label %11, label %40

11:                                               ; preds = %5
  store i32 0, ptr %4, align 4, !tbaa !9
  br label %12

12:                                               ; preds = %33, %11
  %13 = load i32, ptr %4, align 4, !tbaa !9
  %14 = load ptr, ptr %2, align 8, !tbaa !5
  %15 = getelementptr inbounds %struct.smatrixb_s, ptr %14, i32 0, i32 6
  %16 = load ptr, ptr %15, align 8, !tbaa !13
  %17 = load i32, ptr %3, align 4, !tbaa !9
  %18 = zext i32 %17 to i64
  %19 = getelementptr inbounds i32, ptr %16, i64 %18
  %20 = load i32, ptr %19, align 4, !tbaa !9
  %21 = icmp ult i32 %13, %20
  br i1 %21, label %22, label %36

22:                                               ; preds = %12
  %23 = load ptr, ptr %2, align 8, !tbaa !5
  %24 = getelementptr inbounds %struct.smatrixb_s, ptr %23, i32 0, i32 4
  %25 = load ptr, ptr %24, align 8, !tbaa !14
  %26 = load i32, ptr %3, align 4, !tbaa !9
  %27 = zext i32 %26 to i64
  %28 = getelementptr inbounds ptr, ptr %25, i64 %27
  %29 = load ptr, ptr %28, align 8, !tbaa !5
  %30 = load i32, ptr %4, align 4, !tbaa !9
  %31 = zext i32 %30 to i64
  %32 = getelementptr inbounds i8, ptr %29, i64 %31
  store i8 0, ptr %32, align 1, !tbaa !15
  br label %33

33:                                               ; preds = %22
  %34 = load i32, ptr %4, align 4, !tbaa !9
  %35 = add i32 %34, 1
  store i32 %35, ptr %4, align 4, !tbaa !9
  br label %12, !llvm.loop !16

36:                                               ; preds = %12
  br label %37

37:                                               ; preds = %36
  %38 = load i32, ptr %3, align 4, !tbaa !9
  %39 = add i32 %38, 1
  store i32 %39, ptr %3, align 4, !tbaa !9
  br label %5, !llvm.loop !18

40:                                               ; preds = %5
  store i32 0, ptr %4, align 4, !tbaa !9
  br label %41

41:                                               ; preds = %73, %40
  %42 = load i32, ptr %4, align 4, !tbaa !9
  %43 = load ptr, ptr %2, align 8, !tbaa !5
  %44 = getelementptr inbounds %struct.smatrixb_s, ptr %43, i32 0, i32 1
  %45 = load i32, ptr %44, align 4, !tbaa !19
  %46 = icmp ult i32 %42, %45
  br i1 %46, label %47, label %76

47:                                               ; preds = %41
  store i32 0, ptr %3, align 4, !tbaa !9
  br label %48

48:                                               ; preds = %69, %47
  %49 = load i32, ptr %3, align 4, !tbaa !9
  %50 = load ptr, ptr %2, align 8, !tbaa !5
  %51 = getelementptr inbounds %struct.smatrixb_s, ptr %50, i32 0, i32 7
  %52 = load ptr, ptr %51, align 8, !tbaa !20
  %53 = load i32, ptr %4, align 4, !tbaa !9
  %54 = zext i32 %53 to i64
  %55 = getelementptr inbounds i32, ptr %52, i64 %54
  %56 = load i32, ptr %55, align 4, !tbaa !9
  %57 = icmp ult i32 %49, %56
  br i1 %57, label %58, label %72

58:                                               ; preds = %48
  %59 = load ptr, ptr %2, align 8, !tbaa !5
  %60 = getelementptr inbounds %struct.smatrixb_s, ptr %59, i32 0, i32 5
  %61 = load ptr, ptr %60, align 8, !tbaa !21
  %62 = load i32, ptr %4, align 4, !tbaa !9
  %63 = zext i32 %62 to i64
  %64 = getelementptr inbounds ptr, ptr %61, i64 %63
  %65 = load ptr, ptr %64, align 8, !tbaa !5
  %66 = load i32, ptr %3, align 4, !tbaa !9
  %67 = zext i32 %66 to i64
  %68 = getelementptr inbounds i8, ptr %65, i64 %67
  store i8 0, ptr %68, align 1, !tbaa !15
  br label %69

69:                                               ; preds = %58
  %70 = load i32, ptr %3, align 4, !tbaa !9
  %71 = add i32 %70, 1
  store i32 %71, ptr %3, align 4, !tbaa !9
  br label %48, !llvm.loop !22

72:                                               ; preds = %48
  br label %73

73:                                               ; preds = %72
  %74 = load i32, ptr %4, align 4, !tbaa !9
  %75 = add i32 %74, 1
  store i32 %75, ptr %4, align 4, !tbaa !9
  br label %41, !llvm.loop !23

76:                                               ; preds = %41
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #2
  ret i32 0
}

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 = { 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 0}
!12 = !{!"smatrixb_s", !10, i64 0, !10, i64 4, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !6, i64 40, !6, i64 48, !10, i64 56, !10, i64 60}
!13 = !{!12, !6, i64 40}
!14 = !{!12, !6, i64 24}
!15 = !{!7, !7, i64 0}
!16 = distinct !{!16, !17}
!17 = !{!"llvm.loop.mustprogress"}
!18 = distinct !{!18, !17}
!19 = !{!12, !10, i64 4}
!20 = !{!12, !6, i64 48}
!21 = !{!12, !6, i64 32}
!22 = distinct !{!22, !17}
!23 = distinct !{!23, !17}


; 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: nofree norecurse nosync nounwind memory(readwrite, inaccessiblemem: none) uwtable
define dso_local noundef i32 @smatrixb_clear(ptr nocapture noundef readonly %0) local_unnamed_addr #0 {
  %2 = load i32, ptr %0, align 8, !tbaa !5
  %.not = icmp eq i32 %2, 0
  br i1 %.not, label %.preheader21, label %.preheader22.lr.ph

.preheader22.lr.ph:                               ; preds = %1
  %3 = getelementptr inbounds i8, ptr %0, i64 40
  %4 = getelementptr inbounds i8, ptr %0, i64 24
  %.pre = load ptr, ptr %3, align 8, !tbaa !11
  br label %.preheader22

.preheader22:                                     ; preds = %.preheader22.lr.ph, %._crit_edge
  %5 = phi i32 [ %2, %.preheader22.lr.ph ], [ %22, %._crit_edge ]
  %6 = phi ptr [ %.pre, %.preheader22.lr.ph ], [ %23, %._crit_edge ]
  %indvars.iv34 = phi i64 [ 0, %.preheader22.lr.ph ], [ %indvars.iv.next35, %._crit_edge ]
  %7 = getelementptr inbounds i32, ptr %6, i64 %indvars.iv34
  %8 = load i32, ptr %7, align 4, !tbaa !12
  %.not30 = icmp eq i32 %8, 0
  br i1 %.not30, label %._crit_edge, label %.lr.ph

.preheader21:                                     ; preds = %._crit_edge, %1
  %9 = getelementptr inbounds i8, ptr %0, i64 4
  %10 = load i32, ptr %9, align 4, !tbaa !13
  %.not31 = icmp eq i32 %10, 0
  br i1 %.not31, label %._crit_edge29, label %.preheader.lr.ph

.preheader.lr.ph:                                 ; preds = %.preheader21
  %11 = getelementptr inbounds i8, ptr %0, i64 48
  %12 = getelementptr inbounds i8, ptr %0, i64 32
  %.pre44 = load ptr, ptr %11, align 8, !tbaa !14
  br label %.preheader

.lr.ph:                                           ; preds = %.preheader22, %.lr.ph
  %indvars.iv = phi i64 [ %indvars.iv.next, %.lr.ph ], [ 0, %.preheader22 ]
  %13 = load ptr, ptr %4, align 8, !tbaa !15
  %14 = getelementptr inbounds ptr, ptr %13, i64 %indvars.iv34
  %15 = load ptr, ptr %14, align 8, !tbaa !16
  %16 = getelementptr inbounds i8, ptr %15, i64 %indvars.iv
  store i8 0, ptr %16, align 1, !tbaa !17
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %17 = load ptr, ptr %3, align 8, !tbaa !11
  %18 = getelementptr inbounds i32, ptr %17, i64 %indvars.iv34
  %19 = load i32, ptr %18, align 4, !tbaa !12
  %20 = zext i32 %19 to i64
  %21 = icmp ult i64 %indvars.iv.next, %20
  br i1 %21, label %.lr.ph, label %._crit_edge.loopexit, !llvm.loop !18

._crit_edge.loopexit:                             ; preds = %.lr.ph
  %.pre43 = load i32, ptr %0, align 8, !tbaa !5
  br label %._crit_edge

._crit_edge:                                      ; preds = %._crit_edge.loopexit, %.preheader22
  %22 = phi i32 [ %.pre43, %._crit_edge.loopexit ], [ %5, %.preheader22 ]
  %23 = phi ptr [ %17, %._crit_edge.loopexit ], [ %6, %.preheader22 ]
  %indvars.iv.next35 = add nuw nsw i64 %indvars.iv34, 1
  %24 = zext i32 %22 to i64
  %25 = icmp ult i64 %indvars.iv.next35, %24
  br i1 %25, label %.preheader22, label %.preheader21, !llvm.loop !20

.preheader:                                       ; preds = %.preheader.lr.ph, %._crit_edge27
  %26 = phi i32 [ %10, %.preheader.lr.ph ], [ %39, %._crit_edge27 ]
  %27 = phi ptr [ %.pre44, %.preheader.lr.ph ], [ %40, %._crit_edge27 ]
  %indvars.iv40 = phi i64 [ 0, %.preheader.lr.ph ], [ %indvars.iv.next41, %._crit_edge27 ]
  %28 = getelementptr inbounds i32, ptr %27, i64 %indvars.iv40
  %29 = load i32, ptr %28, align 4, !tbaa !12
  %.not32 = icmp eq i32 %29, 0
  br i1 %.not32, label %._crit_edge27, label %.lr.ph26

.lr.ph26:                                         ; preds = %.preheader, %.lr.ph26
  %indvars.iv37 = phi i64 [ %indvars.iv.next38, %.lr.ph26 ], [ 0, %.preheader ]
  %30 = load ptr, ptr %12, align 8, !tbaa !21
  %31 = getelementptr inbounds ptr, ptr %30, i64 %indvars.iv40
  %32 = load ptr, ptr %31, align 8, !tbaa !16
  %33 = getelementptr inbounds i8, ptr %32, i64 %indvars.iv37
  store i8 0, ptr %33, align 1, !tbaa !17
  %indvars.iv.next38 = add nuw nsw i64 %indvars.iv37, 1
  %34 = load ptr, ptr %11, align 8, !tbaa !14
  %35 = getelementptr inbounds i32, ptr %34, i64 %indvars.iv40
  %36 = load i32, ptr %35, align 4, !tbaa !12
  %37 = zext i32 %36 to i64
  %38 = icmp ult i64 %indvars.iv.next38, %37
  br i1 %38, label %.lr.ph26, label %._crit_edge27.loopexit, !llvm.loop !22

._crit_edge27.loopexit:                           ; preds = %.lr.ph26
  %.pre45 = load i32, ptr %9, align 4, !tbaa !13
  br label %._crit_edge27

._crit_edge27:                                    ; preds = %._crit_edge27.loopexit, %.preheader
  %39 = phi i32 [ %.pre45, %._crit_edge27.loopexit ], [ %26, %.preheader ]
  %40 = phi ptr [ %34, %._crit_edge27.loopexit ], [ %27, %.preheader ]
  %indvars.iv.next41 = add nuw nsw i64 %indvars.iv40, 1
  %41 = zext i32 %39 to i64
  %42 = icmp ult i64 %indvars.iv.next41, %41
  br i1 %42, label %.preheader, label %._crit_edge29, !llvm.loop !23

._crit_edge29:                                    ; preds = %._crit_edge27, %.preheader21
  ret i32 0
}

attributes #0 = { nofree norecurse nosync nounwind memory(readwrite, inaccessiblemem: none) 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, !7, i64 0}
!6 = !{!"smatrixb_s", !7, i64 0, !7, i64 4, !10, i64 8, !10, i64 16, !10, i64 24, !10, i64 32, !10, i64 40, !10, i64 48, !7, i64 56, !7, i64 60}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"any pointer", !8, i64 0}
!11 = !{!6, !10, i64 40}
!12 = !{!7, !7, i64 0}
!13 = !{!6, !7, i64 4}
!14 = !{!6, !10, i64 48}
!15 = !{!6, !10, i64 24}
!16 = !{!10, !10, i64 0}
!17 = !{!8, !8, i64 0}
!18 = distinct !{!18, !19}
!19 = !{!"llvm.loop.mustprogress"}
!20 = distinct !{!20, !19}
!21 = !{!6, !10, i64 32}
!22 = distinct !{!22, !19}
!23 = distinct !{!23, !19}


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