; 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_destroy(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) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #3
  %5 = load ptr, ptr %2, align 8, !tbaa !5
  %6 = getelementptr inbounds %struct.smatrixb_s, ptr %5, i32 0, i32 6
  %7 = load ptr, ptr %6, align 8, !tbaa !9
  call void @free(ptr noundef %7) #3
  %8 = load ptr, ptr %2, align 8, !tbaa !5
  %9 = getelementptr inbounds %struct.smatrixb_s, ptr %8, i32 0, i32 7
  %10 = load ptr, ptr %9, align 8, !tbaa !12
  call void @free(ptr noundef %10) #3
  store i32 0, ptr %3, align 4, !tbaa !13
  br label %11

11:                                               ; preds = %25, %1
  %12 = load i32, ptr %3, align 4, !tbaa !13
  %13 = load ptr, ptr %2, align 8, !tbaa !5
  %14 = getelementptr inbounds %struct.smatrixb_s, ptr %13, i32 0, i32 0
  %15 = load i32, ptr %14, align 8, !tbaa !14
  %16 = icmp ult i32 %12, %15
  br i1 %16, label %17, label %28

17:                                               ; preds = %11
  %18 = load ptr, ptr %2, align 8, !tbaa !5
  %19 = getelementptr inbounds %struct.smatrixb_s, ptr %18, i32 0, i32 2
  %20 = load ptr, ptr %19, align 8, !tbaa !15
  %21 = load i32, ptr %3, align 4, !tbaa !13
  %22 = zext i32 %21 to i64
  %23 = getelementptr inbounds ptr, ptr %20, i64 %22
  %24 = load ptr, ptr %23, align 8, !tbaa !5
  call void @free(ptr noundef %24) #3
  br label %25

25:                                               ; preds = %17
  %26 = load i32, ptr %3, align 4, !tbaa !13
  %27 = add i32 %26, 1
  store i32 %27, ptr %3, align 4, !tbaa !13
  br label %11, !llvm.loop !16

28:                                               ; preds = %11
  store i32 0, ptr %4, align 4, !tbaa !13
  br label %29

29:                                               ; preds = %43, %28
  %30 = load i32, ptr %4, align 4, !tbaa !13
  %31 = load ptr, ptr %2, align 8, !tbaa !5
  %32 = getelementptr inbounds %struct.smatrixb_s, ptr %31, i32 0, i32 1
  %33 = load i32, ptr %32, align 4, !tbaa !18
  %34 = icmp ult i32 %30, %33
  br i1 %34, label %35, label %46

35:                                               ; preds = %29
  %36 = load ptr, ptr %2, align 8, !tbaa !5
  %37 = getelementptr inbounds %struct.smatrixb_s, ptr %36, i32 0, i32 3
  %38 = load ptr, ptr %37, align 8, !tbaa !19
  %39 = load i32, ptr %4, align 4, !tbaa !13
  %40 = zext i32 %39 to i64
  %41 = getelementptr inbounds ptr, ptr %38, i64 %40
  %42 = load ptr, ptr %41, align 8, !tbaa !5
  call void @free(ptr noundef %42) #3
  br label %43

43:                                               ; preds = %35
  %44 = load i32, ptr %4, align 4, !tbaa !13
  %45 = add i32 %44, 1
  store i32 %45, ptr %4, align 4, !tbaa !13
  br label %29, !llvm.loop !20

46:                                               ; preds = %29
  %47 = load ptr, ptr %2, align 8, !tbaa !5
  %48 = getelementptr inbounds %struct.smatrixb_s, ptr %47, i32 0, i32 2
  %49 = load ptr, ptr %48, align 8, !tbaa !15
  call void @free(ptr noundef %49) #3
  %50 = load ptr, ptr %2, align 8, !tbaa !5
  %51 = getelementptr inbounds %struct.smatrixb_s, ptr %50, i32 0, i32 3
  %52 = load ptr, ptr %51, align 8, !tbaa !19
  call void @free(ptr noundef %52) #3
  store i32 0, ptr %3, align 4, !tbaa !13
  br label %53

53:                                               ; preds = %67, %46
  %54 = load i32, ptr %3, align 4, !tbaa !13
  %55 = load ptr, ptr %2, align 8, !tbaa !5
  %56 = getelementptr inbounds %struct.smatrixb_s, ptr %55, i32 0, i32 0
  %57 = load i32, ptr %56, align 8, !tbaa !14
  %58 = icmp ult i32 %54, %57
  br i1 %58, label %59, label %70

59:                                               ; preds = %53
  %60 = load ptr, ptr %2, align 8, !tbaa !5
  %61 = getelementptr inbounds %struct.smatrixb_s, ptr %60, i32 0, i32 4
  %62 = load ptr, ptr %61, align 8, !tbaa !21
  %63 = load i32, ptr %3, align 4, !tbaa !13
  %64 = zext i32 %63 to i64
  %65 = getelementptr inbounds ptr, ptr %62, i64 %64
  %66 = load ptr, ptr %65, align 8, !tbaa !5
  call void @free(ptr noundef %66) #3
  br label %67

