; LLVM IR from aferikoglou/GenHLSOptimizer :: dataset/rodinia_nw_5_coalescing_0/nw.ll (Z11buffer_loadiPmPA1024_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 @_Z7copy_inPmPc(ptr noundef, ptr noundef) #1

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @_Z11buffer_loadiPmPA1024_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 [128 x i64]], align 16
  %12 = alloca [64 x [128 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 65536, ptr %11) #3
  br label %15

15:                                               ; preds = %14
  call void @llvm.lifetime.start.p0(i64 65536, 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 = %34, %19
  %21 = load i32, ptr %13, align 4, !tbaa !5
  %22 = icmp slt i32 %21, 64
  br i1 %22, label %23, label %37

23:                                               ; preds = %20
  %24 = load i32, ptr %13, align 4, !tbaa !5
  %25 = sext i32 %24 to i64
  %26 = getelementptr inbounds [64 x [128 x i64]], ptr %11, i64 0, i64 %25
  %27 = getelementptr inbounds [128 x i64], ptr %26, i64 0, i64 0
  %28 = load ptr, ptr %7, align 8, !tbaa !9
  %29 = load i32, ptr %13, align 4, !tbaa !5
  %30 = mul nsw i32 %29, 1024
  %31 = sdiv i32 %30, 8
  %32 = sext i32 %31 to i64
  %33 = getelementptr inbounds i64, ptr %28, i64 %32
  call void @llvm.memcpy.p0.p0.i64(ptr align 16 %27, ptr align 8 %33, i64 1024, i1 false)
  br label %34

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

37:                                               ; preds = %20
  br label %38

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

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

42:                                               ; preds = %39
  %43 = load i32, ptr %13, align 4, !tbaa !5
  %44 = sext i32 %43 to i64
  %45 = getelementptr inbounds [64 x [128 x i64]], ptr %11, i64 0, i64 %44
  %46 = getelementptr inbounds [128 x i64], ptr %45, i64 0, i64 0
  %47 = load ptr, ptr %8, align 8, !tbaa !9
  %48 = load i32, ptr %13, align 4, !tbaa !5
  %49 = sext i32 %48 to i64
  %50 = getelementptr inbounds [1024 x i8], ptr %47, i64 %49
  %51 = getelementptr inbounds [1024 x i8], ptr %50, i64 0, i64 0
  call void @_Z7copy_inPmPc(ptr noundef %46, ptr noundef %51)
  br label %52

52:                                               ; preds = %42
  %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 %39, !llvm.loop !13

55:                                               ; preds = %39
  br label %56

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

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

60:                                               ; preds = %57
  %61 = load i32, ptr %13, align 4, !tbaa !5
  %62 = sext i32 %61 to i64
  %63 = getelementptr inbounds [64 x [128 x i64]], ptr %12, i64 0, i64 %62
  %64 = getelementptr inbounds [128 x i64], ptr %63, i64 0, i64 0
  %65 = load ptr, ptr %9, align 8, !tbaa !9
  %66 = load i32, ptr %13, align 4, !tbaa !5
  %67 = mul nsw i32 %66, 1024
  %68 = sdiv i32 %67, 8
  %69 = sext i32 %68 to i64
  %70 = getelementptr inbounds i64, ptr %65, i64 %69
  call void @llvm.memcpy.p0.p0.i64(ptr align 16 %64, ptr align 8 %70, i64 1024, i1 false)
  br label %71

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

74:                                               ; preds = %57
  br label %75

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

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

79:                                               ; preds = %76
  %80 = load i32, ptr %13, align 4, !tbaa !5
  %81 = sext i32 %80 to i64
  %82 = getelementptr inbounds [64 x [128 x i64]], ptr %12, i64 0, i64 %81
  %83 = getelementptr inbounds [128 x i64], ptr %82, i64 0, i64 0
  %84 = load ptr, ptr %10, align 8, !tbaa !9
  %85 = load i32, ptr %13, align 4, !tbaa !5
  %86 = sext i32 %85 to i64
  %87 = getelementptr inbounds [1024 x i8], ptr %84, i64 %86
  %88 = getelementptr inbounds [1024 x i8], ptr %87, i64 0, i64 0
  call void @_Z7copy_inPmPc(ptr noundef %83, ptr noundef %88)
  br label %89

89:                                               ; preds = %79
  %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 %76, !llvm.loop !15

92:                                               ; preds = %76
  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 65536, ptr %12) #3
  call void @llvm.lifetime.end.p0(i64 65536, 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 = !{!"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 @_Z7copy_inPmPc(ptr noundef, ptr noundef) local_unnamed_addr #1

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

.preheader22.preheader:                           ; preds = %5
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 16 dereferenceable(65536) %6, ptr noundef nonnull align 8 dereferenceable(65536) %1, i64 65536, i1 false)
  br label %.preheader21

.preheader21:                                     ; preds = %.preheader22.preheader, %.preheader21
  %indvars.iv = phi i64 [ 0, %.preheader22.preheader ], [ %indvars.iv.next, %.preheader21 ]
  %8 = getelementptr inbounds [64 x [128 x i64]], ptr %6, i64 0, i64 %indvars.iv
  %9 = getelementptr inbounds [1024 x i8], ptr %2, i64 %indvars.iv
  call void @_Z7copy_inPmPc(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 %.preheader20.preheader, label %.preheader21, !llvm.loop !5

.preheader20.preheader:                           ; preds = %.preheader21
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 16 dereferenceable(65536) %7, ptr noundef nonnull align 8 dereferenceable(65536) %3, i64 65536, i1 false)
  br label %.preheader

.preheader:                                       ; preds = %.preheader20.preheader, %.preheader
  %indvars.iv32 = phi i64 [ 0, %.preheader20.preheader ], [ %indvars.iv.next33, %.preheader ]
  %10 = getelementptr inbounds [64 x [128 x i64]], ptr %7, i64 0, i64 %indvars.iv32
  %11 = getelementptr inbounds [1024 x i8], ptr %4, i64 %indvars.iv32
  call void @_Z7copy_inPmPc(ptr noundef nonnull %10, ptr noundef %11)
  %indvars.iv.next33 = add nuw nsw i64 %indvars.iv32, 1
  %exitcond35.not = icmp eq i64 %indvars.iv.next33, 64
  br i1 %exitcond35.not, label %.loopexit, label %.preheader, !llvm.loop !7

.loopexit:                                        ; preds = %.preheader, %5
  call void @llvm.lifetime.end.p0(i64 65536, ptr nonnull %7) #3
  call void @llvm.lifetime.end.p0(i64 65536, 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,JumpThreadingPass,LoopIdiomRecognizePass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass