; 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::NovaSSPLAOStarCPU" = type { ptr, i32, ptr, ptr }
%"struct.nova::NovaMDP" = type { i32, i32, i32, float, i32, float, i32, i32, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr }

@stderr = external global ptr, align 8
@.str.5 = external hidden unnamed_addr constant [36 x i8], align 1
@.str.9 = external hidden unnamed_addr constant [50 x i8], align 1
@.str.10 = external hidden unnamed_addr constant [61 x i8], align 1

; 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 i32 @_ZN4nova23ssp_lao_star_expand_cpuEPKNS_7NovaMDPEPNS_17NovaSSPLAOStarCPUERj(ptr noundef, ptr noundef, ptr noundef nonnull align 4 dereferenceable(4)) #1

; Function Attrs: mustprogress uwtable
declare dso_local noundef i32 @_ZN4nova34ssp_lao_star_check_convergence_cpuEPKNS_7NovaMDPEPNS_17NovaSSPLAOStarCPUERbS5_(ptr noundef, ptr noundef, ptr noundef nonnull align 1 dereferenceable(1), ptr noundef nonnull align 1 dereferenceable(1)) #1

; Function Attrs: nounwind
declare i32 @fprintf(ptr noundef, ptr noundef, ...) #2

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

11:                                               ; preds = %34, %2
  %12 = load ptr, ptr %5, align 8, !tbaa !5
  %13 = getelementptr inbounds %"struct.nova::NovaSSPLAOStarCPU", ptr %12, i32 0, i32 1
  %14 = load i32, ptr %13, align 8, !tbaa !11
  %15 = load ptr, ptr %4, align 8, !tbaa !5
  %16 = getelementptr inbounds %"struct.nova::NovaMDP", ptr %15, i32 0, i32 4
  %17 = load i32, ptr %16, align 8, !tbaa !13
  %18 = icmp ult i32 %14, %17
  br i1 %18, label %19, label %22

19:                                               ; preds = %11
  %20 = load i32, ptr %7, align 4, !tbaa !9
  %21 = icmp ne i32 %20, 0
  br label %22

22:                                               ; preds = %19, %11
  %23 = phi i1 [ false, %11 ], [ %21, %19 ]
  br i1 %23, label %24, label %35

24:                                               ; preds = %22
  %25 = load ptr, ptr %4, align 8, !tbaa !5
  %26 = load ptr, ptr %5, align 8, !tbaa !5
  %27 = call noundef i32 @_ZN4nova23ssp_lao_star_expand_cpuEPKNS_7NovaMDPEPNS_17NovaSSPLAOStarCPUERj(ptr noundef %25, ptr noundef %26, ptr noundef nonnull align 4 dereferenceable(4) %7)
  store i32 %27, ptr %6, align 4, !tbaa !9
  %28 = load i32, ptr %6, align 4, !tbaa !9
  %29 = icmp ne i32 %28, 0
  br i1 %29, label %30, label %34

30:                                               ; preds = %24
  %31 = load ptr, ptr @stderr, align 8, !tbaa !5
  %32 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %31, ptr noundef @.str.5, ptr noundef @.str.9) #3
  %33 = load i32, ptr %6, align 4, !tbaa !9
  store i32 %33, ptr %3, align 4
  store i32 1, ptr %8, align 4
  br label %81

34:                                               ; preds = %24
  br label %11, !llvm.loop !16

35:                                               ; preds = %22
  call void @llvm.lifetime.start.p0(i64 1, ptr %9) #3
  store i8 0, ptr %9, align 1, !tbaa !18
  call void @llvm.lifetime.start.p0(i64 1, ptr %10) #3
  store i8 0, ptr %10, align 1, !tbaa !18
  br label %36

36:                                               ; preds = %63, %35
  %37 = load ptr, ptr %5, align 8, !tbaa !5
  %38 = getelementptr inbounds %"struct.nova::NovaSSPLAOStarCPU", ptr %37, i32 0, i32 1
  %39 = load i32, ptr %38, align 8, !tbaa !11
  %40 = load ptr, ptr %4, align 8, !tbaa !5
  %41 = getelementptr inbounds %"struct.nova::NovaMDP", ptr %40, i32 0, i32 4
  %42 = load i32, ptr %41, align 8, !tbaa !13
  %43 = icmp ult i32 %39, %42
  br i1 %43, label %44, label %51

44:                                               ; preds = %36
  %45 = load i8, ptr %9, align 1, !tbaa !18, !range !20, !noundef !21
  %46 = trunc i8 %45 to i1
  br i1 %46, label %51, label %47

47:                                               ; preds = %44
  %48 = load i8, ptr %10, align 1, !tbaa !18, !range !20, !noundef !21
  %49 = trunc i8 %48 to i1
  %50 = xor i1 %49, true
  br label %51

51:                                               ; preds = %47, %44, %36
  %52 = phi i1 [ false, %44 ], [ false, %36 ], [ %50, %47 ]
  br i1 %52, label %53, label %64

53:                                               ; preds = %51
  %54 = load ptr, ptr %4, align 8, !tbaa !5
  %55 = load ptr, ptr %5, align 8, !tbaa !5
  %56 = call noundef i32 @_ZN4nova34ssp_lao_star_check_convergence_cpuEPKNS_7NovaMDPEPNS_17NovaSSPLAOStarCPUERbS5_(ptr noundef %54, ptr noundef %55, ptr noundef nonnull align 1 dereferenceable(1) %9, ptr noundef nonnull align 1 dereferenceable(1) %10)
  store i32 %56, ptr %6, align 4, !tbaa !9
  %57 = load i32, ptr %6, align 4, !tbaa !9
  %58 = icmp ne i32 %57, 0
  br i1 %58, label %59, label %63

59:                                               ; preds = %53
  %60 = load ptr, ptr @stderr, align 8, !tbaa !5
  %61 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %60, ptr noundef @.str.5, ptr noundef @.str.10) #3
  %62 = load i32, ptr %6, align 4, !tbaa !9
  store i32 %62, ptr %3, align 4
  store i32 1, ptr %8, align 4
  br label %80

63:                                               ; preds = %53
  br label %36, !llvm.loop !22

64:                                               ; preds = %51
  %65 = load ptr, ptr %5, align 8, !tbaa !5
  %66 = getelementptr inbounds %"struct.nova::NovaSSPLAOStarCPU", ptr %65, i32 0, i32 1
  %67 = load i32, ptr %66, align 8, !tbaa !11
  %68 = load ptr, ptr %4, align 8, !tbaa !5
  %69 = getelementptr inbounds %"struct.nova::NovaMDP", ptr %68, i32 0, i32 4
  %70 = load i32, ptr %69, align 8, !tbaa !13
  %71 = icmp uge i32 %67, %70
  br i1 %71, label %78, label %72

72:                                               ; preds = %64
  %73 = load i8, ptr %9, align 1, !tbaa !18, !range !20, !noundef !21
  %74 = trunc i8 %73 to i1
  br i1 %74, label %75, label %79

75:                                               ; preds = %72
  %76 = load i8, ptr %10, align 1, !tbaa !18, !range !20, !noundef !21
  %77 = trunc i8 %76 to i1
  br i1 %77, label %79, label %78

78:                                               ; preds = %75, %64
  store i32 9, ptr %3, align 4
  store i32 1, ptr %8, align 4
  br label %80

79:                                               ; preds = %75, %72
  store i32 0, ptr %3, align 4
  store i32 1, ptr %8, align 4
  br label %80

80:                                               ; preds = %79, %78, %59
  call void @llvm.lifetime.end.p0(i64 1, ptr %10) #3
  call void @llvm.lifetime.end.p0(i64 1, ptr %9) #3
  br label %81

81:                                               ; preds = %80, %30
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #3
  %82 = load i32, ptr %3, align 4
  ret i32 %82
}

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 = { 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++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!12, !10, i64 8}
!12 = !{!"_ZTSN4nova17NovaSSPLAOStarCPUE", !6, i64 0, !10, i64 8, !6, i64 16, !6, i64 24}
!13 = !{!14, !10, i64 16}
!14 = !{!"_ZTSN4nova7NovaMDPE", !10, i64 0, !10, i64 4, !10, i64 8, !15, i64 12, !10, i64 16, !15, 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}
!15 = !{!"float", !7, i64 0}
!16 = distinct !{!16, !17}
!17 = !{!"llvm.loop.mustprogress"}
!18 = !{!19, !19, i64 0}
!19 = !{!"bool", !7, i64 0}
!20 = !{i8 0, i8 2}
!21 = !{}
!22 = distinct !{!22, !17}


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

@stderr = external local_unnamed_addr global ptr, align 8
@.str.5 = external hidden unnamed_addr constant [36 x i8], align 1
@.str.9 = external hidden unnamed_addr constant [50 x i8], align 1
@.str.10 = external hidden unnamed_addr constant [61 x i8], align 1

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

; Function Attrs: mustprogress 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 i32 @_ZN4nova23ssp_lao_star_expand_cpuEPKNS_7NovaMDPEPNS_17NovaSSPLAOStarCPUERj(ptr noundef, ptr noundef, ptr noundef nonnull align 4 dereferenceable(4)) local_unnamed_addr #1

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

; Function Attrs: nofree nounwind
declare noundef i32 @fprintf(ptr nocapture noundef, ptr nocapture noundef readonly, ...) local_unnamed_addr #2

; Function Attrs: mustprogress uwtable
define dso_local i32 @ssp_lao_star_update_cpu(ptr noundef %0, ptr noundef %1) local_unnamed_addr #1 {
  %3 = alloca i32, align 4
  %4 = alloca i8, align 1
  %5 = alloca i8, align 1
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %3) #3
  store i32 1, ptr %3, align 4, !tbaa !5
  %6 = getelementptr inbounds i8, ptr %1, i64 8
  %7 = getelementptr inbounds i8, ptr %0, i64 16
  br label %8

