; LLVM IR from bondhugula/pluto :: test (heat-3d-imperfect)

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

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

9:                                                ; preds = %52, %2
  %10 = load i32, ptr %6, align 4, !tbaa !9
  %11 = sext i32 %10 to i64
  %12 = icmp slt i64 %11, 152
  br i1 %12, label %13, label %55

13:                                               ; preds = %9
  store i32 0, ptr %7, align 4, !tbaa !9
  br label %14

14:                                               ; preds = %48, %13
  %15 = load i32, ptr %7, align 4, !tbaa !9
  %16 = sext i32 %15 to i64
  %17 = icmp slt i64 %16, 152
  br i1 %17, label %18, label %51

18:                                               ; preds = %14
  store i32 0, ptr %8, align 4, !tbaa !9
  br label %19

19:                                               ; preds = %44, %18
  %20 = load i32, ptr %8, align 4, !tbaa !9
  %21 = sext i32 %20 to i64
  %22 = icmp slt i64 %21, 152
  br i1 %22, label %23, label %47

23:                                               ; preds = %19
  %24 = load ptr, ptr %3, align 8, !tbaa !5
  %25 = load i32, ptr %6, align 4, !tbaa !9
  %26 = sext i32 %25 to i64
  %27 = getelementptr inbounds [152 x [152 x double]], ptr %24, i64 %26
  %28 = load i32, ptr %7, align 4, !tbaa !9
  %29 = sext i32 %28 to i64
  %30 = getelementptr inbounds [152 x [152 x double]], ptr %27, i64 0, i64 %29
  %31 = load i32, ptr %8, align 4, !tbaa !9
  %32 = sext i32 %31 to i64
  %33 = getelementptr inbounds [152 x double], ptr %30, i64 0, i64 %32
  store double 0.000000e+00, ptr %33, align 8, !tbaa !11
  %34 = load ptr, ptr %4, align 8, !tbaa !5
  %35 = load i32, ptr %6, align 4, !tbaa !9
  %36 = sext i32 %35 to i64
  %37 = getelementptr inbounds [152 x [152 x double]], ptr %34, i64 %36
  %38 = load i32, ptr %7, align 4, !tbaa !9
  %39 = sext i32 %38 to i64
  %40 = getelementptr inbounds [152 x [152 x double]], ptr %37, i64 0, i64 %39
  %41 = load i32, ptr %8, align 4, !tbaa !9
  %42 = sext i32 %41 to i64
  %43 = getelementptr inbounds [152 x double], ptr %40, i64 0, i64 %42
  store double 0.000000e+00, ptr %43, align 8, !tbaa !11
  br label %44

44:                                               ; preds = %23
  %45 = load i32, ptr %8, align 4, !tbaa !9
  %46 = add nsw i32 %45, 1
  store i32 %46, ptr %8, align 4, !tbaa !9
  br label %19, !llvm.loop !13

47:                                               ; preds = %19
  br label %48

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

51:                                               ; preds = %14
  br label %52

52:                                               ; preds = %51
  %53 = load i32, ptr %6, align 4, !tbaa !9
  %54 = add nsw i32 %53, 1
  store i32 %54, ptr %6, align 4, !tbaa !9
  br label %9, !llvm.loop !16

55:                                               ; preds = %9
  store i32 1, ptr %6, align 4, !tbaa !9
  br label %56

56:                                               ; preds = %93, %55
  %57 = load i32, ptr %6, align 4, !tbaa !9
  %58 = sext i32 %57 to i64
  %59 = icmp slt i64 %58, 151
  br i1 %59, label %60, label %96

60:                                               ; preds = %56
  store i32 1, ptr %7, align 4, !tbaa !9
  br label %61

61:                                               ; preds = %89, %60
  %62 = load i32, ptr %7, align 4, !tbaa !9
  %63 = sext i32 %62 to i64
  %64 = icmp slt i64 %63, 151
  br i1 %64, label %65, label %92

65:                                               ; preds = %61
  store i32 0, ptr %8, align 4, !tbaa !9
  br label %66

66:                                               ; preds = %85, %65
  %67 = load i32, ptr %8, align 4, !tbaa !9
  %68 = sext i32 %67 to i64
  %69 = icmp slt i64 %68, 152
  br i1 %69, label %70, label %88

70:                                               ; preds = %66
  %71 = call i32 @rand() #3
  %72 = srem i32 %71, 1024
  %73 = sitofp i32 %72 to double
  %74 = fmul double 1.000000e+00, %73
  %75 = load ptr, ptr %3, align 8, !tbaa !5
  %76 = load i32, ptr %6, align 4, !tbaa !9
  %77 = sext i32 %76 to i64
  %78 = getelementptr inbounds [152 x [152 x double]], ptr %75, i64 %77
  %79 = load i32, ptr %7, align 4, !tbaa !9
  %80 = sext i32 %79 to i64
  %81 = getelementptr inbounds [152 x [152 x double]], ptr %78, i64 0, i64 %80
  %82 = load i32, ptr %8, align 4, !tbaa !9
  %83 = sext i32 %82 to i64
  %84 = getelementptr inbounds [152 x double], ptr %81, i64 0, i64 %83
  store double %74, ptr %84, align 8, !tbaa !11
  br label %85

85:                                               ; preds = %70
  %86 = load i32, ptr %8, align 4, !tbaa !9
  %87 = add nsw i32 %86, 1
  store i32 %87, ptr %8, align 4, !tbaa !9
  br label %66, !llvm.loop !17

88:                                               ; preds = %66
  br label %89

89:                                               ; preds = %88
  %90 = load i32, ptr %7, align 4, !tbaa !9
  %91 = add nsw i32 %90, 1
  store i32 %91, ptr %7, align 4, !tbaa !9
  br label %61, !llvm.loop !18

92:                                               ; preds = %61
  br label %93

93:                                               ; preds = %92
  %94 = load i32, ptr %6, align 4, !tbaa !9
  %95 = add nsw i32 %94, 1
  store i32 %95, ptr %6, align 4, !tbaa !9
  br label %56, !llvm.loop !19

