; LLVM IR from aferikoglou/GenHLSOptimizer :: dataset/spcl_example_00/Example0.ll (Z18InitiationIntervalPKfS0_Pf)

; 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: mustprogress nounwind uwtable
define dso_local void @_Z18InitiationIntervalPKfS0_Pf(ptr noundef %0, ptr noundef %1, ptr noundef %2) #0 {
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca i32, align 4
  %8 = alloca float, align 4
  %9 = alloca float, align 4
  %10 = alloca float, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  store ptr %2, ptr %6, align 8, !tbaa !5
  br label %11

11:                                               ; preds = %3
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #2
  store i32 0, ptr %7, align 4, !tbaa !9
  br label %12

12:                                               ; preds = %39, %11
  %13 = load i32, ptr %7, align 4, !tbaa !9
  %14 = icmp slt i32 %13, 1024000
  br i1 %14, label %16, label %15

15:                                               ; preds = %12
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #2
  br label %42

16:                                               ; preds = %12
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #2
  %17 = load ptr, ptr %4, align 8, !tbaa !5
  %18 = load i32, ptr %7, align 4, !tbaa !9
  %19 = sext i32 %18 to i64
  %20 = getelementptr inbounds float, ptr %17, i64 %19
  %21 = load float, ptr %20, align 4, !tbaa !11
  store float %21, ptr %8, align 4, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #2
  %22 = load ptr, ptr %5, align 8, !tbaa !5
  %23 = load i32, ptr %7, align 4, !tbaa !9
  %24 = sext i32 %23 to i64
  %25 = getelementptr inbounds float, ptr %22, i64 %24
  %26 = load float, ptr %25, align 4, !tbaa !11
  store float %26, ptr %9, align 4, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #2
  %27 = load float, ptr %8, align 4, !tbaa !11
  %28 = load float, ptr %9, align 4, !tbaa !11
  %29 = fadd float %27, %28
  %30 = load float, ptr %8, align 4, !tbaa !11
  %31 = load float, ptr %9, align 4, !tbaa !11
  %32 = fsub float %30, %31
  %33 = fmul float %29, %32
  store float %33, ptr %10, align 4, !tbaa !11
  %34 = load float, ptr %10, align 4, !tbaa !11
  %35 = load ptr, ptr %6, align 8, !tbaa !5
  %36 = load i32, ptr %7, align 4, !tbaa !9
  %37 = sext i32 %36 to i64
  %38 = getelementptr inbounds float, ptr %35, i64 %37
  store float %34, ptr %38, align 4, !tbaa !11
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #2
  br label %39

39:                                               ; preds = %16
  %40 = load i32, ptr %7, align 4, !tbaa !9
  %41 = add nsw i32 %40, 1
  store i32 %41, ptr %7, align 4, !tbaa !9
  br label %12, !llvm.loop !13

42:                                               ; preds = %15
  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 memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1

attributes #0 = { mustprogress 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 = { 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++ 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"

; Function Attrs: mustprogress nofree norecurse nosync nounwind memory(argmem: readwrite) uwtable
define dso_local void @_Z18InitiationIntervalPKfS0_Pf(ptr nocapture noundef readonly %0, ptr nocapture noundef readonly %1, ptr nocapture noundef writeonly %2) local_unnamed_addr #0 {
vector.memcheck:
  %3 = ptrtoint ptr %2 to i64
  %4 = ptrtoint ptr %0 to i64
  %5 = ptrtoint ptr %1 to i64
  %6 = sub i64 %3, %4
  %diff.check = icmp ult i64 %6, 32
  %7 = sub i64 %3, %5
  %diff.check14 = icmp ult i64 %7, 32
  %conflict.rdx = or i1 %diff.check, %diff.check14
  br i1 %conflict.rdx, label %scalar.ph, label %vector.body

vector.body:                                      ; preds = %vector.memcheck, %vector.body
  %index = phi i64 [ %index.next, %vector.body ], [ 0, %vector.memcheck ]
  %8 = getelementptr inbounds float, ptr %0, i64 %index
  %9 = getelementptr inbounds i8, ptr %8, i64 16
  %wide.load = load <4 x float>, ptr %8, align 4, !tbaa !5
  %wide.load15 = load <4 x float>, ptr %9, align 4, !tbaa !5
  %10 = getelementptr inbounds float, ptr %1, i64 %index
  %11 = getelementptr inbounds i8, ptr %10, i64 16
  %wide.load16 = load <4 x float>, ptr %10, align 4, !tbaa !5
  %wide.load17 = load <4 x float>, ptr %11, align 4, !tbaa !5
  %12 = fadd <4 x float> %wide.load, %wide.load16
  %13 = fadd <4 x float> %wide.load15, %wide.load17
  %14 = fsub <4 x float> %wide.load, %wide.load16
  %15 = fsub <4 x float> %wide.load15, %wide.load17
  %16 = fmul <4 x float> %12, %14
  %17 = fmul <4 x float> %13, %15
  %18 = getelementptr inbounds float, ptr %2, i64 %index
  %19 = getelementptr inbounds i8, ptr %18, i64 16
  store <4 x float> %16, ptr %18, align 4, !tbaa !5
  store <4 x float> %17, ptr %19, align 4, !tbaa !5
  %index.next = add nuw i64 %index, 8
  %20 = icmp eq i64 %index.next, 1024000
  br i1 %20, label %middle.block, label %vector.body, !llvm.loop !9

middle.block:                                     ; preds = %vector.body, %scalar.ph
  ret void

scalar.ph:                                        ; preds = %vector.memcheck, %scalar.ph
  %indvars.iv = phi i64 [ %indvars.iv.next.1, %scalar.ph ], [ 0, %vector.memcheck ]
  %21 = getelementptr inbounds float, ptr %0, i64 %indvars.iv
  %22 = load float, ptr %21, align 4, !tbaa !5
  %23 = getelementptr inbounds float, ptr %1, i64 %indvars.iv
  %24 = load float, ptr %23, align 4, !tbaa !5
  %25 = fadd float %22, %24
  %26 = fsub float %22, %24
  %27 = fmul float %25, %26
  %28 = getelementptr inbounds float, ptr %2, i64 %indvars.iv
  store float %27, ptr %28, align 4, !tbaa !5
  %indvars.iv.next = or disjoint i64 %indvars.iv, 1
  %29 = getelementptr inbounds float, ptr %0, i64 %indvars.iv.next
  %30 = load float, ptr %29, align 4, !tbaa !5
  %31 = getelementptr inbounds float, ptr %1, i64 %indvars.iv.next
  %32 = load float, ptr %31, align 4, !tbaa !5
  %33 = fadd float %30, %32
  %34 = fsub float %30, %32
  %35 = fmul float %33, %34
  %36 = getelementptr inbounds float, ptr %2, i64 %indvars.iv.next
  store float %35, ptr %36, align 4, !tbaa !5
  %indvars.iv.next.1 = add nuw nsw i64 %indvars.iv, 2
  %exitcond.not.1 = icmp eq i64 %indvars.iv.next.1, 1024000
  br i1 %exitcond.not.1, label %middle.block, label %scalar.ph, !llvm.loop !13
}

attributes #0 = { mustprogress 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++ TBAA"}
!9 = distinct !{!9, !10, !11, !12}
!10 = !{!"llvm.loop.mustprogress"}
!11 = !{!"llvm.loop.isvectorized", i32 1}
!12 = !{!"llvm.loop.unroll.runtime.disable"}
!13 = distinct !{!13, !10, !11}


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