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

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

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

24:                                               ; preds = %4
  %25 = load ptr, ptr %7, align 8, !tbaa !5
  store i64 1, ptr %25, align 8, !tbaa !11
  br label %26

26:                                               ; preds = %24, %4
  %27 = load i32, ptr %8, align 4, !tbaa !9
  %28 = load i32, ptr %8, align 4, !tbaa !9
  %29 = mul i32 %27, %28
  %30 = zext i32 %29 to i64
  %31 = call ptr @llvm.stacksave.p0()
  store ptr %31, ptr %9, align 8
  %32 = alloca float, i64 %30, align 16
  store i64 %30, ptr %10, align 8
  %33 = load i32, ptr %8, align 4, !tbaa !9
  %34 = load i32, ptr %8, align 4, !tbaa !9
  %35 = mul i32 %33, %34
  %36 = zext i32 %35 to i64
  %37 = alloca float, i64 %36, align 16
  store i64 %36, ptr %11, align 8
  %38 = load i32, ptr %8, align 4, !tbaa !9
  %39 = load i32, ptr %8, align 4, !tbaa !9
  %40 = mul i32 %38, %39
  %41 = zext i32 %40 to i64
  %42 = alloca float, i64 %41, align 16
  store i64 %41, ptr %12, align 8
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #5
  store i32 0, ptr %13, align 4, !tbaa !9
  br label %43

43:                                               ; preds = %58, %26
  %44 = load i32, ptr %13, align 4, !tbaa !9
  %45 = load i32, ptr %8, align 4, !tbaa !9
  %46 = load i32, ptr %8, align 4, !tbaa !9
  %47 = mul i32 %45, %46
  %48 = icmp ult i32 %44, %47
  br i1 %48, label %49, label %61

49:                                               ; preds = %43
  %50 = call float (...) @randnf()
  %51 = load i32, ptr %13, align 4, !tbaa !9
  %52 = zext i32 %51 to i64
  %53 = getelementptr inbounds float, ptr %32, i64 %52
  store float %50, ptr %53, align 4, !tbaa !13
  %54 = call float (...) @randnf()
  %55 = load i32, ptr %13, align 4, !tbaa !9
  %56 = zext i32 %55 to i64
  %57 = getelementptr inbounds float, ptr %37, i64 %56
  store float %54, ptr %57, align 4, !tbaa !13
  br label %58

58:                                               ; preds = %49
  %59 = load i32, ptr %13, align 4, !tbaa !9
  %60 = add i32 %59, 1
  store i32 %60, ptr %13, align 4, !tbaa !9
  br label %43, !llvm.loop !15

61:                                               ; preds = %43
  %62 = load ptr, ptr %5, align 8, !tbaa !5
  %63 = call i32 @getrusage(i32 noundef 0, ptr noundef %62) #5
  store i32 0, ptr %13, align 4, !tbaa !9
  br label %64

64:                                               ; preds = %99, %61
  %65 = load i32, ptr %13, align 4, !tbaa !9
  %66 = zext i32 %65 to i64
  %67 = load ptr, ptr %7, align 8, !tbaa !5
  %68 = load i64, ptr %67, align 8, !tbaa !11
  %69 = icmp ult i64 %66, %68
  br i1 %69, label %70, label %102

70:                                               ; preds = %64
  %71 = load i32, ptr %8, align 4, !tbaa !9
  %72 = load i32, ptr %8, align 4, !tbaa !9
  %73 = load i32, ptr %8, align 4, !tbaa !9
  %74 = load i32, ptr %8, align 4, !tbaa !9
  %75 = load i32, ptr %8, align 4, !tbaa !9
  %76 = load i32, ptr %8, align 4, !tbaa !9
  %77 = call i32 @matrixf_mul(ptr noundef %32, i32 noundef %71, i32 noundef %72, ptr noundef %37, i32 noundef %73, i32 noundef %74, ptr noundef %42, i32 noundef %75, i32 noundef %76)
  %78 = load i32, ptr %8, align 4, !tbaa !9
  %79 = load i32, ptr %8, align 4, !tbaa !9
  %80 = load i32, ptr %8, align 4, !tbaa !9
  %81 = load i32, ptr %8, align 4, !tbaa !9
  %82 = load i32, ptr %8, align 4, !tbaa !9
  %83 = load i32, ptr %8, align 4, !tbaa !9
  %84 = call i32 @matrixf_mul(ptr noundef %32, i32 noundef %78, i32 noundef %79, ptr noundef %37, i32 noundef %80, i32 noundef %81, ptr noundef %42, i32 noundef %82, i32 noundef %83)
  %85 = load i32, ptr %8, align 4, !tbaa !9
  %86 = load i32, ptr %8, align 4, !tbaa !9
  %87 = load i32, ptr %8, align 4, !tbaa !9
  %88 = load i32, ptr %8, align 4, !tbaa !9
  %89 = load i32, ptr %8, align 4, !tbaa !9
  %90 = load i32, ptr %8, align 4, !tbaa !9
  %91 = call i32 @matrixf_mul(ptr noundef %32, i32 noundef %85, i32 noundef %86, ptr noundef %37, i32 noundef %87, i32 noundef %88, ptr noundef %42, i32 noundef %89, i32 noundef %90)
  %92 = load i32, ptr %8, align 4, !tbaa !9
  %93 = load i32, ptr %8, align 4, !tbaa !9
  %94 = load i32, ptr %8, align 4, !tbaa !9
  %95 = load i32, ptr %8, align 4, !tbaa !9
  %96 = load i32, ptr %8, align 4, !tbaa !9
  %97 = load i32, ptr %8, align 4, !tbaa !9
  %98 = call i32 @matrixf_mul(ptr noundef %32, i32 noundef %92, i32 noundef %93, ptr noundef %37, i32 noundef %94, i32 noundef %95, ptr noundef %42, i32 noundef %96, i32 noundef %97)
  br label %99

99:                                               ; preds = %70
  %100 = load i32, ptr %13, align 4, !tbaa !9
  %101 = add i32 %100, 1
  store i32 %101, ptr %13, align 4, !tbaa !9
  br label %64, !llvm.loop !17

102:                                              ; preds = %64
  %103 = load ptr, ptr %6, align 8, !tbaa !5
  %104 = call i32 @getrusage(i32 noundef 0, ptr noundef %103) #5
  %105 = load ptr, ptr %7, align 8, !tbaa !5
  %106 = load i64, ptr %105, align 8, !tbaa !11
  %107 = mul i64 %106, 4
  store i64 %107, ptr %105, align 8, !tbaa !11
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #5
  %108 = load ptr, ptr %9, align 8
  call void @llvm.stackrestore.p0(ptr %108)
  ret void
}

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

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

declare float @randnf(...) #3

; Function Attrs: nounwind
declare i32 @getrusage(i32 noundef, ptr noundef) #4

declare i32 @matrixf_mul(ptr noundef, i32 noundef, i32 noundef, ptr noundef, i32 noundef, i32 noundef, ptr noundef, i32 noundef, i32 noundef) #3

; 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) #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 }
attributes #2 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { "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 #4 = { 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 #5 = { 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, !12, i64 0}
!12 = !{!"long", !7, i64 0}
!13 = !{!14, !14, i64 0}
!14 = !{!"float", !7, i64 0}
!15 = distinct !{!15, !16}
!16 = !{!"llvm.loop.mustprogress"}
!17 = distinct !{!17, !16}


; 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 void @matrixf_mul_bench(ptr noundef %0, ptr noundef %1, ptr nocapture noundef %2, i32 noundef %3) local_unnamed_addr #0 {
  %5 = mul i32 %3, %3
  %6 = zext i32 %5 to i64
  %7 = load i64, ptr %2, align 8, !tbaa !5
  %8 = udiv i64 %7, %6
  %9 = icmp ult i64 %7, %6
  %spec.select = select i1 %9, i64 1, i64 %8
  store i64 %spec.select, ptr %2, align 8, !tbaa !5
  %10 = alloca float, i64 %6, align 16
  %11 = alloca float, i64 %6, align 16
  %12 = alloca float, i64 %6, align 16
  %.not = icmp eq i32 %5, 0
  br i1 %.not, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %4, %.lr.ph
  %indvars.iv = phi i64 [ %indvars.iv.next, %.lr.ph ], [ 0, %4 ]
  %13 = tail call float (...) @randnf() #3
  %14 = getelementptr inbounds float, ptr %10, i64 %indvars.iv
  store float %13, ptr %14, align 4, !tbaa !9
  %15 = tail call float (...) @randnf() #3
  %16 = getelementptr inbounds float, ptr %11, i64 %indvars.iv
  store float %15, ptr %16, align 4, !tbaa !9
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next, %6
  br i1 %exitcond.not, label %._crit_edge, label %.lr.ph, !llvm.loop !11

._crit_edge:                                      ; preds = %.lr.ph, %4
  %17 = tail call i32 @getrusage(i32 noundef 0, ptr noundef %0) #3
  %18 = load i64, ptr %2, align 8, !tbaa !5
  %.not52 = icmp eq i64 %18, 0
  br i1 %.not52, label %._crit_edge51, label %.lr.ph50

.lr.ph50:                                         ; preds = %._crit_edge, %.lr.ph50
  %.148 = phi i32 [ %23, %.lr.ph50 ], [ 0, %._crit_edge ]
  %19 = call i32 @matrixf_mul(ptr noundef nonnull %10, i32 noundef %3, i32 noundef %3, ptr noundef nonnull %11, i32 noundef %3, i32 noundef %3, ptr noundef nonnull %12, i32 noundef %3, i32 noundef %3) #3
  %20 = call i32 @matrixf_mul(ptr noundef nonnull %10, i32 noundef %3, i32 noundef %3, ptr noundef nonnull %11, i32 noundef %3, i32 noundef %3, ptr noundef nonnull %12, i32 noundef %3, i32 noundef %3) #3
  %21 = call i32 @matrixf_mul(ptr noundef nonnull %10, i32 noundef %3, i32 noundef %3, ptr noundef nonnull %11, i32 noundef %3, i32 noundef %3, ptr noundef nonnull %12, i32 noundef %3, i32 noundef %3) #3
  %22 = call i32 @matrixf_mul(ptr noundef nonnull %10, i32 noundef %3, i32 noundef %3, ptr noundef nonnull %11, i32 noundef %3, i32 noundef %3, ptr noundef nonnull %12, i32 noundef %3, i32 noundef %3) #3
  %23 = add i32 %.148, 1
  %24 = zext i32 %23 to i64
  %25 = load i64, ptr %2, align 8, !tbaa !5
  %26 = icmp ugt i64 %25, %24
  br i1 %26, label %.lr.ph50, label %._crit_edge51, !llvm.loop !13

._crit_edge51:                                    ; preds = %.lr.ph50, %._crit_edge
  %27 = call i32 @getrusage(i32 noundef 0, ptr noundef %1) #3
  %28 = load i64, ptr %2, align 8, !tbaa !5
  %29 = shl i64 %28, 2
  store i64 %29, ptr %2, align 8, !tbaa !5
  ret void
}

declare float @randnf(...) local_unnamed_addr #1

; Function Attrs: nounwind
declare i32 @getrusage(i32 noundef, ptr noundef) local_unnamed_addr #2

declare i32 @matrixf_mul(ptr noundef, i32 noundef, i32 noundef, ptr noundef, i32 noundef, i32 noundef, ptr noundef, i32 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 "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 = !{!"long", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"float", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = distinct !{!13, !12}


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