96:                                               ; preds = %56
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #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 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !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}
!18 = distinct !{!18, !14}
!19 = distinct !{!19, !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"

; Function Attrs: nounwind uwtable
define dso_local void @init_array(ptr nocapture noundef writeonly %0, ptr nocapture noundef writeonly %1) local_unnamed_addr #0 {
  %3 = ptrtoint ptr %0 to i64
  %4 = ptrtoint ptr %1 to i64
  tail call void @srand(i32 noundef 42) #2
  %5 = sub i64 %4, %3
  %diff.check = icmp ult i64 %5, 32
  br label %.preheader36

.preheader36:                                     ; preds = %2, %19
  %indvars.iv52 = phi i64 [ 0, %2 ], [ %indvars.iv.next53, %19 ]
  br label %vector.memcheck

vector.memcheck:                                  ; preds = %middle.block, %.preheader36
  %indvars.iv48 = phi i64 [ 0, %.preheader36 ], [ %indvars.iv.next49, %middle.block ]
  br i1 %diff.check, label %scalar.ph, label %vector.body

vector.body:                                      ; preds = %vector.memcheck, %vector.body
  %index = phi i64 [ %index.next.1, %vector.body ], [ 0, %vector.memcheck ]
  %6 = getelementptr inbounds [152 x [152 x double]], ptr %0, i64 %indvars.iv52, i64 %indvars.iv48, i64 %index
  %7 = getelementptr inbounds i8, ptr %6, i64 16
  store <2 x double> zeroinitializer, ptr %6, align 8, !tbaa !5
  store <2 x double> zeroinitializer, ptr %7, align 8, !tbaa !5
  %8 = getelementptr inbounds [152 x [152 x double]], ptr %1, i64 %indvars.iv52, i64 %indvars.iv48, i64 %index
  %9 = getelementptr inbounds i8, ptr %8, i64 16
  store <2 x double> zeroinitializer, ptr %8, align 8, !tbaa !5
  store <2 x double> zeroinitializer, ptr %9, align 8, !tbaa !5
  %index.next = or disjoint i64 %index, 4
  %10 = getelementptr inbounds [152 x [152 x double]], ptr %0, i64 %indvars.iv52, i64 %indvars.iv48, i64 %index.next
  %11 = getelementptr inbounds i8, ptr %10, i64 16
  store <2 x double> zeroinitializer, ptr %10, align 8, !tbaa !5
  store <2 x double> zeroinitializer, ptr %11, align 8, !tbaa !5
  %12 = getelementptr inbounds [152 x [152 x double]], ptr %1, i64 %indvars.iv52, i64 %indvars.iv48, i64 %index.next
  %13 = getelementptr inbounds i8, ptr %12, i64 16
  store <2 x double> zeroinitializer, ptr %12, align 8, !tbaa !5
  store <2 x double> zeroinitializer, ptr %13, align 8, !tbaa !5
  %index.next.1 = add nuw nsw i64 %index, 8
  %14 = icmp eq i64 %index.next.1, 152
  br i1 %14, label %middle.block, label %vector.body, !llvm.loop !9

scalar.ph:                                        ; preds = %vector.memcheck, %scalar.ph
  %indvars.iv = phi i64 [ %indvars.iv.next.1, %scalar.ph ], [ 0, %vector.memcheck ]
  %15 = getelementptr inbounds [152 x [152 x double]], ptr %0, i64 %indvars.iv52, i64 %indvars.iv48, i64 %indvars.iv
  store double 0.000000e+00, ptr %15, align 8, !tbaa !5
  %16 = getelementptr inbounds [152 x [152 x double]], ptr %1, i64 %indvars.iv52, i64 %indvars.iv48, i64 %indvars.iv
  store double 0.000000e+00, ptr %16, align 8, !tbaa !5
  %indvars.iv.next = or disjoint i64 %indvars.iv, 1
  %17 = getelementptr inbounds [152 x [152 x double]], ptr %0, i64 %indvars.iv52, i64 %indvars.iv48, i64 %indvars.iv.next
  store double 0.000000e+00, ptr %17, align 8, !tbaa !5
  %18 = getelementptr inbounds [152 x [152 x double]], ptr %1, i64 %indvars.iv52, i64 %indvars.iv48, i64 %indvars.iv.next
  store double 0.000000e+00, ptr %18, align 8, !tbaa !5
  %indvars.iv.next.1 = add nuw nsw i64 %indvars.iv, 2
  %exitcond.not.1 = icmp eq i64 %indvars.iv.next.1, 152
  br i1 %exitcond.not.1, label %middle.block, label %scalar.ph, !llvm.loop !13

middle.block:                                     ; preds = %vector.body, %scalar.ph
  %indvars.iv.next49 = add nuw nsw i64 %indvars.iv48, 1
  %exitcond51.not = icmp eq i64 %indvars.iv.next49, 152
  br i1 %exitcond51.not, label %19, label %vector.memcheck, !llvm.loop !14

19:                                               ; preds = %middle.block
  %indvars.iv.next53 = add nuw nsw i64 %indvars.iv52, 1
  %exitcond55.not = icmp eq i64 %indvars.iv.next53, 152
  br i1 %exitcond55.not, label %.preheader33, label %.preheader36, !llvm.loop !15

.preheader33:                                     ; preds = %19, %26
  %indvars.iv64 = phi i64 [ %indvars.iv.next65, %26 ], [ 1, %19 ]
  br label %.preheader

.preheader:                                       ; preds = %.preheader33, %25
  %indvars.iv60 = phi i64 [ 1, %.preheader33 ], [ %indvars.iv.next61, %25 ]
  br label %20

20:                                               ; preds = %.preheader, %20
  %indvars.iv56 = phi i64 [ 0, %.preheader ], [ %indvars.iv.next57, %20 ]
  %21 = tail call i32 @rand() #2
  %22 = srem i32 %21, 1024
  %23 = sitofp i32 %22 to double
  %24 = getelementptr inbounds [152 x [152 x double]], ptr %0, i64 %indvars.iv64, i64 %indvars.iv60, i64 %indvars.iv56
  store double %23, ptr %24, align 8, !tbaa !5
  %indvars.iv.next57 = add nuw nsw i64 %indvars.iv56, 1
  %exitcond59.not = icmp eq i64 %indvars.iv.next57, 152
  br i1 %exitcond59.not, label %25, label %20, !llvm.loop !16

25:                                               ; preds = %20
  %indvars.iv.next61 = add nuw nsw i64 %indvars.iv60, 1
  %exitcond63.not = icmp eq i64 %indvars.iv.next61, 151
  br i1 %exitcond63.not, label %26, label %.preheader, !llvm.loop !17

26:                                               ; preds = %25
  %indvars.iv.next65 = add nuw nsw i64 %indvars.iv64, 1
  %exitcond67.not = icmp eq i64 %indvars.iv.next65, 151
  br i1 %exitcond67.not, label %27, label %.preheader33, !llvm.loop !18

27:                                               ; preds = %26
  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, !11, !12}
!10 = !{!"llvm.loop.mustprogress"}
!11 = !{!"llvm.loop.isvectorized", i32 1}
!12 = !{!"llvm.loop.unroll.runtime.disable"}
!13 = distinct !{!13, !10, !11}
!14 = distinct !{!14, !10}
!15 = distinct !{!15, !10}
!16 = distinct !{!16, !10}
!17 = distinct !{!17, !10}
!18 = distinct !{!18, !10}


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