; LLVM IR from bondhugula/pluto :: examples/floyd (floyd)

; 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"

@pathDistanceMatrix = external dso_local global [2048 x [2048 x double]], align 16
@.str.3 = external hidden unnamed_addr constant [6 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [2 x i8], align 1

; 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: nounwind uwtable
declare dso_local void @init_array() #1

; Function Attrs: nounwind uwtable
declare dso_local void @print_array() #1

; Function Attrs: nounwind uwtable
define dso_local i32 @main() #1 {
  %1 = alloca i32, align 4
  %2 = alloca i32, align 4
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  store i32 0, ptr %1, align 4
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #3
  store i32 2048, ptr %10, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #3
  call void @init_array()
  store i32 0, ptr %4, align 4, !tbaa !5
  br label %12

12:                                               ; preds = %87, %0
  %13 = load i32, ptr %4, align 4, !tbaa !5
  %14 = icmp slt i32 %13, 2048
  br i1 %14, label %15, label %90

15:                                               ; preds = %12
  store i32 0, ptr %6, align 4, !tbaa !5
  br label %16

16:                                               ; preds = %83, %15
  %17 = load i32, ptr %6, align 4, !tbaa !5
  %18 = icmp slt i32 %17, 2048
  br i1 %18, label %19, label %86

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

20:                                               ; preds = %79, %19
  %21 = load i32, ptr %5, align 4, !tbaa !5
  %22 = icmp slt i32 %21, 2048
  br i1 %22, label %23, label %82

23:                                               ; preds = %20
  %24 = load i32, ptr %6, align 4, !tbaa !5
  %25 = sext i32 %24 to i64
  %26 = getelementptr inbounds [2048 x [2048 x double]], ptr @pathDistanceMatrix, i64 0, i64 %25
  %27 = load i32, ptr %4, align 4, !tbaa !5
  %28 = sext i32 %27 to i64
  %29 = getelementptr inbounds [2048 x double], ptr %26, i64 0, i64 %28
  %30 = load double, ptr %29, align 8, !tbaa !9
  %31 = load i32, ptr %4, align 4, !tbaa !5
  %32 = sext i32 %31 to i64
  %33 = getelementptr inbounds [2048 x [2048 x double]], ptr @pathDistanceMatrix, i64 0, i64 %32
  %34 = load i32, ptr %5, align 4, !tbaa !5
  %35 = sext i32 %34 to i64
  %36 = getelementptr inbounds [2048 x double], ptr %33, i64 0, i64 %35
  %37 = load double, ptr %36, align 8, !tbaa !9
  %38 = fadd double %30, %37
  %39 = load i32, ptr %6, align 4, !tbaa !5
  %40 = sext i32 %39 to i64
  %41 = getelementptr inbounds [2048 x [2048 x double]], ptr @pathDistanceMatrix, i64 0, i64 %40
  %42 = load i32, ptr %5, align 4, !tbaa !5
  %43 = sext i32 %42 to i64
  %44 = getelementptr inbounds [2048 x double], ptr %41, i64 0, i64 %43
  %45 = load double, ptr %44, align 8, !tbaa !9
  %46 = fcmp olt double %38, %45
  br i1 %46, label %47, label %63

47:                                               ; preds = %23
  %48 = load i32, ptr %6, align 4, !tbaa !5
  %49 = sext i32 %48 to i64
  %50 = getelementptr inbounds [2048 x [2048 x double]], ptr @pathDistanceMatrix, i64 0, i64 %49
  %51 = load i32, ptr %4, align 4, !tbaa !5
  %52 = sext i32 %51 to i64
  %53 = getelementptr inbounds [2048 x double], ptr %50, i64 0, i64 %52
  %54 = load double, ptr %53, align 8, !tbaa !9
  %55 = load i32, ptr %4, align 4, !tbaa !5
  %56 = sext i32 %55 to i64
  %57 = getelementptr inbounds [2048 x [2048 x double]], ptr @pathDistanceMatrix, i64 0, i64 %56
  %58 = load i32, ptr %5, align 4, !tbaa !5
  %59 = sext i32 %58 to i64
  %60 = getelementptr inbounds [2048 x double], ptr %57, i64 0, i64 %59
  %61 = load double, ptr %60, align 8, !tbaa !9
  %62 = fadd double %54, %61
  br label %71

63:                                               ; preds = %23
  %64 = load i32, ptr %6, align 4, !tbaa !5
  %65 = sext i32 %64 to i64
  %66 = getelementptr inbounds [2048 x [2048 x double]], ptr @pathDistanceMatrix, i64 0, i64 %65
  %67 = load i32, ptr %5, align 4, !tbaa !5
  %68 = sext i32 %67 to i64
  %69 = getelementptr inbounds [2048 x double], ptr %66, i64 0, i64 %68
  %70 = load double, ptr %69, align 8, !tbaa !9
  br label %71

71:                                               ; preds = %63, %47
  %72 = phi double [ %62, %47 ], [ %70, %63 ]
  %73 = load i32, ptr %6, align 4, !tbaa !5
  %74 = sext i32 %73 to i64
  %75 = getelementptr inbounds [2048 x [2048 x double]], ptr @pathDistanceMatrix, i64 0, i64 %74
  %76 = load i32, ptr %5, align 4, !tbaa !5
  %77 = sext i32 %76 to i64
  %78 = getelementptr inbounds [2048 x double], ptr %75, i64 0, i64 %77
  store double %72, ptr %78, align 8, !tbaa !9
  br label %79

79:                                               ; preds = %71
  %80 = load i32, ptr %5, align 4, !tbaa !5
  %81 = add nsw i32 %80, 1
  store i32 %81, ptr %5, align 4, !tbaa !5
  br label %20, !llvm.loop !11

82:                                               ; preds = %20
  br label %83

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

86:                                               ; preds = %16
  br label %87

87:                                               ; preds = %86
  %88 = load i32, ptr %4, align 4, !tbaa !5
  %89 = add nsw i32 %88, 1
  store i32 %89, ptr %4, align 4, !tbaa !5
  br label %12, !llvm.loop !14

90:                                               ; preds = %12
  %91 = call noalias ptr @fopen(ptr noundef @.str.3, ptr noundef @.str.4)
  %92 = icmp ne ptr %91, null
  br i1 %92, label %93, label %94

93:                                               ; preds = %90
  call void @print_array()
  br label %94

94:                                               ; preds = %93, %90
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #3
  ret i32 0
}

declare noalias ptr @fopen(ptr noundef, ptr noundef) #2

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 = { "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 #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/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"double", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = distinct !{!13, !12}
!14 = distinct !{!14, !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"

@pathDistanceMatrix = external dso_local local_unnamed_addr global [2048 x [2048 x double]], align 16
@.str.3 = external hidden unnamed_addr constant [6 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [2 x i8], align 1

; Function Attrs: nounwind uwtable
declare dso_local void @init_array() local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare dso_local void @print_array() local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local noundef i32 @main() local_unnamed_addr #0 {
  tail call void @init_array()
  br label %.preheader24

.preheader24:                                     ; preds = %0, %30
  %indvars.iv33 = phi i64 [ 0, %0 ], [ %indvars.iv.next34, %30 ]
  %1 = shl nuw nsw i64 %indvars.iv33, 3
  %scevgep = getelementptr i8, ptr @pathDistanceMatrix, i64 %1
  %gep = getelementptr i8, ptr getelementptr (i8, ptr @pathDistanceMatrix, i64 33538056), i64 %1
  %2 = shl nuw nsw i64 %indvars.iv33, 14
  %scevgep38 = getelementptr i8, ptr @pathDistanceMatrix, i64 %2
  %gep49 = getelementptr i8, ptr getelementptr (i8, ptr @pathDistanceMatrix, i64 16384), i64 %2
  %bound0 = icmp ugt ptr %gep, @pathDistanceMatrix
  %bound1 = icmp ult ptr %scevgep, getelementptr inbounds (i8, ptr @pathDistanceMatrix, i64 33554432)
  %found.conflict = and i1 %bound0, %bound1
  %bound040 = icmp ugt ptr %gep49, @pathDistanceMatrix
  %bound141 = icmp ult ptr %scevgep38, getelementptr inbounds (i8, ptr @pathDistanceMatrix, i64 33554432)
  %found.conflict42 = and i1 %bound040, %bound141
  %conflict.rdx = or i1 %found.conflict, %found.conflict42
  br label %.preheader

.preheader:                                       ; preds = %.preheader24, %middle.block
  %indvars.iv29 = phi i64 [ 0, %.preheader24 ], [ %indvars.iv.next30, %middle.block ]
  %3 = getelementptr inbounds [2048 x [2048 x double]], ptr @pathDistanceMatrix, i64 0, i64 %indvars.iv29, i64 %indvars.iv33
  br i1 %conflict.rdx, label %scalar.ph, label %vector.body.preheader

vector.body.preheader:                            ; preds = %.preheader
  %4 = load double, ptr %3, align 8, !tbaa !5, !alias.scope !9
  %broadcast.splatinsert44 = insertelement <2 x double> poison, double %4, i64 0
  %broadcast.splat45 = shufflevector <2 x double> %broadcast.splatinsert44, <2 x double> poison, <2 x i32> zeroinitializer
  br label %vector.body

vector.body:                                      ; preds = %vector.body.preheader, %vector.body
  %index = phi i64 [ %index.next, %vector.body ], [ 0, %vector.body.preheader ]
  %5 = getelementptr inbounds [2048 x [2048 x double]], ptr @pathDistanceMatrix, i64 0, i64 %indvars.iv33, i64 %index
  %6 = getelementptr inbounds i8, ptr %5, i64 16
  %wide.load = load <2 x double>, ptr %5, align 16, !tbaa !5, !alias.scope !12
  %wide.load43 = load <2 x double>, ptr %6, align 16, !tbaa !5, !alias.scope !12
  %7 = fadd <2 x double> %broadcast.splat45, %wide.load
  %8 = fadd <2 x double> %broadcast.splat45, %wide.load43
  %9 = getelementptr inbounds [2048 x [2048 x double]], ptr @pathDistanceMatrix, i64 0, i64 %indvars.iv29, i64 %index
  %10 = getelementptr inbounds i8, ptr %9, i64 16
  %wide.load46 = load <2 x double>, ptr %9, align 16, !tbaa !5, !alias.scope !14, !noalias !16
  %wide.load47 = load <2 x double>, ptr %10, align 16, !tbaa !5, !alias.scope !14, !noalias !16
  %11 = fcmp olt <2 x double> %7, %wide.load46
  %12 = fcmp olt <2 x double> %8, %wide.load47
  %13 = select <2 x i1> %11, <2 x double> %7, <2 x double> %wide.load46
  %14 = select <2 x i1> %12, <2 x double> %8, <2 x double> %wide.load47
  store <2 x double> %13, ptr %9, align 16, !tbaa !5, !alias.scope !14, !noalias !16
  store <2 x double> %14, ptr %10, align 16, !tbaa !5, !alias.scope !14, !noalias !16
  %index.next = add nuw i64 %index, 4
  %15 = icmp eq i64 %index.next, 2048
  br i1 %15, label %middle.block, label %vector.body, !llvm.loop !17

scalar.ph:                                        ; preds = %.preheader, %scalar.ph
  %indvars.iv = phi i64 [ %indvars.iv.next.1, %scalar.ph ], [ 0, %.preheader ]
  %16 = load double, ptr %3, align 8, !tbaa !5
  %17 = getelementptr inbounds [2048 x [2048 x double]], ptr @pathDistanceMatrix, i64 0, i64 %indvars.iv33, i64 %indvars.iv
  %18 = load double, ptr %17, align 16, !tbaa !5
  %19 = fadd double %16, %18
  %20 = getelementptr inbounds [2048 x [2048 x double]], ptr @pathDistanceMatrix, i64 0, i64 %indvars.iv29, i64 %indvars.iv
  %21 = load double, ptr %20, align 16, !tbaa !5
  %22 = fcmp olt double %19, %21
  %. = select i1 %22, double %19, double %21
  store double %., ptr %20, align 16, !tbaa !5
  %indvars.iv.next = or disjoint i64 %indvars.iv, 1
  %23 = load double, ptr %3, align 8, !tbaa !5
  %24 = getelementptr inbounds [2048 x [2048 x double]], ptr @pathDistanceMatrix, i64 0, i64 %indvars.iv33, i64 %indvars.iv.next
  %25 = load double, ptr %24, align 8, !tbaa !5
  %26 = fadd double %23, %25
  %27 = getelementptr inbounds [2048 x [2048 x double]], ptr @pathDistanceMatrix, i64 0, i64 %indvars.iv29, i64 %indvars.iv.next
  %28 = load double, ptr %27, align 8, !tbaa !5
  %29 = fcmp olt double %26, %28
  %..1 = select i1 %29, double %26, double %28
  store double %..1, ptr %27, align 8, !tbaa !5
  %indvars.iv.next.1 = add nuw nsw i64 %indvars.iv, 2
  %exitcond.not.1 = icmp eq i64 %indvars.iv.next.1, 2048
  br i1 %exitcond.not.1, label %middle.block, label %scalar.ph, !llvm.loop !21

middle.block:                                     ; preds = %vector.body, %scalar.ph
  %indvars.iv.next30 = add nuw nsw i64 %indvars.iv29, 1
  %exitcond32.not = icmp eq i64 %indvars.iv.next30, 2048
  br i1 %exitcond32.not, label %30, label %.preheader, !llvm.loop !22

30:                                               ; preds = %middle.block
  %indvars.iv.next34 = add nuw nsw i64 %indvars.iv33, 1
  %exitcond36.not = icmp eq i64 %indvars.iv.next34, 2048
  br i1 %exitcond36.not, label %31, label %.preheader24, !llvm.loop !23

31:                                               ; preds = %30
  %32 = tail call noalias ptr @fopen(ptr noundef nonnull @.str.3, ptr noundef nonnull @.str.4)
  %.not = icmp eq ptr %32, null
  br i1 %.not, label %34, label %33

33:                                               ; preds = %31
  tail call void @print_array()
  br label %34

34:                                               ; preds = %33, %31
  ret i32 0
}

; Function Attrs: nofree nounwind
declare noalias noundef ptr @fopen(ptr nocapture noundef readonly, ptr nocapture noundef readonly) local_unnamed_addr #1

attributes #0 = { 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 = { nofree nounwind "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" }

!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 = !{!"double", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10}
!10 = distinct !{!10, !11}
!11 = distinct !{!11, !"LVerDomain"}
!12 = !{!13}
!13 = distinct !{!13, !11}
!14 = !{!15}
!15 = distinct !{!15, !11}
!16 = !{!10, !13}
!17 = distinct !{!17, !18, !19, !20}
!18 = !{!"llvm.loop.mustprogress"}
!19 = !{!"llvm.loop.isvectorized", i32 1}
!20 = !{!"llvm.loop.unroll.runtime.disable"}
!21 = distinct !{!21, !18, !19}
!22 = distinct !{!22, !18}
!23 = distinct !{!23, !18}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,IndVarSimplifyPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,LICMPass,LoopLoadEliminationPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,LoopVectorizePass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass