; LLVM IR from jgaeddert/liquid-dsp :: src/matrix/bench (smatrixf_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 @smatrixf_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 i64, align 8
  %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 i32, align 4
  %16 = alloca float, align 4
  %17 = alloca i32, align 4
  %18 = alloca i32, align 4
  %19 = alloca float, 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
  %20 = load ptr, ptr %7, align 8, !tbaa !5
  %21 = load i64, ptr %20, align 8, !tbaa !11
  %22 = mul i64 %21, 8192
  %23 = load i32, ptr %8, align 4, !tbaa !9
  %24 = load i32, ptr %8, align 4, !tbaa !9
  %25 = mul i32 %23, %24
  %26 = load i32, ptr %8, align 4, !tbaa !9
  %27 = mul i32 %25, %26
  %28 = add i32 %27, 1
  %29 = zext i32 %28 to i64
  %30 = udiv i64 %22, %29
  %31 = add i64 1, %30
  %32 = load ptr, ptr %7, align 8, !tbaa !5
  store i64 %31, ptr %32, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #4
  %33 = load i32, ptr %8, align 4, !tbaa !9
  %34 = load i32, ptr %8, align 4, !tbaa !9
  %35 = call ptr @smatrixf_create(i32 noundef %33, i32 noundef %34)
  store ptr %35, ptr %10, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #4
  %36 = load i32, ptr %8, align 4, !tbaa !9
  %37 = load i32, ptr %8, align 4, !tbaa !9
  %38 = call ptr @smatrixf_create(i32 noundef %36, i32 noundef %37)
  store ptr %38, ptr %11, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #4
  %39 = load i32, ptr %8, align 4, !tbaa !9
  %40 = load i32, ptr %8, align 4, !tbaa !9
  %41 = call ptr @smatrixf_create(i32 noundef %39, i32 noundef %40)
  store ptr %41, ptr %12, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #4
  %42 = load i32, ptr %8, align 4, !tbaa !9
  %43 = udiv i32 %42, 20
  %44 = icmp ult i32 %43, 4
  br i1 %44, label %45, label %46

45:                                               ; preds = %4
  br label %49

46:                                               ; preds = %4
  %47 = load i32, ptr %8, align 4, !tbaa !9
  %48 = udiv i32 %47, 20
  br label %49

49:                                               ; preds = %46, %45
  %50 = phi i32 [ 4, %45 ], [ %48, %46 ]
  store i32 %50, ptr %13, align 4, !tbaa !9
  store i64 0, ptr %9, align 8, !tbaa !11
  br label %51

51:                                               ; preds = %69, %49
  %52 = load i64, ptr %9, align 8, !tbaa !11
  %53 = load i32, ptr %13, align 4, !tbaa !9
  %54 = zext i32 %53 to i64
  %55 = icmp ult i64 %52, %54
  br i1 %55, label %56, label %72

56:                                               ; preds = %51
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #4
  %57 = call i32 @rand() #4
  %58 = load i32, ptr %8, align 4, !tbaa !9
  %59 = urem i32 %57, %58
  store i32 %59, ptr %14, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %15) #4
  %60 = call i32 @rand() #4
  %61 = load i32, ptr %8, align 4, !tbaa !9
  %62 = urem i32 %60, %61
  store i32 %62, ptr %15, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %16) #4
  %63 = call float (...) @randf()
  store float %63, ptr %16, align 4, !tbaa !13
  %64 = load ptr, ptr %10, align 8, !tbaa !5
  %65 = load i32, ptr %14, align 4, !tbaa !9
  %66 = load i32, ptr %15, align 4, !tbaa !9
  %67 = load float, ptr %16, align 4, !tbaa !13
  %68 = call i32 @smatrixf_set(ptr noundef %64, i32 noundef %65, i32 noundef %66, float noundef %67)
  call void @llvm.lifetime.end.p0(i64 4, ptr %16) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #4
  br label %69

69:                                               ; preds = %56
  %70 = load i64, ptr %9, align 8, !tbaa !11
  %71 = add i64 %70, 1
  store i64 %71, ptr %9, align 8, !tbaa !11
  br label %51, !llvm.loop !15

72:                                               ; preds = %51
  store i64 0, ptr %9, align 8, !tbaa !11
  br label %73

73:                                               ; preds = %91, %72
  %74 = load i64, ptr %9, align 8, !tbaa !11
  %75 = load i32, ptr %13, align 4, !tbaa !9
  %76 = zext i32 %75 to i64
  %77 = icmp ult i64 %74, %76
  br i1 %77, label %78, label %94

