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

@stdout = external global ptr, align 8
@.str = external hidden unnamed_addr constant [5 x i8], align 1
@B = external dso_local global [55 x [55 x [55 x [55 x double]]]], align 16
@.str.1 = 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
define dso_local void @print_array() #1 {
  %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) #3
  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
  store i32 0, ptr %1, align 4, !tbaa !5
  br label %5

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

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

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

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

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

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

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

20:                                               ; preds = %17
  %21 = load ptr, ptr @stdout, align 8, !tbaa !9
  %22 = load i32, ptr %1, align 4, !tbaa !5
  %23 = sext i32 %22 to i64
  %24 = getelementptr inbounds [55 x [55 x [55 x [55 x double]]]], ptr @B, i64 0, i64 %23
  %25 = load i32, ptr %2, align 4, !tbaa !5
  %26 = sext i32 %25 to i64
  %27 = getelementptr inbounds [55 x [55 x [55 x double]]], ptr %24, i64 0, i64 %26
  %28 = load i32, ptr %3, align 4, !tbaa !5
  %29 = sext i32 %28 to i64
  %30 = getelementptr inbounds [55 x [55 x double]], ptr %27, i64 0, i64 %29
  %31 = load i32, ptr %4, align 4, !tbaa !5
  %32 = sext i32 %31 to i64
  %33 = getelementptr inbounds [55 x double], ptr %30, i64 0, i64 %32
  %34 = load double, ptr %33, align 8, !tbaa !11
  %35 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %21, ptr noundef @.str, double noundef %34) #3
  br label %36

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

39:                                               ; preds = %17
  br label %40

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

43:                                               ; preds = %13
  br label %44

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

47:                                               ; preds = %9
  br label %48

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

51:                                               ; preds = %5
  %52 = load ptr, ptr @stdout, align 8, !tbaa !9
  %53 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %52, ptr noundef @.str.1) #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
  call void @llvm.lifetime.end.p0(i64 4, ptr %1) #3
  ret void
}

; Function Attrs: nounwind
declare i32 @fprintf(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 = { 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 = !{!"any pointer", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"double", !7, i64 0}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}
!15 = distinct !{!15, !14}
!16 = distinct !{!16, !14}
!17 = distinct !{!17, !14}


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

@stdout = external local_unnamed_addr global ptr, align 8
@.str = external hidden unnamed_addr constant [5 x i8], align 1
@B = external dso_local local_unnamed_addr global [55 x [55 x [55 x [55 x double]]]], align 16
@.str.1 = external hidden unnamed_addr constant [2 x i8], align 1

; Function Attrs: nofree nounwind uwtable
define dso_local void @print_array() local_unnamed_addr #0 {
  br label %.preheader16

.preheader16:                                     ; preds = %0, %8
  %indvars.iv30 = phi i64 [ 0, %0 ], [ %indvars.iv.next31, %8 ]
  br label %.preheader15

.preheader15:                                     ; preds = %.preheader16, %7
  %indvars.iv26 = phi i64 [ 0, %.preheader16 ], [ %indvars.iv.next27, %7 ]
  br label %.preheader

.preheader:                                       ; preds = %.preheader15, %6
  %indvars.iv22 = phi i64 [ 0, %.preheader15 ], [ %indvars.iv.next23, %6 ]
  br label %1

1:                                                ; preds = %.preheader, %1
  %indvars.iv = phi i64 [ 0, %.preheader ], [ %indvars.iv.next, %1 ]
  %2 = load ptr, ptr @stdout, align 8, !tbaa !5
  %3 = getelementptr inbounds [55 x [55 x [55 x [55 x double]]]], ptr @B, i64 0, i64 %indvars.iv30, i64 %indvars.iv26, i64 %indvars.iv22, i64 %indvars.iv
  %4 = load double, ptr %3, align 8, !tbaa !9
  %5 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %2, ptr noundef nonnull @.str, double noundef %4) #2
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next, 55
  br i1 %exitcond.not, label %6, label %1, !llvm.loop !11

6:                                                ; preds = %1
  %indvars.iv.next23 = add nuw nsw i64 %indvars.iv22, 1
  %exitcond25.not = icmp eq i64 %indvars.iv.next23, 55
  br i1 %exitcond25.not, label %7, label %.preheader, !llvm.loop !13

7:                                                ; preds = %6
  %indvars.iv.next27 = add nuw nsw i64 %indvars.iv26, 1
  %exitcond29.not = icmp eq i64 %indvars.iv.next27, 55
  br i1 %exitcond29.not, label %8, label %.preheader15, !llvm.loop !14

8:                                                ; preds = %7
  %indvars.iv.next31 = add nuw nsw i64 %indvars.iv30, 1
  %exitcond33.not = icmp eq i64 %indvars.iv.next31, 55
  br i1 %exitcond33.not, label %9, label %.preheader16, !llvm.loop !15

9:                                                ; preds = %8
  %10 = load ptr, ptr @stdout, align 8, !tbaa !5
  %11 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %10, ptr noundef nonnull @.str.1) #2
  ret void
}

; Function Attrs: nofree nounwind
declare noundef i32 @fprintf(ptr nocapture noundef, ptr nocapture noundef readonly, ...) local_unnamed_addr #1

attributes #0 = { nofree 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" }
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 = !{!"any pointer", !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}


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