; LLVM IR from mrbid/CSGO_TENSOR_TRIGGER :: GOBOT15/KERAS2C/include (k2c_helper_functions)

; 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 @k2c_matmul(ptr noundef %0, ptr noundef %1, ptr noundef %2, i64 noundef %3, i64 noundef %4, i64 noundef %5) #0 {
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  %10 = alloca i64, align 8
  %11 = alloca i64, align 8
  %12 = alloca i64, align 8
  %13 = alloca i64, align 8
  %14 = alloca i32, align 4
  %15 = alloca i64, align 8
  %16 = alloca i64, align 8
  %17 = alloca i64, align 8
  %18 = alloca i64, align 8
  store ptr %0, ptr %7, align 8, !tbaa !5
  store ptr %1, ptr %8, align 8, !tbaa !5
  store ptr %2, ptr %9, align 8, !tbaa !5
  store i64 %3, ptr %10, align 8, !tbaa !9
  store i64 %4, ptr %11, align 8, !tbaa !9
  store i64 %5, ptr %12, align 8, !tbaa !9
  %19 = load ptr, ptr %7, align 8, !tbaa !5
  %20 = load i64, ptr %10, align 8, !tbaa !9
  %21 = load i64, ptr %11, align 8, !tbaa !9
  %22 = mul i64 %20, %21
  %23 = mul i64 %22, 4
  call void @llvm.memset.p0.i64(ptr align 4 %19, i8 0, i64 %23, i1 false)
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #4
  store i64 0, ptr %13, align 8, !tbaa !9
  br label %24

24:                                               ; preds = %77, %6
  %25 = load i64, ptr %13, align 8, !tbaa !9
  %26 = load i64, ptr %10, align 8, !tbaa !9
  %27 = icmp ult i64 %25, %26
  br i1 %27, label %29, label %28

28:                                               ; preds = %24
  store i32 2, ptr %14, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #4
  br label %80

29:                                               ; preds = %24
  call void @llvm.lifetime.start.p0(i64 8, ptr %15) #4
  %30 = load i64, ptr %13, align 8, !tbaa !9
  %31 = load i64, ptr %11, align 8, !tbaa !9
  %32 = mul i64 %30, %31
  store i64 %32, ptr %15, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %16) #4
  %33 = load i64, ptr %13, align 8, !tbaa !9
  %34 = load i64, ptr %12, align 8, !tbaa !9
  %35 = mul i64 %33, %34
  store i64 %35, ptr %16, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %17) #4
  store i64 0, ptr %17, align 8, !tbaa !9
  br label %36

36:                                               ; preds = %73, %29
  %37 = load i64, ptr %17, align 8, !tbaa !9
  %38 = load i64, ptr %12, align 8, !tbaa !9
  %39 = icmp ult i64 %37, %38
  br i1 %39, label %41, label %40

40:                                               ; preds = %36
  store i32 5, ptr %14, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %17) #4
  br label %76

41:                                               ; preds = %36
  call void @llvm.lifetime.start.p0(i64 8, ptr %18) #4
  store i64 0, ptr %18, align 8, !tbaa !9
  br label %42

42:                                               ; preds = %69, %41
  %43 = load i64, ptr %18, align 8, !tbaa !9
  %44 = load i64, ptr %11, align 8, !tbaa !9
  %45 = icmp ult i64 %43, %44
  br i1 %45, label %47, label %46

46:                                               ; preds = %42
  store i32 8, ptr %14, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %18) #4
  br label %72

47:                                               ; preds = %42
  %48 = load ptr, ptr %8, align 8, !tbaa !5
  %49 = load i64, ptr %16, align 8, !tbaa !9
  %50 = load i64, ptr %17, align 8, !tbaa !9
  %51 = add i64 %49, %50
  %52 = getelementptr inbounds float, ptr %48, i64 %51
  %53 = load float, ptr %52, align 4, !tbaa !11
  %54 = load ptr, ptr %9, align 8, !tbaa !5
  %55 = load i64, ptr %17, align 8, !tbaa !9
  %56 = load i64, ptr %11, align 8, !tbaa !9
  %57 = mul i64 %55, %56
  %58 = load i64, ptr %18, align 8, !tbaa !9
  %59 = add i64 %57, %58
  %60 = getelementptr inbounds float, ptr %54, i64 %59
  %61 = load float, ptr %60, align 4, !tbaa !11
  %62 = load ptr, ptr %7, align 8, !tbaa !5
  %63 = load i64, ptr %15, align 8, !tbaa !9
  %64 = load i64, ptr %18, align 8, !tbaa !9
  %65 = add i64 %63, %64
  %66 = getelementptr inbounds float, ptr %62, i64 %65
  %67 = load float, ptr %66, align 4, !tbaa !11
  %68 = call float @llvm.fmuladd.f32(float %53, float %61, float %67)
  store float %68, ptr %66, align 4, !tbaa !11
  br label %69

