; LLVM IR from stivalaa/EstimNetDirected :: Test/TestChangeStatsBipartite (bipartiteStats)

; 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.graph_s = type { i32, i32, i32, i32, ptr, ptr, ptr, ptr, ptr, i32, ptr, ptr, ptr, i32, i32, i32, ptr, ptr, i32, ptr, ptr, i32, ptr, ptr, i32, ptr, ptr, ptr, i32, i32, i32, i32, i32, ptr, i32, i32, ptr, ptr, i32, ptr, i32, ptr, ptr, i32, i32, ptr, i32, ptr }

@.str = external hidden unnamed_addr constant [16 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [106 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [16 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [15 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [36 x i8], align 1
@__PRETTY_FUNCTION__.FourCyclesB_sum_by_node = external hidden unnamed_addr constant [53 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: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) #1

declare i32 @bipartite_node_mode(ptr noundef, i32 noundef) #2

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

declare i32 @num_four_cycles_node(ptr noundef, i32 noundef) #2

; Function Attrs: nounwind uwtable
define dso_local i64 @FourCyclesB_sum_by_node(ptr noundef %0) #3 {
  %2 = alloca ptr, align 8
  %3 = alloca i32, align 4
  %4 = alloca i64, align 8
  store ptr %0, ptr %2, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #4
  store i64 0, ptr %4, align 8, !tbaa !9
  %5 = load ptr, ptr %2, align 8, !tbaa !5
  %6 = getelementptr inbounds %struct.graph_s, ptr %5, i32 0, i32 2
  %7 = load i32, ptr %6, align 8, !tbaa !11
  %8 = icmp ne i32 %7, 0
  br i1 %8, label %9, label %10

9:                                                ; preds = %1
  br label %11

10:                                               ; preds = %1
  call void @__assert_fail(ptr noundef @.str, ptr noundef @.str.1, i32 noundef 239, ptr noundef @__PRETTY_FUNCTION__.FourCyclesB_sum_by_node) #5
  unreachable

11:                                               ; preds = %9
  %12 = load ptr, ptr %2, align 8, !tbaa !5
  %13 = getelementptr inbounds %struct.graph_s, ptr %12, i32 0, i32 1
  %14 = load i32, ptr %13, align 4, !tbaa !14
  %15 = icmp ne i32 %14, 0
  br i1 %15, label %17, label %16

16:                                               ; preds = %11
  br label %18

17:                                               ; preds = %11
  call void @__assert_fail(ptr noundef @.str.2, ptr noundef @.str.1, i32 noundef 240, ptr noundef @__PRETTY_FUNCTION__.FourCyclesB_sum_by_node) #5
  unreachable

18:                                               ; preds = %16
  %19 = load ptr, ptr %2, align 8, !tbaa !5
  %20 = getelementptr inbounds %struct.graph_s, ptr %19, i32 0, i32 13
  %21 = load i32, ptr %20, align 8, !tbaa !15
  store i32 %21, ptr %3, align 4, !tbaa !16
  br label %22

22:                                               ; preds = %46, %18
  %23 = load i32, ptr %3, align 4, !tbaa !16
  %24 = load ptr, ptr %2, align 8, !tbaa !5
  %25 = getelementptr inbounds %struct.graph_s, ptr %24, i32 0, i32 13
  %26 = load i32, ptr %25, align 8, !tbaa !15
  %27 = load ptr, ptr %2, align 8, !tbaa !5
  %28 = getelementptr inbounds %struct.graph_s, ptr %27, i32 0, i32 14
  %29 = load i32, ptr %28, align 4, !tbaa !17
  %30 = add i32 %26, %29
  %31 = icmp ult i32 %23, %30
  br i1 %31, label %32, label %49

32:                                               ; preds = %22
  %33 = load ptr, ptr %2, align 8, !tbaa !5
  %34 = load i32, ptr %3, align 4, !tbaa !16
  %35 = call i32 @bipartite_node_mode(ptr noundef %33, i32 noundef %34)
  %36 = icmp eq i32 %35, 1
  br i1 %36, label %37, label %38

37:                                               ; preds = %32
  br label %39

38:                                               ; preds = %32
  call void @__assert_fail(ptr noundef @.str.6, ptr noundef @.str.1, i32 noundef 243, ptr noundef @__PRETTY_FUNCTION__.FourCyclesB_sum_by_node) #5
  unreachable

39:                                               ; preds = %37
  %40 = load ptr, ptr %2, align 8, !tbaa !5
  %41 = load i32, ptr %3, align 4, !tbaa !16
  %42 = call i32 @num_four_cycles_node(ptr noundef %40, i32 noundef %41)
  %43 = zext i32 %42 to i64
  %44 = load i64, ptr %4, align 8, !tbaa !9
  %45 = add i64 %44, %43
  store i64 %45, ptr %4, align 8, !tbaa !9
  br label %46

46:                                               ; preds = %39
  %47 = load i32, ptr %3, align 4, !tbaa !16
  %48 = add i32 %47, 1
  store i32 %48, ptr %3, align 4, !tbaa !16
  br label %22, !llvm.loop !18

49:                                               ; preds = %22
  %50 = load i64, ptr %4, align 8, !tbaa !9
  %51 = urem i64 %50, 2
  %52 = icmp eq i64 %51, 0
  br i1 %52, label %53, label %54

53:                                               ; preds = %49
  br label %55

54:                                               ; preds = %49
  call void @__assert_fail(ptr noundef @.str.5, ptr noundef @.str.1, i32 noundef 247, ptr noundef @__PRETTY_FUNCTION__.FourCyclesB_sum_by_node) #5
  unreachable

55:                                               ; preds = %53
  %56 = load i64, ptr %4, align 8, !tbaa !9
  %57 = udiv i64 %56, 2
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #4
  ret i64 %57
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { noreturn 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 #2 = { "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 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 #4 = { nounwind }
attributes #5 = { noreturn 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/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"long long", !7, i64 0}
!11 = !{!12, !13, i64 8}
!12 = !{!"graph_s", !13, i64 0, !13, i64 4, !13, i64 8, !13, i64 12, !6, i64 16, !6, i64 24, !6, i64 32, !6, i64 40, !6, i64 48, !13, i64 56, !6, i64 64, !6, i64 72, !6, i64 80, !13, i64 88, !13, i64 92, !13, i64 96, !6, i64 104, !6, i64 112, !13, i64 120, !6, i64 128, !6, i64 136, !13, i64 144, !6, i64 152, !6, i64 160, !13, i64 168, !6, i64 176, !6, i64 184, !6, i64 192, !13, i64 200, !13, i64 204, !13, i64 208, !13, i64 212, !13, i64 216, !6, i64 224, !13, i64 232, !13, i64 236, !6, i64 240, !6, i64 248, !13, i64 256, !6, i64 264, !13, i64 272, !6, i64 280, !6, i64 288, !13, i64 296, !13, i64 300, !6, i64 304, !13, i64 312, !6, i64 320}
!13 = !{!"int", !7, i64 0}
!14 = !{!12, !13, i64 4}
!15 = !{!12, !13, i64 88}
!16 = !{!13, !13, i64 0}
!17 = !{!12, !13, i64 92}
!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"

@.str = external hidden unnamed_addr constant [16 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [106 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [16 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [15 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [36 x i8], align 1
@__PRETTY_FUNCTION__.FourCyclesB_sum_by_node = external hidden unnamed_addr constant [53 x i8], align 1

; Function Attrs: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) local_unnamed_addr #0

declare i32 @bipartite_node_mode(ptr noundef, i32 noundef) local_unnamed_addr #1

declare i32 @num_four_cycles_node(ptr noundef, i32 noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
define dso_local range(i64 0, -9223372036854775808) i64 @FourCyclesB_sum_by_node(ptr noundef %0) local_unnamed_addr #2 {
  %2 = getelementptr inbounds i8, ptr %0, i64 8
  %3 = load i32, ptr %2, align 8, !tbaa !5
  %.not = icmp eq i32 %3, 0
  br i1 %.not, label %4, label %5

4:                                                ; preds = %1
  tail call void @__assert_fail(ptr noundef nonnull @.str, ptr noundef nonnull @.str.1, i32 noundef 239, ptr noundef nonnull @__PRETTY_FUNCTION__.FourCyclesB_sum_by_node) #3
  unreachable

5:                                                ; preds = %1
  %6 = getelementptr inbounds i8, ptr %0, i64 4
  %7 = load i32, ptr %6, align 4, !tbaa !11
  %.not14 = icmp eq i32 %7, 0
  br i1 %.not14, label %9, label %8

8:                                                ; preds = %5
  tail call void @__assert_fail(ptr noundef nonnull @.str.2, ptr noundef nonnull @.str.1, i32 noundef 240, ptr noundef nonnull @__PRETTY_FUNCTION__.FourCyclesB_sum_by_node) #3
  unreachable

9:                                                ; preds = %5
  %10 = getelementptr inbounds i8, ptr %0, i64 88
  %11 = load i32, ptr %10, align 8, !tbaa !12
  %12 = getelementptr inbounds i8, ptr %0, i64 92
  %13 = load i32, ptr %12, align 4, !tbaa !13
  %14 = add i32 %13, %11
  %15 = icmp ult i32 %11, %14
  br i1 %15, label %.lr.ph, label %._crit_edge.thread

.lr.ph:                                           ; preds = %9, %19
  %.017 = phi i64 [ %22, %19 ], [ 0, %9 ]
  %.01316 = phi i32 [ %23, %19 ], [ %11, %9 ]
  %16 = tail call i32 @bipartite_node_mode(ptr noundef nonnull %0, i32 noundef %.01316) #4
  %17 = icmp eq i32 %16, 1
  br i1 %17, label %19, label %18

18:                                               ; preds = %.lr.ph
  tail call void @__assert_fail(ptr noundef nonnull @.str.6, ptr noundef nonnull @.str.1, i32 noundef 243, ptr noundef nonnull @__PRETTY_FUNCTION__.FourCyclesB_sum_by_node) #3
  unreachable

19:                                               ; preds = %.lr.ph
  %20 = tail call i32 @num_four_cycles_node(ptr noundef nonnull %0, i32 noundef %.01316) #4
  %21 = zext i32 %20 to i64
  %22 = add i64 %.017, %21
  %23 = add nuw i32 %.01316, 1
  %24 = load i32, ptr %10, align 8, !tbaa !12
  %25 = load i32, ptr %12, align 4, !tbaa !13
  %26 = add i32 %25, %24
  %27 = icmp ult i32 %23, %26
  br i1 %27, label %.lr.ph, label %._crit_edge, !llvm.loop !14

._crit_edge:                                      ; preds = %19
  %28 = and i64 %22, 1
  %29 = icmp eq i64 %28, 0
  br i1 %29, label %._crit_edge.thread, label %30

30:                                               ; preds = %._crit_edge
  tail call void @__assert_fail(ptr noundef nonnull @.str.5, ptr noundef nonnull @.str.1, i32 noundef 247, ptr noundef nonnull @__PRETTY_FUNCTION__.FourCyclesB_sum_by_node) #3
  unreachable

._crit_edge.thread:                               ; preds = %9, %._crit_edge
  %.0.lcssa19 = phi i64 [ %22, %._crit_edge ], [ 0, %9 ]
  %31 = lshr exact i64 %.0.lcssa19, 1
  ret i64 %31
}

attributes #0 = { noreturn 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 #1 = { "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 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 = { noreturn nounwind }
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, !7, i64 8}
!6 = !{!"graph_s", !7, i64 0, !7, i64 4, !7, i64 8, !7, i64 12, !10, i64 16, !10, i64 24, !10, i64 32, !10, i64 40, !10, i64 48, !7, i64 56, !10, i64 64, !10, i64 72, !10, i64 80, !7, i64 88, !7, i64 92, !7, i64 96, !10, i64 104, !10, i64 112, !7, i64 120, !10, i64 128, !10, i64 136, !7, i64 144, !10, i64 152, !10, i64 160, !7, i64 168, !10, i64 176, !10, i64 184, !10, i64 192, !7, i64 200, !7, i64 204, !7, i64 208, !7, i64 212, !7, i64 216, !10, i64 224, !7, i64 232, !7, i64 236, !10, i64 240, !10, i64 248, !7, i64 256, !10, i64 264, !7, i64 272, !10, i64 280, !10, i64 288, !7, i64 296, !7, i64 300, !10, i64 304, !7, i64 312, !10, i64 320}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"any pointer", !8, i64 0}
!11 = !{!6, !7, i64 4}
!12 = !{!6, !7, i64 88}
!13 = !{!6, !7, i64 92}
!14 = distinct !{!14, !15}
!15 = !{!"llvm.loop.mustprogress"}


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