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

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

%struct.k2c_tensor = type { ptr, i64, i64, [5 x i64] }

; 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 willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #0

; Function Attrs: nounwind uwtable
define dso_local void @k2c_repeat_vector(ptr noundef %0, ptr noundef %1, i64 noundef %2) #1 {
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca i64, align 8
  %7 = alloca i64, align 8
  %8 = alloca i64, align 8
  %9 = alloca i32, align 4
  %10 = alloca i64, align 8
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  store i64 %2, ptr %6, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #2
  %11 = load ptr, ptr %5, align 8, !tbaa !5
  %12 = getelementptr inbounds %struct.k2c_tensor, ptr %11, i32 0, i32 3
  %13 = getelementptr inbounds [5 x i64], ptr %12, i64 0, i64 0
  %14 = load i64, ptr %13, align 8, !tbaa !9
  store i64 %14, ptr %7, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #2
  store i64 0, ptr %8, align 8, !tbaa !9
  br label %15

15:                                               ; preds = %46, %3
  %16 = load i64, ptr %8, align 8, !tbaa !9
  %17 = load i64, ptr %6, align 8, !tbaa !9
  %18 = icmp ult i64 %16, %17
  br i1 %18, label %20, label %19

19:                                               ; preds = %15
  store i32 2, ptr %9, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #2
  br label %49

20:                                               ; preds = %15
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #2
  store i64 0, ptr %10, align 8, !tbaa !9
  br label %21

21:                                               ; preds = %42, %20
  %22 = load i64, ptr %10, align 8, !tbaa !9
  %23 = load i64, ptr %7, align 8, !tbaa !9
  %24 = icmp ult i64 %22, %23
  br i1 %24, label %26, label %25

25:                                               ; preds = %21
  store i32 5, ptr %9, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #2
  br label %45

26:                                               ; preds = %21
  %27 = load ptr, ptr %5, align 8, !tbaa !5
  %28 = getelementptr inbounds %struct.k2c_tensor, ptr %27, i32 0, i32 0
  %29 = load ptr, ptr %28, align 8, !tbaa !11
  %30 = load i64, ptr %10, align 8, !tbaa !9
  %31 = getelementptr inbounds float, ptr %29, i64 %30
  %32 = load float, ptr %31, align 4, !tbaa !13
  %33 = load ptr, ptr %4, align 8, !tbaa !5
  %34 = getelementptr inbounds %struct.k2c_tensor, ptr %33, i32 0, i32 0
  %35 = load ptr, ptr %34, align 8, !tbaa !11
  %36 = load i64, ptr %8, align 8, !tbaa !9
  %37 = load i64, ptr %7, align 8, !tbaa !9
  %38 = mul i64 %36, %37
  %39 = load i64, ptr %10, align 8, !tbaa !9
  %40 = add i64 %38, %39
  %41 = getelementptr inbounds float, ptr %35, i64 %40
  store float %32, ptr %41, align 4, !tbaa !13
  br label %42

42:                                               ; preds = %26
  %43 = load i64, ptr %10, align 8, !tbaa !9
  %44 = add i64 %43, 1
  store i64 %44, ptr %10, align 8, !tbaa !9
  br label %21, !llvm.loop !15

45:                                               ; preds = %25
  br label %46

46:                                               ; preds = %45
  %47 = load i64, ptr %8, align 8, !tbaa !9
  %48 = add i64 %47, 1
  store i64 %48, ptr %8, align 8, !tbaa !9
  br label %15, !llvm.loop !17

49:                                               ; preds = %19
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #2
  ret void
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #2 = { 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, !6, i64 0}
!12 = !{!"k2c_tensor", !6, i64 0, !10, i64 8, !10, i64 16, !7, i64 24}
!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: nofree norecurse nosync nounwind memory(readwrite, inaccessiblemem: none) uwtable
define dso_local void @k2c_repeat_vector(ptr nocapture noundef readonly %0, ptr nocapture noundef readonly %1, i64 noundef %2) local_unnamed_addr #0 {
  %4 = getelementptr inbounds i8, ptr %1, i64 24
  %5 = load i64, ptr %4, align 8, !tbaa !5
  %.not = icmp eq i64 %2, 0
  %.not17 = icmp eq i64 %5, 0
  %or.cond = select i1 %.not, i1 true, i1 %.not17
  br i1 %or.cond, label %._crit_edge16, label %.preheader.lr.ph.split.us

.preheader.lr.ph.split.us:                        ; preds = %3
  %6 = load ptr, ptr %1, align 8, !tbaa !9
  %7 = ptrtoint ptr %6 to i64
  %8 = load ptr, ptr %0, align 8, !tbaa !9
  %9 = ptrtoint ptr %8 to i64
  %10 = sub i64 %9, %7
  %11 = shl i64 %5, 2
  %min.iters.check = icmp ult i64 %5, 8
  %n.vec = and i64 %5, -8
  %cmp.n = icmp eq i64 %5, %n.vec
  %xtraiter = and i64 %5, 3
  %lcmp.mod.not = icmp eq i64 %xtraiter, 0
  br label %.preheader.us

.preheader.us:                                    ; preds = %._crit_edge.us, %.preheader.lr.ph.split.us
  %.01215.us = phi i64 [ 0, %.preheader.lr.ph.split.us ], [ %43, %._crit_edge.us ]
  %12 = mul i64 %.01215.us, %5
  %13 = getelementptr float, ptr %8, i64 %12
  br i1 %min.iters.check, label %scalar.ph.preheader, label %vector.memcheck

vector.memcheck:                                  ; preds = %.preheader.us
  %14 = mul i64 %11, %.01215.us
  %15 = add i64 %10, %14
  %diff.check = icmp ult i64 %15, 32
  br i1 %diff.check, label %scalar.ph.preheader, label %vector.body

vector.body:                                      ; preds = %vector.memcheck, %vector.body
  %index = phi i64 [ %index.next, %vector.body ], [ 0, %vector.memcheck ]
  %16 = getelementptr inbounds float, ptr %6, i64 %index
  %17 = getelementptr inbounds i8, ptr %16, i64 16
  %wide.load = load <4 x float>, ptr %16, align 4, !tbaa !12
  %wide.load20 = load <4 x float>, ptr %17, align 4, !tbaa !12
  %18 = getelementptr float, ptr %13, i64 %index
  %19 = getelementptr i8, ptr %18, i64 16
  store <4 x float> %wide.load, ptr %18, align 4, !tbaa !12
  store <4 x float> %wide.load20, ptr %19, align 4, !tbaa !12
  %index.next = add nuw i64 %index, 8
  %20 = icmp eq i64 %index.next, %n.vec
  br i1 %20, label %middle.block, label %vector.body, !llvm.loop !14

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

scalar.ph.preheader:                              ; preds = %middle.block, %vector.memcheck, %.preheader.us
  %.014.us.ph = phi i64 [ 0, %vector.memcheck ], [ 0, %.preheader.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, %scalar.ph.prol
  %.014.us.prol = phi i64 [ %24, %scalar.ph.prol ], [ %.014.us.ph, %scalar.ph.preheader ]
  %prol.iter = phi i64 [ %prol.iter.next, %scalar.ph.prol ], [ 0, %scalar.ph.preheader ]
  %21 = getelementptr inbounds float, ptr %6, i64 %.014.us.prol
  %22 = load float, ptr %21, align 4, !tbaa !12
  %23 = getelementptr float, ptr %13, i64 %.014.us.prol
  store float %22, ptr %23, align 4, !tbaa !12
  %24 = add nuw i64 %.014.us.prol, 1
  %prol.iter.next = add i64 %prol.iter, 1
  %prol.iter.cmp.not = icmp eq i64 %prol.iter.next, %xtraiter
  br i1 %prol.iter.cmp.not, label %scalar.ph.prol.loopexit, label %scalar.ph.prol, !llvm.loop !18

scalar.ph.prol.loopexit:                          ; preds = %scalar.ph.prol, %scalar.ph.preheader
  %.014.us.unr = phi i64 [ %.014.us.ph, %scalar.ph.preheader ], [ %24, %scalar.ph.prol ]
  %25 = sub i64 %.014.us.ph, %5
  %26 = icmp ugt i64 %25, -4
  br i1 %26, label %._crit_edge.us, label %scalar.ph

scalar.ph:                                        ; preds = %scalar.ph.prol.loopexit, %scalar.ph
  %.014.us = phi i64 [ %42, %scalar.ph ], [ %.014.us.unr, %scalar.ph.prol.loopexit ]
  %27 = getelementptr inbounds float, ptr %6, i64 %.014.us
  %28 = load float, ptr %27, align 4, !tbaa !12
  %29 = getelementptr float, ptr %13, i64 %.014.us
  store float %28, ptr %29, align 4, !tbaa !12
  %30 = add nuw i64 %.014.us, 1
  %31 = getelementptr inbounds float, ptr %6, i64 %30
  %32 = load float, ptr %31, align 4, !tbaa !12
  %33 = getelementptr float, ptr %13, i64 %30
  store float %32, ptr %33, align 4, !tbaa !12
  %34 = add nuw i64 %.014.us, 2
  %35 = getelementptr inbounds float, ptr %6, i64 %34
  %36 = load float, ptr %35, align 4, !tbaa !12
  %37 = getelementptr float, ptr %13, i64 %34
  store float %36, ptr %37, align 4, !tbaa !12
  %38 = add nuw i64 %.014.us, 3
  %39 = getelementptr inbounds float, ptr %6, i64 %38
  %40 = load float, ptr %39, align 4, !tbaa !12
  %41 = getelementptr float, ptr %13, i64 %38
  store float %40, ptr %41, align 4, !tbaa !12
  %42 = add nuw i64 %.014.us, 4
  %exitcond.not.3 = icmp eq i64 %42, %5
  br i1 %exitcond.not.3, label %._crit_edge.us, label %scalar.ph, !llvm.loop !20

._crit_edge.us:                                   ; preds = %scalar.ph.prol.loopexit, %scalar.ph, %middle.block
  %43 = add nuw i64 %.01215.us, 1
  %exitcond19.not = icmp eq i64 %43, %2
  br i1 %exitcond19.not, label %._crit_edge16, label %.preheader.us, !llvm.loop !21

._crit_edge16:                                    ; preds = %._crit_edge.us, %3
  ret void
}

attributes #0 = { nofree norecurse nosync nounwind memory(readwrite, inaccessiblemem: none) 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 = !{!"long", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !11, i64 0}
!10 = !{!"k2c_tensor", !11, i64 0, !6, i64 8, !6, i64 16, !7, i64 24}
!11 = !{!"any pointer", !7, i64 0}
!12 = !{!13, !13, i64 0}
!13 = !{!"float", !7, i64 0}
!14 = distinct !{!14, !15, !16, !17}
!15 = !{!"llvm.loop.mustprogress"}
!16 = !{!"llvm.loop.isvectorized", i32 1}
!17 = !{!"llvm.loop.unroll.runtime.disable"}
!18 = distinct !{!18, !19}
!19 = !{!"llvm.loop.unroll.disable"}
!20 = distinct !{!20, !15, !16}
!21 = distinct !{!21, !15}


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