; LLVM IR from sympiler/nasoq :: src/symbolic/performanceModel.ll (ZN5nasoq17computeCostperColEiiPiS0_S0_S0_Ri)

; 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: mustprogress uwtable
define dso_local noundef double @_ZN5nasoq17computeCostperColEiiPiS0_S0_S0_Ri(i32 noundef %0, i32 noundef %1, ptr noundef %2, ptr noundef %3, ptr noundef %4, ptr noundef %5, ptr noundef nonnull align 4 dereferenceable(4) %6) #1 {
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca ptr, align 8
  %11 = alloca ptr, align 8
  %12 = alloca ptr, align 8
  %13 = alloca ptr, align 8
  %14 = alloca ptr, align 8
  %15 = alloca double, align 8
  %16 = alloca i32, align 4
  %17 = alloca i32, align 4
  %18 = alloca i8, align 1
  %19 = alloca i32, align 4
  store i32 %0, ptr %8, align 4, !tbaa !5
  store i32 %1, ptr %9, align 4, !tbaa !5
  store ptr %2, ptr %10, align 8, !tbaa !9
  store ptr %3, ptr %11, align 8, !tbaa !9
  store ptr %4, ptr %12, align 8, !tbaa !9
  store ptr %5, ptr %13, align 8, !tbaa !9
  store ptr %6, ptr %14, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %15) #3
  store double 0.000000e+00, ptr %15, align 8, !tbaa !11
  %20 = load i32, ptr %8, align 4, !tbaa !5
  %21 = load ptr, ptr %11, align 8, !tbaa !9
  %22 = load ptr, ptr %12, align 8, !tbaa !9
  %23 = load i32, ptr %9, align 4, !tbaa !5
  %24 = load ptr, ptr %10, align 8, !tbaa !9
  %25 = load ptr, ptr %13, align 8, !tbaa !9
  %26 = load ptr, ptr %13, align 8, !tbaa !9
  %27 = load i32, ptr %8, align 4, !tbaa !5
  %28 = sext i32 %27 to i64
  %29 = getelementptr inbounds i32, ptr %26, i64 %28
  %30 = call noundef i32 @_ZN5nasoq6ereachEiPiS0_iPKiS0_S0_(i32 noundef %20, ptr noundef %21, ptr noundef %22, i32 noundef %23, ptr noundef %24, ptr noundef %25, ptr noundef %29)
  %31 = load ptr, ptr %14, align 8, !tbaa !9
  store i32 %30, ptr %31, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %16) #3
  %32 = load ptr, ptr %14, align 8, !tbaa !9
  %33 = load i32, ptr %32, align 4, !tbaa !5
  store i32 %33, ptr %16, align 4, !tbaa !5
  br label %34

34:                                               ; preds = %60, %7
  %35 = load i32, ptr %16, align 4, !tbaa !5
  %36 = load i32, ptr %8, align 4, !tbaa !5
  %37 = icmp slt i32 %35, %36
  br i1 %37, label %39, label %38

38:                                               ; preds = %34
  call void @llvm.lifetime.end.p0(i64 4, ptr %16) #3
  br label %63

39:                                               ; preds = %34
  call void @llvm.lifetime.start.p0(i64 4, ptr %17) #3
  %40 = load ptr, ptr %13, align 8, !tbaa !9
  %41 = load i32, ptr %16, align 4, !tbaa !5
  %42 = sext i32 %41 to i64
  %43 = getelementptr inbounds i32, ptr %40, i64 %42
  %44 = load i32, ptr %43, align 4, !tbaa !5
  store i32 %44, ptr %17, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 1, ptr %18) #3
  store i8 0, ptr %18, align 1, !tbaa !13
  call void @llvm.lifetime.start.p0(i64 4, ptr %19) #3
  store i32 0, ptr %19, align 4, !tbaa !5
  %45 = load ptr, ptr %11, align 8, !tbaa !9
  %46 = load i32, ptr %17, align 4, !tbaa !5
  %47 = add nsw i32 %46, 1
  %48 = sext i32 %47 to i64
  %49 = getelementptr inbounds i32, ptr %45, i64 %48
  %50 = load i32, ptr %49, align 4, !tbaa !5
  %51 = load ptr, ptr %11, align 8, !tbaa !9
  %52 = load i32, ptr %17, align 4, !tbaa !5
  %53 = sext i32 %52 to i64
  %54 = getelementptr inbounds i32, ptr %51, i64 %53
  %55 = load i32, ptr %54, align 4, !tbaa !5
  %56 = sub nsw i32 %50, %55
  %57 = sitofp i32 %56 to double
  %58 = load double, ptr %15, align 8, !tbaa !11
  %59 = fadd double %58, %57
  store double %59, ptr %15, align 8, !tbaa !11
  call void @llvm.lifetime.end.p0(i64 4, ptr %19) #3
  call void @llvm.lifetime.end.p0(i64 1, ptr %18) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %17) #3
  br label %60

60:                                               ; preds = %39
  %61 = load i32, ptr %16, align 4, !tbaa !5
  %62 = add nsw i32 %61, 1
  store i32 %62, ptr %16, align 4, !tbaa !5
  br label %34, !llvm.loop !15

63:                                               ; preds = %38
  %64 = load ptr, ptr %11, align 8, !tbaa !9
  %65 = load i32, ptr %9, align 4, !tbaa !5
  %66 = add nsw i32 %65, 1
  %67 = sext i32 %66 to i64
  %68 = getelementptr inbounds i32, ptr %64, i64 %67
  %69 = load i32, ptr %68, align 4, !tbaa !5
  %70 = load ptr, ptr %11, align 8, !tbaa !9
  %71 = load i32, ptr %9, align 4, !tbaa !5
  %72 = sext i32 %71 to i64
  %73 = getelementptr inbounds i32, ptr %70, i64 %72
  %74 = load i32, ptr %73, align 4, !tbaa !5
  %75 = sub nsw i32 %69, %74
  %76 = sitofp i32 %75 to double
  %77 = load double, ptr %15, align 8, !tbaa !11
  %78 = fadd double %77, %76
  store double %78, ptr %15, align 8, !tbaa !11
  %79 = load double, ptr %15, align 8, !tbaa !11
  call void @llvm.lifetime.end.p0(i64 8, ptr %15) #3
  ret double %79
}

declare noundef i32 @_ZN5nasoq6ereachEiPiS0_iPKiS0_S0_(i32 noundef, ptr noundef, ptr noundef, i32 noundef, ptr noundef, ptr noundef, ptr noundef) #2

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #2 = { "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++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"any pointer", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"double", !7, i64 0}
!13 = !{!14, !14, i64 0}
!14 = !{!"bool", !7, i64 0}
!15 = distinct !{!15, !16}
!16 = !{!"llvm.loop.mustprogress"}


; 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 uwtable
define dso_local noundef double @_ZN5nasoq17computeCostperColEiiPiS0_S0_S0_Ri(i32 noundef %0, i32 noundef %1, ptr noundef %2, ptr noundef %3, ptr noundef %4, ptr noundef %5, ptr nocapture noundef nonnull writeonly align 4 dereferenceable(4) %6) local_unnamed_addr #0 {
  %8 = sext i32 %0 to i64
  %9 = getelementptr inbounds i32, ptr %5, i64 %8
  %10 = tail call noundef i32 @_ZN5nasoq6ereachEiPiS0_iPKiS0_S0_(i32 noundef %0, ptr noundef %3, ptr noundef %4, i32 noundef %1, ptr noundef %2, ptr noundef %5, ptr noundef %9)
  store i32 %10, ptr %6, align 4, !tbaa !5
  %11 = icmp slt i32 %10, %0
  br i1 %11, label %.lr.ph.preheader, label %._crit_edge

.lr.ph.preheader:                                 ; preds = %7
  %12 = sext i32 %10 to i64
  %13 = sub nsw i64 %8, %12
  %xtraiter = and i64 %13, 1
  %lcmp.mod.not = icmp eq i64 %xtraiter, 0
  br i1 %lcmp.mod.not, label %.lr.ph.prol.loopexit, label %.lr.ph.prol

.lr.ph.prol:                                      ; preds = %.lr.ph.preheader
  %14 = getelementptr inbounds i32, ptr %5, i64 %12
  %15 = load i32, ptr %14, align 4, !tbaa !5
  %16 = sext i32 %15 to i64
  %17 = getelementptr i32, ptr %3, i64 %16
  %18 = getelementptr i8, ptr %17, i64 4
  %19 = load i32, ptr %18, align 4, !tbaa !5
  %20 = load i32, ptr %17, align 4, !tbaa !5
  %21 = sub nsw i32 %19, %20
  %22 = sitofp i32 %21 to double
  %indvars.iv.next.prol = add nsw i64 %12, 1
  br label %.lr.ph.prol.loopexit

.lr.ph.prol.loopexit:                             ; preds = %.lr.ph.prol, %.lr.ph.preheader
  %.lcssa.unr = phi double [ poison, %.lr.ph.preheader ], [ %22, %.lr.ph.prol ]
  %indvars.iv.unr = phi i64 [ %12, %.lr.ph.preheader ], [ %indvars.iv.next.prol, %.lr.ph.prol ]
  %.027.unr = phi double [ 0.000000e+00, %.lr.ph.preheader ], [ %22, %.lr.ph.prol ]
  %23 = add nsw i64 %8, -1
  %24 = icmp eq i64 %23, %12
  br i1 %24, label %._crit_edge, label %.lr.ph.preheader.new

.lr.ph.preheader.new:                             ; preds = %.lr.ph.prol.loopexit
  %invariant.gep = getelementptr i8, ptr %5, i64 4
  br label %.lr.ph

._crit_edge:                                      ; preds = %.lr.ph.prol.loopexit, %.lr.ph, %7
  %.0.lcssa = phi double [ 0.000000e+00, %7 ], [ %.lcssa.unr, %.lr.ph.prol.loopexit ], [ %51, %.lr.ph ]
  %25 = sext i32 %1 to i64
  %26 = getelementptr i32, ptr %3, i64 %25
  %27 = getelementptr i8, ptr %26, i64 4
  %28 = load i32, ptr %27, align 4, !tbaa !5
  %29 = load i32, ptr %26, align 4, !tbaa !5
  %30 = sub nsw i32 %28, %29
  %31 = sitofp i32 %30 to double
  %32 = fadd double %.0.lcssa, %31
  ret double %32

.lr.ph:                                           ; preds = %.lr.ph, %.lr.ph.preheader.new
  %indvars.iv = phi i64 [ %indvars.iv.unr, %.lr.ph.preheader.new ], [ %indvars.iv.next.1, %.lr.ph ]
  %.027 = phi double [ %.027.unr, %.lr.ph.preheader.new ], [ %51, %.lr.ph ]
  %33 = getelementptr inbounds i32, ptr %5, i64 %indvars.iv
  %34 = load i32, ptr %33, align 4, !tbaa !5
  %35 = sext i32 %34 to i64
  %36 = getelementptr i32, ptr %3, i64 %35
  %37 = getelementptr i8, ptr %36, i64 4
  %38 = load i32, ptr %37, align 4, !tbaa !5
  %39 = load i32, ptr %36, align 4, !tbaa !5
  %40 = sub nsw i32 %38, %39
  %41 = sitofp i32 %40 to double
  %42 = fadd double %.027, %41
  %gep = getelementptr i32, ptr %invariant.gep, i64 %indvars.iv
  %43 = load i32, ptr %gep, align 4, !tbaa !5
  %44 = sext i32 %43 to i64
  %45 = getelementptr i32, ptr %3, i64 %44
  %46 = getelementptr i8, ptr %45, i64 4
  %47 = load i32, ptr %46, align 4, !tbaa !5
  %48 = load i32, ptr %45, align 4, !tbaa !5
  %49 = sub nsw i32 %47, %48
  %50 = sitofp i32 %49 to double
  %51 = fadd double %42, %50
  %indvars.iv.next.1 = add nsw i64 %indvars.iv, 2
  %exitcond.not.1 = icmp eq i64 %indvars.iv.next.1, %8
  br i1 %exitcond.not.1, label %._crit_edge, label %.lr.ph, !llvm.loop !9
}

declare noundef i32 @_ZN5nasoq6ereachEiPiS0_iPKiS0_S0_(i32 noundef, ptr noundef, ptr noundef, i32 noundef, ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #1

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


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