; LLVM IR from aferikoglou/GenHLSOptimizer :: dataset/rodinia_nw_3_unroll_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
  call void @llvm.lifetime.start.p0(i64 32768, ptr %11) #3
  call void @llvm.lifetime.start.p0(i64 32768, ptr %12) #3
  call void @llvm.lifetime.start.p0(i64 65536, ptr %13) #3
  call void @llvm.lifetime.start.p0(i64 65536, ptr %14) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %15) #3
  %19 = load i32, ptr %10, align 4, !tbaa !9
  %20 = sdiv i32 %19, 256
  store i32 %20, 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 %21

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

22:                                               ; preds = %142, %21
  %23 = load i32, ptr %16, align 4, !tbaa !9
  %24 = load i32, ptr %15, align 4, !tbaa !9
  %25 = icmp slt i32 %23, %24
  br i1 %25, label %26, label %145

26:                                               ; preds = %22
  br label %27

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

28:                                               ; preds = %45, %27
  %29 = load i32, ptr %17, align 4, !tbaa !9
  %30 = icmp slt i32 %29, 64
  br i1 %30, label %31, label %48

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

45:                                               ; preds = %31
  %46 = load i32, ptr %17, align 4, !tbaa !9
  %47 = add nsw i32 %46, 1
  store i32 %47, ptr %17, align 4, !tbaa !9
  br label %28, !llvm.loop !11

48:                                               ; preds = %28
  br label %49

49:                                               ; preds = %48
  store i32 0, ptr %17, align 4, !tbaa !9
  br label %50

50:                                               ; preds = %67, %49
  %51 = load i32, ptr %17, align 4, !tbaa !9
  %52 = icmp slt i32 %51, 64
  br i1 %52, label %53, label %70

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

67:                                               ; preds = %53
  %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 %50, !llvm.loop !13

70:                                               ; preds = %50
  br label %71

71:                                               ; preds = %70
  store i32 0, ptr %17, align 4, !tbaa !9
  br label %72

72:                                               ; preds = %92, %71
  %73 = load i32, ptr %17, align 4, !tbaa !9
  %74 = icmp slt i32 %73, 64
  br i1 %74, label %75, label %95

75:                                               ; preds = %72
  %76 = load i32, ptr %17, align 4, !tbaa !9
  %77 = sext i32 %76 to i64
  %78 = getelementptr inbounds [64 x [512 x i8]], ptr %11, i64 0, i64 %77
  %79 = getelementptr inbounds [512 x i8], ptr %78, i64 0, i64 0
  %80 = load i32, ptr %17, align 4, !tbaa !9
  %81 = sext i32 %80 to i64
  %82 = getelementptr inbounds [64 x [512 x i8]], ptr %12, i64 0, i64 %81
  %83 = getelementptr inbounds [512 x i8], ptr %82, i64 0, i64 0
  %84 = load i32, ptr %17, align 4, !tbaa !9
  %85 = sext i32 %84 to i64
  %86 = getelementptr inbounds [64 x [1024 x i8]], ptr %13, i64 0, i64 %85
  %87 = getelementptr inbounds [1024 x i8], ptr %86, i64 0, i64 0
  %88 = load i32, ptr %17, align 4, !tbaa !9
  %89 = sext i32 %88 to i64
  %90 = getelementptr inbounds [64 x [1024 x i8]], ptr %14, i64 0, i64 %89
  %91 = getelementptr inbounds [1024 x i8], ptr %90, i64 0, i64 0
  call void @_Z14needwun_tilingPcS_S_S_(ptr noundef %79, ptr noundef %83, ptr noundef %87, ptr noundef %91)
  br label %92

92:                                               ; preds = %75
  %93 = load i32, ptr %17, align 4, !tbaa !9
  %94 = add nsw i32 %93, 1
  store i32 %94, ptr %17, align 4, !tbaa !9
  br label %72, !llvm.loop !14

95:                                               ; preds = %72
  br label %96

96:                                               ; preds = %95
  store i32 0, ptr %17, align 4, !tbaa !9
  br label %97

97:                                               ; preds = %115, %96
  %98 = load i32, ptr %17, align 4, !tbaa !9
  %99 = icmp slt i32 %98, 64
  br i1 %99, label %100, label %118

100:                                              ; preds = %97
  %101 = load ptr, ptr %8, align 8, !tbaa !5
  %102 = load i32, ptr %16, align 4, !tbaa !9
  %103 = mul nsw i32 %102, 65536
  %104 = sext i32 %103 to i64
  %105 = getelementptr inbounds i8, ptr %101, i64 %104
  %106 = load i32, ptr %17, align 4, !tbaa !9
  %107 = mul nsw i32 %106, 256
  %108 = mul nsw i32 %107, 4
  %109 = sext i32 %108 to i64
  %110 = getelementptr inbounds i8, ptr %105, i64 %109
  %111 = load i32, ptr %17, align 4, !tbaa !9
  %112 = sext i32 %111 to i64
  %113 = getelementptr inbounds [64 x [1024 x i8]], ptr %13, i64 0, i64 %112
  %114 = getelementptr inbounds [1024 x i8], ptr %113, i64 0, i64 0
  call void @llvm.memcpy.p0.p0.i64(ptr align 1 %110, ptr align 16 %114, i64 1024, i1 false)
  br label %115

115:                                              ; preds = %100
  %116 = load i32, ptr %17, align 4, !tbaa !9
  %117 = add nsw i32 %116, 1
  store i32 %117, ptr %17, align 4, !tbaa !9
  br label %97, !llvm.loop !15

118:                                              ; preds = %97
  br label %119

119:                                              ; preds = %118
  store i32 0, ptr %17, align 4, !tbaa !9
  br label %120

120:                                              ; preds = %138, %119
  %121 = load i32, ptr %17, align 4, !tbaa !9
  %122 = icmp slt i32 %121, 64
  br i1 %122, label %123, label %141

123:                                              ; preds = %120
  %124 = load ptr, ptr %9, align 8, !tbaa !5
  %125 = load i32, ptr %16, align 4, !tbaa !9
  %126 = mul nsw i32 %125, 65536
  %127 = sext i32 %126 to i64
  %128 = getelementptr inbounds i8, ptr %124, i64 %127
  %129 = load i32, ptr %17, align 4, !tbaa !9
  %130 = mul nsw i32 %129, 256
  %131 = mul nsw i32 %130, 4
  %132 = sext i32 %131 to i64
  %133 = getelementptr inbounds i8, ptr %128, i64 %132
  %134 = load i32, ptr %17, align 4, !tbaa !9
  %135 = sext i32 %134 to i64
  %136 = getelementptr inbounds [64 x [1024 x i8]], ptr %14, i64 0, i64 %135
  %137 = getelementptr inbounds [1024 x i8], ptr %136, i64 0, i64 0
  call void @llvm.memcpy.p0.p0.i64(ptr align 1 %133, ptr align 16 %137, i64 1024, i1 false)
  br label %138

138:                                              ; preds = %123
  %139 = load i32, ptr %17, align 4, !tbaa !9
  %140 = add nsw i32 %139, 1
  store i32 %140, ptr %17, align 4, !tbaa !9
  br label %120, !llvm.loop !16

141:                                              ; preds = %120
  br label %142

142:                                              ; preds = %141
  %143 = load i32, ptr %16, align 4, !tbaa !9
  %144 = add nsw i32 %143, 1
  store i32 %144, ptr %16, align 4, !tbaa !9
  br label %22, !llvm.loop !17

145:                                              ; preds = %22
  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
  %10 = icmp sgt i32 %4, 255
  br i1 %10, label %.preheader37.preheader, label %._crit_edge

.preheader37.preheader:                           ; preds = %5
  %11 = lshr i32 %4, 8
  %wide.trip.count = zext nneg i32 %11 to i64
  br label %.preheader37

.preheader37:                                     ; preds = %.preheader37.preheader, %.preheader34
  %indvar = phi i64 [ 0, %.preheader37.preheader ], [ %indvar.next, %.preheader34 ]
  %12 = shl i64 %indvar, 16
  %13 = and i64 %12, 4294901760
  %scevgep52 = getelementptr i8, ptr %3, i64 %13
  %scevgep48 = getelementptr i8, ptr %2, i64 %13
  %14 = shl nuw nsw i64 %indvar, 15
  %scevgep45 = getelementptr i8, ptr %1, i64 %14
  %scevgep = getelementptr i8, ptr %0, i64 %14
  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) %scevgep45, i64 32768, i1 false)
  br label %.preheader35

.preheader34:                                     ; preds = %.preheader35
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 1 dereferenceable(65536) %scevgep48, 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) %scevgep52, ptr noundef nonnull align 16 dereferenceable(65536) %9, i64 65536, i1 false)
  %indvar.next = add nuw nsw i64 %indvar, 1
  %exitcond57.not = icmp eq i64 %indvar.next, %wide.trip.count
  br i1 %exitcond57.not, label %._crit_edge, label %.preheader37, !llvm.loop !5

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

._crit_edge:                                      ; preds = %.preheader34, %5
  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: CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LICMPass,LoopIdiomRecognizePass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass