; LLVM IR from conradlee/network-community-benchmark :: comm_algs/louvain/community.ll (ZN9Community10modularityEv)

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

%class.Community = type { %class.Graph, i32, %"class.std::vector", %"class.std::vector", %"class.std::vector", i32, double, double }
%class.Graph = type { i32, i32, i32, ptr, ptr, ptr }
%"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 }

; 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 nounwind uwtable
declare dso_local noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt6vectorIiSaIiEEixEm(ptr noundef nonnull align 8 dereferenceable(24), i64 noundef) #1 align 2

; Function Attrs: mustprogress nounwind uwtable
define dso_local noundef double @_ZN9Community10modularityEv(ptr noundef nonnull align 8 dereferenceable(144) %0) #1 align 2 {
  %2 = alloca ptr, align 8
  %3 = alloca double, align 8
  %4 = alloca double, align 8
  %5 = alloca i32, align 4
  store ptr %0, ptr %2, align 8, !tbaa !5
  %6 = load ptr, ptr %2, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #3
  %7 = getelementptr inbounds %class.Community, ptr %6, i32 0, i32 7
  %8 = load double, ptr %7, align 8, !tbaa !9
  %9 = fsub double 1.000000e+00, %8
  store double %9, ptr %3, align 8, !tbaa !18
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #3
  %10 = getelementptr inbounds %class.Community, ptr %6, i32 0, i32 0
  %11 = getelementptr inbounds %class.Graph, ptr %10, i32 0, i32 2
  %12 = load i32, ptr %11, align 8, !tbaa !19
  %13 = sitofp i32 %12 to double
  store double %13, ptr %4, align 8, !tbaa !18
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #3
  store i32 0, ptr %5, align 4, !tbaa !20
  br label %14

14:                                               ; preds = %60, %1
  %15 = load i32, ptr %5, align 4, !tbaa !20
  %16 = getelementptr inbounds %class.Community, ptr %6, i32 0, i32 1
  %17 = load i32, ptr %16, align 8, !tbaa !21
  %18 = icmp slt i32 %15, %17
  br i1 %18, label %20, label %19

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

20:                                               ; preds = %14
  %21 = getelementptr inbounds %class.Community, ptr %6, i32 0, i32 4
  %22 = load i32, ptr %5, align 4, !tbaa !20
  %23 = sext i32 %22 to i64
  %24 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt6vectorIiSaIiEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %21, i64 noundef %23) #3
  %25 = load i32, ptr %24, align 4, !tbaa !20
  %26 = icmp sgt i32 %25, 0
  br i1 %26, label %27, label %59

27:                                               ; preds = %20
  %28 = getelementptr inbounds %class.Community, ptr %6, i32 0, i32 7
  %29 = load double, ptr %28, align 8, !tbaa !9
  %30 = getelementptr inbounds %class.Community, ptr %6, i32 0, i32 3
  %31 = load i32, ptr %5, align 4, !tbaa !20
  %32 = sext i32 %31 to i64
  %33 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt6vectorIiSaIiEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %30, i64 noundef %32) #3
  %34 = load i32, ptr %33, align 4, !tbaa !20
  %35 = sitofp i32 %34 to double
  %36 = fmul double %29, %35
  %37 = load double, ptr %4, align 8, !tbaa !18
  %38 = fdiv double %36, %37
  %39 = getelementptr inbounds %class.Community, ptr %6, i32 0, i32 4
  %40 = load i32, ptr %5, align 4, !tbaa !20
  %41 = sext i32 %40 to i64
  %42 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt6vectorIiSaIiEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %39, i64 noundef %41) #3
  %43 = load i32, ptr %42, align 4, !tbaa !20
  %44 = sitofp i32 %43 to double
  %45 = load double, ptr %4, align 8, !tbaa !18
  %46 = fdiv double %44, %45
  %47 = getelementptr inbounds %class.Community, ptr %6, i32 0, i32 4
  %48 = load i32, ptr %5, align 4, !tbaa !20
  %49 = sext i32 %48 to i64
  %50 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt6vectorIiSaIiEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %47, i64 noundef %49) #3
  %51 = load i32, ptr %50, align 4, !tbaa !20
  %52 = sitofp i32 %51 to double
  %53 = load double, ptr %4, align 8, !tbaa !18
  %54 = fdiv double %52, %53
  %55 = fneg double %46
  %56 = call double @llvm.fmuladd.f64(double %55, double %54, double %38)
  %57 = load double, ptr %3, align 8, !tbaa !18
  %58 = fadd double %57, %56
  store double %58, ptr %3, align 8, !tbaa !18
  br label %59

59:                                               ; preds = %27, %20
  br label %60

60:                                               ; preds = %59
  %61 = load i32, ptr %5, align 4, !tbaa !20
  %62 = add nsw i32 %61, 1
  store i32 %62, ptr %5, align 4, !tbaa !20
  br label %14, !llvm.loop !22