69:                                               ; preds = %47
  %70 = load i64, ptr %18, align 8, !tbaa !9
  %71 = add i64 %70, 1
  store i64 %71, ptr %18, align 8, !tbaa !9
  br label %42, !llvm.loop !13

72:                                               ; preds = %46
  br label %73

73:                                               ; preds = %72
  %74 = load i64, ptr %17, align 8, !tbaa !9
  %75 = add i64 %74, 1
  store i64 %75, ptr %17, align 8, !tbaa !9
  br label %36, !llvm.loop !15

76:                                               ; preds = %40
  call void @llvm.lifetime.end.p0(i64 8, ptr %16) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %15) #4
  br label %77

77:                                               ; preds = %76
  %78 = load i64, ptr %13, align 8, !tbaa !9
  %79 = add i64 %78, 1
  store i64 %79, ptr %13, align 8, !tbaa !9
  br label %24, !llvm.loop !16

80:                                               ; preds = %28
  ret void
}

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #1

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

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare float @llvm.fmuladd.f32(float, float, float) #3

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #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 nounwind willreturn memory(argmem: write) }
attributes #2 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"long", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"float", !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: nofree norecurse nosync nounwind memory(argmem: readwrite) uwtable
define dso_local void @k2c_matmul(ptr nocapture noundef %0, ptr nocapture noundef readonly %1, ptr nocapture noundef readonly %2, i64 noundef %3, i64 noundef %4, i64 noundef %5) local_unnamed_addr #0 {
  %7 = shl i64 %3, 2
  %8 = mul i64 %7, %4
  tail call void @llvm.memset.p0.i64(ptr align 4 %0, i8 0, i64 %8, i1 false)
  %.not = icmp eq i64 %3, 0
  %.not36 = icmp eq i64 %5, 0
  %or.cond = or i1 %.not, %.not36
  %.not37 = icmp eq i64 %4, 0
  %or.cond42 = or i1 %or.cond, %.not37
  br i1 %or.cond42, label %._crit_edge, label %.preheader.lr.ph.us.us.preheader

.preheader.lr.ph.us.us.preheader:                 ; preds = %6
  %9 = shl i64 %4, 2
  %10 = shl i64 %5, 2
  %11 = mul i64 %5, %4
  %12 = shl i64 %11, 2
  %scevgep46 = getelementptr i8, ptr %2, i64 %12
  %13 = getelementptr i8, ptr %0, i64 %9
  %14 = getelementptr i8, ptr %1, i64 %10
  %min.iters.check = icmp ult i64 %4, 8
  %stride.check = icmp slt i64 %9, 0
  %n.vec = and i64 %4, -8
  %cmp.n = icmp eq i64 %n.vec, %4
  %xtraiter = and i64 %4, 1
  %lcmp.mod.not = icmp eq i64 %xtraiter, 0
  %15 = add i64 %4, -1
  br label %.preheader.lr.ph.us.us