78:                                               ; preds = %73
  call void @llvm.lifetime.start.p0(i64 4, ptr %17) #4
  %79 = call i32 @rand() #4
  %80 = load i32, ptr %8, align 4, !tbaa !9
  %81 = urem i32 %79, %80
  store i32 %81, ptr %17, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %18) #4
  %82 = call i32 @rand() #4
  %83 = load i32, ptr %8, align 4, !tbaa !9
  %84 = urem i32 %82, %83
  store i32 %84, ptr %18, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %19) #4
  %85 = call float (...) @randf()
  store float %85, ptr %19, align 4, !tbaa !13
  %86 = load ptr, ptr %11, align 8, !tbaa !5
  %87 = load i32, ptr %17, align 4, !tbaa !9
  %88 = load i32, ptr %18, align 4, !tbaa !9
  %89 = load float, ptr %19, align 4, !tbaa !13
  %90 = call i32 @smatrixf_set(ptr noundef %86, i32 noundef %87, i32 noundef %88, float noundef %89)
  call void @llvm.lifetime.end.p0(i64 4, ptr %19) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %18) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %17) #4
  br label %91

91:                                               ; preds = %78
  %92 = load i64, ptr %9, align 8, !tbaa !11
  %93 = add i64 %92, 1
  store i64 %93, ptr %9, align 8, !tbaa !11
  br label %73, !llvm.loop !17

94:                                               ; preds = %73
  %95 = load ptr, ptr %10, align 8, !tbaa !5
  %96 = load ptr, ptr %11, align 8, !tbaa !5
  %97 = load ptr, ptr %12, align 8, !tbaa !5
  %98 = call i32 @smatrixf_mul(ptr noundef %95, ptr noundef %96, ptr noundef %97)
  %99 = load ptr, ptr %5, align 8, !tbaa !5
  %100 = call i32 @getrusage(i32 noundef 0, ptr noundef %99) #4
  store i64 0, ptr %9, align 8, !tbaa !11
  br label %101

101:                                              ; preds = %123, %94
  %102 = load i64, ptr %9, align 8, !tbaa !11
  %103 = load ptr, ptr %7, align 8, !tbaa !5
  %104 = load i64, ptr %103, align 8, !tbaa !11
  %105 = icmp ult i64 %102, %104
  br i1 %105, label %106, label %126

106:                                              ; preds = %101
  %107 = load ptr, ptr %10, align 8, !tbaa !5
  %108 = load ptr, ptr %11, align 8, !tbaa !5
  %109 = load ptr, ptr %12, align 8, !tbaa !5
  %110 = call i32 @smatrixf_mul(ptr noundef %107, ptr noundef %108, ptr noundef %109)
  %111 = load ptr, ptr %10, align 8, !tbaa !5
  %112 = load ptr, ptr %11, align 8, !tbaa !5
  %113 = load ptr, ptr %12, align 8, !tbaa !5
  %114 = call i32 @smatrixf_mul(ptr noundef %111, ptr noundef %112, ptr noundef %113)
  %115 = load ptr, ptr %10, align 8, !tbaa !5
  %116 = load ptr, ptr %11, align 8, !tbaa !5
  %117 = load ptr, ptr %12, align 8, !tbaa !5
  %118 = call i32 @smatrixf_mul(ptr noundef %115, ptr noundef %116, ptr noundef %117)
  %119 = load ptr, ptr %10, align 8, !tbaa !5
  %120 = load ptr, ptr %11, align 8, !tbaa !5
  %121 = load ptr, ptr %12, align 8, !tbaa !5
  %122 = call i32 @smatrixf_mul(ptr noundef %119, ptr noundef %120, ptr noundef %121)
  br label %123

123:                                              ; preds = %106
  %124 = load i64, ptr %9, align 8, !tbaa !11
  %125 = add i64 %124, 1
  store i64 %125, ptr %9, align 8, !tbaa !11
  br label %101, !llvm.loop !18

126:                                              ; preds = %101
  %127 = load ptr, ptr %6, align 8, !tbaa !5
  %128 = call i32 @getrusage(i32 noundef 0, ptr noundef %127) #4
  %129 = load ptr, ptr %7, align 8, !tbaa !5
  %130 = load i64, ptr %129, align 8, !tbaa !11
  %131 = mul i64 %130, 4
  store i64 %131, ptr %129, align 8, !tbaa !11
  %132 = load ptr, ptr %10, align 8, !tbaa !5
  %133 = call i32 @smatrixf_destroy(ptr noundef %132)
  %134 = load ptr, ptr %11, align 8, !tbaa !5
  %135 = call i32 @smatrixf_destroy(ptr noundef %134)
  %136 = load ptr, ptr %12, align 8, !tbaa !5
  %137 = call i32 @smatrixf_destroy(ptr noundef %136)
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #4
  ret void
}

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

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

; Function Attrs: nounwind
declare i32 @rand() #3

declare float @randf(...) #2

declare i32 @smatrixf_set(ptr noundef, i32 noundef, i32 noundef, float noundef) #2

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

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

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

declare i32 @smatrixf_destroy(ptr noundef) #2

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