63:                                               ; preds = %19
  %64 = load double, ptr %3, align 8, !tbaa !18
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #3
  ret double %64
}

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

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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" }
attributes #2 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
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, !17, i64 136}
!10 = !{!"_ZTS9Community", !11, i64 0, !12, i64 40, !13, i64 48, !13, i64 72, !13, i64 96, !12, i64 120, !17, i64 128, !17, i64 136}
!11 = !{!"_ZTS5Graph", !12, i64 0, !12, i64 4, !12, i64 8, !6, i64 16, !6, i64 24, !6, i64 32}
!12 = !{!"int", !7, i64 0}
!13 = !{!"_ZTSSt6vectorIiSaIiEE", !14, i64 0}
!14 = !{!"_ZTSSt12_Vector_baseIiSaIiEE", !15, i64 0}
!15 = !{!"_ZTSNSt12_Vector_baseIiSaIiEE12_Vector_implE", !16, i64 0}
!16 = !{!"_ZTSNSt12_Vector_baseIiSaIiEE17_Vector_impl_dataE", !6, i64 0, !6, i64 8, !6, i64 16}
!17 = !{!"double", !7, i64 0}
!18 = !{!17, !17, i64 0}
!19 = !{!10, !12, i64 8}
!20 = !{!12, !12, i64 0}
!21 = !{!10, !12, i64 40}
!22 = distinct !{!22, !23}
!23 = !{!"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 noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt6vectorIiSaIiEEixEm(ptr noundef nonnull align 8 dereferenceable(24), i64 noundef) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress nounwind uwtable
define dso_local noundef double @_ZN9Community10modularityEv(ptr noundef nonnull align 8 dereferenceable(144) %0) local_unnamed_addr #0 align 2 {
  %2 = getelementptr inbounds i8, ptr %0, i64 136
  %3 = load double, ptr %2, align 8, !tbaa !5
  %4 = fsub double 1.000000e+00, %3
  %5 = getelementptr inbounds i8, ptr %0, i64 8
  %6 = load i32, ptr %5, align 8, !tbaa !17
  %7 = sitofp i32 %6 to double
  %8 = getelementptr inbounds i8, ptr %0, i64 40
  %9 = load i32, ptr %8, align 8, !tbaa !18
  %10 = icmp sgt i32 %9, 0
  br i1 %10, label %.lr.ph, label %._crit_edge

.lr.ph:                                           ; preds = %1
  %11 = getelementptr inbounds i8, ptr %0, i64 96
  %12 = getelementptr inbounds i8, ptr %0, i64 72
  br label %13

._crit_edge:                                      ; preds = %35, %1
  %.011.lcssa = phi double [ %4, %1 ], [ %.1, %35 ]
  ret double %.011.lcssa

13:                                               ; preds = %.lr.ph, %35
  %indvars.iv = phi i64 [ 0, %.lr.ph ], [ %indvars.iv.next, %35 ]
  %.01112 = phi double [ %4, %.lr.ph ], [ %.1, %35 ]
  %14 = tail call noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt6vectorIiSaIiEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %11, i64 noundef %indvars.iv) #2
  %15 = load i32, ptr %14, align 4, !tbaa !19
  %16 = icmp sgt i32 %15, 0
  br i1 %16, label %17, label %35

17:                                               ; preds = %13
  %18 = load double, ptr %2, align 8, !tbaa !5
  %19 = tail call noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt6vectorIiSaIiEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %12, i64 noundef %indvars.iv) #2
  %20 = load i32, ptr %19, align 4, !tbaa !19
  %21 = sitofp i32 %20 to double
  %22 = fmul double %18, %21
  %23 = fdiv double %22, %7
  %24 = tail call noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt6vectorIiSaIiEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %11, i64 noundef %indvars.iv) #2
  %25 = load i32, ptr %24, align 4, !tbaa !19
  %26 = sitofp i32 %25 to double
  %27 = tail call noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt6vectorIiSaIiEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %11, i64 noundef %indvars.iv) #2
  %28 = load i32, ptr %27, align 4, !tbaa !19
  %29 = sitofp i32 %28 to double
  %30 = fdiv double %29, %7
  %31 = fneg double %26
  %32 = fdiv double %31, %7
  %33 = tail call double @llvm.fmuladd.f64(double %32, double %30, double %23)
  %34 = fadd double %.01112, %33
  br label %35

35:                                               ; preds = %13, %17
  %.1 = phi double [ %34, %17 ], [ %.01112, %13 ]
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %36 = load i32, ptr %8, align 8, !tbaa !18
  %37 = sext i32 %36 to i64
  %38 = icmp slt i64 %indvars.iv.next, %37
  br i1 %38, label %13, label %._crit_edge, !llvm.loop !20
}

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

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 speculatable willreturn memory(none) }
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, !16, i64 136}
!6 = !{!"_ZTS9Community", !7, i64 0, !8, i64 40, !12, i64 48, !12, i64 72, !12, i64 96, !8, i64 120, !16, i64 128, !16, i64 136}
!7 = !{!"_ZTS5Graph", !8, i64 0, !8, i64 4, !8, i64 8, !11, i64 16, !11, i64 24, !11, i64 32}
!8 = !{!"int", !9, i64 0}
!9 = !{!"omnipotent char", !10, i64 0}
!10 = !{!"Simple C++ TBAA"}
!11 = !{!"any pointer", !9, i64 0}
!12 = !{!"_ZTSSt6vectorIiSaIiEE", !13, i64 0}
!13 = !{!"_ZTSSt12_Vector_baseIiSaIiEE", !14, i64 0}
!14 = !{!"_ZTSNSt12_Vector_baseIiSaIiEE12_Vector_implE", !15, i64 0}
!15 = !{!"_ZTSNSt12_Vector_baseIiSaIiEE17_Vector_impl_dataE", !11, i64 0, !11, i64 8, !11, i64 16}
!16 = !{!"double", !9, i64 0}
!17 = !{!6, !8, i64 8}
!18 = !{!6, !8, i64 40}
!19 = !{!8, !8, i64 0}
!20 = distinct !{!20, !21}
!21 = !{!"llvm.loop.mustprogress"}


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