; LLVM IR from jgaeddert/liquid-dsp :: src/matrix/bench (matrixf_linsolve_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_linsolve_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 i64, align 8
  %12 = alloca i64, align 8
  %13 = alloca i64, align 8
  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
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #5
  %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 %10, align 8
  %32 = alloca float, i64 %30, align 16
  store i64 %30, ptr %11, align 8
  %33 = load i32, ptr %8, align 4, !tbaa !9
  %34 = zext i32 %33 to i64
  %35 = alloca float, i64 %34, align 16
  store i64 %34, ptr %12, align 8
  %36 = load i32, ptr %8, align 4, !tbaa !9
  %37 = zext i32 %36 to i64
  %38 = alloca float, i64 %37, align 16
  store i64 %37, ptr %13, align 8
  store i64 0, ptr %9, align 8, !tbaa !11
  br label %39

39:                                               ; preds = %50, %26
  %40 = load i64, ptr %9, align 8, !tbaa !11
  %41 = load i32, ptr %8, align 4, !tbaa !9
  %42 = load i32, ptr %8, align 4, !tbaa !9
  %43 = mul i32 %41, %42
  %44 = zext i32 %43 to i64
  %45 = icmp ult i64 %40, %44
  br i1 %45, label %46, label %53

46:                                               ; preds = %39
  %47 = call float (...) @randnf()
  %48 = load i64, ptr %9, align 8, !tbaa !11
  %49 = getelementptr inbounds float, ptr %32, i64 %48
  store float %47, ptr %49, align 4, !tbaa !13
  br label %50

50:                                               ; preds = %46
  %51 = load i64, ptr %9, align 8, !tbaa !11
  %52 = add i64 %51, 1
  store i64 %52, ptr %9, align 8, !tbaa !11
  br label %39, !llvm.loop !15

53:                                               ; preds = %39
  store i64 0, ptr %9, align 8, !tbaa !11
  br label %54

54:                                               ; preds = %63, %53
  %55 = load i64, ptr %9, align 8, !tbaa !11
  %56 = load i32, ptr %8, align 4, !tbaa !9
  %57 = zext i32 %56 to i64
  %58 = icmp ult i64 %55, %57
  br i1 %58, label %59, label %66

59:                                               ; preds = %54
  %60 = call float (...) @randnf()
  %61 = load i64, ptr %9, align 8, !tbaa !11
  %62 = getelementptr inbounds float, ptr %35, i64 %61
  store float %60, ptr %62, align 4, !tbaa !13
  br label %63

63:                                               ; preds = %59
  %64 = load i64, ptr %9, align 8, !tbaa !11
  %65 = add i64 %64, 1
  store i64 %65, ptr %9, align 8, !tbaa !11
  br label %54, !llvm.loop !17

66:                                               ; preds = %54
  %67 = load ptr, ptr %5, align 8, !tbaa !5
  %68 = call i32 @getrusage(i32 noundef 0, ptr noundef %67) #5
  store i64 0, ptr %9, align 8, !tbaa !11
  br label %69

69:                                               ; preds = %83, %66
  %70 = load i64, ptr %9, align 8, !tbaa !11
  %71 = load ptr, ptr %7, align 8, !tbaa !5
  %72 = load i64, ptr %71, align 8, !tbaa !11
  %73 = icmp ult i64 %70, %72
  br i1 %73, label %74, label %86

74:                                               ; preds = %69
  %75 = load i32, ptr %8, align 4, !tbaa !9
  %76 = call i32 @matrixf_linsolve(ptr noundef %32, i32 noundef %75, ptr noundef %35, ptr noundef %38, ptr noundef null)
  %77 = load i32, ptr %8, align 4, !tbaa !9
  %78 = call i32 @matrixf_linsolve(ptr noundef %32, i32 noundef %77, ptr noundef %35, ptr noundef %38, ptr noundef null)
  %79 = load i32, ptr %8, align 4, !tbaa !9
  %80 = call i32 @matrixf_linsolve(ptr noundef %32, i32 noundef %79, ptr noundef %35, ptr noundef %38, ptr noundef null)
  %81 = load i32, ptr %8, align 4, !tbaa !9
  %82 = call i32 @matrixf_linsolve(ptr noundef %32, i32 noundef %81, ptr noundef %35, ptr noundef %38, ptr noundef null)
  br label %83

83:                                               ; preds = %74
  %84 = load i64, ptr %9, align 8, !tbaa !11
  %85 = add i64 %84, 1
  store i64 %85, ptr %9, align 8, !tbaa !11
  br label %69, !llvm.loop !18

86:                                               ; preds = %69
  %87 = load ptr, ptr %6, align 8, !tbaa !5
  %88 = call i32 @getrusage(i32 noundef 0, ptr noundef %87) #5
  %89 = load ptr, ptr %7, align 8, !tbaa !5
  %90 = load i64, ptr %89, align 8, !tbaa !11
  %91 = mul i64 %90, 4
  store i64 %91, ptr %89, align 8, !tbaa !11
  %92 = load ptr, ptr %10, align 8
  call void @llvm.stackrestore.p0(ptr %92)
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #5
  ret void
}

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

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

declare float @randnf(...) #3

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

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

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

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #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 memory(argmem: readwrite) }
attributes #2 = { nocallback nofree nosync nounwind willreturn }
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}
!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 @matrixf_linsolve_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 = zext i32 %3 to i64
  %12 = alloca float, i64 %11, align 16
  %13 = alloca float, i64 %11, align 16
  %umax = tail call i64 @llvm.umax.i64(i64 %6, i64 1)
  br label %14

.preheader:                                       ; preds = %14
  %.not = icmp eq i32 %3, 0
  br i1 %.not, label %._crit_edge, label %.lr.ph

14:                                               ; preds = %4, %14
  %.028 = phi i64 [ 0, %4 ], [ %17, %14 ]
  %15 = tail call float (...) @randnf() #4
  %16 = getelementptr inbounds float, ptr %10, i64 %.028
  store float %15, ptr %16, align 4, !tbaa !9
  %17 = add nuw nsw i64 %.028, 1
  %exitcond.not = icmp eq i64 %17, %umax
  br i1 %exitcond.not, label %.preheader, label %14, !llvm.loop !11

.lr.ph:                                           ; preds = %.preheader, %.lr.ph
  %.129 = phi i64 [ %20, %.lr.ph ], [ 0, %.preheader ]
  %18 = tail call float (...) @randnf() #4
  %19 = getelementptr inbounds float, ptr %12, i64 %.129
  store float %18, ptr %19, align 4, !tbaa !9
  %20 = add nuw nsw i64 %.129, 1
  %exitcond35.not = icmp eq i64 %20, %11
  br i1 %exitcond35.not, label %._crit_edge, label %.lr.ph, !llvm.loop !13

._crit_edge:                                      ; preds = %.lr.ph, %.preheader
  %21 = tail call i32 @getrusage(i32 noundef 0, ptr noundef %0) #4
  %22 = load i64, ptr %2, align 8, !tbaa !5
  %.not34 = icmp eq i64 %22, 0
  br i1 %.not34, label %._crit_edge33, label %.lr.ph32

.lr.ph32:                                         ; preds = %._crit_edge, %.lr.ph32
  %.230 = phi i64 [ %27, %.lr.ph32 ], [ 0, %._crit_edge ]
  %23 = call i32 @matrixf_linsolve(ptr noundef nonnull %10, i32 noundef %3, ptr noundef nonnull %12, ptr noundef nonnull %13, ptr noundef null) #4
  %24 = call i32 @matrixf_linsolve(ptr noundef nonnull %10, i32 noundef %3, ptr noundef nonnull %12, ptr noundef nonnull %13, ptr noundef null) #4
  %25 = call i32 @matrixf_linsolve(ptr noundef nonnull %10, i32 noundef %3, ptr noundef nonnull %12, ptr noundef nonnull %13, ptr noundef null) #4
  %26 = call i32 @matrixf_linsolve(ptr noundef nonnull %10, i32 noundef %3, ptr noundef nonnull %12, ptr noundef nonnull %13, ptr noundef null) #4
  %27 = add nuw i64 %.230, 1
  %28 = load i64, ptr %2, align 8, !tbaa !5
  %29 = icmp ult i64 %27, %28
  br i1 %29, label %.lr.ph32, label %._crit_edge33, !llvm.loop !14

._crit_edge33:                                    ; preds = %.lr.ph32, %._crit_edge
  %30 = call i32 @getrusage(i32 noundef 0, ptr noundef %1) #4
  %31 = load i64, ptr %2, align 8, !tbaa !5
  %32 = shl i64 %31, 2
  store i64 %32, 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_linsolve(ptr noundef, i32 noundef, ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #1

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i64 @llvm.umax.i64(i64, i64) #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 = { 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 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
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 = !{!"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}
!14 = distinct !{!14, !12}


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