; LLVM IR from bondhugula/pluto :: test (tss1)

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

@C = external dso_local global [2048 x [2061 x double]], align 16
@A = external dso_local global [2048 x [2061 x double]], align 16
@B = external dso_local global [2048 x [2061 x double]], align 16

; Function Attrs: nounwind uwtable
define dso_local i32 @main() #0 {
  %1 = alloca i32, align 4
  %2 = alloca i32, align 4
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = alloca double, align 8
  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 8, ptr %5) #3
  store i32 0, ptr %2, align 4, !tbaa !5
  br label %6

6:                                                ; preds = %60, %0
  %7 = load i32, ptr %2, align 4, !tbaa !5
  %8 = icmp slt i32 %7, 2048
  br i1 %8, label %9, label %63

9:                                                ; preds = %6
  store i32 0, ptr %3, align 4, !tbaa !5
  br label %10

10:                                               ; preds = %56, %9
  %11 = load i32, ptr %3, align 4, !tbaa !5
  %12 = icmp slt i32 %11, 2048
  br i1 %12, label %13, label %59

13:                                               ; preds = %10
  %14 = load i32, ptr %2, align 4, !tbaa !5
  %15 = sext i32 %14 to i64
  %16 = getelementptr inbounds [2048 x [2061 x double]], ptr @C, i64 0, i64 %15
  %17 = load i32, ptr %3, align 4, !tbaa !5
  %18 = sext i32 %17 to i64
  %19 = getelementptr inbounds [2061 x double], ptr %16, i64 0, i64 %18
  store double 0.000000e+00, ptr %19, align 8, !tbaa !9
  store i32 0, ptr %4, align 4, !tbaa !5
  br label %20

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

23:                                               ; preds = %20
  %24 = load i32, ptr %2, align 4, !tbaa !5
  %25 = sext i32 %24 to i64
  %26 = getelementptr inbounds [2048 x [2061 x double]], ptr @C, i64 0, i64 %25
  %27 = load i32, ptr %3, align 4, !tbaa !5
  %28 = sext i32 %27 to i64
  %29 = getelementptr inbounds [2061 x double], ptr %26, i64 0, i64 %28
  %30 = load double, ptr %29, align 8, !tbaa !9
  %31 = load i32, ptr %2, align 4, !tbaa !5
  %32 = sext i32 %31 to i64
  %33 = getelementptr inbounds [2048 x [2061 x double]], ptr @A, i64 0, i64 %32
  %34 = load i32, ptr %4, align 4, !tbaa !5
  %35 = sext i32 %34 to i64
  %36 = getelementptr inbounds [2061 x double], ptr %33, i64 0, i64 %35
  %37 = load double, ptr %36, align 8, !tbaa !9
  %38 = load i32, ptr %4, align 4, !tbaa !5
  %39 = sext i32 %38 to i64
  %40 = getelementptr inbounds [2048 x [2061 x double]], ptr @B, i64 0, i64 %39
  %41 = load i32, ptr %3, align 4, !tbaa !5
  %42 = sext i32 %41 to i64
  %43 = getelementptr inbounds [2061 x double], ptr %40, i64 0, i64 %42
  %44 = load double, ptr %43, align 8, !tbaa !9
  %45 = call double @llvm.fmuladd.f64(double %37, double %44, double %30)
  %46 = load i32, ptr %2, align 4, !tbaa !5
  %47 = sext i32 %46 to i64
  %48 = getelementptr inbounds [2048 x [2061 x double]], ptr @C, i64 0, i64 %47
  %49 = load i32, ptr %3, align 4, !tbaa !5
  %50 = sext i32 %49 to i64
  %51 = getelementptr inbounds [2061 x double], ptr %48, i64 0, i64 %50
  store double %45, ptr %51, align 8, !tbaa !9
  br label %52

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

55:                                               ; preds = %20
  br label %56

56:                                               ; preds = %55
  %57 = load i32, ptr %3, align 4, !tbaa !5
  %58 = add nsw i32 %57, 1
  store i32 %58, ptr %3, align 4, !tbaa !5
  br label %10, !llvm.loop !13

59:                                               ; preds = %10
  br label %60

60:                                               ; preds = %59
  %61 = load i32, ptr %2, align 4, !tbaa !5
  %62 = add nsw i32 %61, 1
  store i32 %62, ptr %2, align 4, !tbaa !5
  br label %6, !llvm.loop !14

63:                                               ; preds = %6
  call void @llvm.lifetime.end.p0(i64 8, 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
}

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #1

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare double @llvm.fmuladd.f64(double, double, double) #2

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
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"

@C = external dso_local local_unnamed_addr global [2048 x [2061 x double]], align 16
@A = external dso_local local_unnamed_addr global [2048 x [2061 x double]], align 16
@B = external dso_local local_unnamed_addr global [2048 x [2061 x double]], align 16

; Function Attrs: nofree norecurse nosync nounwind memory(readwrite, argmem: none, inaccessiblemem: none) uwtable
define dso_local noundef i32 @main() local_unnamed_addr #0 {
  br label %.preheader

.preheader:                                       ; preds = %0, %16
  %indvars.iv26 = phi i64 [ 0, %0 ], [ %indvars.iv.next27, %16 ]
  br label %1

1:                                                ; preds = %.preheader, %15
  %indvars.iv22 = phi i64 [ 0, %.preheader ], [ %indvars.iv.next23, %15 ]
  %2 = getelementptr inbounds [2048 x [2061 x double]], ptr @C, i64 0, i64 %indvars.iv26, i64 %indvars.iv22
  br label %3

3:                                                ; preds = %3, %1
  %indvars.iv = phi i64 [ 0, %1 ], [ %indvars.iv.next.1, %3 ]
  %4 = phi double [ 0.000000e+00, %1 ], [ %14, %3 ]
  %5 = getelementptr inbounds [2048 x [2061 x double]], ptr @A, i64 0, i64 %indvars.iv26, i64 %indvars.iv
  %6 = load double, ptr %5, align 8, !tbaa !5
  %7 = getelementptr inbounds [2048 x [2061 x double]], ptr @B, i64 0, i64 %indvars.iv, i64 %indvars.iv22
  %8 = load double, ptr %7, align 8, !tbaa !5
  %9 = tail call double @llvm.fmuladd.f64(double %6, double %8, double %4)
  %indvars.iv.next = or disjoint i64 %indvars.iv, 1
  %10 = getelementptr inbounds [2048 x [2061 x double]], ptr @A, i64 0, i64 %indvars.iv26, i64 %indvars.iv.next
  %11 = load double, ptr %10, align 8, !tbaa !5
  %12 = getelementptr inbounds [2048 x [2061 x double]], ptr @B, i64 0, i64 %indvars.iv.next, i64 %indvars.iv22
  %13 = load double, ptr %12, align 8, !tbaa !5
  %14 = tail call double @llvm.fmuladd.f64(double %11, double %13, double %9)
  %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 %15, label %3, !llvm.loop !9

15:                                               ; preds = %3
  store double %14, ptr %2, align 8, !tbaa !5
  %indvars.iv.next23 = add nuw nsw i64 %indvars.iv22, 1
  %exitcond25.not = icmp eq i64 %indvars.iv.next23, 2048
  br i1 %exitcond25.not, label %16, label %1, !llvm.loop !11

16:                                               ; preds = %15
  %indvars.iv.next27 = add nuw nsw i64 %indvars.iv26, 1
  %exitcond29.not = icmp eq i64 %indvars.iv.next27, 2048
  br i1 %exitcond29.not, label %17, label %.preheader, !llvm.loop !12

17:                                               ; preds = %16
  ret i32 0
}

; Function Attrs: mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare double @llvm.fmuladd.f64(double, double, double) #1

attributes #0 = { nofree norecurse nosync nounwind memory(readwrite, argmem: none, inaccessiblemem: none) 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 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }

!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: DSEPass,EarlyCSEPass,GVNPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,LCSSAPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass