; 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 = external hidden unnamed_addr constant [15 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [71 x i8], align 1
@__PRETTY_FUNCTION__.insertArc_all_maxtermsender_arcs = external hidden unnamed_addr constant [65 x i8], align 1
@.str.29 = external hidden unnamed_addr constant [55 x i8], align 1

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

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

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

; Function Attrs: nounwind uwtable
define dso_local void @insertArc_all_maxtermsender_arcs(ptr noundef %0, i32 noundef %1, i32 noundef %2) #1 {
  %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 %11, label %12

11:                                               ; preds = %3
  br label %13

12:                                               ; preds = %3
  call void @__assert_fail(ptr noundef @.str, ptr noundef @.str.1, i32 noundef 1677, ptr noundef @__PRETTY_FUNCTION__.insertArc_all_maxtermsender_arcs) #3
  unreachable

13:                                               ; preds = %11
  %14 = load ptr, ptr %4, align 8, !tbaa !5
  %15 = getelementptr inbounds %struct.graph_s, ptr %14, i32 0, i32 42
  %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 43
  %23 = load i32, ptr %22, align 8, !tbaa !14
  %24 = icmp eq 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 42
  %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 43
  %35 = load i32, ptr %34, align 8, !tbaa !14
  %36 = icmp ule 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.29, ptr noundef @.str.1, i32 noundef 1678, ptr noundef @__PRETTY_FUNCTION__.insertArc_all_maxtermsender_arcs) #3
  unreachable

39:                                               ; preds = %37
  %40 = load ptr, ptr %4, align 8, !tbaa !5
  %41 = load i32, ptr %5, align 4, !tbaa !9
  %42 = load i32, ptr %6, align 4, !tbaa !9
  call void @insertArc(ptr noundef %40, i32 noundef %41, i32 noundef %42)
  %43 = load ptr, ptr %4, align 8, !tbaa !5
  %44 = getelementptr inbounds %struct.graph_s, ptr %43, i32 0, i32 46
  %45 = load i32, ptr %44, align 8, !tbaa !15
  %46 = add i32 %45, 1
  store i32 %46, ptr %44, align 8, !tbaa !15
  %47 = load ptr, ptr %4, align 8, !tbaa !5
  %48 = getelementptr inbounds %struct.graph_s, ptr %47, i32 0, i32 47
  %49 = load ptr, ptr %48, align 8, !tbaa !16
  %50 = load ptr, ptr %4, align 8, !tbaa !5
  %51 = getelementptr inbounds %struct.graph_s, ptr %50, i32 0, i32 46
  %52 = load i32, ptr %51, align 8, !tbaa !15
  %53 = zext i32 %52 to i64
  %54 = mul i64 %53, 8
  %55 = call ptr @safe_realloc(ptr noundef %49, i64 noundef %54)
  %56 = load ptr, ptr %4, align 8, !tbaa !5
  %57 = getelementptr inbounds %struct.graph_s, ptr %56, i32 0, i32 47
  store ptr %55, ptr %57, align 8, !tbaa !16
  %58 = load i32, ptr %5, align 4, !tbaa !9
  %59 = load ptr, ptr %4, align 8, !tbaa !5
  %60 = getelementptr inbounds %struct.graph_s, ptr %59, i32 0, i32 47
  %61 = load ptr, ptr %60, align 8, !tbaa !16
  %62 = load ptr, ptr %4, align 8, !tbaa !5
  %63 = getelementptr inbounds %struct.graph_s, ptr %62, i32 0, i32 46
  %64 = load i32, ptr %63, align 8, !tbaa !15
  %65 = sub i32 %64, 1
  %66 = zext i32 %65 to i64
  %67 = getelementptr inbounds %struct.nodepair_s, ptr %61, i64 %66
  %68 = getelementptr inbounds %struct.nodepair_s, ptr %67, i32 0, i32 0
  store i32 %58, ptr %68, align 4, !tbaa !17
  %69 = load i32, ptr %6, align 4, !tbaa !9
  %70 = load ptr, ptr %4, align 8, !tbaa !5
  %71 = getelementptr inbounds %struct.graph_s, ptr %70, i32 0, i32 47
  %72 = load ptr, ptr %71, align 8, !tbaa !16
  %73 = load ptr, ptr %4, align 8, !tbaa !5
  %74 = getelementptr inbounds %struct.graph_s, ptr %73, i32 0, i32 46
  %75 = load i32, ptr %74, align 8, !tbaa !15
  %76 = sub i32 %75, 1
  %77 = zext i32 %76 to i64
  %78 = getelementptr inbounds %struct.nodepair_s, ptr %72, i64 %77
  %79 = getelementptr inbounds %struct.nodepair_s, ptr %78, i32 0, i32 1
  store i32 %69, ptr %79, 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 = { 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 = { "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 }

!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 288}
!14 = !{!12, !10, i64 296}
!15 = !{!12, !10, i64 312}
!16 = !{!12, !6, i64 320}
!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 = external hidden unnamed_addr constant [15 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [71 x i8], align 1
@__PRETTY_FUNCTION__.insertArc_all_maxtermsender_arcs = external hidden unnamed_addr constant [65 x i8], align 1
@.str.29 = external hidden unnamed_addr constant [55 x i8], align 1

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

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

declare ptr @safe_realloc(ptr noundef, i64 noundef) local_unnamed_addr #2

; Function Attrs: nounwind uwtable
define dso_local void @insertArc_all_maxtermsender_arcs(ptr noundef %0, i32 noundef %1, i32 noundef %2) local_unnamed_addr #1 {
  %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 %6, label %7

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

7:                                                ; preds = %3
  %8 = getelementptr inbounds i8, ptr %0, i64 288
  %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 296
  %14 = load i32, ptr %13, align 8, !tbaa !13
  %15 = icmp eq i32 %12, %14
  br i1 %15, label %16, label %20

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
  %.not19 = icmp ugt i32 %19, %12
  br i1 %.not19, label %20, label %21

20:                                               ; preds = %16, %7
  tail call void @__assert_fail(ptr noundef nonnull @.str.29, ptr noundef nonnull @.str.1, i32 noundef 1678, ptr noundef nonnull @__PRETTY_FUNCTION__.insertArc_all_maxtermsender_arcs) #3
  unreachable

21:                                               ; preds = %16
  tail call void @insertArc(ptr noundef nonnull %0, i32 noundef %1, i32 noundef %2)
  %22 = getelementptr inbounds i8, ptr %0, i64 312
  %23 = load i32, ptr %22, align 8, !tbaa !14
  %24 = add i32 %23, 1
  store i32 %24, ptr %22, align 8, !tbaa !14
  %25 = getelementptr inbounds i8, ptr %0, i64 320
  %26 = load ptr, ptr %25, align 8, !tbaa !15
  %27 = zext i32 %24 to i64
  %28 = shl nuw nsw i64 %27, 3
  %29 = tail call ptr @safe_realloc(ptr noundef %26, i64 noundef %28) #4
  store ptr %29, ptr %25, align 8, !tbaa !15
  %30 = load i32, ptr %22, align 8, !tbaa !14
  %31 = add i32 %30, -1
  %32 = zext i32 %31 to i64
  %33 = getelementptr inbounds %struct.nodepair_s, ptr %29, i64 %32
  store i32 %1, ptr %33, align 4, !tbaa !16
  %34 = getelementptr inbounds %struct.nodepair_s, ptr %29, i64 %32, i32 1
  store i32 %2, ptr %34, 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 = { 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 = { "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 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 288}
!12 = !{!7, !7, i64 0}
!13 = !{!6, !7, i64 296}
!14 = !{!6, !7, i64 312}
!15 = !{!6, !10, i64 320}
!16 = !{!17, !7, i64 0}
!17 = !{!"nodepair_s", !7, i64 0, !7, i64 4}
!18 = !{!17, !7, i64 4}


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