; LLVM IR from ShahjalalShohag/code-library :: Graph Theory/Maximum Density Subgraph.ll (Z2yod)

; 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.Dinic = type { i32, i32, i32, i32, %"class.std::vector", %"class.std::vector", %"class.std::vector", %"class.std::vector.0" }
%"class.std::vector" = type { %"struct.std::_Vector_base" }
%"struct.std::_Vector_base" = type { %"struct.std::_Vector_base<int, std::allocator<int>>::_Vector_impl" }
%"struct.std::_Vector_base<int, std::allocator<int>>::_Vector_impl" = type { %"struct.std::_Vector_base<int, std::allocator<int>>::_Vector_impl_data" }
%"struct.std::_Vector_base<int, std::allocator<int>>::_Vector_impl_data" = type { ptr, ptr, ptr }
%"class.std::vector.0" = type { %"struct.std::_Vector_base.1" }
%"struct.std::_Vector_base.1" = type { %"struct.std::_Vector_base<std::vector<Dinic::edge>, std::allocator<std::vector<Dinic::edge>>>::_Vector_impl" }
%"struct.std::_Vector_base<std::vector<Dinic::edge>, std::allocator<std::vector<Dinic::edge>>>::_Vector_impl" = type { %"struct.std::_Vector_base<std::vector<Dinic::edge>, std::allocator<std::vector<Dinic::edge>>>::_Vector_impl_data" }
%"struct.std::_Vector_base<std::vector<Dinic::edge>, std::allocator<std::vector<Dinic::edge>>>::_Vector_impl_data" = type { ptr, ptr, ptr }

@F = external dso_local global %struct.Dinic, align 8
@s = external dso_local global i32, align 4
@t = external dso_local global i32, align 4
@n = external dso_local global i32, align 4
@m = external dso_local global i32, align 4
@u = external dso_local global [1010 x i32], align 16
@v = external dso_local global [1010 x i32], align 16
@deg = external dso_local global [1010 x i32], align 16

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local void @_ZN5DinicD2Ev(ptr noundef nonnull align 8 dereferenceable(112)) unnamed_addr #0 align 2

; 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 uwtable
define dso_local noundef zeroext i1 @_Z2yod(double noundef %0) #2 {
  %2 = alloca double, align 8
  %3 = alloca %struct.Dinic, align 8
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  %6 = alloca double, align 8
  store double %0, ptr %2, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 112, ptr %3) #4
  %7 = load i32, ptr @t, align 4, !tbaa !9
  call void @_ZN5DinicC2Ei(ptr noundef nonnull align 8 dereferenceable(112) %3, i32 noundef %7)
  %8 = call noundef nonnull align 8 dereferenceable(112) ptr @_ZN5DinicaSEOS_(ptr noundef nonnull align 8 dereferenceable(112) @F, ptr noundef nonnull align 8 dereferenceable(112) %3) #4
  call void @_ZN5DinicD2Ev(ptr noundef nonnull align 8 dereferenceable(112) %3) #4
  call void @llvm.lifetime.end.p0(i64 112, ptr %3) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #4
  store i32 1, ptr %4, align 4, !tbaa !9
  br label %9

9:                                                ; preds = %31, %1
  %10 = load i32, ptr %4, align 4, !tbaa !9
  %11 = load i32, ptr @m, align 4, !tbaa !9
  %12 = icmp sle i32 %10, %11
  br i1 %12, label %14, label %13

13:                                               ; preds = %9
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #4
  br label %34

14:                                               ; preds = %9
  %15 = load i32, ptr %4, align 4, !tbaa !9
  %16 = sext i32 %15 to i64
  %17 = getelementptr inbounds [1010 x i32], ptr @u, i64 0, i64 %16
  %18 = load i32, ptr %17, align 4, !tbaa !9
  %19 = load i32, ptr %4, align 4, !tbaa !9
  %20 = sext i32 %19 to i64
  %21 = getelementptr inbounds [1010 x i32], ptr @v, i64 0, i64 %20
  %22 = load i32, ptr %21, align 4, !tbaa !9
  call void @_ZN5Dinic8add_edgeEiidi(ptr noundef nonnull align 8 dereferenceable(112) @F, i32 noundef %18, i32 noundef %22, double noundef 1.000000e+00, i32 noundef -1)
  %23 = load i32, ptr %4, align 4, !tbaa !9
  %24 = sext i32 %23 to i64
  %25 = getelementptr inbounds [1010 x i32], ptr @v, i64 0, i64 %24
  %26 = load i32, ptr %25, align 4, !tbaa !9
  %27 = load i32, ptr %4, align 4, !tbaa !9
  %28 = sext i32 %27 to i64
  %29 = getelementptr inbounds [1010 x i32], ptr @u, i64 0, i64 %28
  %30 = load i32, ptr %29, align 4, !tbaa !9
  call void @_ZN5Dinic8add_edgeEiidi(ptr noundef nonnull align 8 dereferenceable(112) @F, i32 noundef %26, i32 noundef %30, double noundef 1.000000e+00, i32 noundef -1)
  br label %31

31:                                               ; preds = %14
  %32 = load i32, ptr %4, align 4, !tbaa !9
  %33 = add nsw i32 %32, 1
  store i32 %33, ptr %4, align 4, !tbaa !9
  br label %9, !llvm.loop !11

34:                                               ; preds = %13
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #4
  store i32 1, ptr %5, align 4, !tbaa !9
  br label %35

35:                                               ; preds = %57, %34
  %36 = load i32, ptr %5, align 4, !tbaa !9
  %37 = load i32, ptr @n, align 4, !tbaa !9
  %38 = icmp sle i32 %36, %37
  br i1 %38, label %40, label %39

39:                                               ; preds = %35
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #4
  br label %60

40:                                               ; preds = %35
  %41 = load i32, ptr @s, align 4, !tbaa !9
  %42 = load i32, ptr %5, align 4, !tbaa !9
  %43 = load i32, ptr @m, align 4, !tbaa !9
  %44 = sitofp i32 %43 to double
  call void @_ZN5Dinic8add_edgeEiidi(ptr noundef nonnull align 8 dereferenceable(112) @F, i32 noundef %41, i32 noundef %42, double noundef %44, i32 noundef -1)
  %45 = load i32, ptr %5, align 4, !tbaa !9
  %46 = load i32, ptr @t, align 4, !tbaa !9
  %47 = load i32, ptr @m, align 4, !tbaa !9
  %48 = sitofp i32 %47 to double
  %49 = load double, ptr %2, align 8, !tbaa !5
  %50 = call double @llvm.fmuladd.f64(double 2.000000e+00, double %49, double %48)
  %51 = load i32, ptr %5, align 4, !tbaa !9
  %52 = sext i32 %51 to i64
  %53 = getelementptr inbounds [1010 x i32], ptr @deg, i64 0, i64 %52
  %54 = load i32, ptr %53, align 4, !tbaa !9
  %55 = sitofp i32 %54 to double
  %56 = fsub double %50, %55
  call void @_ZN5Dinic8add_edgeEiidi(ptr noundef nonnull align 8 dereferenceable(112) @F, i32 noundef %45, i32 noundef %46, double noundef %56, i32 noundef -1)
  br label %57

57:                                               ; preds = %40
  %58 = load i32, ptr %5, align 4, !tbaa !9
  %59 = add nsw i32 %58, 1
  store i32 %59, ptr %5, align 4, !tbaa !9
  br label %35, !llvm.loop !13

60:                                               ; preds = %39
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #4
  %61 = load i32, ptr @s, align 4, !tbaa !9
  %62 = load i32, ptr @t, align 4, !tbaa !9
  %63 = call noundef double @_ZN5Dinic8max_flowEii(ptr noundef nonnull align 8 dereferenceable(112) @F, i32 noundef %61, i32 noundef %62)
  store double %63, ptr %6, align 8, !tbaa !5
  %64 = load i32, ptr @m, align 4, !tbaa !9
  %65 = sitofp i32 %64 to double
  %66 = fmul double 1.000000e+00, %65
  %67 = load i32, ptr @n, align 4, !tbaa !9
  %68 = sitofp i32 %67 to double
  %69 = load double, ptr %6, align 8, !tbaa !5
  %70 = fneg double %69
  %71 = call double @llvm.fmuladd.f64(double %66, double %68, double %70)
  %72 = fcmp ogt double %71, 1.000000e-09
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #4
  ret i1 %72
}

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN5DinicC2Ei(ptr noundef nonnull align 8 dereferenceable(112), i32 noundef) unnamed_addr #2 align 2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(112) ptr @_ZN5DinicaSEOS_(ptr noundef nonnull align 8 dereferenceable(112), ptr noundef nonnull align 8 dereferenceable(112)) #0 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN5Dinic8add_edgeEiidi(ptr noundef nonnull align 8 dereferenceable(112), i32 noundef, i32 noundef, double noundef, i32 noundef) #2 align 2

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

; Function Attrs: mustprogress uwtable
declare dso_local noundef double @_ZN5Dinic8max_flowEii(ptr noundef nonnull align 8 dereferenceable(112), i32 noundef, i32 noundef) #2 align 2

attributes #0 = { inlinehint 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 = { 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 #3 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
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 = !{!"double", !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"}
!13 = distinct !{!13, !12}


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

%struct.Dinic = type { i32, i32, i32, i32, %"class.std::vector", %"class.std::vector", %"class.std::vector", %"class.std::vector.0" }
%"class.std::vector" = type { %"struct.std::_Vector_base" }
%"struct.std::_Vector_base" = type { %"struct.std::_Vector_base<int, std::allocator<int>>::_Vector_impl" }
%"struct.std::_Vector_base<int, std::allocator<int>>::_Vector_impl" = type { %"struct.std::_Vector_base<int, std::allocator<int>>::_Vector_impl_data" }
%"struct.std::_Vector_base<int, std::allocator<int>>::_Vector_impl_data" = type { ptr, ptr, ptr }
%"class.std::vector.0" = type { %"struct.std::_Vector_base.1" }
%"struct.std::_Vector_base.1" = type { %"struct.std::_Vector_base<std::vector<Dinic::edge>, std::allocator<std::vector<Dinic::edge>>>::_Vector_impl" }
%"struct.std::_Vector_base<std::vector<Dinic::edge>, std::allocator<std::vector<Dinic::edge>>>::_Vector_impl" = type { %"struct.std::_Vector_base<std::vector<Dinic::edge>, std::allocator<std::vector<Dinic::edge>>>::_Vector_impl_data" }
%"struct.std::_Vector_base<std::vector<Dinic::edge>, std::allocator<std::vector<Dinic::edge>>>::_Vector_impl_data" = type { ptr, ptr, ptr }

@F = external dso_local global %struct.Dinic, align 8
@s = external dso_local local_unnamed_addr global i32, align 4
@t = external dso_local local_unnamed_addr global i32, align 4
@n = external dso_local local_unnamed_addr global i32, align 4
@m = external dso_local local_unnamed_addr global i32, align 4
@u = external dso_local local_unnamed_addr global [1010 x i32], align 16
@v = external dso_local local_unnamed_addr global [1010 x i32], align 16
@deg = external dso_local local_unnamed_addr global [1010 x i32], align 16

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local void @_ZN5DinicD2Ev(ptr noundef nonnull align 8 dereferenceable(112)) unnamed_addr #0 align 2

; 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 uwtable
define dso_local noundef zeroext i1 @_Z2yod(double noundef %0) local_unnamed_addr #2 {
  %2 = alloca %struct.Dinic, align 8
  call void @llvm.lifetime.start.p0(i64 112, ptr nonnull %2) #4
  %3 = load i32, ptr @t, align 4, !tbaa !5
  call void @_ZN5DinicC2Ei(ptr noundef nonnull align 8 dereferenceable(112) %2, i32 noundef %3)
  %4 = call noundef nonnull align 8 dereferenceable(112) ptr @_ZN5DinicaSEOS_(ptr noundef nonnull align 8 dereferenceable(112) @F, ptr noundef nonnull align 8 dereferenceable(112) %2) #4
  call void @_ZN5DinicD2Ev(ptr noundef nonnull align 8 dereferenceable(112) %2) #4
  call void @llvm.lifetime.end.p0(i64 112, ptr nonnull %2) #4
  %5 = load i32, ptr @m, align 4, !tbaa !5
  %.not14 = icmp slt i32 %5, 1
  br i1 %.not14, label %.preheader, label %.lr.ph

.preheader:                                       ; preds = %.lr.ph, %1
  %6 = load i32, ptr @n, align 4, !tbaa !5
  %.not1316 = icmp slt i32 %6, 1
  br i1 %.not1316, label %._crit_edge, label %.lr.ph18

.lr.ph:                                           ; preds = %1, %.lr.ph
  %indvars.iv = phi i64 [ %indvars.iv.next, %.lr.ph ], [ 1, %1 ]
  %7 = getelementptr inbounds [1010 x i32], ptr @u, i64 0, i64 %indvars.iv
  %8 = load i32, ptr %7, align 4, !tbaa !5
  %9 = getelementptr inbounds [1010 x i32], ptr @v, i64 0, i64 %indvars.iv
  %10 = load i32, ptr %9, align 4, !tbaa !5
  call void @_ZN5Dinic8add_edgeEiidi(ptr noundef nonnull align 8 dereferenceable(112) @F, i32 noundef %8, i32 noundef %10, double noundef 1.000000e+00, i32 noundef -1)
  %11 = load i32, ptr %9, align 4, !tbaa !5
  %12 = load i32, ptr %7, align 4, !tbaa !5
  call void @_ZN5Dinic8add_edgeEiidi(ptr noundef nonnull align 8 dereferenceable(112) @F, i32 noundef %11, i32 noundef %12, double noundef 1.000000e+00, i32 noundef -1)
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %13 = load i32, ptr @m, align 4, !tbaa !5
  %14 = sext i32 %13 to i64
  %.not.not = icmp slt i64 %indvars.iv, %14
  br i1 %.not.not, label %.lr.ph, label %.preheader, !llvm.loop !9

._crit_edge:                                      ; preds = %.lr.ph18, %.preheader
  %15 = load i32, ptr @s, align 4, !tbaa !5
  %16 = load i32, ptr @t, align 4, !tbaa !5
  %17 = call noundef double @_ZN5Dinic8max_flowEii(ptr noundef nonnull align 8 dereferenceable(112) @F, i32 noundef %15, i32 noundef %16)
  %18 = load i32, ptr @m, align 4, !tbaa !5
  %19 = sitofp i32 %18 to double
  %20 = load i32, ptr @n, align 4, !tbaa !5
  %21 = sitofp i32 %20 to double
  %22 = fneg double %17
  %23 = call double @llvm.fmuladd.f64(double %19, double %21, double %22)
  %24 = fcmp ogt double %23, 1.000000e-09
  ret i1 %24

.lr.ph18:                                         ; preds = %.preheader, %.lr.ph18
  %indvars.iv20 = phi i64 [ %indvars.iv.next21, %.lr.ph18 ], [ 1, %.preheader ]
  %25 = load i32, ptr @s, align 4, !tbaa !5
  %26 = load i32, ptr @m, align 4, !tbaa !5
  %27 = sitofp i32 %26 to double
  %28 = trunc nuw nsw i64 %indvars.iv20 to i32
  call void @_ZN5Dinic8add_edgeEiidi(ptr noundef nonnull align 8 dereferenceable(112) @F, i32 noundef %25, i32 noundef %28, double noundef %27, i32 noundef -1)
  %29 = load i32, ptr @t, align 4, !tbaa !5
  %30 = load i32, ptr @m, align 4, !tbaa !5
  %31 = sitofp i32 %30 to double
  %32 = call double @llvm.fmuladd.f64(double %0, double 2.000000e+00, double %31)
  %33 = getelementptr inbounds [1010 x i32], ptr @deg, i64 0, i64 %indvars.iv20
  %34 = load i32, ptr %33, align 4, !tbaa !5
  %35 = sitofp i32 %34 to double
  %36 = fsub double %32, %35
  call void @_ZN5Dinic8add_edgeEiidi(ptr noundef nonnull align 8 dereferenceable(112) @F, i32 noundef %28, i32 noundef %29, double noundef %36, i32 noundef -1)
  %indvars.iv.next21 = add nuw nsw i64 %indvars.iv20, 1
  %37 = load i32, ptr @n, align 4, !tbaa !5
  %38 = sext i32 %37 to i64
  %.not13.not = icmp slt i64 %indvars.iv20, %38
  br i1 %.not13.not, label %.lr.ph18, label %._crit_edge, !llvm.loop !11
}

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN5DinicC2Ei(ptr noundef nonnull align 8 dereferenceable(112), i32 noundef) unnamed_addr #2 align 2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(112) ptr @_ZN5DinicaSEOS_(ptr noundef nonnull align 8 dereferenceable(112), ptr noundef nonnull align 8 dereferenceable(112)) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN5Dinic8add_edgeEiidi(ptr noundef nonnull align 8 dereferenceable(112), i32 noundef, i32 noundef, double noundef, i32 noundef) local_unnamed_addr #2 align 2

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

; Function Attrs: mustprogress uwtable
declare dso_local noundef double @_ZN5Dinic8max_flowEii(ptr noundef nonnull align 8 dereferenceable(112), i32 noundef, i32 noundef) local_unnamed_addr #2 align 2

attributes #0 = { inlinehint 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 = { 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 #3 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }
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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}
!11 = distinct !{!11, !10}


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