67:                                               ; preds = %59
  %68 = load i32, ptr %3, align 4, !tbaa !13
  %69 = add i32 %68, 1
  store i32 %69, ptr %3, align 4, !tbaa !13
  br label %53, !llvm.loop !22

70:                                               ; preds = %53
  store i32 0, ptr %4, align 4, !tbaa !13
  br label %71

71:                                               ; preds = %85, %70
  %72 = load i32, ptr %4, align 4, !tbaa !13
  %73 = load ptr, ptr %2, align 8, !tbaa !5
  %74 = getelementptr inbounds %struct.smatrixb_s, ptr %73, i32 0, i32 1
  %75 = load i32, ptr %74, align 4, !tbaa !18
  %76 = icmp ult i32 %72, %75
  br i1 %76, label %77, label %88

77:                                               ; preds = %71
  %78 = load ptr, ptr %2, align 8, !tbaa !5
  %79 = getelementptr inbounds %struct.smatrixb_s, ptr %78, i32 0, i32 5
  %80 = load ptr, ptr %79, align 8, !tbaa !23
  %81 = load i32, ptr %4, align 4, !tbaa !13
  %82 = zext i32 %81 to i64
  %83 = getelementptr inbounds ptr, ptr %80, i64 %82
  %84 = load ptr, ptr %83, align 8, !tbaa !5
  call void @free(ptr noundef %84) #3
  br label %85

85:                                               ; preds = %77
  %86 = load i32, ptr %4, align 4, !tbaa !13
  %87 = add i32 %86, 1
  store i32 %87, ptr %4, align 4, !tbaa !13
  br label %71, !llvm.loop !24

88:                                               ; preds = %71
  %89 = load ptr, ptr %2, align 8, !tbaa !5
  %90 = getelementptr inbounds %struct.smatrixb_s, ptr %89, i32 0, i32 4
  %91 = load ptr, ptr %90, align 8, !tbaa !21
  call void @free(ptr noundef %91) #3
  %92 = load ptr, ptr %2, align 8, !tbaa !5
  %93 = getelementptr inbounds %struct.smatrixb_s, ptr %92, i32 0, i32 5
  %94 = load ptr, ptr %93, align 8, !tbaa !23
  call void @free(ptr noundef %94) #3
  %95 = load ptr, ptr %2, align 8, !tbaa !5
  call void @free(ptr noundef %95) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #3
  ret i32 0
}

