; LLVM IR from aferikoglou/GenHLSOptimizer :: dataset/rodinia_lc_mgvf_1_tiling_0 (lc_mgvf)

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

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

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @workload(ptr noundef %0, ptr noundef %1, ptr noundef %2) #1 {
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca [65536 x float], align 16
  %8 = alloca [67584 x float], align 16
  %9 = alloca [65536 x float], align 16
  %10 = alloca i32, align 4
  %11 = alloca float, align 4
  %12 = alloca i32, 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 %13

13:                                               ; preds = %3
  call void @llvm.lifetime.start.p0(i64 262144, ptr %7) #3
  br label %14

14:                                               ; preds = %13
  call void @llvm.lifetime.start.p0(i64 270336, ptr %8) #3
  br label %15

15:                                               ; preds = %14
  call void @llvm.lifetime.start.p0(i64 262144, ptr %9) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #3
  store float 1.000000e+00, ptr %11, align 4, !tbaa !9
  br label %16

16:                                               ; preds = %15
  store i32 0, ptr %10, align 4, !tbaa !11
  br label %17

17:                                               ; preds = %91, %16
  %18 = load i32, ptr %10, align 4, !tbaa !11
  %19 = icmp slt i32 %18, 32
  br i1 %19, label %20, label %94

20:                                               ; preds = %17
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #3
  br label %21

21:                                               ; preds = %20
  store i32 0, ptr %12, align 4, !tbaa !11
  br label %22

22:                                               ; preds = %52, %21
  %23 = load i32, ptr %12, align 4, !tbaa !11
  %24 = icmp slt i32 %23, 16
  br i1 %24, label %25, label %55

25:                                               ; preds = %22
  %26 = getelementptr inbounds [67584 x float], ptr %8, i64 0, i64 0
  %27 = load ptr, ptr %5, align 8, !tbaa !5
  %28 = load i32, ptr %12, align 4, !tbaa !11
  %29 = mul nsw i32 %28, 64
  %30 = mul nsw i32 %29, 1024
  %31 = sext i32 %30 to i64
  %32 = getelementptr inbounds float, ptr %27, i64 %31
  %33 = getelementptr inbounds float, ptr %32, i64 -1024
  call void @llvm.memcpy.p0.p0.i64(ptr align 16 %26, ptr align 4 %33, i64 270336, i1 false)
  %34 = getelementptr inbounds [65536 x float], ptr %9, i64 0, i64 0
  %35 = load ptr, ptr %6, align 8, !tbaa !5
  %36 = load i32, ptr %12, align 4, !tbaa !11
  %37 = mul nsw i32 %36, 64
  %38 = mul nsw i32 %37, 1024
  %39 = sext i32 %38 to i64
  %40 = getelementptr inbounds float, ptr %35, i64 %39
  call void @llvm.memcpy.p0.p0.i64(ptr align 16 %34, ptr align 4 %40, i64 262144, i1 false)
  %41 = getelementptr inbounds [65536 x float], ptr %7, i64 0, i64 0
  %42 = getelementptr inbounds [67584 x float], ptr %8, i64 0, i64 0
  %43 = getelementptr inbounds [65536 x float], ptr %9, i64 0, i64 0
  %44 = load i32, ptr %12, align 4, !tbaa !11
  call void @lc_mgvf(ptr noundef %41, ptr noundef %42, ptr noundef %43, i32 noundef %44)
  %45 = load ptr, ptr %4, align 8, !tbaa !5
  %46 = load i32, ptr %12, align 4, !tbaa !11
  %47 = mul nsw i32 %46, 64
  %48 = mul nsw i32 %47, 1024
  %49 = sext i32 %48 to i64
  %50 = getelementptr inbounds float, ptr %45, i64 %49
  %51 = getelementptr inbounds [65536 x float], ptr %7, i64 0, i64 0
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %50, ptr align 16 %51, i64 262144, i1 false)
  br label %52

52:                                               ; preds = %25
  %53 = load i32, ptr %12, align 4, !tbaa !11
  %54 = add nsw i32 %53, 1
  store i32 %54, ptr %12, align 4, !tbaa !11
  br label %22, !llvm.loop !13

