; LLVM IR from yuikns/panther :: ann/test/rand.ll (Z15annCoLaplacePtsPPdiid)

; 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: mustprogress nounwind uwtable
declare dso_local noundef double @_Z7annRan0v() #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 willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1

; Function Attrs: mustprogress nounwind uwtable
declare hidden noundef double @_ZL13annRanLaplacev() #0

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

; Function Attrs: mustprogress uwtable
define dso_local void @_Z15annCoLaplacePtsPPdiid(ptr noundef %0, i32 noundef %1, i32 noundef %2, double noundef %3) #3 {
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca double, align 8
  %9 = alloca double, align 8
  %10 = alloca double, align 8
  %11 = alloca i32, align 4
  %12 = alloca i32, align 4
  %13 = alloca double, align 8
  %14 = alloca i32, align 4
  %15 = alloca double, align 8
  store ptr %0, ptr %5, align 8, !tbaa !5
  store i32 %1, ptr %6, align 4, !tbaa !9
  store i32 %2, ptr %7, align 4, !tbaa !9
  store double %3, ptr %8, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #4
  %16 = load double, ptr %8, align 8, !tbaa !11
  %17 = load double, ptr %8, align 8, !tbaa !11
  %18 = fmul double %16, %17
  store double %18, ptr %10, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #4
  store i32 0, ptr %11, align 4, !tbaa !9
  br label %19

19:                                               ; preds = %64, %4
  %20 = load i32, ptr %11, align 4, !tbaa !9
  %21 = load i32, ptr %6, align 4, !tbaa !9
  %22 = icmp slt i32 %20, %21
  br i1 %22, label %24, label %23

23:                                               ; preds = %19
  store i32 2, ptr %12, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #4
  br label %67

24:                                               ; preds = %19
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #4
  %25 = call noundef double @_ZL13annRanLaplacev()
  store double %25, ptr %13, align 8, !tbaa !11
  %26 = load double, ptr %13, align 8, !tbaa !11
  %27 = load ptr, ptr %5, align 8, !tbaa !5
  %28 = load i32, ptr %11, align 4, !tbaa !9
  %29 = sext i32 %28 to i64
  %30 = getelementptr inbounds ptr, ptr %27, i64 %29
  %31 = load ptr, ptr %30, align 8, !tbaa !5
  %32 = getelementptr inbounds double, ptr %31, i64 0
  store double %26, ptr %32, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #4
  store i32 1, ptr %14, align 4, !tbaa !9
  br label %33

33:                                               ; preds = %60, %24
  %34 = load i32, ptr %14, align 4, !tbaa !9
  %35 = load i32, ptr %7, align 4, !tbaa !9
  %36 = icmp slt i32 %34, %35
  br i1 %36, label %38, label %37

37:                                               ; preds = %33
  store i32 5, ptr %12, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #4
  br label %63

38:                                               ; preds = %33
  call void @llvm.lifetime.start.p0(i64 8, ptr %15) #4
  %39 = call noundef double @_Z7annRan0v()
  store double %39, ptr %15, align 8, !tbaa !11
  %40 = load double, ptr %15, align 8, !tbaa !11
  %41 = load double, ptr %10, align 8, !tbaa !11
  %42 = fcmp olt double %40, %41
  br i1 %42, label %43, label %44

43:                                               ; preds = %38
  store double 0.000000e+00, ptr %9, align 8, !tbaa !11
  br label %46

44:                                               ; preds = %38
  %45 = call noundef double @_ZL13annRanLaplacev()
  store double %45, ptr %9, align 8, !tbaa !11
  br label %46

46:                                               ; preds = %44, %43
  %47 = load double, ptr %8, align 8, !tbaa !11
  %48 = load double, ptr %13, align 8, !tbaa !11
  %49 = load double, ptr %9, align 8, !tbaa !11
  %50 = call double @llvm.fmuladd.f64(double %47, double %48, double %49)
  store double %50, ptr %13, align 8, !tbaa !11
  %51 = load double, ptr %13, align 8, !tbaa !11
  %52 = load ptr, ptr %5, align 8, !tbaa !5
  %53 = load i32, ptr %11, align 4, !tbaa !9
  %54 = sext i32 %53 to i64
  %55 = getelementptr inbounds ptr, ptr %52, i64 %54
  %56 = load ptr, ptr %55, align 8, !tbaa !5
  %57 = load i32, ptr %14, align 4, !tbaa !9
  %58 = sext i32 %57 to i64
  %59 = getelementptr inbounds double, ptr %56, i64 %58
  store double %51, ptr %59, align 8, !tbaa !11
  call void @llvm.lifetime.end.p0(i64 8, ptr %15) #4
  br label %60

60:                                               ; preds = %46
  %61 = load i32, ptr %14, align 4, !tbaa !9
  %62 = add nsw i32 %61, 1
  store i32 %62, ptr %14, align 4, !tbaa !9
  br label %33, !llvm.loop !13

63:                                               ; preds = %37
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #4
  br label %64

64:                                               ; preds = %63
  %65 = load i32, ptr %11, align 4, !tbaa !9
  %66 = add nsw i32 %65, 1
  store i32 %66, ptr %11, align 4, !tbaa !9
  br label %19, !llvm.loop !15

67:                                               ; preds = %23
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #4
  ret void
}

attributes #0 = { mustprogress 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 = { mustprogress 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 #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 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple 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}


; 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: mustprogress nounwind uwtable
declare dso_local noundef double @_Z7annRan0v() local_unnamed_addr #0

; Function Attrs: mustprogress nounwind uwtable
declare hidden noundef double @_ZL13annRanLaplacev() local_unnamed_addr #0

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

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @_Z15annCoLaplacePtsPPdiid(ptr nocapture noundef readonly %0, i32 noundef %1, i32 noundef %2, double noundef %3) local_unnamed_addr #0 {
  %5 = fmul double %3, %3
  %6 = icmp sgt i32 %1, 0
  br i1 %6, label %.lr.ph26, label %._crit_edge27

.lr.ph26:                                         ; preds = %4
  %7 = icmp sgt i32 %2, 1
  %wide.trip.count38 = zext nneg i32 %1 to i64
  br i1 %7, label %.lr.ph.us.preheader, label %.lr.ph26.split

.lr.ph.us.preheader:                              ; preds = %.lr.ph26
  %wide.trip.count33 = zext nneg i32 %2 to i64
  br label %.lr.ph.us

.lr.ph.us:                                        ; preds = %.lr.ph.us.preheader, %._crit_edge.us
  %indvars.iv35 = phi i64 [ 0, %.lr.ph.us.preheader ], [ %indvars.iv.next36, %._crit_edge.us ]
  %8 = tail call noundef double @_ZL13annRanLaplacev()
  %9 = getelementptr inbounds ptr, ptr %0, i64 %indvars.iv35
  %10 = load ptr, ptr %9, align 8, !tbaa !5
  store double %8, ptr %10, align 8, !tbaa !9
  br label %11

11:                                               ; preds = %.lr.ph.us, %16
  %indvars.iv30 = phi i64 [ 1, %.lr.ph.us ], [ %indvars.iv.next31, %16 ]
  %.02022.us = phi double [ %8, %.lr.ph.us ], [ %17, %16 ]
  %12 = tail call noundef double @_Z7annRan0v()
  %13 = fcmp olt double %12, %5
  br i1 %13, label %16, label %14

14:                                               ; preds = %11
  %15 = tail call noundef double @_ZL13annRanLaplacev()
  br label %16

16:                                               ; preds = %14, %11
  %.0.us = phi double [ %15, %14 ], [ 0.000000e+00, %11 ]
  %17 = tail call double @llvm.fmuladd.f64(double %3, double %.02022.us, double %.0.us)
  %18 = load ptr, ptr %9, align 8, !tbaa !5
  %19 = getelementptr inbounds double, ptr %18, i64 %indvars.iv30
  store double %17, ptr %19, align 8, !tbaa !9
  %indvars.iv.next31 = add nuw nsw i64 %indvars.iv30, 1
  %exitcond34.not = icmp eq i64 %indvars.iv.next31, %wide.trip.count33
  br i1 %exitcond34.not, label %._crit_edge.us, label %11, !llvm.loop !11

._crit_edge.us:                                   ; preds = %16
  %indvars.iv.next36 = add nuw nsw i64 %indvars.iv35, 1
  %exitcond39.not = icmp eq i64 %indvars.iv.next36, %wide.trip.count38
  br i1 %exitcond39.not, label %._crit_edge27, label %.lr.ph.us, !llvm.loop !13

._crit_edge27:                                    ; preds = %.lr.ph26.split, %._crit_edge.us, %4
  ret void

.lr.ph26.split:                                   ; preds = %.lr.ph26, %.lr.ph26.split
  %indvars.iv = phi i64 [ %indvars.iv.next, %.lr.ph26.split ], [ 0, %.lr.ph26 ]
  %20 = tail call noundef double @_ZL13annRanLaplacev()
  %21 = getelementptr inbounds ptr, ptr %0, i64 %indvars.iv
  %22 = load ptr, ptr %21, align 8, !tbaa !5
  store double %20, ptr %22, align 8, !tbaa !9
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next, %wide.trip.count38
  br i1 %exitcond.not, label %._crit_edge27, label %.lr.ph26.split, !llvm.loop !13
}

attributes #0 = { mustprogress 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 = { 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 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"double", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = distinct !{!13, !12}


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