; LLVM IR from kylewray/nova :: src/mdp/algorithms (ssp_lao_star_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"

%"struct.nova::NovaMDP" = type { i32, i32, i32, float, i32, float, i32, i32, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr }
%"struct.nova::NovaSSPLAOStarCPU" = type { ptr, i32, ptr, ptr }

; 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
declare dso_local noundef zeroext i1 @_ZN4nova27ssp_lao_star_is_visited_cpuEPKNS_7NovaMDPEPNS_17NovaSSPLAOStarCPUEj(ptr noundef, ptr noundef, i32 noundef) #1

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN4nova27ssp_lao_star_stack_push_cpuEPKNS_7NovaMDPEPNS_17NovaSSPLAOStarCPUERjPjj(ptr noundef, ptr noundef, ptr noundef nonnull align 4 dereferenceable(4), ptr noundef, i32 noundef) #2

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

14:                                               ; preds = %69, %5
  %15 = load i32, ptr %11, align 4, !tbaa !9
  %16 = load ptr, ptr %6, align 8, !tbaa !5
  %17 = getelementptr inbounds %"struct.nova::NovaMDP", ptr %16, i32 0, i32 1
  %18 = load i32, ptr %17, align 4, !tbaa !11
  %19 = icmp ult i32 %15, %18
  br i1 %19, label %21, label %20

20:                                               ; preds = %14
  store i32 2, ptr %12, align 4
  br label %72

21:                                               ; preds = %14
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #3
  %22 = load ptr, ptr %6, align 8, !tbaa !5
  %23 = getelementptr inbounds %"struct.nova::NovaMDP", ptr %22, i32 0, i32 9
  %24 = load ptr, ptr %23, align 8, !tbaa !14
  %25 = load i32, ptr %10, align 4, !tbaa !9
  %26 = load ptr, ptr %6, align 8, !tbaa !5
  %27 = getelementptr inbounds %"struct.nova::NovaMDP", ptr %26, i32 0, i32 2
  %28 = load i32, ptr %27, align 8, !tbaa !15
  %29 = mul i32 %25, %28
  %30 = load ptr, ptr %6, align 8, !tbaa !5
  %31 = getelementptr inbounds %"struct.nova::NovaMDP", ptr %30, i32 0, i32 1
  %32 = load i32, ptr %31, align 4, !tbaa !11
  %33 = mul i32 %29, %32
  %34 = load ptr, ptr %7, align 8, !tbaa !5
  %35 = getelementptr inbounds %"struct.nova::NovaSSPLAOStarCPU", ptr %34, i32 0, i32 3
  %36 = load ptr, ptr %35, align 8, !tbaa !16
  %37 = load i32, ptr %10, align 4, !tbaa !9
  %38 = zext i32 %37 to i64
  %39 = getelementptr inbounds i32, ptr %36, i64 %38
  %40 = load i32, ptr %39, align 4, !tbaa !9
  %41 = load ptr, ptr %6, align 8, !tbaa !5
  %42 = getelementptr inbounds %"struct.nova::NovaMDP", ptr %41, i32 0, i32 1
  %43 = load i32, ptr %42, align 4, !tbaa !11
  %44 = mul i32 %40, %43
  %45 = add i32 %33, %44
  %46 = load i32, ptr %11, align 4, !tbaa !9
  %47 = add i32 %45, %46
  %48 = zext i32 %47 to i64
  %49 = getelementptr inbounds i32, ptr %24, i64 %48
  %50 = load i32, ptr %49, align 4, !tbaa !9
  store i32 %50, ptr %13, align 4, !tbaa !9
  %51 = load i32, ptr %13, align 4, !tbaa !9
  %52 = icmp slt i32 %51, 0
  br i1 %52, label %53, label %54

53:                                               ; preds = %21
  store i32 2, ptr %12, align 4
  br label %66

54:                                               ; preds = %21
  %55 = load ptr, ptr %6, align 8, !tbaa !5
  %56 = load ptr, ptr %7, align 8, !tbaa !5
  %57 = load i32, ptr %13, align 4, !tbaa !9
  %58 = call noundef zeroext i1 @_ZN4nova27ssp_lao_star_is_visited_cpuEPKNS_7NovaMDPEPNS_17NovaSSPLAOStarCPUEj(ptr noundef %55, ptr noundef %56, i32 noundef %57)
  br i1 %58, label %65, label %59

59:                                               ; preds = %54
  %60 = load ptr, ptr %6, align 8, !tbaa !5
  %61 = load ptr, ptr %7, align 8, !tbaa !5
  %62 = load ptr, ptr %8, align 8, !tbaa !5
  %63 = load ptr, ptr %9, align 8, !tbaa !5
  %64 = load i32, ptr %13, align 4, !tbaa !9
  call void @_ZN4nova27ssp_lao_star_stack_push_cpuEPKNS_7NovaMDPEPNS_17NovaSSPLAOStarCPUERjPjj(ptr noundef %60, ptr noundef %61, ptr noundef nonnull align 4 dereferenceable(4) %62, ptr noundef %63, i32 noundef %64)
  br label %65

65:                                               ; preds = %59, %54
  store i32 0, ptr %12, align 4
  br label %66

66:                                               ; preds = %65, %53
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #3
  %67 = load i32, ptr %12, align 4
  switch i32 %67, label %72 [
    i32 0, label %68
  ]

68:                                               ; preds = %66
  br label %69

69:                                               ; preds = %68
  %70 = load i32, ptr %11, align 4, !tbaa !9
  %71 = add i32 %70, 1
  store i32 %71, ptr %11, align 4, !tbaa !9
  br label %14, !llvm.loop !18

72:                                               ; preds = %66, %20
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #3
  br label %73

73:                                               ; preds = %72
  ret void
}

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 = { 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 #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++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!12, !10, i64 4}
!12 = !{!"_ZTSN4nova7NovaMDPE", !10, i64 0, !10, i64 4, !10, i64 8, !13, i64 12, !10, i64 16, !13, i64 20, !10, i64 24, !10, i64 28, !6, i64 32, !6, i64 40, !6, i64 48, !6, i64 56, !6, i64 64, !6, i64 72, !6, i64 80, !6, i64 88}
!13 = !{!"float", !7, i64 0}
!14 = !{!12, !6, i64 40}
!15 = !{!12, !10, i64 8}
!16 = !{!17, !6, i64 24}
!17 = !{!"_ZTSN4nova17NovaSSPLAOStarCPUE", !6, i64 0, !10, i64 8, !6, i64 16, !6, i64 24}
!18 = distinct !{!18, !19}
!19 = !{!"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
declare dso_local noundef zeroext i1 @_ZN4nova27ssp_lao_star_is_visited_cpuEPKNS_7NovaMDPEPNS_17NovaSSPLAOStarCPUEj(ptr noundef, ptr noundef, i32 noundef) local_unnamed_addr #0

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN4nova27ssp_lao_star_stack_push_cpuEPKNS_7NovaMDPEPNS_17NovaSSPLAOStarCPUERjPjj(ptr noundef, ptr noundef, ptr noundef nonnull align 4 dereferenceable(4), ptr noundef, i32 noundef) local_unnamed_addr #1

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN4nova38ssp_lao_star_stack_push_successors_cpuEPKNS_7NovaMDPEPNS_17NovaSSPLAOStarCPUERjPjj(ptr noundef %0, ptr noundef %1, ptr noundef nonnull align 4 dereferenceable(4) %2, ptr noundef %3, i32 noundef %4) local_unnamed_addr #0 {
  %6 = getelementptr inbounds i8, ptr %0, i64 40
  %7 = getelementptr inbounds i8, ptr %0, i64 4
  %8 = load i32, ptr %7, align 4, !tbaa !5
  %.not = icmp eq i32 %8, 0
  br i1 %.not, label %.critedge, label %.lr.ph

.lr.ph:                                           ; preds = %5
  %9 = getelementptr inbounds i8, ptr %0, i64 8
  %10 = getelementptr inbounds i8, ptr %1, i64 24
  %11 = zext i32 %4 to i64
  br label %12

12:                                               ; preds = %.lr.ph, %30
  %13 = phi i32 [ %8, %.lr.ph ], [ %32, %30 ]
  %.023 = phi i32 [ 0, %.lr.ph ], [ %31, %30 ]
  %14 = load ptr, ptr %6, align 8, !tbaa !12
  %15 = load i32, ptr %9, align 8, !tbaa !13
  %16 = mul i32 %15, %4
  %17 = load ptr, ptr %10, align 8, !tbaa !14
  %18 = getelementptr inbounds i32, ptr %17, i64 %11
  %19 = load i32, ptr %18, align 4, !tbaa !16
  %20 = add i32 %19, %16
  %21 = mul i32 %20, %13
  %22 = add i32 %21, %.023
  %23 = zext i32 %22 to i64
  %24 = getelementptr inbounds i32, ptr %14, i64 %23
  %25 = load i32, ptr %24, align 4, !tbaa !16
  %26 = icmp sgt i32 %25, -1
  br i1 %26, label %27, label %.critedge

27:                                               ; preds = %12
  %28 = tail call noundef zeroext i1 @_ZN4nova27ssp_lao_star_is_visited_cpuEPKNS_7NovaMDPEPNS_17NovaSSPLAOStarCPUEj(ptr noundef nonnull %0, ptr noundef nonnull %1, i32 noundef %25)
  br i1 %28, label %30, label %29

29:                                               ; preds = %27
  tail call void @_ZN4nova27ssp_lao_star_stack_push_cpuEPKNS_7NovaMDPEPNS_17NovaSSPLAOStarCPUERjPjj(ptr noundef nonnull %0, ptr noundef nonnull %1, ptr noundef nonnull align 4 dereferenceable(4) %2, ptr noundef %3, i32 noundef %25)
  br label %30

30:                                               ; preds = %29, %27
  %31 = add nuw i32 %.023, 1
  %32 = load i32, ptr %7, align 4, !tbaa !5
  %33 = icmp ult i32 %31, %32
  br i1 %33, label %12, label %.critedge, !llvm.loop !17

.critedge:                                        ; preds = %30, %12, %5
  ret void
}

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 = { 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" }

!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, !7, i64 4}
!6 = !{!"_ZTSN4nova7NovaMDPE", !7, i64 0, !7, i64 4, !7, i64 8, !10, i64 12, !7, i64 16, !10, i64 20, !7, i64 24, !7, i64 28, !11, i64 32, !11, i64 40, !11, i64 48, !11, i64 56, !11, i64 64, !11, i64 72, !11, i64 80, !11, i64 88}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"float", !8, i64 0}
!11 = !{!"any pointer", !8, i64 0}
!12 = !{!6, !11, i64 40}
!13 = !{!6, !7, i64 8}
!14 = !{!15, !11, i64 24}
!15 = !{!"_ZTSN4nova17NovaSSPLAOStarCPUE", !11, i64 0, !7, i64 8, !11, i64 16, !11, i64 24}
!16 = !{!7, !7, i64 0}
!17 = distinct !{!17, !18}
!18 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass