; LLVM IR from aferikoglou/GenHLSOptimizer :: dataset/rodinia_nw_2_pipeline_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: 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 @_Z14needwun_tilingPcS_S_S_(ptr noundef, ptr noundef, ptr noundef, ptr noundef) #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) #1 {
  %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 [64 x [512 x i8]], align 16
  %12 = alloca [64 x [512 x i8]], align 16
  %13 = alloca [64 x [1024 x i8]], align 16
  %14 = alloca [64 x [1024 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
  br label %26

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

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

30:                                               ; preds = %27
  br label %31

31:                                               ; preds = %30
  br label %32

32:                                               ; preds = %31
  store i32 0, ptr %17, align 4, !tbaa !9
  br label %33

33:                                               ; preds = %50, %32
  %34 = load i32, ptr %17, align 4, !tbaa !9
  %35 = icmp slt i32 %34, 64
  br i1 %35, label %36, label %53

36:                                               ; preds = %33
  %37 = load i32, ptr %17, align 4, !tbaa !9
  %38 = sext i32 %37 to i64
  %39 = getelementptr inbounds [64 x [512 x i8]], ptr %11, i64 0, i64 %38
  %40 = getelementptr inbounds [512 x i8], ptr %39, i64 0, i64 0
  %41 = load ptr, ptr %6, align 8, !tbaa !5
  %42 = load i32, ptr %16, align 4, !tbaa !9
  %43 = mul nsw i32 %42, 32768
  %44 = sext i32 %43 to i64
  %45 = getelementptr inbounds i8, ptr %41, i64 %44
  %46 = load i32, ptr %17, align 4, !tbaa !9
  %47 = mul nsw i32 %46, 512
  %48 = sext i32 %47 to i64
  %49 = getelementptr inbounds i8, ptr %45, i64 %48
  call void @llvm.memcpy.p0.p0.i64(ptr align 16 %40, ptr align 1 %49, i64 512, i1 false)
  br label %50

50:                                               ; preds = %36
  %51 = load i32, ptr %17, align 4, !tbaa !9
  %52 = add nsw i32 %51, 1
  store i32 %52, ptr %17, align 4, !tbaa !9
  br label %33, !llvm.loop !11

53:                                               ; preds = %33
  br label %54

54:                                               ; preds = %53
  br label %55

55:                                               ; preds = %54
  store i32 0, ptr %17, align 4, !tbaa !9
  br label %56

56:                                               ; preds = %73, %55
  %57 = load i32, ptr %17, align 4, !tbaa !9
  %58 = icmp slt i32 %57, 64
  br i1 %58, label %59, label %76

59:                                               ; preds = %56
  %60 = load i32, ptr %17, align 4, !tbaa !9
  %61 = sext i32 %60 to i64
  %62 = getelementptr inbounds [64 x [512 x i8]], ptr %12, i64 0, i64 %61
  %63 = getelementptr inbounds [512 x i8], ptr %62, i64 0, i64 0
  %64 = load ptr, ptr %7, align 8, !tbaa !5
  %65 = load i32, ptr %16, align 4, !tbaa !9
  %66 = mul nsw i32 %65, 32768
  %67 = sext i32 %66 to i64
  %68 = getelementptr inbounds i8, ptr %64, i64 %67
  %69 = load i32, ptr %17, align 4, !tbaa !9
  %70 = mul nsw i32 %69, 512
  %71 = sext i32 %70 to i64
  %72 = getelementptr inbounds i8, ptr %68, i64 %71
  call void @llvm.memcpy.p0.p0.i64(ptr align 16 %63, ptr align 1 %72, i64 512, i1 false)
  br label %73

73:                                               ; preds = %59
  %74 = load i32, ptr %17, align 4, !tbaa !9
  %75 = add nsw i32 %74, 1
  store i32 %75, ptr %17, align 4, !tbaa !9
  br label %56, !llvm.loop !13

76:                                               ; preds = %56
  br label %77

77:                                               ; preds = %76
  br label %78

78:                                               ; preds = %77
  store i32 0, ptr %17, align 4, !tbaa !9
  br label %79

79:                                               ; preds = %99, %78
  %80 = load i32, ptr %17, align 4, !tbaa !9
  %81 = icmp slt i32 %80, 64
  br i1 %81, label %82, label %102

82:                                               ; preds = %79
  %83 = load i32, ptr %17, align 4, !tbaa !9
  %84 = sext i32 %83 to i64
  %85 = getelementptr inbounds [64 x [512 x i8]], ptr %11, i64 0, i64 %84
  %86 = getelementptr inbounds [512 x i8], ptr %85, i64 0, i64 0
  %87 = load i32, ptr %17, align 4, !tbaa !9
  %88 = sext i32 %87 to i64
  %89 = getelementptr inbounds [64 x [512 x i8]], ptr %12, i64 0, i64 %88
  %90 = getelementptr inbounds [512 x i8], ptr %89, i64 0, i64 0
  %91 = load i32, ptr %17, align 4, !tbaa !9
  %92 = sext i32 %91 to i64
  %93 = getelementptr inbounds [64 x [1024 x i8]], ptr %13, i64 0, i64 %92
  %94 = getelementptr inbounds [1024 x i8], ptr %93, i64 0, i64 0
  %95 = load i32, ptr %17, align 4, !tbaa !9
  %96 = sext i32 %95 to i64
  %97 = getelementptr inbounds [64 x [1024 x i8]], ptr %14, i64 0, i64 %96
  %98 = getelementptr inbounds [1024 x i8], ptr %97, i64 0, i64 0
  call void @_Z14needwun_tilingPcS_S_S_(ptr noundef %86, ptr noundef %90, ptr noundef %94, ptr noundef %98)
  br label %99

99:                                               ; preds = %82
  %100 = load i32, ptr %17, align 4, !tbaa !9
  %101 = add nsw i32 %100, 1
  store i32 %101, ptr %17, align 4, !tbaa !9
  br label %79, !llvm.loop !14

102:                                              ; preds = %79
  br label %103

103:                                              ; preds = %102
  br label %104

104:                                              ; preds = %103
  store i32 0, ptr %17, align 4, !tbaa !9
  br label %105

105:                                              ; preds = %123, %104
  %106 = load i32, ptr %17, align 4, !tbaa !9
  %107 = icmp slt i32 %106, 64
  br i1 %107, label %108, label %126

108:                                              ; preds = %105
  %109 = load ptr, ptr %8, align 8, !tbaa !5
  %110 = load i32, ptr %16, align 4, !tbaa !9
  %111 = mul nsw i32 %110, 65536
  %112 = sext i32 %111 to i64
  %113 = getelementptr inbounds i8, ptr %109, i64 %112
  %114 = load i32, ptr %17, align 4, !tbaa !9
  %115 = mul nsw i32 %114, 256
  %116 = mul nsw i32 %115, 4
  %117 = sext i32 %116 to i64
  %118 = getelementptr inbounds i8, ptr %113, i64 %117
  %119 = load i32, ptr %17, align 4, !tbaa !9
  %120 = sext i32 %119 to i64
  %121 = getelementptr inbounds [64 x [1024 x i8]], ptr %13, i64 0, i64 %120
  %122 = getelementptr inbounds [1024 x i8], ptr %121, i64 0, i64 0
  call void @llvm.memcpy.p0.p0.i64(ptr align 1 %118, ptr align 16 %122, i64 1024, i1 false)
  br label %123

123:                                              ; preds = %108
  %124 = load i32, ptr %17, align 4, !tbaa !9
  %125 = add nsw i32 %124, 1
  store i32 %125, ptr %17, align 4, !tbaa !9
  br label %105, !llvm.loop !15

126:                                              ; preds = %105
  br label %127

127:                                              ; preds = %126
  br label %128

128:                                              ; preds = %127
  store i32 0, ptr %17, align 4, !tbaa !9
  br label %129

129:                                              ; preds = %147, %128
  %130 = load i32, ptr %17, align 4, !tbaa !9
  %131 = icmp slt i32 %130, 64
  br i1 %131, label %132, label %150

132:                                              ; preds = %129
  %133 = load ptr, ptr %9, align 8, !tbaa !5
  %134 = load i32, ptr %16, align 4, !tbaa !9
  %135 = mul nsw i32 %134, 65536
  %136 = sext i32 %135 to i64
  %137 = getelementptr inbounds i8, ptr %133, i64 %136
  %138 = load i32, ptr %17, align 4, !tbaa !9
  %139 = mul nsw i32 %138, 256
  %140 = mul nsw i32 %139, 4
  %141 = sext i32 %140 to i64
  %142 = getelementptr inbounds i8, ptr %137, i64 %141
  %143 = load i32, ptr %17, align 4, !tbaa !9
  %144 = sext i32 %143 to i64
  %145 = getelementptr inbounds [64 x [1024 x i8]], ptr %14, i64 0, i64 %144
  %146 = getelementptr inbounds [1024 x i8], ptr %145, i64 0, i64 0
  call void @llvm.memcpy.p0.p0.i64(ptr align 1 %142, ptr align 16 %146, i64 1024, i1 false)
  br label %147

147:                                              ; preds = %132
  %148 = load i32, ptr %17, align 4, !tbaa !9
  %149 = add nsw i32 %148, 1
  store i32 %149, ptr %17, align 4, !tbaa !9
  br label %129, !llvm.loop !16

150:                                              ; preds = %129
  br label %151

151:                                              ; preds = %150
  %152 = load i32, ptr %16, align 4, !tbaa !9
  %153 = add nsw i32 %152, 1
  store i32 %153, ptr %16, align 4, !tbaa !9
  br label %27, !llvm.loop !17

154:                                              ; preds = %27
  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 = { 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 = !{!"int", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = distinct !{!13, !12}
!14 = distinct !{!14, !12}
!15 = distinct !{!15, !12}
!16 = distinct !{!16, !12}
!17 = distinct !{!17, !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 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 @_Z14needwun_tilingPcS_S_S_(ptr noundef, ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #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 #1 {
  %6 = alloca [64 x [512 x i8]], align 16
  %7 = alloca [64 x [512 x i8]], align 16
  %8 = alloca [64 x [1024 x i8]], align 16
  %9 = alloca [64 x [1024 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 %.preheader36

.preheader36:                                     ; preds = %5, %.preheader33
  %indvar = phi i64 [ 0, %5 ], [ %indvar.next, %.preheader33 ]
  %10 = shl nuw nsw i64 %indvar, 16
  %scevgep51 = getelementptr i8, ptr %3, i64 %10
  %scevgep47 = getelementptr i8, ptr %2, i64 %10
  %11 = shl nuw nsw i64 %indvar, 15
  %scevgep44 = getelementptr i8, ptr %1, i64 %11
  %scevgep = getelementptr 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) %scevgep, i64 32768, i1 false)
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 16 dereferenceable(32768) %7, ptr noundef nonnull align 1 dereferenceable(32768) %scevgep44, i64 32768, i1 false)
  br label %.preheader34

.preheader33:                                     ; preds = %.preheader34
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 1 dereferenceable(65536) %scevgep47, ptr noundef nonnull align 16 dereferenceable(65536) %8, i64 65536, i1 false)
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 1 dereferenceable(65536) %scevgep51, ptr noundef nonnull align 16 dereferenceable(65536) %9, i64 65536, i1 false)
  %indvar.next = add nuw nsw i64 %indvar, 1
  %exitcond56.not = icmp eq i64 %indvar.next, 100
  br i1 %exitcond56.not, label %16, label %.preheader36, !llvm.loop !5

.preheader34:                                     ; preds = %.preheader36, %.preheader34
  %indvars.iv = phi i64 [ 0, %.preheader36 ], [ %indvars.iv.next, %.preheader34 ]
  %12 = getelementptr inbounds [64 x [512 x i8]], ptr %6, i64 0, i64 %indvars.iv
  %13 = getelementptr inbounds [64 x [512 x i8]], ptr %7, i64 0, i64 %indvars.iv
  %14 = getelementptr inbounds [64 x [1024 x i8]], ptr %8, i64 0, i64 %indvars.iv
  %15 = getelementptr inbounds [64 x [1024 x i8]], ptr %9, i64 0, i64 %indvars.iv
  call void @_Z14needwun_tilingPcS_S_S_(ptr noundef nonnull %12, ptr noundef nonnull %13, ptr noundef nonnull %14, ptr noundef nonnull %15)
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next, 64
  br i1 %exitcond.not, label %.preheader33, label %.preheader34, !llvm.loop !7

16:                                               ; preds = %.preheader33
  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 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}


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