; 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__.insertEdge_allinneredges = external hidden unnamed_addr constant [57 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 @insertEdge(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 @insertEdge_allinneredges(ptr noundef %0, i32 noundef %1, i32 noundef %2) #2 {
  %4 = alloca ptr, align 8
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  store i32 %1, ptr %5, align 4, !tbaa !9
  store i32 %2, ptr %6, align 4, !tbaa !9
  %7 = load ptr, ptr %4, align 8, !tbaa !5
  %8 = getelementptr inbounds %struct.graph_s, ptr %7, i32 0, i32 1
  %9 = load i32, ptr %8, align 4, !tbaa !11
  %10 = icmp ne i32 %9, 0
  br i1 %10, label %12, label %11

11:                                               ; preds = %3
  br label %13

12:                                               ; preds = %3
  call void @__assert_fail(ptr noundef @.str.2, ptr noundef @.str.1, i32 noundef 1582, ptr noundef @__PRETTY_FUNCTION__.insertEdge_allinneredges) #4
  unreachable

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

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

37:                                               ; preds = %25
  br label %39

38:                                               ; preds = %25, %13
  call void @__assert_fail(ptr noundef @.str.25, ptr noundef @.str.1, i32 noundef 1583, ptr noundef @__PRETTY_FUNCTION__.insertEdge_allinneredges) #4
  unreachable

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

59:                                               ; preds = %39
  br label %61

60:                                               ; preds = %39
  call void @__assert_fail(ptr noundef @.str.26, ptr noundef @.str.1, i32 noundef 1584, ptr noundef @__PRETTY_FUNCTION__.insertEdge_allinneredges) #4
  unreachable

61:                                               ; preds = %59
  %62 = load ptr, ptr %4, align 8, !tbaa !5
  %63 = load i32, ptr %5, align 4, !tbaa !9
  %64 = load i32, ptr %6, align 4, !tbaa !9
  call void @insertEdge(ptr noundef %62, i32 noundef %63, i32 noundef %64)
  %65 = load ptr, ptr %4, align 8, !tbaa !5
  %66 = getelementptr inbounds %struct.graph_s, ptr %65, i32 0, i32 40
  %67 = load i32, ptr %66, align 8, !tbaa !15
  %68 = add i32 %67, 1
  store i32 %68, ptr %66, align 8, !tbaa !15
  %69 = load ptr, ptr %4, align 8, !tbaa !5
  %70 = getelementptr inbounds %struct.graph_s, ptr %69, i32 0, i32 41
  %71 = load ptr, ptr %70, align 8, !tbaa !16
  %72 = load ptr, ptr %4, align 8, !tbaa !5
  %73 = getelementptr inbounds %struct.graph_s, ptr %72, i32 0, i32 40
  %74 = load i32, ptr %73, align 8, !tbaa !15
  %75 = zext i32 %74 to i64
  %76 = mul i64 %75, 8
  %77 = call ptr @safe_realloc(ptr noundef %71, i64 noundef %76)
  %78 = load ptr, ptr %4, align 8, !tbaa !5
  %79 = getelementptr inbounds %struct.graph_s, ptr %78, i32 0, i32 41
  store ptr %77, ptr %79, align 8, !tbaa !16
  %80 = load i32, ptr %5, align 4, !tbaa !9
  %81 = load ptr, ptr %4, align 8, !tbaa !5
  %82 = getelementptr inbounds %struct.graph_s, ptr %81, i32 0, i32 41
  %83 = load ptr, ptr %82, align 8, !tbaa !16
  %84 = load ptr, ptr %4, align 8, !tbaa !5
  %85 = getelementptr inbounds %struct.graph_s, ptr %84, i32 0, i32 40
  %86 = load i32, ptr %85, align 8, !tbaa !15
  %87 = sub i32 %86, 1
  %88 = zext i32 %87 to i64
  %89 = getelementptr inbounds %struct.nodepair_s, ptr %83, i64 %88
  %90 = getelementptr inbounds %struct.nodepair_s, ptr %89, i32 0, i32 0
  store i32 %80, ptr %90, align 4, !tbaa !17
  %91 = load i32, ptr %6, align 4, !tbaa !9
  %92 = load ptr, ptr %4, align 8, !tbaa !5
  %93 = getelementptr inbounds %struct.graph_s, ptr %92, i32 0, i32 41
  %94 = load ptr, ptr %93, align 8, !tbaa !16
  %95 = load ptr, ptr %4, align 8, !tbaa !5
  %96 = getelementptr inbounds %struct.graph_s, ptr %95, i32 0, i32 40
  %97 = load i32, ptr %96, align 8, !tbaa !15
  %98 = sub i32 %97, 1
  %99 = zext i32 %98 to i64
  %100 = getelementptr inbounds %struct.nodepair_s, ptr %94, i64 %99
  %101 = getelementptr inbounds %struct.nodepair_s, ptr %100, i32 0, i32 1
  store i32 %91, ptr %101, align 4, !tbaa !19
  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, !10, i64 272}
!16 = !{!12, !6, i64 280}
!17 = !{!18, !10, i64 0}
!18 = !{!"nodepair_s", !10, i64 0, !10, i64 4}
!19 = !{!18, !10, i64 4}


; 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__.insertEdge_allinneredges = external hidden unnamed_addr constant [57 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 @insertEdge(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 @insertEdge_allinneredges(ptr noundef %0, i32 noundef %1, i32 noundef %2) local_unnamed_addr #2 {
  %4 = getelementptr inbounds i8, ptr %0, i64 4
  %5 = load i32, ptr %4, align 4, !tbaa !5
  %.not = icmp eq i32 %5, 0
  br i1 %.not, label %7, label %6

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

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

16:                                               ; preds = %7
  %17 = zext i32 %2 to i64
  %18 = getelementptr inbounds i32, ptr %9, i64 %17
  %19 = load i32, ptr %18, align 4, !tbaa !12
  %20 = icmp ult i32 %19, %14
  br i1 %20, label %22, label %21

21:                                               ; preds = %16, %7
  tail call void @__assert_fail(ptr noundef nonnull @.str.25, ptr noundef nonnull @.str.1, i32 noundef 1583, ptr noundef nonnull @__PRETTY_FUNCTION__.insertEdge_allinneredges) #4
  unreachable

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

28:                                               ; preds = %22
  tail call void @__assert_fail(ptr noundef nonnull @.str.26, ptr noundef nonnull @.str.1, i32 noundef 1584, ptr noundef nonnull @__PRETTY_FUNCTION__.insertEdge_allinneredges) #4
  unreachable

29:                                               ; preds = %22
  tail call void @insertEdge(ptr noundef nonnull %0, i32 noundef %1, i32 noundef %2)
  %30 = getelementptr inbounds i8, ptr %0, i64 272
  %31 = load i32, ptr %30, align 8, !tbaa !14
  %32 = add i32 %31, 1
  store i32 %32, ptr %30, align 8, !tbaa !14
  %33 = getelementptr inbounds i8, ptr %0, i64 280
  %34 = load ptr, ptr %33, align 8, !tbaa !15
  %35 = zext i32 %32 to i64
  %36 = shl nuw nsw i64 %35, 3
  %37 = tail call ptr @safe_realloc(ptr noundef %34, i64 noundef %36) #5
  store ptr %37, ptr %33, align 8, !tbaa !15
  %38 = load i32, ptr %30, align 8, !tbaa !14
  %39 = add i32 %38, -1
  %40 = zext i32 %39 to i64
  %41 = getelementptr inbounds %struct.nodepair_s, ptr %37, i64 %40
  store i32 %1, ptr %41, align 4, !tbaa !16
  %42 = getelementptr inbounds %struct.nodepair_s, ptr %37, i64 %40, i32 1
  store i32 %2, ptr %42, align 4, !tbaa !18
  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, !7, i64 272}
!15 = !{!6, !10, i64 280}
!16 = !{!17, !7, i64 0}
!17 = !{!"nodepair_s", !7, i64 0, !7, i64 4}
!18 = !{!17, !7, i64 4}


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