; LLVM IR from aferikoglou/GenHLSOptimizer :: dataset/rodinia_nw_5_coalescing_0/nw.ll (Z12buffer_storeiPmPA2048_cS_S1_)

; 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 @_Z8copy_outPmPc(ptr noundef, ptr noundef) #1

; 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

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @_Z12buffer_storeiPmPA2048_cS_S1_(i32 noundef %0, ptr noundef %1, ptr noundef %2, ptr noundef %3, ptr noundef %4) #1 {
  %6 = alloca i32, align 4
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  %10 = alloca ptr, align 8
  %11 = alloca [64 x [256 x i64]], align 16
  %12 = alloca [64 x [256 x i64]], align 16
  %13 = alloca i32, align 4
  store i32 %0, ptr %6, align 4, !tbaa !5
  store ptr %1, ptr %7, align 8, !tbaa !9
  store ptr %2, ptr %8, align 8, !tbaa !9
  store ptr %3, ptr %9, align 8, !tbaa !9
  store ptr %4, ptr %10, align 8, !tbaa !9
  br label %14

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

15:                                               ; preds = %14
  call void @llvm.lifetime.start.p0(i64 131072, ptr %12) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #3
  %16 = load i32, ptr %6, align 4, !tbaa !5
  %17 = icmp ne i32 %16, 0
  br i1 %17, label %18, label %93

18:                                               ; preds = %15
  br label %19

19:                                               ; preds = %18
  store i32 0, ptr %13, align 4, !tbaa !5
  br label %20

20:                                               ; preds = %33, %19
  %21 = load i32, ptr %13, align 4, !tbaa !5
  %22 = icmp slt i32 %21, 64
  br i1 %22, label %23, label %36

23:                                               ; preds = %20
  %24 = load i32, ptr %13, align 4, !tbaa !5
  %25 = sext i32 %24 to i64
  %26 = getelementptr inbounds [64 x [256 x i64]], ptr %11, i64 0, i64 %25
  %27 = getelementptr inbounds [256 x i64], ptr %26, i64 0, i64 0
  %28 = load ptr, ptr %8, align 8, !tbaa !9
  %29 = load i32, ptr %13, align 4, !tbaa !5
  %30 = sext i32 %29 to i64
  %31 = getelementptr inbounds [2048 x i8], ptr %28, i64 %30
  %32 = getelementptr inbounds [2048 x i8], ptr %31, i64 0, i64 0
  call void @_Z8copy_outPmPc(ptr noundef %27, ptr noundef %32)
  br label %33

33:                                               ; preds = %23
  %34 = load i32, ptr %13, align 4, !tbaa !5
  %35 = add nsw i32 %34, 1
  store i32 %35, ptr %13, align 4, !tbaa !5
  br label %20, !llvm.loop !11

36:                                               ; preds = %20
  br label %37

37:                                               ; preds = %36
  store i32 0, ptr %13, align 4, !tbaa !5
  br label %38

38:                                               ; preds = %52, %37
  %39 = load i32, ptr %13, align 4, !tbaa !5
  %40 = icmp slt i32 %39, 64
  br i1 %40, label %41, label %55

41:                                               ; preds = %38
  %42 = load ptr, ptr %7, align 8, !tbaa !9
  %43 = load i32, ptr %13, align 4, !tbaa !5
  %44 = mul nsw i32 %43, 2048
  %45 = sdiv i32 %44, 64
  %46 = sext i32 %45 to i64
  %47 = getelementptr inbounds i64, ptr %42, i64 %46
  %48 = load i32, ptr %13, align 4, !tbaa !5
  %49 = sext i32 %48 to i64
  %50 = getelementptr inbounds [64 x [256 x i64]], ptr %11, i64 0, i64 %49
  %51 = getelementptr inbounds [256 x i64], ptr %50, i64 0, i64 0
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %47, ptr align 16 %51, i64 2048, i1 false)
  br label %52

52:                                               ; preds = %41
  %53 = load i32, ptr %13, align 4, !tbaa !5
  %54 = add nsw i32 %53, 1
  store i32 %54, ptr %13, align 4, !tbaa !5
  br label %38, !llvm.loop !13

55:                                               ; preds = %38
  br label %56

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

57:                                               ; preds = %70, %56
  %58 = load i32, ptr %13, align 4, !tbaa !5
  %59 = icmp slt i32 %58, 64
  br i1 %59, label %60, label %73

60:                                               ; preds = %57
  %61 = load i32, ptr %13, align 4, !tbaa !5
  %62 = sext i32 %61 to i64
  %63 = getelementptr inbounds [64 x [256 x i64]], ptr %12, i64 0, i64 %62
  %64 = getelementptr inbounds [256 x i64], ptr %63, i64 0, i64 0
  %65 = load ptr, ptr %10, align 8, !tbaa !9
  %66 = load i32, ptr %13, align 4, !tbaa !5
  %67 = sext i32 %66 to i64
  %68 = getelementptr inbounds [2048 x i8], ptr %65, i64 %67
  %69 = getelementptr inbounds [2048 x i8], ptr %68, i64 0, i64 0
  call void @_Z8copy_outPmPc(ptr noundef %64, ptr noundef %69)
  br label %70

70:                                               ; preds = %60
  %71 = load i32, ptr %13, align 4, !tbaa !5
  %72 = add nsw i32 %71, 1
  store i32 %72, ptr %13, align 4, !tbaa !5
  br label %57, !llvm.loop !14

73:                                               ; preds = %57
  br label %74

74:                                               ; preds = %73
  store i32 0, ptr %13, align 4, !tbaa !5
  br label %75

75:                                               ; preds = %89, %74
  %76 = load i32, ptr %13, align 4, !tbaa !5
  %77 = icmp slt i32 %76, 64
  br i1 %77, label %78, label %92

78:                                               ; preds = %75
  %79 = load ptr, ptr %9, align 8, !tbaa !9
  %80 = load i32, ptr %13, align 4, !tbaa !5
  %81 = mul nsw i32 %80, 2048
  %82 = sdiv i32 %81, 64
  %83 = sext i32 %82 to i64
  %84 = getelementptr inbounds i64, ptr %79, i64 %83
  %85 = load i32, ptr %13, align 4, !tbaa !5
  %86 = sext i32 %85 to i64
  %87 = getelementptr inbounds [64 x [256 x i64]], ptr %12, i64 0, i64 %86
  %88 = getelementptr inbounds [256 x i64], ptr %87, i64 0, i64 0
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %84, ptr align 16 %88, i64 2048, i1 false)
  br label %89

89:                                               ; preds = %78
  %90 = load i32, ptr %13, align 4, !tbaa !5
  %91 = add nsw i32 %90, 1
  store i32 %91, ptr %13, align 4, !tbaa !5
  br label %75, !llvm.loop !15

92:                                               ; preds = %75
  br label %93

