; LLVM IR from aferikoglou/GenHLSOptimizer :: dataset/rodinia_nw_1_tiling_0 (nw)

; 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
declare dso_local void @_Z7needwunPcS_S_S_(ptr noundef, ptr noundef, ptr noundef, ptr noundef) #0

; 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

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @workload(ptr noundef %0, ptr noundef %1, ptr noundef %2, ptr noundef %3, i32 noundef %4) #0 {
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  %10 = alloca i32, align 4
  %11 = alloca [32768 x i8], align 16
  %12 = alloca [32768 x i8], align 16
  %13 = alloca [65536 x i8], align 16
  %14 = alloca [65536 x i8], align 16
  %15 = alloca i32, align 4
  %16 = alloca i32, align 4
  %17 = alloca i32, align 4
  %18 = alloca i32, align 4
  store ptr %0, ptr %6, align 8, !tbaa !5
  store ptr %1, ptr %7, align 8, !tbaa !5
  store ptr %2, ptr %8, align 8, !tbaa !5
  store ptr %3, ptr %9, align 8, !tbaa !5
  store i32 %4, ptr %10, align 4, !tbaa !9
  br label %19

19:                                               ; preds = %5
  call void @llvm.lifetime.start.p0(i64 32768, ptr %11) #3
  br label %20

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

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

22:                                               ; preds = %21
  call void @llvm.lifetime.start.p0(i64 65536, ptr %14) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %15) #3
  %23 = load i32, ptr %10, align 4, !tbaa !9
  %24 = sdiv i32 %23, 256
  store i32 %24, ptr %15, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %16) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %17) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %18) #3
  br label %25

25:                                               ; preds = %22
  store i32 0, ptr %16, align 4, !tbaa !9
  br label %26

26:                                               ; preds = %83, %25
  %27 = load i32, ptr %16, align 4, !tbaa !9
  %28 = icmp slt i32 %27, 100
  br i1 %28, label %29, label %86

29:                                               ; preds = %26
  %30 = getelementptr inbounds [32768 x i8], ptr %11, i64 0, i64 0
  %31 = load ptr, ptr %6, align 8, !tbaa !5
  %32 = load i32, ptr %16, align 4, !tbaa !9
  %33 = mul nsw i32 %32, 32768
  %34 = sext i32 %33 to i64
  %35 = getelementptr inbounds i8, ptr %31, i64 %34
  call void @llvm.memcpy.p0.p0.i64(ptr align 16 %30, ptr align 1 %35, i64 32768, i1 false)
  %36 = getelementptr inbounds [32768 x i8], ptr %12, i64 0, i64 0
  %37 = load ptr, ptr %7, align 8, !tbaa !5
  %38 = load i32, ptr %16, align 4, !tbaa !9
  %39 = mul nsw i32 %38, 32768
  %40 = sext i32 %39 to i64
  %41 = getelementptr inbounds i8, ptr %37, i64 %40
  call void @llvm.memcpy.p0.p0.i64(ptr align 16 %36, ptr align 1 %41, i64 32768, i1 false)
  br label %42

42:                                               ; preds = %29
  store i32 0, ptr %17, align 4, !tbaa !9
  br label %43

43:                                               ; preds = %67, %42
  %44 = load i32, ptr %17, align 4, !tbaa !9
  %45 = icmp slt i32 %44, 256
  br i1 %45, label %46, label %70

46:                                               ; preds = %43
  %47 = getelementptr inbounds [32768 x i8], ptr %11, i64 0, i64 0
  %48 = load i32, ptr %17, align 4, !tbaa !9
  %49 = mul nsw i32 %48, 128
  %50 = sext i32 %49 to i64
  %51 = getelementptr inbounds i8, ptr %47, i64 %50
  %52 = getelementptr inbounds [32768 x i8], ptr %12, i64 0, i64 0
  %53 = load i32, ptr %17, align 4, !tbaa !9
  %54 = mul nsw i32 %53, 128
  %55 = sext i32 %54 to i64
  %56 = getelementptr inbounds i8, ptr %52, i64 %55
  %57 = getelementptr inbounds [65536 x i8], ptr %13, i64 0, i64 0
  %58 = load i32, ptr %17, align 4, !tbaa !9
  %59 = mul nsw i32 %58, 256
  %60 = sext i32 %59 to i64
  %61 = getelementptr inbounds i8, ptr %57, i64 %60
  %62 = getelementptr inbounds [65536 x i8], ptr %14, i64 0, i64 0
  %63 = load i32, ptr %17, align 4, !tbaa !9
  %64 = mul nsw i32 %63, 256
  %65 = sext i32 %64 to i64
  %66 = getelementptr inbounds i8, ptr %62, i64 %65
  call void @_Z7needwunPcS_S_S_(ptr noundef %51, ptr noundef %56, ptr noundef %61, ptr noundef %66)
  br label %67

67:                                               ; preds = %46
  %68 = load i32, ptr %17, align 4, !tbaa !9
  %69 = add nsw i32 %68, 1
  store i32 %69, ptr %17, align 4, !tbaa !9
  br label %43, !llvm.loop !11

