; LLVM IR from Smorodov/Multitarget-tracker :: src/Detector/darknet/src (cpu_gemm)

; 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: 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 speculatable willreturn memory(none)
declare float @llvm.fmuladd.f32(float, float, float) #1

; 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 void @cpu_gemm_nt(i32 noundef %0, i32 noundef %1, i32 noundef %2, i32 noundef %3, i32 noundef %4, float noundef %5, ptr noundef %6, i32 noundef %7, ptr noundef %8, i32 noundef %9, float noundef %10, ptr noundef %11, i32 noundef %12) #2 {
  %14 = alloca i32, align 4
  %15 = alloca i32, align 4
  %16 = alloca i32, align 4
  %17 = alloca i32, align 4
  %18 = alloca i32, align 4
  %19 = alloca float, align 4
  %20 = alloca ptr, align 8
  %21 = alloca i32, align 4
  %22 = alloca ptr, align 8
  %23 = alloca i32, align 4
  %24 = alloca float, align 4
  %25 = alloca ptr, align 8
  %26 = alloca i32, align 4
  %27 = alloca i32, align 4
  %28 = alloca i32, align 4
  %29 = alloca i32, align 4
  %30 = alloca float, align 4
  store i32 %0, ptr %14, align 4, !tbaa !5
  store i32 %1, ptr %15, align 4, !tbaa !5
  store i32 %2, ptr %16, align 4, !tbaa !5
  store i32 %3, ptr %17, align 4, !tbaa !5
  store i32 %4, ptr %18, align 4, !tbaa !5
  store float %5, ptr %19, align 4, !tbaa !9
  store ptr %6, ptr %20, align 8, !tbaa !11
  store i32 %7, ptr %21, align 4, !tbaa !5
  store ptr %8, ptr %22, align 8, !tbaa !11
  store i32 %9, ptr %23, align 4, !tbaa !5
  store float %10, ptr %24, align 4, !tbaa !9
  store ptr %11, ptr %25, align 8, !tbaa !11
  store i32 %12, ptr %26, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %27) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %28) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %29) #3
  store i32 0, ptr %27, align 4, !tbaa !5
  br label %31

31:                                               ; preds = %87, %13
  %32 = load i32, ptr %27, align 4, !tbaa !5
  %33 = load i32, ptr %16, align 4, !tbaa !5
  %34 = icmp slt i32 %32, %33
  br i1 %34, label %35, label %90

35:                                               ; preds = %31
  store i32 0, ptr %28, align 4, !tbaa !5
  br label %36

36:                                               ; preds = %83, %35
  %37 = load i32, ptr %28, align 4, !tbaa !5
  %38 = load i32, ptr %17, align 4, !tbaa !5
  %39 = icmp slt i32 %37, %38
  br i1 %39, label %40, label %86

40:                                               ; preds = %36
  call void @llvm.lifetime.start.p0(i64 4, ptr %30) #3
  store float 0.000000e+00, ptr %30, align 4, !tbaa !9
  store i32 0, ptr %29, align 4, !tbaa !5
  br label %41

41:                                               ; preds = %68, %40
  %42 = load i32, ptr %29, align 4, !tbaa !5
  %43 = load i32, ptr %18, align 4, !tbaa !5
  %44 = icmp slt i32 %42, %43
  br i1 %44, label %45, label %71

45:                                               ; preds = %41
  %46 = load float, ptr %19, align 4, !tbaa !9
  %47 = load ptr, ptr %20, align 8, !tbaa !11
  %48 = load i32, ptr %27, align 4, !tbaa !5
  %49 = load i32, ptr %21, align 4, !tbaa !5
  %50 = mul nsw i32 %48, %49
  %51 = load i32, ptr %29, align 4, !tbaa !5
  %52 = add nsw i32 %50, %51
  %53 = sext i32 %52 to i64
  %54 = getelementptr inbounds float, ptr %47, i64 %53
  %55 = load float, ptr %54, align 4, !tbaa !9
  %56 = fmul float %46, %55
  %57 = load ptr, ptr %22, align 8, !tbaa !11
  %58 = load i32, ptr %29, align 4, !tbaa !5
  %59 = load i32, ptr %28, align 4, !tbaa !5
  %60 = load i32, ptr %23, align 4, !tbaa !5
  %61 = mul nsw i32 %59, %60
  %62 = add nsw i32 %58, %61
  %63 = sext i32 %62 to i64
  %64 = getelementptr inbounds float, ptr %57, i64 %63
  %65 = load float, ptr %64, align 4, !tbaa !9
  %66 = load float, ptr %30, align 4, !tbaa !9
  %67 = call float @llvm.fmuladd.f32(float %56, float %65, float %66)
  store float %67, ptr %30, align 4, !tbaa !9
  br label %68

68:                                               ; preds = %45
  %69 = load i32, ptr %29, align 4, !tbaa !5
  %70 = add nsw i32 %69, 1
  store i32 %70, ptr %29, align 4, !tbaa !5
  br label %41, !llvm.loop !13

71:                                               ; preds = %41
  %72 = load float, ptr %30, align 4, !tbaa !9
  %73 = load ptr, ptr %25, align 8, !tbaa !11
  %74 = load i32, ptr %27, align 4, !tbaa !5
  %75 = load i32, ptr %26, align 4, !tbaa !5
  %76 = mul nsw i32 %74, %75
  %77 = load i32, ptr %28, align 4, !tbaa !5
  %78 = add nsw i32 %76, %77
  %79 = sext i32 %78 to i64
  %80 = getelementptr inbounds float, ptr %73, i64 %79
  %81 = load float, ptr %80, align 4, !tbaa !9
  %82 = fadd float %81, %72
  store float %82, ptr %80, align 4, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 4, ptr %30) #3
  br label %83

83:                                               ; preds = %71
  %84 = load i32, ptr %28, align 4, !tbaa !5
  %85 = add nsw i32 %84, 1
  store i32 %85, ptr %28, align 4, !tbaa !5
  br label %36, !llvm.loop !15

86:                                               ; preds = %36
  br label %87

87:                                               ; preds = %86
  %88 = load i32, ptr %27, align 4, !tbaa !5
  %89 = add nsw i32 %88, 1
  store i32 %89, ptr %27, align 4, !tbaa !5
  br label %31, !llvm.loop !16

90:                                               ; preds = %31
  call void @llvm.lifetime.end.p0(i64 4, ptr %29) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %28) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %27) #3
  ret void
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #2 = { 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 #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 = !{!"int", !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 = !{!12, !12, i64 0}
!12 = !{!"any pointer", !7, i64 0}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}
!15 = distinct !{!15, !14}
!16 = distinct !{!16, !14}


; 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: mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare float @llvm.fmuladd.f32(float, float, float) #0

; Function Attrs: nofree norecurse nosync nounwind memory(argmem: readwrite) uwtable
define dso_local void @cpu_gemm_nt(i32 noundef %0, i32 noundef %1, i32 noundef %2, i32 noundef %3, i32 noundef %4, float noundef %5, ptr nocapture noundef readonly %6, i32 noundef %7, ptr nocapture noundef readonly %8, i32 noundef %9, float noundef %10, ptr nocapture noundef %11, i32 noundef %12) local_unnamed_addr #1 {
  %14 = icmp sgt i32 %2, 0
  %15 = icmp sgt i32 %3, 0
  %or.cond = and i1 %14, %15
  br i1 %or.cond, label %.preheader26.lr.ph.split.us, label %._crit_edge

.preheader26.lr.ph.split.us:                      ; preds = %13
  %16 = icmp sgt i32 %4, 0
  br i1 %16, label %.preheader26.us.us.preheader, label %.preheader26.us.preheader

.preheader26.us.preheader:                        ; preds = %.preheader26.lr.ph.split.us
  %17 = sext i32 %12 to i64
  %wide.trip.count42 = zext nneg i32 %2 to i64
  %wide.trip.count = zext nneg i32 %3 to i64
  %min.iters.check = icmp ult i32 %3, 8
  %n.vec = and i64 %wide.trip.count, 2147483640
  %cmp.n = icmp eq i64 %n.vec, %wide.trip.count
  br label %.preheader26.us

