; 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

; 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
define dso_local void @init_array() #1 {
  %1 = alloca i32, align 4
  %2 = alloca i32, align 4
  %3 = alloca double, align 8
  call void @llvm.lifetime.start.p0(i64 4, ptr %1) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #3
  call void @srand(i32 noundef 123) #3
  store i32 0, ptr %1, align 4, !tbaa !5
  br label %4

4:                                                ; preds = %28, %0
  %5 = load i32, ptr %1, align 4, !tbaa !5
  %6 = icmp slt i32 %5, 2048
  br i1 %6, label %7, label %31

7:                                                ; preds = %4
  store i32 0, ptr %2, align 4, !tbaa !5
  br label %8

8:                                                ; preds = %24, %7
  %9 = load i32, ptr %2, align 4, !tbaa !5
  %10 = icmp slt i32 %9, 2048
  br i1 %10, label %11, label %27

11:                                               ; preds = %8
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #3
  %12 = call i32 @rand() #3
  %13 = sitofp i32 %12 to double
  %14 = fmul double 2.048000e+03, %13
  %15 = fdiv double %14, 0x41E0000000000000
  %16 = fadd double 1.000000e+00, %15
  store double %16, ptr %3, align 8, !tbaa !9
  %17 = load double, ptr %3, align 8, !tbaa !9
  %18 = load i32, ptr %1, align 4, !tbaa !5
  %19 = sext i32 %18 to i64
  %20 = getelementptr inbounds [2048 x [2048 x double]], ptr @pathDistanceMatrix, i64 0, i64 %19
  %21 = load i32, ptr %2, align 4, !tbaa !5
  %22 = sext i32 %21 to i64
  %23 = getelementptr inbounds [2048 x double], ptr %20, i64 0, i64 %22
  store double %17, ptr %23, align 8, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #3
  br label %24

24:                                               ; preds = %11
  %25 = load i32, ptr %2, align 4, !tbaa !5
  %26 = add nsw i32 %25, 1
  store i32 %26, ptr %2, align 4, !tbaa !5
  br label %8, !llvm.loop !11

27:                                               ; preds = %8
  br label %28

28:                                               ; preds = %27
  %29 = load i32, ptr %1, align 4, !tbaa !5
  %30 = add nsw i32 %29, 1
  store i32 %30, ptr %1, align 4, !tbaa !5
  br label %4, !llvm.loop !13

31:                                               ; preds = %4
  store i32 0, ptr %1, align 4, !tbaa !5
  br label %32

32:                                               ; preds = %42, %31
  %33 = load i32, ptr %1, align 4, !tbaa !5
  %34 = icmp slt i32 %33, 2048
  br i1 %34, label %35, label %45

35:                                               ; preds = %32
  %36 = load i32, ptr %1, align 4, !tbaa !5
  %37 = sext i32 %36 to i64
  %38 = getelementptr inbounds [2048 x [2048 x double]], ptr @pathDistanceMatrix, i64 0, i64 %37
  %39 = load i32, ptr %1, align 4, !tbaa !5
  %40 = sext i32 %39 to i64
  %41 = getelementptr inbounds [2048 x double], ptr %38, i64 0, i64 %40
  store double 0.000000e+00, ptr %41, align 8, !tbaa !9
  br label %42

42:                                               ; preds = %35
  %43 = load i32, ptr %1, align 4, !tbaa !5
  %44 = add nsw i32 %43, 1
  store i32 %44, ptr %1, align 4, !tbaa !5
  br label %32, !llvm.loop !14

45:                                               ; preds = %32
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %1) #3
  ret void
}

; Function Attrs: nounwind
declare void @srand(i32 noundef) #2

; Function Attrs: nounwind
declare i32 @rand() #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 = { 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" }
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

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

.preheader11:                                     ; preds = %0, %8
  %indvars.iv16 = phi i64 [ 0, %0 ], [ %indvars.iv.next17, %8 ]
  br label %1

1:                                                ; preds = %.preheader11, %1
  %indvars.iv = phi i64 [ 0, %.preheader11 ], [ %indvars.iv.next, %1 ]
  %2 = tail call i32 @rand() #2
  %3 = sitofp i32 %2 to double
  %4 = fmul double %3, 2.048000e+03
  %5 = fmul double %4, 0x3E00000000000000
  %6 = fadd double %5, 1.000000e+00
  %7 = getelementptr inbounds [2048 x [2048 x double]], ptr @pathDistanceMatrix, i64 0, i64 %indvars.iv16, i64 %indvars.iv
  store double %6, ptr %7, align 8, !tbaa !5
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next, 2048
  br i1 %exitcond.not, label %8, label %1, !llvm.loop !9

8:                                                ; preds = %1
  %indvars.iv.next17 = add nuw nsw i64 %indvars.iv16, 1
  %exitcond19.not = icmp eq i64 %indvars.iv.next17, 2048
  br i1 %exitcond19.not, label %.preheader, label %.preheader11, !llvm.loop !11

.preheader:                                       ; preds = %8, %.preheader
  %indvars.iv20 = phi i64 [ %indvars.iv.next21.3, %.preheader ], [ 0, %8 ]
  %9 = getelementptr inbounds [2048 x [2048 x double]], ptr @pathDistanceMatrix, i64 0, i64 %indvars.iv20, i64 %indvars.iv20
  store double 0.000000e+00, ptr %9, align 16, !tbaa !5
  %indvars.iv.next21 = or disjoint i64 %indvars.iv20, 1
  %10 = getelementptr inbounds [2048 x [2048 x double]], ptr @pathDistanceMatrix, i64 0, i64 %indvars.iv.next21, i64 %indvars.iv.next21
  store double 0.000000e+00, ptr %10, align 8, !tbaa !5
  %indvars.iv.next21.1 = or disjoint i64 %indvars.iv20, 2
  %11 = getelementptr inbounds [2048 x [2048 x double]], ptr @pathDistanceMatrix, i64 0, i64 %indvars.iv.next21.1, i64 %indvars.iv.next21.1
  store double 0.000000e+00, ptr %11, align 16, !tbaa !5
  %indvars.iv.next21.2 = or disjoint i64 %indvars.iv20, 3
  %12 = getelementptr inbounds [2048 x [2048 x double]], ptr @pathDistanceMatrix, i64 0, i64 %indvars.iv.next21.2, i64 %indvars.iv.next21.2
  store double 0.000000e+00, ptr %12, align 8, !tbaa !5
  %indvars.iv.next21.3 = add nuw nsw i64 %indvars.iv20, 4
  %exitcond23.not.3 = icmp eq i64 %indvars.iv.next21.3, 2048
  br i1 %exitcond23.not.3, label %13, label %.preheader, !llvm.loop !12

13:                                               ; preds = %.preheader
  ret void
}

; Function Attrs: nounwind
declare void @srand(i32 noundef) local_unnamed_addr #1

; Function Attrs: nounwind
declare i32 @rand() 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 = { 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" }
attributes #2 = { 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 = !{!"double", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}
!11 = distinct !{!11, !10}
!12 = distinct !{!12, !10}


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