; LLVM IR from bondhugula/pluto :: examples/tce (tce-4index-transform)

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

@A = external dso_local global [55 x [55 x [55 x [55 x double]]]], align 16

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

5:                                                ; preds = %49, %0
  %6 = load i32, ptr %1, align 4, !tbaa !5
  %7 = icmp slt i32 %6, 55
  br i1 %7, label %8, label %52

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

9:                                                ; preds = %45, %8
  %10 = load i32, ptr %2, align 4, !tbaa !5
  %11 = icmp slt i32 %10, 55
  br i1 %11, label %12, label %48

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

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

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

17:                                               ; preds = %37, %16
  %18 = load i32, ptr %4, align 4, !tbaa !5
  %19 = icmp slt i32 %18, 55
  br i1 %19, label %20, label %40

20:                                               ; preds = %17
  %21 = load i32, ptr %3, align 4, !tbaa !5
  %22 = sitofp i32 %21 to double
  %23 = fdiv double %22, 5.500000e+01
  %24 = fadd double 1.000000e+00, %23
  %25 = load i32, ptr %1, align 4, !tbaa !5
  %26 = sext i32 %25 to i64
  %27 = getelementptr inbounds [55 x [55 x [55 x [55 x double]]]], ptr @A, i64 0, i64 %26
  %28 = load i32, ptr %2, align 4, !tbaa !5
  %29 = sext i32 %28 to i64
  %30 = getelementptr inbounds [55 x [55 x [55 x double]]], ptr %27, i64 0, i64 %29
  %31 = load i32, ptr %3, align 4, !tbaa !5
  %32 = sext i32 %31 to i64
  %33 = getelementptr inbounds [55 x [55 x double]], ptr %30, i64 0, i64 %32
  %34 = load i32, ptr %4, align 4, !tbaa !5
  %35 = sext i32 %34 to i64
  %36 = getelementptr inbounds [55 x double], ptr %33, i64 0, i64 %35
  store double %24, ptr %36, align 8, !tbaa !9
  br label %37

37:                                               ; preds = %20
  %38 = load i32, ptr %4, align 4, !tbaa !5
  %39 = add nsw i32 %38, 1
  store i32 %39, ptr %4, align 4, !tbaa !5
  br label %17, !llvm.loop !11

40:                                               ; preds = %17
  br label %41

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

44:                                               ; preds = %13
  br label %45

45:                                               ; preds = %44
  %46 = load i32, ptr %2, align 4, !tbaa !5
  %47 = add nsw i32 %46, 1
  store i32 %47, ptr %2, align 4, !tbaa !5
  br label %9, !llvm.loop !14

48:                                               ; preds = %9
  br label %49

49:                                               ; preds = %48
  %50 = load i32, ptr %1, align 4, !tbaa !5
  %51 = add nsw i32 %50, 1
  store i32 %51, ptr %1, align 4, !tbaa !5
  br label %5, !llvm.loop !15

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

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

@A = external dso_local local_unnamed_addr global [55 x [55 x [55 x [55 x double]]]], align 16

; Function Attrs: nofree norecurse nosync nounwind memory(write, argmem: none, inaccessiblemem: none) uwtable
define dso_local void @init_array() local_unnamed_addr #0 {
  br label %.preheader17

.preheader17:                                     ; preds = %0, %24
  %indvars.iv28 = phi i64 [ 0, %0 ], [ %indvars.iv.next29, %24 ]
  br label %.preheader16

.preheader16:                                     ; preds = %.preheader17, %23
  %indvars.iv24 = phi i64 [ 0, %.preheader17 ], [ %indvars.iv.next25, %23 ]
  br label %.preheader

.preheader:                                       ; preds = %.preheader16, %.preheader
  %indvars.iv = phi i64 [ 0, %.preheader16 ], [ %indvars.iv.next, %.preheader ]
  %1 = trunc nuw nsw i64 %indvars.iv to i32
  %2 = uitofp nneg i32 %1 to double
  %3 = fdiv double %2, 5.500000e+01
  %4 = fadd double %3, 1.000000e+00
  %5 = getelementptr inbounds [55 x [55 x [55 x [55 x double]]]], ptr @A, i64 0, i64 %indvars.iv28, i64 %indvars.iv24, i64 %indvars.iv, i64 0
  %6 = insertelement <4 x double> poison, double %4, i64 0
  %7 = shufflevector <4 x double> %6, <4 x double> poison, <4 x i32> zeroinitializer
  store <4 x double> %7, ptr %5, align 8, !tbaa !5
  %8 = getelementptr inbounds [55 x [55 x [55 x [55 x double]]]], ptr @A, i64 0, i64 %indvars.iv28, i64 %indvars.iv24, i64 %indvars.iv, i64 4
  store <4 x double> %7, ptr %8, align 8, !tbaa !5
  %9 = getelementptr inbounds [55 x [55 x [55 x [55 x double]]]], ptr @A, i64 0, i64 %indvars.iv28, i64 %indvars.iv24, i64 %indvars.iv, i64 8
  store <4 x double> %7, ptr %9, align 8, !tbaa !5
  %10 = getelementptr inbounds [55 x [55 x [55 x [55 x double]]]], ptr @A, i64 0, i64 %indvars.iv28, i64 %indvars.iv24, i64 %indvars.iv, i64 12
  store <4 x double> %7, ptr %10, align 8, !tbaa !5
  %11 = getelementptr inbounds [55 x [55 x [55 x [55 x double]]]], ptr @A, i64 0, i64 %indvars.iv28, i64 %indvars.iv24, i64 %indvars.iv, i64 16
  store <4 x double> %7, ptr %11, align 8, !tbaa !5
  %12 = getelementptr inbounds [55 x [55 x [55 x [55 x double]]]], ptr @A, i64 0, i64 %indvars.iv28, i64 %indvars.iv24, i64 %indvars.iv, i64 20
  store <4 x double> %7, ptr %12, align 8, !tbaa !5
  %13 = getelementptr inbounds [55 x [55 x [55 x [55 x double]]]], ptr @A, i64 0, i64 %indvars.iv28, i64 %indvars.iv24, i64 %indvars.iv, i64 24
  store <4 x double> %7, ptr %13, align 8, !tbaa !5
  %14 = getelementptr inbounds [55 x [55 x [55 x [55 x double]]]], ptr @A, i64 0, i64 %indvars.iv28, i64 %indvars.iv24, i64 %indvars.iv, i64 28
  store <4 x double> %7, ptr %14, align 8, !tbaa !5
  %15 = getelementptr inbounds [55 x [55 x [55 x [55 x double]]]], ptr @A, i64 0, i64 %indvars.iv28, i64 %indvars.iv24, i64 %indvars.iv, i64 32
  store <4 x double> %7, ptr %15, align 8, !tbaa !5
  %16 = getelementptr inbounds [55 x [55 x [55 x [55 x double]]]], ptr @A, i64 0, i64 %indvars.iv28, i64 %indvars.iv24, i64 %indvars.iv, i64 36
  store <4 x double> %7, ptr %16, align 8, !tbaa !5
  %17 = getelementptr inbounds [55 x [55 x [55 x [55 x double]]]], ptr @A, i64 0, i64 %indvars.iv28, i64 %indvars.iv24, i64 %indvars.iv, i64 40
  store <4 x double> %7, ptr %17, align 8, !tbaa !5
  %18 = getelementptr inbounds [55 x [55 x [55 x [55 x double]]]], ptr @A, i64 0, i64 %indvars.iv28, i64 %indvars.iv24, i64 %indvars.iv, i64 44
  store <4 x double> %7, ptr %18, align 8, !tbaa !5
  %19 = getelementptr inbounds [55 x [55 x [55 x [55 x double]]]], ptr @A, i64 0, i64 %indvars.iv28, i64 %indvars.iv24, i64 %indvars.iv, i64 48
  store <4 x double> %7, ptr %19, align 8, !tbaa !5
  %20 = getelementptr inbounds [55 x [55 x [55 x [55 x double]]]], ptr @A, i64 0, i64 %indvars.iv28, i64 %indvars.iv24, i64 %indvars.iv, i64 52
  store double %4, ptr %20, align 8, !tbaa !5
  %21 = getelementptr inbounds [55 x [55 x [55 x [55 x double]]]], ptr @A, i64 0, i64 %indvars.iv28, i64 %indvars.iv24, i64 %indvars.iv, i64 53
  store double %4, ptr %21, align 8, !tbaa !5
  %22 = getelementptr inbounds [55 x [55 x [55 x [55 x double]]]], ptr @A, i64 0, i64 %indvars.iv28, i64 %indvars.iv24, i64 %indvars.iv, i64 54
  store double %4, ptr %22, align 8, !tbaa !5
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next, 55
  br i1 %exitcond.not, label %23, label %.preheader, !llvm.loop !9

23:                                               ; preds = %.preheader
  %indvars.iv.next25 = add nuw nsw i64 %indvars.iv24, 1
  %exitcond27.not = icmp eq i64 %indvars.iv.next25, 55
  br i1 %exitcond27.not, label %24, label %.preheader16, !llvm.loop !11

24:                                               ; preds = %23
  %indvars.iv.next29 = add nuw nsw i64 %indvars.iv28, 1
  %exitcond31.not = icmp eq i64 %indvars.iv.next29, 55
  br i1 %exitcond31.not, label %25, label %.preheader17, !llvm.loop !12

25:                                               ; preds = %24
  ret void
}

attributes #0 = { nofree norecurse nosync nounwind memory(write, 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" }

!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: GVNPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,LICMPass,LoopRotatePass,LoopSimplifyPass,PostOrderFunctionAttrsPass,SLPVectorizerPass,SROAPass,SimplifyCFGPass