; Function Attrs: nounwind
declare void @free(ptr noundef) #2

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 "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, !6, i64 40}
!10 = !{!"smatrixb_s", !11, i64 0, !11, i64 4, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !6, i64 40, !6, i64 48, !11, i64 56, !11, i64 60}
!11 = !{!"int", !7, i64 0}
!12 = !{!10, !6, i64 48}
!13 = !{!11, !11, i64 0}
!14 = !{!10, !11, i64 0}
!15 = !{!10, !6, i64 8}
!16 = distinct !{!16, !17}
!17 = !{!"llvm.loop.mustprogress"}
!18 = !{!10, !11, i64 4}
!19 = !{!10, !6, i64 16}
!20 = distinct !{!20, !17}
!21 = !{!10, !6, i64 24}
!22 = distinct !{!22, !17}
!23 = !{!10, !6, i64 32}
!24 = distinct !{!24, !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: nounwind uwtable
define dso_local noundef i32 @smatrixb_destroy(ptr nocapture noundef %0) local_unnamed_addr #0 {
  %2 = getelementptr inbounds i8, ptr %0, i64 40
  %3 = load ptr, ptr %2, align 8, !tbaa !5
  tail call void @free(ptr noundef %3) #2
  %4 = getelementptr inbounds i8, ptr %0, i64 48
  %5 = load ptr, ptr %4, align 8, !tbaa !11
  tail call void @free(ptr noundef %5) #2
  %6 = load i32, ptr %0, align 8, !tbaa !12
  %.not = icmp eq i32 %6, 0
  br i1 %.not, label %.preheader28, label %.lr.ph

.lr.ph:                                           ; preds = %1
  %7 = getelementptr inbounds i8, ptr %0, i64 8
  br label %11

.preheader28:                                     ; preds = %11, %1
  %8 = getelementptr inbounds i8, ptr %0, i64 4
  %9 = load i32, ptr %8, align 4, !tbaa !13
  %.not38 = icmp eq i32 %9, 0
  br i1 %.not38, label %._crit_edge, label %.lr.ph31

.lr.ph31:                                         ; preds = %.preheader28
  %10 = getelementptr inbounds i8, ptr %0, i64 16
  br label %18

11:                                               ; preds = %.lr.ph, %11
  %indvars.iv = phi i64 [ 0, %.lr.ph ], [ %indvars.iv.next, %11 ]
  %12 = load ptr, ptr %7, align 8, !tbaa !14
  %13 = getelementptr inbounds ptr, ptr %12, i64 %indvars.iv
  %14 = load ptr, ptr %13, align 8, !tbaa !15
  tail call void @free(ptr noundef %14) #2
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %15 = load i32, ptr %0, align 8, !tbaa !12
  %16 = zext i32 %15 to i64
  %17 = icmp ult i64 %indvars.iv.next, %16
  br i1 %17, label %11, label %.preheader28, !llvm.loop !16

18:                                               ; preds = %.lr.ph31, %18
  %indvars.iv42 = phi i64 [ 0, %.lr.ph31 ], [ %indvars.iv.next43, %18 ]
  %19 = load ptr, ptr %10, align 8, !tbaa !18
  %20 = getelementptr inbounds ptr, ptr %19, i64 %indvars.iv42
  %21 = load ptr, ptr %20, align 8, !tbaa !15
  tail call void @free(ptr noundef %21) #2
  %indvars.iv.next43 = add nuw nsw i64 %indvars.iv42, 1
  %22 = load i32, ptr %8, align 4, !tbaa !13
  %23 = zext i32 %22 to i64
  %24 = icmp ult i64 %indvars.iv.next43, %23
  br i1 %24, label %18, label %._crit_edge, !llvm.loop !19

._crit_edge:                                      ; preds = %18, %.preheader28
  %25 = getelementptr inbounds i8, ptr %0, i64 8
  %26 = load ptr, ptr %25, align 8, !tbaa !14
  tail call void @free(ptr noundef %26) #2
  %27 = getelementptr inbounds i8, ptr %0, i64 16
  %28 = load ptr, ptr %27, align 8, !tbaa !18
  tail call void @free(ptr noundef %28) #2
  %29 = load i32, ptr %0, align 8, !tbaa !12
  %.not39 = icmp eq i32 %29, 0
  br i1 %.not39, label %.preheader, label %.lr.ph34

.lr.ph34:                                         ; preds = %._crit_edge
  %30 = getelementptr inbounds i8, ptr %0, i64 24
  br label %33

.preheader:                                       ; preds = %33, %._crit_edge
  %31 = load i32, ptr %8, align 4, !tbaa !13
  %.not40 = icmp eq i32 %31, 0
  br i1 %.not40, label %._crit_edge37, label %.lr.ph36

.lr.ph36:                                         ; preds = %.preheader
  %32 = getelementptr inbounds i8, ptr %0, i64 32
  br label %40

33:                                               ; preds = %.lr.ph34, %33
  %indvars.iv45 = phi i64 [ 0, %.lr.ph34 ], [ %indvars.iv.next46, %33 ]
  %34 = load ptr, ptr %30, align 8, !tbaa !20
  %35 = getelementptr inbounds ptr, ptr %34, i64 %indvars.iv45
  %36 = load ptr, ptr %35, align 8, !tbaa !15
  tail call void @free(ptr noundef %36) #2
  %indvars.iv.next46 = add nuw nsw i64 %indvars.iv45, 1
  %37 = load i32, ptr %0, align 8, !tbaa !12
  %38 = zext i32 %37 to i64
  %39 = icmp ult i64 %indvars.iv.next46, %38
  br i1 %39, label %33, label %.preheader, !llvm.loop !21

40:                                               ; preds = %.lr.ph36, %40
  %indvars.iv48 = phi i64 [ 0, %.lr.ph36 ], [ %indvars.iv.next49, %40 ]
  %41 = load ptr, ptr %32, align 8, !tbaa !22
  %42 = getelementptr inbounds ptr, ptr %41, i64 %indvars.iv48
  %43 = load ptr, ptr %42, align 8, !tbaa !15
  tail call void @free(ptr noundef %43) #2
  %indvars.iv.next49 = add nuw nsw i64 %indvars.iv48, 1
  %44 = load i32, ptr %8, align 4, !tbaa !13
  %45 = zext i32 %44 to i64
  %46 = icmp ult i64 %indvars.iv.next49, %45
  br i1 %46, label %40, label %._crit_edge37, !llvm.loop !23

._crit_edge37:                                    ; preds = %40, %.preheader
  %47 = getelementptr inbounds i8, ptr %0, i64 24
  %48 = load ptr, ptr %47, align 8, !tbaa !20
  tail call void @free(ptr noundef %48) #2
  %49 = getelementptr inbounds i8, ptr %0, i64 32
  %50 = load ptr, ptr %49, align 8, !tbaa !22
  tail call void @free(ptr noundef %50) #2
  tail call void @free(ptr noundef nonnull %0) #2
  ret i32 0
}

; Function Attrs: mustprogress nounwind willreturn allockind("free") memory(argmem: readwrite, inaccessiblemem: readwrite)
declare void @free(ptr allocptr nocapture 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 = { mustprogress nounwind willreturn allockind("free") memory(argmem: readwrite, inaccessiblemem: readwrite) "alloc-family"="malloc" "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, !10, i64 40}
!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 48}
!12 = !{!6, !7, i64 0}
!13 = !{!6, !7, i64 4}
!14 = !{!6, !10, i64 8}
!15 = !{!10, !10, i64 0}
!16 = distinct !{!16, !17}
!17 = !{!"llvm.loop.mustprogress"}
!18 = !{!6, !10, i64 16}
!19 = distinct !{!19, !17}
!20 = !{!6, !10, i64 24}
!21 = distinct !{!21, !17}
!22 = !{!6, !10, i64 32}
!23 = distinct !{!23, !17}


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