; LLVM IR from stivalaa/EstimNetDirected :: src (graph)

; 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 }
%struct.nodepair_s = type { i32, i32 }

@.str.1 = external hidden unnamed_addr constant [71 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [16 x i8], align 1
@.str.25 = external hidden unnamed_addr constant [53 x i8], align 1
@.str.26 = external hidden unnamed_addr constant [47 x i8], align 1
@__PRETTY_FUNCTION__.removeEdge_allinneredges = external hidden unnamed_addr constant [65 x i8], align 1
@.str.28 = external hidden unnamed_addr constant [69 x i8], align 1

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

declare ptr @safe_realloc(ptr noundef, i64 noundef) #1

; Function Attrs: nounwind uwtable
declare dso_local void @removeEdge(ptr noundef, i32 noundef, i32 noundef) #2

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i64 @llvm.abs.i64(i64, i1 immarg) #3

; Function Attrs: nounwind uwtable
define dso_local void @removeEdge_allinneredges(ptr noundef %0, i32 noundef %1, i32 noundef %2, i32 noundef %3) #2 {
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  store ptr %0, ptr %5, align 8, !tbaa !5
  store i32 %1, ptr %6, align 4, !tbaa !9
  store i32 %2, ptr %7, align 4, !tbaa !9
  store i32 %3, ptr %8, align 4, !tbaa !9
  %9 = load ptr, ptr %5, align 8, !tbaa !5
  %10 = getelementptr inbounds %struct.graph_s, ptr %9, i32 0, i32 1
  %11 = load i32, ptr %10, align 4, !tbaa !11
  %12 = icmp ne i32 %11, 0
  br i1 %12, label %14, label %13

13:                                               ; preds = %4
  br label %15

14:                                               ; preds = %4
  call void @__assert_fail(ptr noundef @.str.2, ptr noundef @.str.1, i32 noundef 1645, ptr noundef @__PRETTY_FUNCTION__.removeEdge_allinneredges) #4
  unreachable

15:                                               ; preds = %13
  %16 = load ptr, ptr %5, align 8, !tbaa !5
  %17 = getelementptr inbounds %struct.graph_s, ptr %16, i32 0, i32 33
  %18 = load ptr, ptr %17, align 8, !tbaa !13
  %19 = load i32, ptr %6, align 4, !tbaa !9
  %20 = zext i32 %19 to i64
  %21 = getelementptr inbounds i32, ptr %18, i64 %20
  %22 = load i32, ptr %21, align 4, !tbaa !9
  %23 = load ptr, ptr %5, align 8, !tbaa !5
  %24 = getelementptr inbounds %struct.graph_s, ptr %23, i32 0, i32 34
  %25 = load i32, ptr %24, align 8, !tbaa !14
  %26 = icmp ult i32 %22, %25
  br i1 %26, label %27, label %40

27:                                               ; preds = %15
  %28 = load ptr, ptr %5, align 8, !tbaa !5
  %29 = getelementptr inbounds %struct.graph_s, ptr %28, i32 0, i32 33
  %30 = load ptr, ptr %29, align 8, !tbaa !13
  %31 = load i32, ptr %7, align 4, !tbaa !9
  %32 = zext i32 %31 to i64
  %33 = getelementptr inbounds i32, ptr %30, i64 %32
  %34 = load i32, ptr %33, align 4, !tbaa !9
  %35 = load ptr, ptr %5, align 8, !tbaa !5
  %36 = getelementptr inbounds %struct.graph_s, ptr %35, i32 0, i32 34
  %37 = load i32, ptr %36, align 8, !tbaa !14
  %38 = icmp ult i32 %34, %37
  br i1 %38, label %39, label %40

39:                                               ; preds = %27
  br label %41

40:                                               ; preds = %27, %15
  call void @__assert_fail(ptr noundef @.str.25, ptr noundef @.str.1, i32 noundef 1646, ptr noundef @__PRETTY_FUNCTION__.removeEdge_allinneredges) #4
  unreachable

41:                                               ; preds = %39
  %42 = load ptr, ptr %5, align 8, !tbaa !5
  %43 = getelementptr inbounds %struct.graph_s, ptr %42, i32 0, i32 33
  %44 = load ptr, ptr %43, align 8, !tbaa !13
  %45 = load i32, ptr %6, align 4, !tbaa !9
  %46 = zext i32 %45 to i64
  %47 = getelementptr inbounds i32, ptr %44, i64 %46
  %48 = load i32, ptr %47, align 4, !tbaa !9
  %49 = zext i32 %48 to i64
  %50 = load ptr, ptr %5, align 8, !tbaa !5
  %51 = getelementptr inbounds %struct.graph_s, ptr %50, i32 0, i32 33
  %52 = load ptr, ptr %51, align 8, !tbaa !13
  %53 = load i32, ptr %7, align 4, !tbaa !9
  %54 = zext i32 %53 to i64
  %55 = getelementptr inbounds i32, ptr %52, i64 %54
  %56 = load i32, ptr %55, align 4, !tbaa !9
  %57 = zext i32 %56 to i64
  %58 = sub nsw i64 %49, %57
  %59 = call i64 @llvm.abs.i64(i64 %58, i1 true)
  %60 = icmp sle i64 %59, 1
  br i1 %60, label %61, label %62

61:                                               ; preds = %41
  br label %63

62:                                               ; preds = %41
  call void @__assert_fail(ptr noundef @.str.26, ptr noundef @.str.1, i32 noundef 1647, ptr noundef @__PRETTY_FUNCTION__.removeEdge_allinneredges) #4
  unreachable

63:                                               ; preds = %61
  %64 = load ptr, ptr %5, align 8, !tbaa !5
  %65 = load i32, ptr %6, align 4, !tbaa !9
  %66 = load i32, ptr %7, align 4, !tbaa !9
  call void @removeEdge(ptr noundef %64, i32 noundef %65, i32 noundef %66)
  %67 = load ptr, ptr %5, align 8, !tbaa !5
  %68 = getelementptr inbounds %struct.graph_s, ptr %67, i32 0, i32 41
  %69 = load ptr, ptr %68, align 8, !tbaa !15
  %70 = load i32, ptr %8, align 4, !tbaa !9
  %71 = zext i32 %70 to i64
  %72 = getelementptr inbounds %struct.nodepair_s, ptr %69, i64 %71
  %73 = getelementptr inbounds %struct.nodepair_s, ptr %72, i32 0, i32 0
  %74 = load i32, ptr %73, align 4, !tbaa !16
  %75 = load i32, ptr %6, align 4, !tbaa !9
  %76 = icmp eq i32 %74, %75
  br i1 %76, label %77, label %89

77:                                               ; preds = %63
  %78 = load ptr, ptr %5, align 8, !tbaa !5
  %79 = getelementptr inbounds %struct.graph_s, ptr %78, i32 0, i32 41
  %80 = load ptr, ptr %79, align 8, !tbaa !15
  %81 = load i32, ptr %8, align 4, !tbaa !9
  %82 = zext i32 %81 to i64
  %83 = getelementptr inbounds %struct.nodepair_s, ptr %80, i64 %82
  %84 = getelementptr inbounds %struct.nodepair_s, ptr %83, i32 0, i32 1
  %85 = load i32, ptr %84, align 4, !tbaa !18
  %86 = load i32, ptr %7, align 4, !tbaa !9
  %87 = icmp eq i32 %85, %86
  br i1 %87, label %88, label %89

88:                                               ; preds = %77
  br label %90

89:                                               ; preds = %77, %63
  call void @__assert_fail(ptr noundef @.str.28, ptr noundef @.str.1, i32 noundef 1650, ptr noundef @__PRETTY_FUNCTION__.removeEdge_allinneredges) #4
  unreachable

90:                                               ; preds = %88
  %91 = load ptr, ptr %5, align 8, !tbaa !5
  %92 = getelementptr inbounds %struct.graph_s, ptr %91, i32 0, i32 40
  %93 = load i32, ptr %92, align 8, !tbaa !19
  %94 = add i32 %93, -1
  store i32 %94, ptr %92, align 8, !tbaa !19
  %95 = load ptr, ptr %5, align 8, !tbaa !5
  %96 = getelementptr inbounds %struct.graph_s, ptr %95, i32 0, i32 41
  %97 = load ptr, ptr %96, align 8, !tbaa !15
  %98 = load ptr, ptr %5, align 8, !tbaa !5
  %99 = getelementptr inbounds %struct.graph_s, ptr %98, i32 0, i32 40
  %100 = load i32, ptr %99, align 8, !tbaa !19
  %101 = zext i32 %100 to i64
  %102 = getelementptr inbounds %struct.nodepair_s, ptr %97, i64 %101
  %103 = getelementptr inbounds %struct.nodepair_s, ptr %102, i32 0, i32 0
  %104 = load i32, ptr %103, align 4, !tbaa !16
  %105 = load ptr, ptr %5, align 8, !tbaa !5
  %106 = getelementptr inbounds %struct.graph_s, ptr %105, i32 0, i32 41
  %107 = load ptr, ptr %106, align 8, !tbaa !15
  %108 = load i32, ptr %8, align 4, !tbaa !9
  %109 = zext i32 %108 to i64
  %110 = getelementptr inbounds %struct.nodepair_s, ptr %107, i64 %109
  %111 = getelementptr inbounds %struct.nodepair_s, ptr %110, i32 0, i32 0
  store i32 %104, ptr %111, align 4, !tbaa !16
  %112 = load ptr, ptr %5, align 8, !tbaa !5
  %113 = getelementptr inbounds %struct.graph_s, ptr %112, i32 0, i32 41
  %114 = load ptr, ptr %113, align 8, !tbaa !15
  %115 = load ptr, ptr %5, align 8, !tbaa !5
  %116 = getelementptr inbounds %struct.graph_s, ptr %115, i32 0, i32 40
  %117 = load i32, ptr %116, align 8, !tbaa !19
  %118 = zext i32 %117 to i64
  %119 = getelementptr inbounds %struct.nodepair_s, ptr %114, i64 %118
  %120 = getelementptr inbounds %struct.nodepair_s, ptr %119, i32 0, i32 1
  %121 = load i32, ptr %120, align 4, !tbaa !18
  %122 = load ptr, ptr %5, align 8, !tbaa !5
  %123 = getelementptr inbounds %struct.graph_s, ptr %122, i32 0, i32 41
  %124 = load ptr, ptr %123, align 8, !tbaa !15
  %125 = load i32, ptr %8, align 4, !tbaa !9
  %126 = zext i32 %125 to i64
  %127 = getelementptr inbounds %struct.nodepair_s, ptr %124, i64 %126
  %128 = getelementptr inbounds %struct.nodepair_s, ptr %127, i32 0, i32 1
  store i32 %121, ptr %128, align 4, !tbaa !18
  %129 = load ptr, ptr %5, align 8, !tbaa !5
  %130 = getelementptr inbounds %struct.graph_s, ptr %129, i32 0, i32 41
  %131 = load ptr, ptr %130, align 8, !tbaa !15
  %132 = load ptr, ptr %5, align 8, !tbaa !5
  %133 = getelementptr inbounds %struct.graph_s, ptr %132, i32 0, i32 40
  %134 = load i32, ptr %133, align 8, !tbaa !19
  %135 = zext i32 %134 to i64
  %136 = mul i64 %135, 8
  %137 = call ptr @safe_realloc(ptr noundef %131, i64 noundef %136)
  %138 = load ptr, ptr %5, align 8, !tbaa !5
  %139 = getelementptr inbounds %struct.graph_s, ptr %138, i32 0, i32 41
  store ptr %137, ptr %139, align 8, !tbaa !15
  ret void
}

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


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