70:                                               ; preds = %43
  %71 = load ptr, ptr %8, align 8, !tbaa !5
  %72 = load i32, ptr %16, align 4, !tbaa !9
  %73 = mul nsw i32 %72, 65536
  %74 = sext i32 %73 to i64
  %75 = getelementptr inbounds i8, ptr %71, i64 %74
  %76 = getelementptr inbounds [65536 x i8], ptr %13, i64 0, i64 0
  call void @llvm.memcpy.p0.p0.i64(ptr align 1 %75, ptr align 16 %76, i64 65536, i1 false)
  %77 = load ptr, ptr %9, align 8, !tbaa !5
  %78 = load i32, ptr %16, align 4, !tbaa !9
  %79 = mul nsw i32 %78, 65536
  %80 = sext i32 %79 to i64
  %81 = getelementptr inbounds i8, ptr %77, i64 %80
  %82 = getelementptr inbounds [65536 x i8], ptr %14, i64 0, i64 0
  call void @llvm.memcpy.p0.p0.i64(ptr align 1 %81, ptr align 16 %82, i64 65536, i1 false)
  br label %83

83:                                               ; preds = %70
  %84 = load i32, ptr %16, align 4, !tbaa !9
  %85 = add nsw i32 %84, 1
  store i32 %85, ptr %16, align 4, !tbaa !9
  br label %26, !llvm.loop !13

86:                                               ; preds = %26
  call void @llvm.lifetime.end.p0(i64 4, ptr %18) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %17) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %16) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #3
  call void @llvm.lifetime.end.p0(i64 65536, ptr %14) #3
  call void @llvm.lifetime.end.p0(i64 65536, ptr %13) #3
  call void @llvm.lifetime.end.p0(i64 32768, ptr %12) #3
  call void @llvm.lifetime.end.p0(i64 32768, ptr %11) #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 = { 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 = { 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 = !{!"int", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = distinct !{!13, !12}


; 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 nounwind uwtable
declare dso_local void @_Z7needwunPcS_S_S_(ptr noundef, ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #0

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

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

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @workload(ptr nocapture noundef readonly %0, ptr nocapture noundef readonly %1, ptr nocapture noundef writeonly %2, ptr nocapture noundef writeonly %3, i32 noundef %4) local_unnamed_addr #0 {
  %6 = alloca [32768 x i8], align 16
  %7 = alloca [32768 x i8], align 16
  %8 = alloca [65536 x i8], align 16
  %9 = alloca [65536 x i8], align 16
  call void @llvm.lifetime.start.p0(i64 32768, ptr nonnull %6) #3
  call void @llvm.lifetime.start.p0(i64 32768, ptr nonnull %7) #3
  call void @llvm.lifetime.start.p0(i64 65536, ptr nonnull %8) #3
  call void @llvm.lifetime.start.p0(i64 65536, ptr nonnull %9) #3
  br label %10

10:                                               ; preds = %5, %21
  %indvars.iv20 = phi i64 [ 0, %5 ], [ %indvars.iv.next21, %21 ]
  %11 = shl nuw nsw i64 %indvars.iv20, 15
  %12 = getelementptr inbounds i8, ptr %0, i64 %11
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 16 dereferenceable(32768) %6, ptr noundef nonnull align 1 dereferenceable(32768) %12, i64 32768, i1 false)
  %13 = getelementptr inbounds i8, ptr %1, i64 %11
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 16 dereferenceable(32768) %7, ptr noundef nonnull align 1 dereferenceable(32768) %13, i64 32768, i1 false)
  br label %14

14:                                               ; preds = %10, %14
  %indvars.iv = phi i64 [ 0, %10 ], [ %indvars.iv.next, %14 ]
  %15 = shl nuw nsw i64 %indvars.iv, 7
  %16 = getelementptr inbounds i8, ptr %6, i64 %15
  %17 = getelementptr inbounds i8, ptr %7, i64 %15
  %18 = shl nuw nsw i64 %indvars.iv, 8
  %19 = getelementptr inbounds i8, ptr %8, i64 %18
  %20 = getelementptr inbounds i8, ptr %9, i64 %18
  call void @_Z7needwunPcS_S_S_(ptr noundef nonnull %16, ptr noundef nonnull %17, ptr noundef nonnull %19, ptr noundef nonnull %20)
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next, 256
  br i1 %exitcond.not, label %21, label %14, !llvm.loop !5

21:                                               ; preds = %14
  %22 = shl nuw nsw i64 %indvars.iv20, 16
  %23 = getelementptr inbounds i8, ptr %2, i64 %22
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 1 dereferenceable(65536) %23, ptr noundef nonnull align 16 dereferenceable(65536) %8, i64 65536, i1 false)
  %24 = getelementptr inbounds i8, ptr %3, i64 %22
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 1 dereferenceable(65536) %24, ptr noundef nonnull align 16 dereferenceable(65536) %9, i64 65536, i1 false)
  %indvars.iv.next21 = add nuw nsw i64 %indvars.iv20, 1
  %exitcond23.not = icmp eq i64 %indvars.iv.next21, 100
  br i1 %exitcond23.not, label %25, label %10, !llvm.loop !7

25:                                               ; preds = %21
  call void @llvm.lifetime.end.p0(i64 65536, ptr nonnull %9) #3
  call void @llvm.lifetime.end.p0(i64 65536, ptr nonnull %8) #3
  call void @llvm.lifetime.end.p0(i64 32768, ptr nonnull %7) #3
  call void @llvm.lifetime.end.p0(i64 32768, ptr nonnull %6) #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 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 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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}


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