8:                                                ; preds = %15, %2
  %9 = load i32, ptr %6, align 8, !tbaa !9
  %10 = load i32, ptr %7, align 8, !tbaa !12
  %11 = icmp ult i32 %9, %10
  %12 = load i32, ptr %3, align 4
  %13 = icmp ne i32 %12, 0
  %14 = select i1 %11, i1 %13, i1 false
  br i1 %14, label %15, label %20

15:                                               ; preds = %8
  %16 = call noundef i32 @_ZN4nova23ssp_lao_star_expand_cpuEPKNS_7NovaMDPEPNS_17NovaSSPLAOStarCPUERj(ptr noundef nonnull %0, ptr noundef nonnull %1, ptr noundef nonnull align 4 dereferenceable(4) %3)
  %.not19 = icmp eq i32 %16, 0
  br i1 %.not19, label %8, label %17, !llvm.loop !15

17:                                               ; preds = %15
  %18 = load ptr, ptr @stderr, align 8, !tbaa !17
  %19 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %18, ptr noundef nonnull @.str.5, ptr noundef nonnull @.str.9) #4
  br label %37

20:                                               ; preds = %8
  call void @llvm.lifetime.start.p0(i64 1, ptr nonnull %4) #3
  store i8 0, ptr %4, align 1, !tbaa !18
  call void @llvm.lifetime.start.p0(i64 1, ptr nonnull %5) #3
  store i8 0, ptr %5, align 1, !tbaa !18
  br label %21

21:                                               ; preds = %31, %20
  %22 = load i32, ptr %6, align 8, !tbaa !9
  %23 = load i32, ptr %7, align 8, !tbaa !12
  %24 = icmp ult i32 %22, %23
  br i1 %24, label %25, label %.critedge

25:                                               ; preds = %21
  %26 = load i8, ptr %4, align 1, !tbaa !18, !range !20, !noundef !21
  %27 = trunc nuw i8 %26 to i1
  %28 = load i8, ptr %5, align 1, !range !20
  %29 = trunc nuw i8 %28 to i1
  %30 = select i1 %27, i1 true, i1 %29
  br i1 %30, label %36, label %31

31:                                               ; preds = %25
  %32 = call noundef i32 @_ZN4nova34ssp_lao_star_check_convergence_cpuEPKNS_7NovaMDPEPNS_17NovaSSPLAOStarCPUERbS5_(ptr noundef nonnull %0, ptr noundef nonnull %1, ptr noundef nonnull align 1 dereferenceable(1) %4, ptr noundef nonnull align 1 dereferenceable(1) %5)
  %.not18 = icmp eq i32 %32, 0
  br i1 %.not18, label %21, label %33, !llvm.loop !22

33:                                               ; preds = %31
  %34 = load ptr, ptr @stderr, align 8, !tbaa !17
  %35 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %34, ptr noundef nonnull @.str.5, ptr noundef nonnull @.str.10) #4
  br label %.critedge

36:                                               ; preds = %25
  %.not = xor i1 %27, true
  %brmerge = select i1 %.not, i1 true, i1 %29
  %spec.select = select i1 %brmerge, i32 0, i32 9
  br label %.critedge

.critedge:                                        ; preds = %21, %36, %33
  %.0 = phi i32 [ %32, %33 ], [ %spec.select, %36 ], [ 9, %21 ]
  call void @llvm.lifetime.end.p0(i64 1, ptr nonnull %5) #3
  call void @llvm.lifetime.end.p0(i64 1, ptr nonnull %4) #3
  br label %37

37:                                               ; preds = %.critedge, %17
  %.1 = phi i32 [ %16, %17 ], [ %.0, %.critedge ]
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %3) #3
  ret i32 %.1
}

attributes #0 = { mustprogress 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 = { nofree 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 }
attributes #4 = { cold 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, !6, i64 8}
!10 = !{!"_ZTSN4nova17NovaSSPLAOStarCPUE", !11, i64 0, !6, i64 8, !11, i64 16, !11, i64 24}
!11 = !{!"any pointer", !7, i64 0}
!12 = !{!13, !6, i64 16}
!13 = !{!"_ZTSN4nova7NovaMDPE", !6, i64 0, !6, i64 4, !6, i64 8, !14, i64 12, !6, i64 16, !14, i64 20, !6, i64 24, !6, 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}
!14 = !{!"float", !7, i64 0}
!15 = distinct !{!15, !16}
!16 = !{!"llvm.loop.mustprogress"}
!17 = !{!11, !11, i64 0}
!18 = !{!19, !19, i64 0}
!19 = !{!"bool", !7, i64 0}
!20 = !{i8 0, i8 2}
!21 = !{}
!22 = distinct !{!22, !16}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LICMPass,LoopSimplifyPass,LoopUnrollPass,SROAPass,SimplifyCFGPass