55:                                               ; preds = %22
  br label %56

56:                                               ; preds = %55
  store i32 0, ptr %12, align 4, !tbaa !11
  br label %57

57:                                               ; preds = %87, %56
  %58 = load i32, ptr %12, align 4, !tbaa !11
  %59 = icmp slt i32 %58, 16
  br i1 %59, label %60, label %90

60:                                               ; preds = %57
  %61 = getelementptr inbounds [67584 x float], ptr %8, i64 0, i64 0
  %62 = load ptr, ptr %4, align 8, !tbaa !5
  %63 = load i32, ptr %12, align 4, !tbaa !11
  %64 = mul nsw i32 %63, 64
  %65 = mul nsw i32 %64, 1024
  %66 = sext i32 %65 to i64
  %67 = getelementptr inbounds float, ptr %62, i64 %66
  %68 = getelementptr inbounds float, ptr %67, i64 -1024
  call void @llvm.memcpy.p0.p0.i64(ptr align 16 %61, ptr align 4 %68, i64 270336, i1 false)
  %69 = getelementptr inbounds [65536 x float], ptr %9, i64 0, i64 0
  %70 = load ptr, ptr %6, align 8, !tbaa !5
  %71 = load i32, ptr %12, align 4, !tbaa !11
  %72 = mul nsw i32 %71, 64
  %73 = mul nsw i32 %72, 1024
  %74 = sext i32 %73 to i64
  %75 = getelementptr inbounds float, ptr %70, i64 %74
  call void @llvm.memcpy.p0.p0.i64(ptr align 16 %69, ptr align 4 %75, i64 262144, i1 false)
  %76 = getelementptr inbounds [65536 x float], ptr %7, i64 0, i64 0
  %77 = getelementptr inbounds [67584 x float], ptr %8, i64 0, i64 0
  %78 = getelementptr inbounds [65536 x float], ptr %9, i64 0, i64 0
  %79 = load i32, ptr %12, align 4, !tbaa !11
  call void @lc_mgvf(ptr noundef %76, ptr noundef %77, ptr noundef %78, i32 noundef %79)
  %80 = load ptr, ptr %5, align 8, !tbaa !5
  %81 = load i32, ptr %12, align 4, !tbaa !11
  %82 = mul nsw i32 %81, 64
  %83 = mul nsw i32 %82, 1024
  %84 = sext i32 %83 to i64
  %85 = getelementptr inbounds float, ptr %80, i64 %84
  %86 = getelementptr inbounds [65536 x float], ptr %7, i64 0, i64 0
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %85, ptr align 16 %86, i64 262144, i1 false)
  br label %87

87:                                               ; preds = %60
  %88 = load i32, ptr %12, align 4, !tbaa !11
  %89 = add nsw i32 %88, 1
  store i32 %89, ptr %12, align 4, !tbaa !11
  br label %57, !llvm.loop !15

90:                                               ; preds = %57
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #3
  br label %91

91:                                               ; preds = %90
  %92 = load i32, ptr %10, align 4, !tbaa !11
  %93 = add nsw i32 %92, 1
  store i32 %93, ptr %10, align 4, !tbaa !11
  br label %17, !llvm.loop !16

94:                                               ; preds = %17
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #3
  call void @llvm.lifetime.end.p0(i64 262144, ptr %9) #3
  call void @llvm.lifetime.end.p0(i64 270336, ptr %8) #3
  call void @llvm.lifetime.end.p0(i64 262144, ptr %7) #3
  ret void
}

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #2

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #2 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
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++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"float", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"int", !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 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: mustprogress nounwind uwtable
declare dso_local void @lc_mgvf(ptr noundef, ptr noundef, ptr noundef, i32 noundef) local_unnamed_addr #1

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @workload(ptr nocapture noundef %0, ptr nocapture noundef %1, ptr nocapture noundef readonly %2) local_unnamed_addr #1 {
  %4 = alloca [65536 x float], align 16
  %5 = alloca [67584 x float], align 16
  %6 = alloca [65536 x float], align 16
  call void @llvm.lifetime.start.p0(i64 262144, ptr nonnull %4) #3
  call void @llvm.lifetime.start.p0(i64 270336, ptr nonnull %5) #3
  call void @llvm.lifetime.start.p0(i64 262144, ptr nonnull %6) #3
  %invariant.gep = getelementptr i8, ptr %1, i64 -4096
  %invariant.gep22 = getelementptr i8, ptr %0, i64 -4096
  br label %.preheader20