!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}
!18 = distinct !{!18, !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 @smatrixf_mul_bench(ptr noundef %0, ptr noundef %1, ptr nocapture noundef %2, i32 noundef %3) local_unnamed_addr #0 {
  %5 = load i64, ptr %2, align 8, !tbaa !5
  %6 = shl i64 %5, 13
  %7 = mul i32 %3, %3
  %8 = mul i32 %7, %3
  %9 = add i32 %8, 1
  %10 = zext i32 %9 to i64
  %11 = udiv i64 %6, %10
  %12 = add nuw i64 %11, 1
  store i64 %12, ptr %2, align 8, !tbaa !5
  %13 = tail call ptr @smatrixf_create(i32 noundef %3, i32 noundef %3) #3
  %14 = tail call ptr @smatrixf_create(i32 noundef %3, i32 noundef %3) #3
  %15 = tail call ptr @smatrixf_create(i32 noundef %3, i32 noundef %3) #3
  %16 = icmp ult i32 %3, 80
  %17 = udiv i32 %3, 20
  %narrow = select i1 %16, i32 4, i32 %17
  %18 = zext nneg i32 %narrow to i64
  %.not = icmp eq i32 %narrow, 0
  br i1 %.not, label %._crit_edge, label %.lr.ph

.preheader:                                       ; preds = %.lr.ph
  br i1 %.not, label %._crit_edge, label %.lr.ph58

.lr.ph:                                           ; preds = %4, %.lr.ph
  %.056 = phi i64 [ %25, %.lr.ph ], [ 0, %4 ]
  %19 = tail call i32 @rand() #3
  %20 = urem i32 %19, %3
  %21 = tail call i32 @rand() #3
  %22 = urem i32 %21, %3
  %23 = tail call float (...) @randf() #3
  %24 = tail call i32 @smatrixf_set(ptr noundef %13, i32 noundef %20, i32 noundef %22, float noundef %23) #3
  %25 = add nuw nsw i64 %.056, 1
  %exitcond.not = icmp eq i64 %25, %18
  br i1 %exitcond.not, label %.preheader, label %.lr.ph, !llvm.loop !9

.lr.ph58:                                         ; preds = %.preheader, %.lr.ph58
  %.157 = phi i64 [ %32, %.lr.ph58 ], [ 0, %.preheader ]
  %26 = tail call i32 @rand() #3
  %27 = urem i32 %26, %3
  %28 = tail call i32 @rand() #3
  %29 = urem i32 %28, %3
  %30 = tail call float (...) @randf() #3
  %31 = tail call i32 @smatrixf_set(ptr noundef %14, i32 noundef %27, i32 noundef %29, float noundef %30) #3
  %32 = add nuw nsw i64 %.157, 1
  %exitcond65.not = icmp eq i64 %32, %18
  br i1 %exitcond65.not, label %._crit_edge, label %.lr.ph58, !llvm.loop !11

._crit_edge:                                      ; preds = %.lr.ph58, %4, %.preheader
  %33 = tail call i32 @smatrixf_mul(ptr noundef %13, ptr noundef %14, ptr noundef %15) #3
  %34 = tail call i32 @getrusage(i32 noundef 0, ptr noundef %0) #3
  %35 = load i64, ptr %2, align 8, !tbaa !5
  %.not64 = icmp eq i64 %35, 0
  br i1 %.not64, label %._crit_edge62, label %.lr.ph61

.lr.ph61:                                         ; preds = %._crit_edge, %.lr.ph61
  %.259 = phi i64 [ %40, %.lr.ph61 ], [ 0, %._crit_edge ]
  %36 = tail call i32 @smatrixf_mul(ptr noundef %13, ptr noundef %14, ptr noundef %15) #3
  %37 = tail call i32 @smatrixf_mul(ptr noundef %13, ptr noundef %14, ptr noundef %15) #3
  %38 = tail call i32 @smatrixf_mul(ptr noundef %13, ptr noundef %14, ptr noundef %15) #3
  %39 = tail call i32 @smatrixf_mul(ptr noundef %13, ptr noundef %14, ptr noundef %15) #3
  %40 = add nuw i64 %.259, 1
  %41 = load i64, ptr %2, align 8, !tbaa !5
  %42 = icmp ult i64 %40, %41
  br i1 %42, label %.lr.ph61, label %._crit_edge62, !llvm.loop !12

._crit_edge62:                                    ; preds = %.lr.ph61, %._crit_edge
  %43 = tail call i32 @getrusage(i32 noundef 0, ptr noundef %1) #3
  %44 = load i64, ptr %2, align 8, !tbaa !5
  %45 = shl i64 %44, 2
  store i64 %45, ptr %2, align 8, !tbaa !5
  %46 = tail call i32 @smatrixf_destroy(ptr noundef %13) #3
  %47 = tail call i32 @smatrixf_destroy(ptr noundef %14) #3
  %48 = tail call i32 @smatrixf_destroy(ptr noundef %15) #3
  ret void
}

declare ptr @smatrixf_create(i32 noundef, i32 noundef) local_unnamed_addr #1

; Function Attrs: nounwind
declare i32 @rand() local_unnamed_addr #2

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

declare i32 @smatrixf_set(ptr noundef, i32 noundef, i32 noundef, float noundef) local_unnamed_addr #1

declare i32 @smatrixf_mul(ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #1

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

declare i32 @smatrixf_destroy(ptr 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 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}
!11 = distinct !{!11, !10}
!12 = distinct !{!12, !10}


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