; LLVM IR from kylewray/nova :: src/pomdp/algorithms (pomdp_perseus_cpu)

; 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 void @_ZN4nova37pomdp_perseus_compute_b_dot_alpha_cpuEjPKiPKfjS3_Pf(i32 noundef, ptr noundef, ptr noundef, i32 noundef, ptr noundef, ptr noundef) #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
define dso_local void @_ZN4nova28pomdp_perseus_compute_Vb_cpuEjjPKiPKfjS3_jPfPj(i32 noundef %0, i32 noundef %1, ptr noundef %2, ptr noundef %3, i32 noundef %4, ptr noundef %5, i32 noundef %6, ptr noundef %7, ptr noundef %8) #0 {
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  %12 = alloca ptr, align 8
  %13 = alloca ptr, align 8
  %14 = alloca i32, align 4
  %15 = alloca ptr, align 8
  %16 = alloca i32, align 4
  %17 = alloca ptr, align 8
  %18 = alloca ptr, align 8
  %19 = alloca i32, align 4
  %20 = alloca float, align 4
  store i32 %0, ptr %10, align 4, !tbaa !5
  store i32 %1, ptr %11, align 4, !tbaa !5
  store ptr %2, ptr %12, align 8, !tbaa !9
  store ptr %3, ptr %13, align 8, !tbaa !9
  store i32 %4, ptr %14, align 4, !tbaa !5
  store ptr %5, ptr %15, align 8, !tbaa !9
  store i32 %6, ptr %16, align 4, !tbaa !5
  store ptr %7, ptr %17, align 8, !tbaa !9
  store ptr %8, ptr %18, align 8, !tbaa !9
  %21 = load ptr, ptr %17, align 8, !tbaa !9
  store float -1.000000e+10, ptr %21, align 4, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %19) #2
  store i32 0, ptr %19, align 4, !tbaa !5
  br label %22

22:                                               ; preds = %48, %9
  %23 = load i32, ptr %19, align 4, !tbaa !5
  %24 = load i32, ptr %16, align 4, !tbaa !5
  %25 = icmp ult i32 %23, %24
  br i1 %25, label %27, label %26

26:                                               ; preds = %22
  call void @llvm.lifetime.end.p0(i64 4, ptr %19) #2
  br label %51

27:                                               ; preds = %22
  call void @llvm.lifetime.start.p0(i64 4, ptr %20) #2
  store float -1.000000e+10, ptr %20, align 4, !tbaa !11
  %28 = load i32, ptr %11, align 4, !tbaa !5
  %29 = load ptr, ptr %12, align 8, !tbaa !9
  %30 = load ptr, ptr %13, align 8, !tbaa !9
  %31 = load i32, ptr %14, align 4, !tbaa !5
  %32 = load ptr, ptr %15, align 8, !tbaa !9
  %33 = load i32, ptr %19, align 4, !tbaa !5
  %34 = load i32, ptr %10, align 4, !tbaa !5
  %35 = mul i32 %33, %34
  %36 = zext i32 %35 to i64
  %37 = getelementptr inbounds float, ptr %32, i64 %36
  call void @_ZN4nova37pomdp_perseus_compute_b_dot_alpha_cpuEjPKiPKfjS3_Pf(i32 noundef %28, ptr noundef %29, ptr noundef %30, i32 noundef %31, ptr noundef %37, ptr noundef %20)
  %38 = load ptr, ptr %17, align 8, !tbaa !9
  %39 = load float, ptr %38, align 4, !tbaa !11
  %40 = load float, ptr %20, align 4, !tbaa !11
  %41 = fcmp olt float %39, %40
  br i1 %41, label %42, label %47

42:                                               ; preds = %27
  %43 = load float, ptr %20, align 4, !tbaa !11
  %44 = load ptr, ptr %17, align 8, !tbaa !9
  store float %43, ptr %44, align 4, !tbaa !11
  %45 = load i32, ptr %19, align 4, !tbaa !5
  %46 = load ptr, ptr %18, align 8, !tbaa !9
  store i32 %45, ptr %46, align 4, !tbaa !5
  br label %47

47:                                               ; preds = %42, %27
  call void @llvm.lifetime.end.p0(i64 4, ptr %20) #2
  br label %48

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

51:                                               ; preds = %26
  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 = { 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 = !{!"float", !7, i64 0}
!13 = distinct !{!13, !14}
!14 = !{!"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 nounwind uwtable
declare dso_local void @_ZN4nova37pomdp_perseus_compute_b_dot_alpha_cpuEjPKiPKfjS3_Pf(i32 noundef, ptr noundef, ptr noundef, i32 noundef, ptr noundef, ptr noundef) local_unnamed_addr #0

; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #1

; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @_ZN4nova28pomdp_perseus_compute_Vb_cpuEjjPKiPKfjS3_jPfPj(i32 noundef %0, i32 noundef %1, ptr noundef %2, ptr noundef %3, i32 noundef %4, ptr noundef %5, i32 noundef %6, ptr nocapture noundef %7, ptr nocapture noundef writeonly %8) local_unnamed_addr #0 {
  %10 = alloca float, align 4
  store float -1.000000e+10, ptr %7, align 4, !tbaa !5
  %.not = icmp eq i32 %6, 0
  br i1 %.not, label %._crit_edge, label %.lr.ph.preheader

.lr.ph.preheader:                                 ; preds = %9
  %wide.trip.count = zext i32 %6 to i64
  br label %.lr.ph

._crit_edge:                                      ; preds = %19, %9
  ret void

.lr.ph:                                           ; preds = %.lr.ph.preheader, %19
  %indvars.iv = phi i64 [ 0, %.lr.ph.preheader ], [ %indvars.iv.next, %19 ]
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %10) #2
  store float -1.000000e+10, ptr %10, align 4, !tbaa !5
  %11 = trunc nuw i64 %indvars.iv to i32
  %12 = mul i32 %11, %0
  %13 = zext i32 %12 to i64
  %14 = getelementptr inbounds float, ptr %5, i64 %13
  call void @_ZN4nova37pomdp_perseus_compute_b_dot_alpha_cpuEjPKiPKfjS3_Pf(i32 noundef %1, ptr noundef %2, ptr noundef %3, i32 noundef %4, ptr noundef %14, ptr noundef nonnull %10)
  %15 = load float, ptr %7, align 4, !tbaa !5
  %16 = load float, ptr %10, align 4, !tbaa !5
  %17 = fcmp olt float %15, %16
  br i1 %17, label %18, label %19

18:                                               ; preds = %.lr.ph
  store float %16, ptr %7, align 4, !tbaa !5
  store i32 %11, ptr %8, align 4, !tbaa !9
  br label %19

19:                                               ; preds = %18, %.lr.ph
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %10) #2
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next, %wide.trip.count
  br i1 %exitcond.not, label %._crit_edge, label %.lr.ph, !llvm.loop !11
}

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


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass