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

@.str.1 = external hidden unnamed_addr constant [71 x i8], align 1
@.str.65 = external hidden unnamed_addr constant [9 x i8], align 1
@.str.102 = external hidden unnamed_addr constant [23 x i8], align 1
@.str.106 = external hidden unnamed_addr constant [49 x i8], align 1
@.str.108 = external hidden unnamed_addr constant [34 x i8], align 1
@__PRETTY_FUNCTION__.print_term_summary = external hidden unnamed_addr constant [41 x i8], align 1
@.str.111 = external hidden unnamed_addr constant [41 x i8], align 1
@.str.112 = external hidden unnamed_addr constant [31 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

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

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

; Function Attrs: nounwind
declare void @free(ptr noundef) #3

declare i32 @printf(ptr noundef, ...) #2

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

13:                                               ; preds = %1
  %14 = call i32 (ptr, ...) @printf(ptr noundef @.str.106)
  store i32 1, ptr %6, align 4
  br label %80

15:                                               ; preds = %1
  %16 = load i32, ptr %5, align 4, !tbaa !12
  %17 = zext i32 %16 to i64
  %18 = call ptr @safe_calloc(i64 noundef %17, i64 noundef 4)
  store ptr %18, ptr %4, align 8, !tbaa !5
  store i32 0, ptr %3, align 4, !tbaa !12
  br label %19

19:                                               ; preds = %50, %15
  %20 = load i32, ptr %3, align 4, !tbaa !12
  %21 = load ptr, ptr %2, align 8, !tbaa !5
  %22 = getelementptr inbounds %struct.graph_s, ptr %21, i32 0, i32 0
  %23 = load i32, ptr %22, align 8, !tbaa !13
  %24 = icmp ult i32 %20, %23
  br i1 %24, label %25, label %53

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

35:                                               ; preds = %25
  br label %37

36:                                               ; preds = %25
  call void @__assert_fail(ptr noundef @.str.102, ptr noundef @.str.1, i32 noundef 2851, ptr noundef @__PRETTY_FUNCTION__.print_term_summary) #6
  unreachable

37:                                               ; preds = %35
  %38 = load ptr, ptr %4, align 8, !tbaa !5
  %39 = load ptr, ptr %2, align 8, !tbaa !5
  %40 = getelementptr inbounds %struct.graph_s, ptr %39, i32 0, i32 42
  %41 = load ptr, ptr %40, align 8, !tbaa !14
  %42 = load i32, ptr %3, align 4, !tbaa !12
  %43 = zext i32 %42 to i64
  %44 = getelementptr inbounds i32, ptr %41, i64 %43
  %45 = load i32, ptr %44, align 4, !tbaa !12
  %46 = zext i32 %45 to i64
  %47 = getelementptr inbounds i32, ptr %38, i64 %46
  %48 = load i32, ptr %47, align 4, !tbaa !12
  %49 = add i32 %48, 1
  store i32 %49, ptr %47, align 4, !tbaa !12
  br label %50

50:                                               ; preds = %37
  %51 = load i32, ptr %3, align 4, !tbaa !12
  %52 = add i32 %51, 1
  store i32 %52, ptr %3, align 4, !tbaa !12
  br label %19, !llvm.loop !15

53:                                               ; preds = %19
  %54 = load i32, ptr %5, align 4, !tbaa !12
  %55 = load i32, ptr %5, align 4, !tbaa !12
  %56 = sub i32 %55, 1
  %57 = call i32 (ptr, ...) @printf(ptr noundef @.str.111, i32 noundef %54, i32 noundef %56)
  %58 = load ptr, ptr %2, align 8, !tbaa !5
  %59 = getelementptr inbounds %struct.graph_s, ptr %58, i32 0, i32 44
  %60 = load i32, ptr %59, align 4, !tbaa !17
  %61 = call i32 (ptr, ...) @printf(ptr noundef @.str.108, i32 noundef %60)
  %62 = call i32 (ptr, ...) @printf(ptr noundef @.str.112)
  store i32 0, ptr %3, align 4, !tbaa !12
  br label %63

63:                                               ; preds = %75, %53
  %64 = load i32, ptr %3, align 4, !tbaa !12
  %65 = load i32, ptr %5, align 4, !tbaa !12
  %66 = icmp ult i32 %64, %65
  br i1 %66, label %67, label %78

67:                                               ; preds = %63
  %68 = load i32, ptr %3, align 4, !tbaa !12
  %69 = load ptr, ptr %4, align 8, !tbaa !5
  %70 = load i32, ptr %3, align 4, !tbaa !12
  %71 = zext i32 %70 to i64
  %72 = getelementptr inbounds i32, ptr %69, i64 %71
  %73 = load i32, ptr %72, align 4, !tbaa !12
  %74 = call i32 (ptr, ...) @printf(ptr noundef @.str.65, i32 noundef %68, i32 noundef %73)
  br label %75

75:                                               ; preds = %67
  %76 = load i32, ptr %3, align 4, !tbaa !12
  %77 = add i32 %76, 1
  store i32 %77, ptr %3, align 4, !tbaa !12
  br label %63, !llvm.loop !18

78:                                               ; preds = %63
  %79 = load ptr, ptr %4, align 8, !tbaa !5
  call void @free(ptr noundef %79) #5
  store i32 0, ptr %6, align 4
  br label %80

80:                                               ; preds = %78, %13
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #5
  %81 = load i32, ptr %6, align 4
  switch i32 %81, label %83 [
    i32 0, label %82
    i32 1, label %82
  ]

82:                                               ; preds = %80, %80
  ret void

83:                                               ; preds = %80
  unreachable
}

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


; 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.1 = external hidden unnamed_addr constant [71 x i8], align 1
@.str.65 = external hidden unnamed_addr constant [9 x i8], align 1
@.str.102 = external hidden unnamed_addr constant [23 x i8], align 1
@.str.106 = external hidden unnamed_addr constant [49 x i8], align 1
@.str.108 = external hidden unnamed_addr constant [34 x i8], align 1
@__PRETTY_FUNCTION__.print_term_summary = external hidden unnamed_addr constant [41 x i8], align 1
@.str.111 = external hidden unnamed_addr constant [41 x i8], align 1
@.str.112 = external hidden unnamed_addr constant [31 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_calloc(i64 noundef, i64 noundef) local_unnamed_addr #1

; Function Attrs: mustprogress nounwind willreturn allockind("free") memory(argmem: readwrite, inaccessiblemem: readwrite)
declare void @free(ptr allocptr nocapture noundef) local_unnamed_addr #2

; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #3

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

6:                                                ; preds = %1
  %7 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.106)
  br label %36

8:                                                ; preds = %1
  %9 = zext i32 %4 to i64
  %10 = tail call ptr @safe_calloc(i64 noundef %9, i64 noundef 4) #5
  %11 = load i32, ptr %0, align 8, !tbaa !11
  %.not = icmp eq i32 %11, 0
  br i1 %.not, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %8
  %12 = getelementptr inbounds i8, ptr %0, i64 288
  %13 = load ptr, ptr %12, align 8, !tbaa !12
  br label %14

14:                                               ; preds = %.lr.ph, %19
  %indvars.iv = phi i64 [ 0, %.lr.ph ], [ %indvars.iv.next, %19 ]
  %15 = getelementptr inbounds i32, ptr %13, i64 %indvars.iv
  %16 = load i32, ptr %15, align 4, !tbaa !13
  %17 = icmp ult i32 %16, %4
  br i1 %17, label %19, label %18

18:                                               ; preds = %14
  tail call void @__assert_fail(ptr noundef nonnull @.str.102, ptr noundef nonnull @.str.1, i32 noundef 2851, ptr noundef nonnull @__PRETTY_FUNCTION__.print_term_summary) #6
  unreachable

19:                                               ; preds = %14
  %20 = zext i32 %16 to i64
  %21 = getelementptr inbounds i32, ptr %10, i64 %20
  %22 = load i32, ptr %21, align 4, !tbaa !13
  %23 = add i32 %22, 1
  store i32 %23, ptr %21, align 4, !tbaa !13
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %24 = load i32, ptr %0, align 8, !tbaa !11
  %25 = zext i32 %24 to i64
  %26 = icmp ult i64 %indvars.iv.next, %25
  br i1 %26, label %14, label %._crit_edge, !llvm.loop !14

._crit_edge:                                      ; preds = %19, %8
  %27 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.111, i32 noundef %4, i32 noundef %3)
  %28 = getelementptr inbounds i8, ptr %0, i64 300
  %29 = load i32, ptr %28, align 4, !tbaa !16
  %30 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.108, i32 noundef %29)
  %31 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.112)
  %.not28 = icmp eq i32 %4, 0
  br i1 %.not28, label %._crit_edge27, label %.lr.ph26

.lr.ph26:                                         ; preds = %._crit_edge, %.lr.ph26
  %indvars.iv30 = phi i64 [ %indvars.iv.next31, %.lr.ph26 ], [ 0, %._crit_edge ]
  %32 = getelementptr inbounds i32, ptr %10, i64 %indvars.iv30
  %33 = load i32, ptr %32, align 4, !tbaa !13
  %34 = trunc nuw i64 %indvars.iv30 to i32
  %35 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.65, i32 noundef %34, i32 noundef %33)
  %indvars.iv.next31 = add nuw nsw i64 %indvars.iv30, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next31, %9
  br i1 %exitcond.not, label %._crit_edge27, label %.lr.ph26, !llvm.loop !17

._crit_edge27:                                    ; preds = %.lr.ph26, %._crit_edge
  tail call void @free(ptr noundef %10) #5
  br label %36

36:                                               ; preds = %._crit_edge27, %6
  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 = { mustprogress nounwind willreturn allockind("free") memory(argmem: readwrite, inaccessiblemem: readwrite) "alloc-family"="malloc" "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 = { nofree 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 #4 = { 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 #5 = { nounwind }
attributes #6 = { 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, !7, i64 296}
!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 0}
!12 = !{!6, !10, i64 288}
!13 = !{!7, !7, i64 0}
!14 = distinct !{!14, !15}
!15 = !{!"llvm.loop.mustprogress"}
!16 = !{!6, !7, i64 300}
!17 = distinct !{!17, !15}


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