.preheader26.us.us.preheader:                     ; preds = %.preheader26.lr.ph.split.us
  %18 = sext i32 %9 to i64
  %19 = sext i32 %7 to i64
  %20 = sext i32 %12 to i64
  %wide.trip.count57 = zext nneg i32 %2 to i64
  %wide.trip.count52 = zext nneg i32 %3 to i64
  %wide.trip.count47 = zext nneg i32 %4 to i64
  %xtraiter = and i64 %wide.trip.count47, 3
  %21 = icmp ult i32 %4, 4
  %unroll_iter = and i64 %wide.trip.count47, 2147483644
  %lcmp.mod.not = icmp eq i64 %xtraiter, 0
  br label %.preheader26.us.us

.preheader26.us.us:                               ; preds = %.preheader26.us.us.preheader, %._crit_edge30.split.us.us.us
  %indvars.iv54 = phi i64 [ 0, %.preheader26.us.us.preheader ], [ %indvars.iv.next55, %._crit_edge30.split.us.us.us ]
  %22 = mul nsw i64 %indvars.iv54, %19
  %23 = mul nsw i64 %indvars.iv54, %20
  %invariant.gep60 = getelementptr float, ptr %6, i64 %22
  %invariant.gep64 = getelementptr float, ptr %11, i64 %23
  br label %.preheader.us.us.us

.preheader.us.us.us:                              ; preds = %._crit_edge.us.us.us, %.preheader26.us.us
  %indvars.iv49 = phi i64 [ %indvars.iv.next50, %._crit_edge.us.us.us ], [ 0, %.preheader26.us.us ]
  %24 = mul nsw i64 %indvars.iv49, %18
  %invariant.gep62 = getelementptr float, ptr %8, i64 %24
  br i1 %21, label %._crit_edge.us.us.us.unr-lcssa, label %.preheader.us.us.us.new

.preheader.us.us.us.new:                          ; preds = %.preheader.us.us.us, %.preheader.us.us.us.new
  %indvars.iv44 = phi i64 [ %indvars.iv.next45.3, %.preheader.us.us.us.new ], [ 0, %.preheader.us.us.us ]
  %.028.us.us.us = phi float [ %40, %.preheader.us.us.us.new ], [ 0.000000e+00, %.preheader.us.us.us ]
  %niter = phi i64 [ %niter.next.3, %.preheader.us.us.us.new ], [ 0, %.preheader.us.us.us ]
  %gep61 = getelementptr float, ptr %invariant.gep60, i64 %indvars.iv44
  %25 = load float, ptr %gep61, align 4, !tbaa !5
  %26 = fmul float %25, %5
  %gep63 = getelementptr float, ptr %invariant.gep62, i64 %indvars.iv44
  %27 = load float, ptr %gep63, align 4, !tbaa !5
  %28 = tail call float @llvm.fmuladd.f32(float %26, float %27, float %.028.us.us.us)
  %indvars.iv.next45 = or disjoint i64 %indvars.iv44, 1
  %gep61.1 = getelementptr float, ptr %invariant.gep60, i64 %indvars.iv.next45
  %29 = load float, ptr %gep61.1, align 4, !tbaa !5
  %30 = fmul float %29, %5
  %gep63.1 = getelementptr float, ptr %invariant.gep62, i64 %indvars.iv.next45
  %31 = load float, ptr %gep63.1, align 4, !tbaa !5
  %32 = tail call float @llvm.fmuladd.f32(float %30, float %31, float %28)
  %indvars.iv.next45.1 = or disjoint i64 %indvars.iv44, 2
  %gep61.2 = getelementptr float, ptr %invariant.gep60, i64 %indvars.iv.next45.1
  %33 = load float, ptr %gep61.2, align 4, !tbaa !5
  %34 = fmul float %33, %5
  %gep63.2 = getelementptr float, ptr %invariant.gep62, i64 %indvars.iv.next45.1
  %35 = load float, ptr %gep63.2, align 4, !tbaa !5
  %36 = tail call float @llvm.fmuladd.f32(float %34, float %35, float %32)
  %indvars.iv.next45.2 = or disjoint i64 %indvars.iv44, 3
  %gep61.3 = getelementptr float, ptr %invariant.gep60, i64 %indvars.iv.next45.2
  %37 = load float, ptr %gep61.3, align 4, !tbaa !5
  %38 = fmul float %37, %5
  %gep63.3 = getelementptr float, ptr %invariant.gep62, i64 %indvars.iv.next45.2
  %39 = load float, ptr %gep63.3, align 4, !tbaa !5
  %40 = tail call float @llvm.fmuladd.f32(float %38, float %39, float %36)
  %indvars.iv.next45.3 = add nuw nsw i64 %indvars.iv44, 4
  %niter.next.3 = add i64 %niter, 4
  %niter.ncmp.3 = icmp eq i64 %niter.next.3, %unroll_iter
  br i1 %niter.ncmp.3, label %._crit_edge.us.us.us.unr-lcssa, label %.preheader.us.us.us.new, !llvm.loop !9

._crit_edge.us.us.us.unr-lcssa:                   ; preds = %.preheader.us.us.us.new, %.preheader.us.us.us
  %.lcssa.ph = phi float [ poison, %.preheader.us.us.us ], [ %40, %.preheader.us.us.us.new ]
  %indvars.iv44.unr = phi i64 [ 0, %.preheader.us.us.us ], [ %indvars.iv.next45.3, %.preheader.us.us.us.new ]
  %.028.us.us.us.unr = phi float [ 0.000000e+00, %.preheader.us.us.us ], [ %40, %.preheader.us.us.us.new ]
  br i1 %lcmp.mod.not, label %._crit_edge.us.us.us, label %.epil.preheader

.epil.preheader:                                  ; preds = %._crit_edge.us.us.us.unr-lcssa, %.epil.preheader
  %indvars.iv44.epil = phi i64 [ %indvars.iv.next45.epil, %.epil.preheader ], [ %indvars.iv44.unr, %._crit_edge.us.us.us.unr-lcssa ]
  %.028.us.us.us.epil = phi float [ %44, %.epil.preheader ], [ %.028.us.us.us.unr, %._crit_edge.us.us.us.unr-lcssa ]
  %epil.iter = phi i64 [ %epil.iter.next, %.epil.preheader ], [ 0, %._crit_edge.us.us.us.unr-lcssa ]
  %gep61.epil = getelementptr float, ptr %invariant.gep60, i64 %indvars.iv44.epil
  %41 = load float, ptr %gep61.epil, align 4, !tbaa !5
  %42 = fmul float %41, %5
  %gep63.epil = getelementptr float, ptr %invariant.gep62, i64 %indvars.iv44.epil
  %43 = load float, ptr %gep63.epil, align 4, !tbaa !5
  %44 = tail call float @llvm.fmuladd.f32(float %42, float %43, float %.028.us.us.us.epil)
  %indvars.iv.next45.epil = add nuw nsw i64 %indvars.iv44.epil, 1
  %epil.iter.next = add i64 %epil.iter, 1
  %epil.iter.cmp.not = icmp eq i64 %epil.iter.next, %xtraiter
  br i1 %epil.iter.cmp.not, label %._crit_edge.us.us.us, label %.epil.preheader, !llvm.loop !11

._crit_edge.us.us.us:                             ; preds = %.epil.preheader, %._crit_edge.us.us.us.unr-lcssa
  %.lcssa = phi float [ %.lcssa.ph, %._crit_edge.us.us.us.unr-lcssa ], [ %44, %.epil.preheader ]
  %gep65 = getelementptr float, ptr %invariant.gep64, i64 %indvars.iv49
  %45 = load float, ptr %gep65, align 4, !tbaa !5
  %46 = fadd float %.lcssa, %45
  store float %46, ptr %gep65, align 4, !tbaa !5
  %indvars.iv.next50 = add nuw nsw i64 %indvars.iv49, 1
  %exitcond53.not = icmp eq i64 %indvars.iv.next50, %wide.trip.count52
  br i1 %exitcond53.not, label %._crit_edge30.split.us.us.us, label %.preheader.us.us.us, !llvm.loop !13

._crit_edge30.split.us.us.us:                     ; preds = %._crit_edge.us.us.us
  %indvars.iv.next55 = add nuw nsw i64 %indvars.iv54, 1
  %exitcond58.not = icmp eq i64 %indvars.iv.next55, %wide.trip.count57
  br i1 %exitcond58.not, label %._crit_edge, label %.preheader26.us.us, !llvm.loop !14

.preheader26.us:                                  ; preds = %.preheader26.us.preheader, %._crit_edge30.split.us34
  %indvars.iv39 = phi i64 [ 0, %.preheader26.us.preheader ], [ %indvars.iv.next40, %._crit_edge30.split.us34 ]
  %47 = mul nsw i64 %indvars.iv39, %17
  %invariant.gep = getelementptr float, ptr %11, i64 %47
  br i1 %min.iters.check, label %.preheader.us32.preheader, label %vector.body

vector.body:                                      ; preds = %.preheader26.us, %vector.body
  %index = phi i64 [ %index.next, %vector.body ], [ 0, %.preheader26.us ]
  %48 = getelementptr float, ptr %invariant.gep, i64 %index
  %49 = getelementptr i8, ptr %48, i64 16
  %wide.load = load <4 x float>, ptr %48, align 4, !tbaa !5
  %wide.load67 = load <4 x float>, ptr %49, align 4, !tbaa !5
  %50 = fadd <4 x float> %wide.load, zeroinitializer
  %51 = fadd <4 x float> %wide.load67, zeroinitializer
  store <4 x float> %50, ptr %48, align 4, !tbaa !5
  store <4 x float> %51, ptr %49, align 4, !tbaa !5
  %index.next = add nuw i64 %index, 8
  %52 = icmp eq i64 %index.next, %n.vec
  br i1 %52, label %middle.block, label %vector.body, !llvm.loop !15

middle.block:                                     ; preds = %vector.body
  br i1 %cmp.n, label %._crit_edge30.split.us34, label %.preheader.us32.preheader

.preheader.us32.preheader:                        ; preds = %middle.block, %.preheader26.us
  %indvars.iv.ph = phi i64 [ 0, %.preheader26.us ], [ %n.vec, %middle.block ]
  br label %.preheader.us32

.preheader.us32:                                  ; preds = %.preheader.us32.preheader, %.preheader.us32
  %indvars.iv = phi i64 [ %indvars.iv.next, %.preheader.us32 ], [ %indvars.iv.ph, %.preheader.us32.preheader ]
  %gep = getelementptr float, ptr %invariant.gep, i64 %indvars.iv
  %53 = load float, ptr %gep, align 4, !tbaa !5
  %54 = fadd float %53, 0.000000e+00
  store float %54, ptr %gep, align 4, !tbaa !5
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next, %wide.trip.count
  br i1 %exitcond.not, label %._crit_edge30.split.us34, label %.preheader.us32, !llvm.loop !18

._crit_edge30.split.us34:                         ; preds = %.preheader.us32, %middle.block
  %indvars.iv.next40 = add nuw nsw i64 %indvars.iv39, 1
  %exitcond43.not = icmp eq i64 %indvars.iv.next40, %wide.trip.count42
  br i1 %exitcond43.not, label %._crit_edge, label %.preheader26.us, !llvm.loop !14

._crit_edge:                                      ; preds = %._crit_edge30.split.us34, %._crit_edge30.split.us.us.us, %13
  ret void
}

attributes #0 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #1 = { nofree norecurse nosync nounwind memory(argmem: readwrite) 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, !6, i64 0}
!6 = !{!"float", !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, !12}
!12 = !{!"llvm.loop.unroll.disable"}
!13 = distinct !{!13, !10}
!14 = distinct !{!14, !10}
!15 = distinct !{!15, !10, !16, !17}
!16 = !{!"llvm.loop.isvectorized", i32 1}
!17 = !{!"llvm.loop.unroll.runtime.disable"}
!18 = distinct !{!18, !10, !17, !16}


; Effective O3 passes: GVNPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LICMPass,LoopInstSimplifyPass,LoopLoadEliminationPass,LoopRotatePass,LoopSimplifyCFGPass,LoopSimplifyPass,LoopUnrollPass,LoopVectorizePass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass