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

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

@y_1 = external dso_local global [10017 x double], align 16
@y_2 = external dso_local global [10019 x double], align 16
@x1 = external dso_local global [10023 x double], align 16
@x2 = external dso_local global [10031 x double], align 16
@a = external dso_local global [10000 x [10000 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 speculatable willreturn memory(none)
declare double @llvm.fmuladd.f64(double, double, double) #1

; 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() #2

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

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

9:                                                ; preds = %40, %0
  %10 = load i32, ptr %2, align 4, !tbaa !5
  %11 = icmp slt i32 %10, 10000
  br i1 %11, label %12, label %43

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

13:                                               ; preds = %36, %12
  %14 = load i32, ptr %3, align 4, !tbaa !5
  %15 = icmp slt i32 %14, 10000
  br i1 %15, label %16, label %39

16:                                               ; preds = %13
  %17 = load i32, ptr %2, align 4, !tbaa !5
  %18 = sext i32 %17 to i64
  %19 = getelementptr inbounds [10023 x double], ptr @x1, i64 0, i64 %18
  %20 = load double, ptr %19, align 8, !tbaa !9
  %21 = load i32, ptr %2, align 4, !tbaa !5
  %22 = sext i32 %21 to i64
  %23 = getelementptr inbounds [10000 x [10000 x double]], ptr @a, i64 0, i64 %22
  %24 = load i32, ptr %3, align 4, !tbaa !5
  %25 = sext i32 %24 to i64
  %26 = getelementptr inbounds [10000 x double], ptr %23, i64 0, i64 %25
  %27 = load double, ptr %26, align 8, !tbaa !9
  %28 = load i32, ptr %3, align 4, !tbaa !5
  %29 = sext i32 %28 to i64
  %30 = getelementptr inbounds [10017 x double], ptr @y_1, i64 0, i64 %29
  %31 = load double, ptr %30, align 8, !tbaa !9
  %32 = call double @llvm.fmuladd.f64(double %27, double %31, double %20)
  %33 = load i32, ptr %2, align 4, !tbaa !5
  %34 = sext i32 %33 to i64
  %35 = getelementptr inbounds [10023 x double], ptr @x1, i64 0, i64 %34
  store double %32, ptr %35, align 8, !tbaa !9
  br label %36

36:                                               ; preds = %16
  %37 = load i32, ptr %3, align 4, !tbaa !5
  %38 = add nsw i32 %37, 1
  store i32 %38, ptr %3, align 4, !tbaa !5
  br label %13, !llvm.loop !11

39:                                               ; preds = %13
  br label %40

40:                                               ; preds = %39
  %41 = load i32, ptr %2, align 4, !tbaa !5
  %42 = add nsw i32 %41, 1
  store i32 %42, ptr %2, align 4, !tbaa !5
  br label %9, !llvm.loop !13

43:                                               ; preds = %9
  store i32 0, ptr %2, align 4, !tbaa !5
  br label %44

44:                                               ; preds = %75, %43
  %45 = load i32, ptr %2, align 4, !tbaa !5
  %46 = icmp slt i32 %45, 10000
  br i1 %46, label %47, label %78

47:                                               ; preds = %44
  store i32 0, ptr %3, align 4, !tbaa !5
  br label %48

48:                                               ; preds = %71, %47
  %49 = load i32, ptr %3, align 4, !tbaa !5
  %50 = icmp slt i32 %49, 10000
  br i1 %50, label %51, label %74

51:                                               ; preds = %48
  %52 = load i32, ptr %2, align 4, !tbaa !5
  %53 = sext i32 %52 to i64
  %54 = getelementptr inbounds [10031 x double], ptr @x2, i64 0, i64 %53
  %55 = load double, ptr %54, align 8, !tbaa !9
  %56 = load i32, ptr %3, align 4, !tbaa !5
  %57 = sext i32 %56 to i64
  %58 = getelementptr inbounds [10000 x [10000 x double]], ptr @a, i64 0, i64 %57
  %59 = load i32, ptr %2, align 4, !tbaa !5
  %60 = sext i32 %59 to i64
  %61 = getelementptr inbounds [10000 x double], ptr %58, i64 0, i64 %60
  %62 = load double, ptr %61, align 8, !tbaa !9
  %63 = load i32, ptr %3, align 4, !tbaa !5
  %64 = sext i32 %63 to i64
  %65 = getelementptr inbounds [10019 x double], ptr @y_2, i64 0, i64 %64
  %66 = load double, ptr %65, align 8, !tbaa !9
  %67 = call double @llvm.fmuladd.f64(double %62, double %66, double %55)
  %68 = load i32, ptr %2, align 4, !tbaa !5
  %69 = sext i32 %68 to i64
  %70 = getelementptr inbounds [10031 x double], ptr @x2, i64 0, i64 %69
  store double %67, ptr %70, align 8, !tbaa !9
  br label %71

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

74:                                               ; preds = %48
  br label %75

75:                                               ; preds = %74
  %76 = load i32, ptr %2, align 4, !tbaa !5
  %77 = add nsw i32 %76, 1
  store i32 %77, ptr %2, align 4, !tbaa !5
  br label %44, !llvm.loop !15

78:                                               ; preds = %44
  %79 = call noalias ptr @fopen(ptr noundef @.str.3, ptr noundef @.str.4)
  %80 = icmp ne ptr %79, null
  br i1 %80, label %81, label %82

81:                                               ; preds = %78
  call void @print_array()
  br label %82

82:                                               ; preds = %81, %78
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #4
  ret i32 0
}

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

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #2 = { 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 #3 = { "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 #4 = { 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}
!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"

@y_1 = external dso_local local_unnamed_addr global [10017 x double], align 16
@y_2 = external dso_local local_unnamed_addr global [10019 x double], align 16
@x1 = external dso_local local_unnamed_addr global [10023 x double], align 16
@x2 = external dso_local local_unnamed_addr global [10031 x double], align 16
@a = external dso_local local_unnamed_addr global [10000 x [10000 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: mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare double @llvm.fmuladd.f64(double, double, double) #0

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

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

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

.preheader21:                                     ; preds = %0, %24
  %indvars.iv30 = phi i64 [ 0, %0 ], [ %indvars.iv.next31, %24 ]
  %1 = getelementptr inbounds [10023 x double], ptr @x1, i64 0, i64 %indvars.iv30
  %.promoted = load double, ptr %1, align 8, !tbaa !5
  br label %2

2:                                                ; preds = %2, %.preheader21
  %indvars.iv = phi i64 [ 0, %.preheader21 ], [ %indvars.iv.next.3, %2 ]
  %3 = phi double [ %.promoted, %.preheader21 ], [ %23, %2 ]
  %4 = getelementptr inbounds [10000 x [10000 x double]], ptr @a, i64 0, i64 %indvars.iv30, i64 %indvars.iv
  %5 = load double, ptr %4, align 16, !tbaa !5
  %6 = getelementptr inbounds [10017 x double], ptr @y_1, i64 0, i64 %indvars.iv
  %7 = load double, ptr %6, align 16, !tbaa !5
  %8 = tail call double @llvm.fmuladd.f64(double %5, double %7, double %3)
  %indvars.iv.next = or disjoint i64 %indvars.iv, 1
  %9 = getelementptr inbounds [10000 x [10000 x double]], ptr @a, i64 0, i64 %indvars.iv30, i64 %indvars.iv.next
  %10 = load double, ptr %9, align 8, !tbaa !5
  %11 = getelementptr inbounds [10017 x double], ptr @y_1, i64 0, i64 %indvars.iv.next
  %12 = load double, ptr %11, align 8, !tbaa !5
  %13 = tail call double @llvm.fmuladd.f64(double %10, double %12, double %8)
  %indvars.iv.next.1 = or disjoint i64 %indvars.iv, 2
  %14 = getelementptr inbounds [10000 x [10000 x double]], ptr @a, i64 0, i64 %indvars.iv30, i64 %indvars.iv.next.1
  %15 = load double, ptr %14, align 16, !tbaa !5
  %16 = getelementptr inbounds [10017 x double], ptr @y_1, i64 0, i64 %indvars.iv.next.1
  %17 = load double, ptr %16, align 16, !tbaa !5
  %18 = tail call double @llvm.fmuladd.f64(double %15, double %17, double %13)
  %indvars.iv.next.2 = or disjoint i64 %indvars.iv, 3
  %19 = getelementptr inbounds [10000 x [10000 x double]], ptr @a, i64 0, i64 %indvars.iv30, i64 %indvars.iv.next.2
  %20 = load double, ptr %19, align 8, !tbaa !5
  %21 = getelementptr inbounds [10017 x double], ptr @y_1, i64 0, i64 %indvars.iv.next.2
  %22 = load double, ptr %21, align 8, !tbaa !5
  %23 = tail call double @llvm.fmuladd.f64(double %20, double %22, double %18)
  %indvars.iv.next.3 = add nuw nsw i64 %indvars.iv, 4
  %exitcond.not.3 = icmp eq i64 %indvars.iv.next.3, 10000
  br i1 %exitcond.not.3, label %24, label %2, !llvm.loop !9

24:                                               ; preds = %2
  store double %23, ptr %1, align 8, !tbaa !5
  %indvars.iv.next31 = add nuw nsw i64 %indvars.iv30, 1
  %exitcond33.not = icmp eq i64 %indvars.iv.next31, 10000
  br i1 %exitcond33.not, label %.preheader, label %.preheader21, !llvm.loop !11

.preheader:                                       ; preds = %24, %48
  %indvars.iv38 = phi i64 [ %indvars.iv.next39, %48 ], [ 0, %24 ]
  %25 = getelementptr inbounds [10031 x double], ptr @x2, i64 0, i64 %indvars.iv38
  %.promoted24 = load double, ptr %25, align 8, !tbaa !5
  br label %26

26:                                               ; preds = %26, %.preheader
  %indvars.iv34 = phi i64 [ 0, %.preheader ], [ %indvars.iv.next35.3, %26 ]
  %27 = phi double [ %.promoted24, %.preheader ], [ %47, %26 ]
  %28 = getelementptr inbounds [10000 x [10000 x double]], ptr @a, i64 0, i64 %indvars.iv34, i64 %indvars.iv38
  %29 = load double, ptr %28, align 8, !tbaa !5
  %30 = getelementptr inbounds [10019 x double], ptr @y_2, i64 0, i64 %indvars.iv34
  %31 = load double, ptr %30, align 16, !tbaa !5
  %32 = tail call double @llvm.fmuladd.f64(double %29, double %31, double %27)
  %indvars.iv.next35 = or disjoint i64 %indvars.iv34, 1
  %33 = getelementptr inbounds [10000 x [10000 x double]], ptr @a, i64 0, i64 %indvars.iv.next35, i64 %indvars.iv38
  %34 = load double, ptr %33, align 8, !tbaa !5
  %35 = getelementptr inbounds [10019 x double], ptr @y_2, i64 0, i64 %indvars.iv.next35
  %36 = load double, ptr %35, align 8, !tbaa !5
  %37 = tail call double @llvm.fmuladd.f64(double %34, double %36, double %32)
  %indvars.iv.next35.1 = or disjoint i64 %indvars.iv34, 2
  %38 = getelementptr inbounds [10000 x [10000 x double]], ptr @a, i64 0, i64 %indvars.iv.next35.1, i64 %indvars.iv38
  %39 = load double, ptr %38, align 8, !tbaa !5
  %40 = getelementptr inbounds [10019 x double], ptr @y_2, i64 0, i64 %indvars.iv.next35.1
  %41 = load double, ptr %40, align 16, !tbaa !5
  %42 = tail call double @llvm.fmuladd.f64(double %39, double %41, double %37)
  %indvars.iv.next35.2 = or disjoint i64 %indvars.iv34, 3
  %43 = getelementptr inbounds [10000 x [10000 x double]], ptr @a, i64 0, i64 %indvars.iv.next35.2, i64 %indvars.iv38
  %44 = load double, ptr %43, align 8, !tbaa !5
  %45 = getelementptr inbounds [10019 x double], ptr @y_2, i64 0, i64 %indvars.iv.next35.2
  %46 = load double, ptr %45, align 8, !tbaa !5
  %47 = tail call double @llvm.fmuladd.f64(double %44, double %46, double %42)
  %indvars.iv.next35.3 = add nuw nsw i64 %indvars.iv34, 4
  %exitcond37.not.3 = icmp eq i64 %indvars.iv.next35.3, 10000
  br i1 %exitcond37.not.3, label %48, label %26, !llvm.loop !12

48:                                               ; preds = %26
  store double %47, ptr %25, align 8, !tbaa !5
  %indvars.iv.next39 = add nuw nsw i64 %indvars.iv38, 1
  %exitcond41.not = icmp eq i64 %indvars.iv.next39, 10000
  br i1 %exitcond41.not, label %49, label %.preheader, !llvm.loop !13

49:                                               ; preds = %48
  %50 = tail call noalias ptr @fopen(ptr noundef nonnull @.str.3, ptr noundef nonnull @.str.4)
  %.not = icmp eq ptr %50, null
  br i1 %.not, label %52, label %51

51:                                               ; preds = %49
  tail call void @print_array()
  br label %52

52:                                               ; preds = %51, %49
  ret i32 0
}

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

attributes #0 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }
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 = { 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 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}
!11 = distinct !{!11, !10}
!12 = distinct !{!12, !10}
!13 = distinct !{!13, !10}


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