.preheader.lr.ph.us.us:                           ; preds = %.preheader.lr.ph.us.us.preheader, %._crit_edge30.split.us.us.us
  %.02631.us.us = phi i64 [ %57, %._crit_edge30.split.us.us.us ], [ 0, %.preheader.lr.ph.us.us.preheader ]
  %16 = mul i64 %9, %.02631.us.us
  %scevgep = getelementptr i8, ptr %0, i64 %16
  %scevgep43 = getelementptr i8, ptr %13, i64 %16
  %17 = mul i64 %10, %.02631.us.us
  %scevgep44 = getelementptr i8, ptr %1, i64 %17
  %scevgep45 = getelementptr i8, ptr %14, i64 %17
  %18 = mul i64 %.02631.us.us, %4
  %19 = mul i64 %.02631.us.us, %5
  %20 = getelementptr float, ptr %1, i64 %19
  %21 = getelementptr float, ptr %0, i64 %18
  %bound0 = icmp ult ptr %scevgep, %scevgep45
  %bound1 = icmp ult ptr %scevgep44, %scevgep43
  %found.conflict = and i1 %bound0, %bound1
  %bound047 = icmp ult ptr %scevgep, %scevgep46
  %bound148 = icmp ugt ptr %scevgep43, %2
  %found.conflict49 = and i1 %bound047, %bound148
  %22 = or i1 %found.conflict49, %stride.check
  %conflict.rdx = or i1 %found.conflict, %22
  br label %.preheader.us.us.us

.preheader.us.us.us:                              ; preds = %._crit_edge.us.us.us, %.preheader.lr.ph.us.us
  %.02529.us.us.us = phi i64 [ 0, %.preheader.lr.ph.us.us ], [ %56, %._crit_edge.us.us.us ]
  %23 = getelementptr float, ptr %20, i64 %.02529.us.us.us
  %24 = mul i64 %.02529.us.us.us, %4
  %25 = getelementptr float, ptr %2, i64 %24
  %brmerge = or i1 %min.iters.check, %conflict.rdx
  br i1 %brmerge, label %scalar.ph.preheader, label %vector.ph

vector.ph:                                        ; preds = %.preheader.us.us.us
  %26 = load float, ptr %23, align 4, !tbaa !5, !alias.scope !9
  %broadcast.splatinsert53 = insertelement <4 x float> poison, float %26, i64 0
  %broadcast.splat54 = shufflevector <4 x float> %broadcast.splatinsert53, <4 x float> poison, <4 x i32> zeroinitializer
  br label %vector.body

vector.body:                                      ; preds = %vector.body, %vector.ph
  %index = phi i64 [ 0, %vector.ph ], [ %index.next, %vector.body ]
  %27 = getelementptr float, ptr %25, i64 %index
  %28 = getelementptr i8, ptr %27, i64 16
  %wide.load = load <4 x float>, ptr %27, align 4, !tbaa !5, !alias.scope !12
  %wide.load50 = load <4 x float>, ptr %28, align 4, !tbaa !5, !alias.scope !12
  %29 = getelementptr float, ptr %21, i64 %index
  %30 = getelementptr i8, ptr %29, i64 16
  %wide.load51 = load <4 x float>, ptr %29, align 4, !tbaa !5, !alias.scope !14, !noalias !16
  %wide.load52 = load <4 x float>, ptr %30, align 4, !tbaa !5, !alias.scope !14, !noalias !16
  %31 = tail call <4 x float> @llvm.fmuladd.v4f32(<4 x float> %broadcast.splat54, <4 x float> %wide.load, <4 x float> %wide.load51)
  %32 = tail call <4 x float> @llvm.fmuladd.v4f32(<4 x float> %broadcast.splat54, <4 x float> %wide.load50, <4 x float> %wide.load52)
  store <4 x float> %31, ptr %29, align 4, !tbaa !5, !alias.scope !14, !noalias !16
  store <4 x float> %32, ptr %30, align 4, !tbaa !5, !alias.scope !14, !noalias !16
  %index.next = add nuw i64 %index, 8
  %33 = icmp eq i64 %index.next, %n.vec
  br i1 %33, label %middle.block, label %vector.body, !llvm.loop !17

middle.block:                                     ; preds = %vector.body
  br i1 %cmp.n, label %._crit_edge.us.us.us, label %scalar.ph.preheader

scalar.ph.preheader:                              ; preds = %.preheader.us.us.us, %middle.block
  %.028.us.us.us.ph = phi i64 [ 0, %.preheader.us.us.us ], [ %n.vec, %middle.block ]
  br i1 %lcmp.mod.not, label %scalar.ph.prol.loopexit, label %scalar.ph.prol