.preheader20:                                     ; preds = %3, %16
  %.01925 = phi i32 [ 0, %3 ], [ %17, %16 ]
  br label %7

7:                                                ; preds = %.preheader20, %7
  %indvars.iv = phi i64 [ 0, %.preheader20 ], [ %indvars.iv.next, %7 ]
  %8 = shl nuw nsw i64 %indvars.iv, 16
  %gep = getelementptr float, ptr %invariant.gep, i64 %8
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 16 dereferenceable(270336) %5, ptr noundef nonnull align 4 dereferenceable(270336) %gep, i64 270336, i1 false)
  %9 = getelementptr inbounds float, ptr %2, i64 %8
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 16 dereferenceable(262144) %6, ptr noundef nonnull align 4 dereferenceable(262144) %9, i64 262144, i1 false)
  %10 = trunc nuw nsw i64 %indvars.iv to i32
  call void @lc_mgvf(ptr noundef nonnull %4, ptr noundef nonnull %5, ptr noundef nonnull %6, i32 noundef %10)
  %11 = getelementptr inbounds float, ptr %0, i64 %8
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 4 dereferenceable(262144) %11, ptr noundef nonnull align 16 dereferenceable(262144) %4, i64 262144, i1 false)
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next, 16
  br i1 %exitcond.not, label %.preheader, label %7, !llvm.loop !5

.preheader:                                       ; preds = %7, %.preheader
  %indvars.iv27 = phi i64 [ %indvars.iv.next28, %.preheader ], [ 0, %7 ]
  %12 = shl nuw nsw i64 %indvars.iv27, 16
  %gep23 = getelementptr float, ptr %invariant.gep22, i64 %12
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 16 dereferenceable(270336) %5, ptr noundef nonnull align 4 dereferenceable(270336) %gep23, i64 270336, i1 false)
  %13 = getelementptr inbounds float, ptr %2, i64 %12
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 16 dereferenceable(262144) %6, ptr noundef nonnull align 4 dereferenceable(262144) %13, i64 262144, i1 false)
  %14 = trunc nuw nsw i64 %indvars.iv27 to i32
  call void @lc_mgvf(ptr noundef nonnull %4, ptr noundef nonnull %5, ptr noundef nonnull %6, i32 noundef %14)
  %15 = getelementptr inbounds float, ptr %1, i64 %12
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 4 dereferenceable(262144) %15, ptr noundef nonnull align 16 dereferenceable(262144) %4, i64 262144, i1 false)
  %indvars.iv.next28 = add nuw nsw i64 %indvars.iv27, 1
  %exitcond30.not = icmp eq i64 %indvars.iv.next28, 16
  br i1 %exitcond30.not, label %16, label %.preheader, !llvm.loop !7

16:                                               ; preds = %.preheader
  %17 = add nuw nsw i32 %.01925, 1
  %exitcond31.not = icmp eq i32 %17, 32
  br i1 %exitcond31.not, label %18, label %.preheader20, !llvm.loop !8

18:                                               ; preds = %16
  call void @llvm.lifetime.end.p0(i64 262144, ptr nonnull %6) #3
  call void @llvm.lifetime.end.p0(i64 270336, ptr nonnull %5) #3
  call void @llvm.lifetime.end.p0(i64 262144, ptr nonnull %4) #3
  ret void
}

; Function Attrs: mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #2

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #2 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite) }
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 = distinct !{!5, !6}
!6 = !{!"llvm.loop.mustprogress"}
!7 = distinct !{!7, !6}
!8 = distinct !{!8, !6}


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