@.str.1 = external hidden unnamed_addr constant [71 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [16 x i8], align 1
@.str.25 = external hidden unnamed_addr constant [53 x i8], align 1
@.str.26 = external hidden unnamed_addr constant [47 x i8], align 1
@__PRETTY_FUNCTION__.removeEdge_allinneredges = external hidden unnamed_addr constant [65 x i8], align 1
@.str.28 = external hidden unnamed_addr constant [69 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 ptr @safe_realloc(ptr noundef, i64 noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
declare dso_local void @removeEdge(ptr noundef, i32 noundef, i32 noundef) local_unnamed_addr #2

; Function Attrs: mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i64 @llvm.abs.i64(i64, i1 immarg) #3

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

7:                                                ; preds = %4
  tail call void @__assert_fail(ptr noundef nonnull @.str.2, ptr noundef nonnull @.str.1, i32 noundef 1645, ptr noundef nonnull @__PRETTY_FUNCTION__.removeEdge_allinneredges) #4
  unreachable

8:                                                ; preds = %4
  %9 = getelementptr inbounds i8, ptr %0, i64 224
  %10 = load ptr, ptr %9, align 8, !tbaa !11
  %11 = zext i32 %1 to i64
  %12 = getelementptr inbounds i32, ptr %10, i64 %11
  %13 = load i32, ptr %12, align 4, !tbaa !12
  %14 = getelementptr inbounds i8, ptr %0, i64 232
  %15 = load i32, ptr %14, align 8, !tbaa !13
  %16 = icmp ult i32 %13, %15
  br i1 %16, label %17, label %22

17:                                               ; preds = %8
  %18 = zext i32 %2 to i64
  %19 = getelementptr inbounds i32, ptr %10, i64 %18
  %20 = load i32, ptr %19, align 4, !tbaa !12
  %21 = icmp ult i32 %20, %15
  br i1 %21, label %23, label %22

22:                                               ; preds = %17, %8
  tail call void @__assert_fail(ptr noundef nonnull @.str.25, ptr noundef nonnull @.str.1, i32 noundef 1646, ptr noundef nonnull @__PRETTY_FUNCTION__.removeEdge_allinneredges) #4
  unreachable

23:                                               ; preds = %17
  %24 = zext i32 %13 to i64
  %25 = zext i32 %20 to i64
  %26 = sub nsw i64 %24, %25
  %27 = tail call i64 @llvm.abs.i64(i64 %26, i1 true)
  %28 = icmp ult i64 %27, 2
  br i1 %28, label %30, label %29

29:                                               ; preds = %23
  tail call void @__assert_fail(ptr noundef nonnull @.str.26, ptr noundef nonnull @.str.1, i32 noundef 1647, ptr noundef nonnull @__PRETTY_FUNCTION__.removeEdge_allinneredges) #4
  unreachable

30:                                               ; preds = %23
  tail call void @removeEdge(ptr noundef nonnull %0, i32 noundef %1, i32 noundef %2)
  %31 = getelementptr inbounds i8, ptr %0, i64 280
  %32 = load ptr, ptr %31, align 8, !tbaa !14
  %33 = zext i32 %3 to i64
  %34 = getelementptr inbounds %struct.nodepair_s, ptr %32, i64 %33
  %35 = load i32, ptr %34, align 4, !tbaa !15
  %36 = icmp eq i32 %35, %1
  br i1 %36, label %37, label %41

37:                                               ; preds = %30
  %38 = getelementptr inbounds i8, ptr %34, i64 4
  %39 = load i32, ptr %38, align 4, !tbaa !17
  %40 = icmp eq i32 %39, %2
  br i1 %40, label %42, label %41

41:                                               ; preds = %37, %30
  tail call void @__assert_fail(ptr noundef nonnull @.str.28, ptr noundef nonnull @.str.1, i32 noundef 1650, ptr noundef nonnull @__PRETTY_FUNCTION__.removeEdge_allinneredges) #4
  unreachable

42:                                               ; preds = %37
  %43 = getelementptr inbounds i8, ptr %0, i64 272
  %44 = load i32, ptr %43, align 8, !tbaa !18
  %45 = add i32 %44, -1
  store i32 %45, ptr %43, align 8, !tbaa !18
  %46 = zext i32 %45 to i64
  %47 = getelementptr inbounds %struct.nodepair_s, ptr %32, i64 %46
  %48 = load <2 x i32>, ptr %47, align 4, !tbaa !12
  store <2 x i32> %48, ptr %34, align 4, !tbaa !12
  %49 = shl nuw nsw i64 %46, 3
  %50 = tail call ptr @safe_realloc(ptr noundef nonnull %32, i64 noundef %49) #5
  store ptr %50, ptr %31, align 8, !tbaa !14
  ret void
}

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 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #4 = { noreturn nounwind }
attributes #5 = { 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 4}
!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, !10, i64 224}
!12 = !{!7, !7, i64 0}
!13 = !{!6, !7, i64 232}
!14 = !{!6, !10, i64 280}
!15 = !{!16, !7, i64 0}
!16 = !{!"nodepair_s", !7, i64 0, !7, i64 4}
!17 = !{!16, !7, i64 4}
!18 = !{!6, !7, i64 272}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,SLPVectorizerPass,SROAPass,SimplifyCFGPass,TailCallElimPass