scalar.ph.prol:                                   ; preds = %scalar.ph.preheader
  %34 = load float, ptr %23, align 4, !tbaa !5
  %35 = getelementptr float, ptr %25, i64 %.028.us.us.us.ph
  %36 = load float, ptr %35, align 4, !tbaa !5
  %37 = getelementptr float, ptr %21, i64 %.028.us.us.us.ph
  %38 = load float, ptr %37, align 4, !tbaa !5
  %39 = tail call float @llvm.fmuladd.f32(float %34, float %36, float %38)
  store float %39, ptr %37, align 4, !tbaa !5
  %40 = or disjoint i64 %.028.us.us.us.ph, 1
  br label %scalar.ph.prol.loopexit

scalar.ph.prol.loopexit:                          ; preds = %scalar.ph.prol, %scalar.ph.preheader
  %.028.us.us.us.unr = phi i64 [ %.028.us.us.us.ph, %scalar.ph.preheader ], [ %40, %scalar.ph.prol ]
  %41 = icmp eq i64 %.028.us.us.us.ph, %15
  br i1 %41, label %._crit_edge.us.us.us, label %scalar.ph

scalar.ph:                                        ; preds = %scalar.ph.prol.loopexit, %scalar.ph
  %.028.us.us.us = phi i64 [ %55, %scalar.ph ], [ %.028.us.us.us.unr, %scalar.ph.prol.loopexit ]
  %42 = load float, ptr %23, align 4, !tbaa !5
  %43 = getelementptr float, ptr %25, i64 %.028.us.us.us
  %44 = load float, ptr %43, align 4, !tbaa !5
  %45 = getelementptr float, ptr %21, i64 %.028.us.us.us
  %46 = load float, ptr %45, align 4, !tbaa !5
  %47 = tail call float @llvm.fmuladd.f32(float %42, float %44, float %46)
  store float %47, ptr %45, align 4, !tbaa !5
  %48 = add nuw i64 %.028.us.us.us, 1
  %49 = load float, ptr %23, align 4, !tbaa !5
  %50 = getelementptr float, ptr %25, i64 %48
  %51 = load float, ptr %50, align 4, !tbaa !5
  %52 = getelementptr float, ptr %21, i64 %48
  %53 = load float, ptr %52, align 4, !tbaa !5
  %54 = tail call float @llvm.fmuladd.f32(float %49, float %51, float %53)
  store float %54, ptr %52, align 4, !tbaa !5
  %55 = add nuw i64 %.028.us.us.us, 2
  %exitcond.not.1 = icmp eq i64 %55, %4
  br i1 %exitcond.not.1, label %._crit_edge.us.us.us, label %scalar.ph, !llvm.loop !21

._crit_edge.us.us.us:                             ; preds = %scalar.ph.prol.loopexit, %scalar.ph, %middle.block
  %56 = add nuw i64 %.02529.us.us.us, 1
  %exitcond40.not = icmp eq i64 %56, %5
  br i1 %exitcond40.not, label %._crit_edge30.split.us.us.us, label %.preheader.us.us.us, !llvm.loop !22

._crit_edge30.split.us.us.us:                     ; preds = %._crit_edge.us.us.us
  %57 = add nuw i64 %.02631.us.us, 1
  %exitcond41.not = icmp eq i64 %57, %3
  br i1 %exitcond41.not, label %._crit_edge, label %.preheader.lr.ph.us.us, !llvm.loop !23

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

; Function Attrs: mustprogress nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #1

; Function Attrs: mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare float @llvm.fmuladd.f32(float, float, float) #2

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare <4 x float> @llvm.fmuladd.v4f32(<4 x float>, <4 x float>, <4 x float>) #3

attributes #0 = { 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" }
attributes #1 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #2 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #3 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }

!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 = !{!10}
!10 = distinct !{!10, !11}
!11 = distinct !{!11, !"LVerDomain"}
!12 = !{!13}
!13 = distinct !{!13, !11}
!14 = !{!15}
!15 = distinct !{!15, !11}
!16 = !{!10, !13}
!17 = distinct !{!17, !18, !19, !20}
!18 = !{!"llvm.loop.mustprogress"}
!19 = !{!"llvm.loop.isvectorized", i32 1}
!20 = !{!"llvm.loop.unroll.runtime.disable"}
!21 = distinct !{!21, !18, !19}
!22 = distinct !{!22, !18}
!23 = distinct !{!23, !18}


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