93:                                               ; preds = %92, %15
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #3
  call void @llvm.lifetime.end.p0(i64 131072, ptr %12) #3
  call void @llvm.lifetime.end.p0(i64 131072, ptr %11) #3
  ret void
}

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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"any pointer", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = distinct !{!13, !12}
!14 = distinct !{!14, !12}
!15 = distinct !{!15, !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 @_Z8copy_outPmPc(ptr noundef, ptr noundef) local_unnamed_addr #1

; 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

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @_Z12buffer_storeiPmPA2048_cS_S1_(i32 noundef %0, ptr nocapture noundef writeonly %1, ptr noundef %2, ptr nocapture noundef writeonly %3, ptr noundef %4) local_unnamed_addr #1 {
  %6 = alloca [64 x [256 x i64]], align 16
  %7 = alloca [64 x [256 x i64]], align 16
  call void @llvm.lifetime.start.p0(i64 131072, ptr nonnull %6) #3
  call void @llvm.lifetime.start.p0(i64 131072, ptr nonnull %7) #3
  %.not = icmp eq i32 %0, 0
  br i1 %.not, label %.loopexit, label %.preheader22

.preheader22:                                     ; preds = %5, %.preheader22
  %indvars.iv = phi i64 [ %indvars.iv.next, %.preheader22 ], [ 0, %5 ]
  %8 = getelementptr inbounds [64 x [256 x i64]], ptr %6, i64 0, i64 %indvars.iv
  %9 = getelementptr inbounds [2048 x i8], ptr %2, i64 %indvars.iv
  call void @_Z8copy_outPmPc(ptr noundef nonnull %8, ptr noundef %9)
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next, 64
  br i1 %exitcond.not, label %.preheader21, label %.preheader22, !llvm.loop !5

.preheader21:                                     ; preds = %.preheader22, %.preheader21
  %indvars.iv28 = phi i64 [ %indvars.iv.next29.1, %.preheader21 ], [ 0, %.preheader22 ]
  %.idx = shl nsw i64 %indvars.iv28, 8
  %10 = getelementptr inbounds i8, ptr %1, i64 %.idx
  %11 = getelementptr inbounds [64 x [256 x i64]], ptr %6, i64 0, i64 %indvars.iv28
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 8 dereferenceable(2048) %10, ptr noundef nonnull align 16 dereferenceable(2048) %11, i64 2048, i1 false)
  %indvars.iv.next29 = or disjoint i64 %indvars.iv28, 1
  %.idx.1 = shl nsw i64 %indvars.iv.next29, 8
  %12 = getelementptr inbounds i8, ptr %1, i64 %.idx.1
  %13 = getelementptr inbounds [64 x [256 x i64]], ptr %6, i64 0, i64 %indvars.iv.next29
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 8 dereferenceable(2048) %12, ptr noundef nonnull align 16 dereferenceable(2048) %13, i64 2048, i1 false)
  %indvars.iv.next29.1 = add nuw nsw i64 %indvars.iv28, 2
  %exitcond31.not.1 = icmp eq i64 %indvars.iv.next29.1, 64
  br i1 %exitcond31.not.1, label %.preheader20, label %.preheader21, !llvm.loop !7

.preheader20:                                     ; preds = %.preheader21, %.preheader20
  %indvars.iv32 = phi i64 [ %indvars.iv.next33, %.preheader20 ], [ 0, %.preheader21 ]
  %14 = getelementptr inbounds [64 x [256 x i64]], ptr %7, i64 0, i64 %indvars.iv32
  %15 = getelementptr inbounds [2048 x i8], ptr %4, i64 %indvars.iv32
  call void @_Z8copy_outPmPc(ptr noundef nonnull %14, ptr noundef %15)
  %indvars.iv.next33 = add nuw nsw i64 %indvars.iv32, 1
  %exitcond35.not = icmp eq i64 %indvars.iv.next33, 64
  br i1 %exitcond35.not, label %.preheader, label %.preheader20, !llvm.loop !8

.preheader:                                       ; preds = %.preheader20, %.preheader
  %indvars.iv36 = phi i64 [ %indvars.iv.next37.1, %.preheader ], [ 0, %.preheader20 ]
  %.idx40 = shl nsw i64 %indvars.iv36, 8
  %16 = getelementptr inbounds i8, ptr %3, i64 %.idx40
  %17 = getelementptr inbounds [64 x [256 x i64]], ptr %7, i64 0, i64 %indvars.iv36
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 8 dereferenceable(2048) %16, ptr noundef nonnull align 16 dereferenceable(2048) %17, i64 2048, i1 false)
  %indvars.iv.next37 = or disjoint i64 %indvars.iv36, 1
  %.idx40.1 = shl nsw i64 %indvars.iv.next37, 8
  %18 = getelementptr inbounds i8, ptr %3, i64 %.idx40.1
  %19 = getelementptr inbounds [64 x [256 x i64]], ptr %7, i64 0, i64 %indvars.iv.next37
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 8 dereferenceable(2048) %18, ptr noundef nonnull align 16 dereferenceable(2048) %19, i64 2048, i1 false)
  %indvars.iv.next37.1 = add nuw nsw i64 %indvars.iv36, 2
  %exitcond39.not.1 = icmp eq i64 %indvars.iv.next37.1, 64
  br i1 %exitcond39.not.1, label %.loopexit, label %.preheader, !llvm.loop !9

.loopexit:                                        ; preds = %.preheader, %5
  call void @llvm.lifetime.end.p0(i64 131072, ptr nonnull %7) #3
  call void @llvm.lifetime.end.p0(i64 131072, ptr nonnull %6) #3
  ret void
}

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}
!9 = distinct !{!9, !6}


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