; LLVM IR from istoony/winograd-convolutional-nn :: main (twoDcorrelation)

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

@B = external hidden global ptr, align 8
@G = external hidden global ptr, align 8

; 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 @twoDcorrelation(ptr noundef %0, ptr noundef %1, ptr noundef %2, i32 noundef %3, i32 noundef %4, i32 noundef %5) #1 {
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  %12 = alloca i32, align 4
  %13 = alloca [100 x float], align 16
  %14 = alloca [100 x float], align 16
  %15 = alloca i32, align 4
  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 i32 %3, ptr %10, align 4, !tbaa !9
  store i32 %4, ptr %11, align 4, !tbaa !9
  store i32 %5, ptr %12, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 400, ptr %13) #2
  call void @llvm.lifetime.start.p0(i64 400, ptr %14) #2
  call void @llvm.lifetime.start.p0(i64 4, ptr %15) #2
  store i32 0, ptr %15, align 4, !tbaa !9
  %16 = getelementptr inbounds [100 x float], ptr %13, i64 0, i64 0
  %17 = load ptr, ptr @G, align 8, !tbaa !5
  %18 = load ptr, ptr %8, align 8, !tbaa !5
  %19 = load i32, ptr %12, align 4, !tbaa !9
  %20 = load i32, ptr %11, align 4, !tbaa !9
  %21 = load i32, ptr %11, align 4, !tbaa !9
  call void @productABAt(ptr noundef %16, ptr noundef %17, ptr noundef %18, i32 noundef %19, i32 noundef %20, i32 noundef %21)
  %22 = getelementptr inbounds [100 x float], ptr %14, i64 0, i64 0
  %23 = load ptr, ptr @B, align 8, !tbaa !5
  %24 = load ptr, ptr %9, align 8, !tbaa !5
  %25 = load i32, ptr %12, align 4, !tbaa !9
  %26 = load i32, ptr %12, align 4, !tbaa !9
  %27 = load i32, ptr %12, align 4, !tbaa !9
  call void @productABAt(ptr noundef %22, ptr noundef %23, ptr noundef %24, i32 noundef %25, i32 noundef %26, i32 noundef %27)
  store i32 0, ptr %15, align 4, !tbaa !9
  br label %28

28:                                               ; preds = %48, %6
  %29 = load i32, ptr %15, align 4, !tbaa !9
  %30 = load i32, ptr %12, align 4, !tbaa !9
  %31 = load i32, ptr %12, align 4, !tbaa !9
  %32 = mul nsw i32 %30, %31
  %33 = icmp slt i32 %29, %32
  br i1 %33, label %34, label %51

34:                                               ; preds = %28
  %35 = load i32, ptr %15, align 4, !tbaa !9
  %36 = sext i32 %35 to i64
  %37 = getelementptr inbounds [100 x float], ptr %13, i64 0, i64 %36
  %38 = load float, ptr %37, align 4, !tbaa !11
  %39 = load i32, ptr %15, align 4, !tbaa !9
  %40 = sext i32 %39 to i64
  %41 = getelementptr inbounds [100 x float], ptr %14, i64 0, i64 %40
  %42 = load float, ptr %41, align 4, !tbaa !11
  %43 = fmul float %38, %42
  %44 = load ptr, ptr %7, align 8, !tbaa !5
  %45 = load i32, ptr %15, align 4, !tbaa !9
  %46 = sext i32 %45 to i64
  %47 = getelementptr inbounds float, ptr %44, i64 %46
  store float %43, ptr %47, align 4, !tbaa !11
  br label %48

48:                                               ; preds = %34
  %49 = load i32, ptr %15, align 4, !tbaa !9
  %50 = add nsw i32 %49, 1
  store i32 %50, ptr %15, align 4, !tbaa !9
  br label %28, !llvm.loop !13

51:                                               ; preds = %28
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #2
  call void @llvm.lifetime.end.p0(i64 400, ptr %14) #2
  call void @llvm.lifetime.end.p0(i64 400, ptr %13) #2
  ret void
}

; Function Attrs: nounwind uwtable
declare dso_local void @productABAt(ptr noundef, ptr noundef, ptr noundef, i32 noundef, i32 noundef, i32 noundef) #1

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 = !{!"int", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"float", !7, i64 0}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}


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

@B = external hidden local_unnamed_addr global ptr, align 8
@G = external hidden local_unnamed_addr global ptr, align 8

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

; Function Attrs: mustprogress 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 @twoDcorrelation(ptr nocapture noundef writeonly %0, ptr noundef %1, ptr noundef %2, i32 noundef %3, i32 noundef %4, i32 noundef %5) local_unnamed_addr #1 {
  %7 = alloca [100 x float], align 16
  %8 = alloca [100 x float], align 16
  call void @llvm.lifetime.start.p0(i64 400, ptr nonnull %7) #3
  call void @llvm.lifetime.start.p0(i64 400, ptr nonnull %8) #3
  %9 = load ptr, ptr @G, align 8, !tbaa !5
  call void @productABAt(ptr noundef nonnull %7, ptr noundef %9, ptr noundef %1, i32 noundef %5, i32 noundef %4, i32 noundef %4)
  %10 = load ptr, ptr @B, align 8, !tbaa !5
  call void @productABAt(ptr noundef nonnull %8, ptr noundef %10, ptr noundef %2, i32 noundef %5, i32 noundef %5, i32 noundef %5)
  %.not = icmp eq i32 %5, 0
  br i1 %.not, label %._crit_edge, label %.lr.ph.preheader

.lr.ph.preheader:                                 ; preds = %6
  %11 = mul i32 %5, %5
  %umax = call i32 @llvm.umax.i32(i32 %11, i32 1)
  %wide.trip.count = zext i32 %umax to i64
  %min.iters.check = icmp ult i32 %11, 8
  br i1 %min.iters.check, label %.lr.ph.preheader20, label %vector.ph

vector.ph:                                        ; preds = %.lr.ph.preheader
  %n.vec = and i64 %wide.trip.count, 4294967288
  br label %vector.body

vector.body:                                      ; preds = %vector.body, %vector.ph
  %index = phi i64 [ 0, %vector.ph ], [ %index.next, %vector.body ]
  %12 = getelementptr inbounds [100 x float], ptr %7, i64 0, i64 %index
  %13 = getelementptr inbounds i8, ptr %12, i64 16
  %wide.load = load <4 x float>, ptr %12, align 16, !tbaa !9
  %wide.load17 = load <4 x float>, ptr %13, align 16, !tbaa !9
  %14 = getelementptr inbounds [100 x float], ptr %8, i64 0, i64 %index
  %15 = getelementptr inbounds i8, ptr %14, i64 16
  %wide.load18 = load <4 x float>, ptr %14, align 16, !tbaa !9
  %wide.load19 = load <4 x float>, ptr %15, align 16, !tbaa !9
  %16 = fmul <4 x float> %wide.load, %wide.load18
  %17 = fmul <4 x float> %wide.load17, %wide.load19
  %18 = getelementptr inbounds float, ptr %0, i64 %index
  %19 = getelementptr inbounds i8, ptr %18, i64 16
  store <4 x float> %16, ptr %18, align 4, !tbaa !9
  store <4 x float> %17, ptr %19, align 4, !tbaa !9
  %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 !11

middle.block:                                     ; preds = %vector.body
  %cmp.n = icmp eq i64 %n.vec, %wide.trip.count
  br i1 %cmp.n, label %._crit_edge, label %.lr.ph.preheader20

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

.lr.ph:                                           ; preds = %.lr.ph.preheader20, %.lr.ph
  %indvars.iv = phi i64 [ %indvars.iv.next, %.lr.ph ], [ %indvars.iv.ph, %.lr.ph.preheader20 ]
  %21 = getelementptr inbounds [100 x float], ptr %7, i64 0, i64 %indvars.iv
  %22 = load float, ptr %21, align 4, !tbaa !9
  %23 = getelementptr inbounds [100 x float], ptr %8, i64 0, i64 %indvars.iv
  %24 = load float, ptr %23, align 4, !tbaa !9
  %25 = fmul float %22, %24
  %26 = getelementptr inbounds float, ptr %0, i64 %indvars.iv
  store float %25, ptr %26, align 4, !tbaa !9
  %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_edge, label %.lr.ph, !llvm.loop !15

._crit_edge:                                      ; preds = %.lr.ph, %middle.block, %6
  call void @llvm.lifetime.end.p0(i64 400, ptr nonnull %8) #3
  call void @llvm.lifetime.end.p0(i64 400, ptr nonnull %7) #3
  ret void
}

; Function Attrs: nounwind uwtable
declare dso_local void @productABAt(ptr noundef, ptr noundef, ptr noundef, i32 noundef, i32 noundef, i32 noundef) local_unnamed_addr #1

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i32 @llvm.umax.i32(i32, i32) #2

attributes #0 = { mustprogress 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 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
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 = !{!"any pointer", !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, !13, !14}
!12 = !{!"llvm.loop.mustprogress"}
!13 = !{!"llvm.loop.isvectorized", i32 1}
!14 = !{!"llvm.loop.unroll.runtime.disable"}
!15 = distinct !{!15, !12, !14, !13}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,IndVarSimplifyPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LICMPass,LoopLoadEliminationPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,LoopVectorizePass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass