; 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.54 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.85 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.106 = external hidden unnamed_addr constant [49 x i8], align 1
@.str.107 = external hidden unnamed_addr constant [42 x i8], align 1
@.str.108 = external hidden unnamed_addr constant [34 x i8], align 1
@.str.109 = external hidden unnamed_addr constant [20 x i8], align 1
@.str.110 = external hidden unnamed_addr constant [19 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: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #0

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

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

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

14:                                               ; preds = %1
  %15 = load i32, ptr %4, align 4, !tbaa !12
  %16 = load ptr, ptr %2, align 8, !tbaa !5
  %17 = getelementptr inbounds %struct.graph_s, ptr %16, i32 0, i32 43
  %18 = load i32, ptr %17, align 8, !tbaa !9
  %19 = call i32 (ptr, ...) @printf(ptr noundef @.str.107, i32 noundef %15, i32 noundef %18)
  %20 = load ptr, ptr %2, align 8, !tbaa !5
  %21 = getelementptr inbounds %struct.graph_s, ptr %20, i32 0, i32 44
  %22 = load i32, ptr %21, align 4, !tbaa !13
  %23 = call i32 (ptr, ...) @printf(ptr noundef @.str.108, i32 noundef %22)
  %24 = call i32 (ptr, ...) @printf(ptr noundef @.str.109)
  store i32 0, ptr %3, align 4, !tbaa !12
  br label %25

25:                                               ; preds = %40, %14
  %26 = load i32, ptr %3, align 4, !tbaa !12
  %27 = load ptr, ptr %2, align 8, !tbaa !5
  %28 = getelementptr inbounds %struct.graph_s, ptr %27, i32 0, i32 44
  %29 = load i32, ptr %28, align 4, !tbaa !13
  %30 = icmp ult i32 %26, %29
  br i1 %30, label %31, label %43

31:                                               ; preds = %25
  %32 = load ptr, ptr %2, align 8, !tbaa !5
  %33 = getelementptr inbounds %struct.graph_s, ptr %32, i32 0, i32 45
  %34 = load ptr, ptr %33, align 8, !tbaa !14
  %35 = load i32, ptr %3, align 4, !tbaa !12
  %36 = zext i32 %35 to i64
  %37 = getelementptr inbounds i32, ptr %34, i64 %36
  %38 = load i32, ptr %37, align 4, !tbaa !12
  %39 = call i32 (ptr, ...) @printf(ptr noundef @.str.85, i32 noundef %38)
  br label %40

40:                                               ; preds = %31
  %41 = load i32, ptr %3, align 4, !tbaa !12
  %42 = add i32 %41, 1
  store i32 %42, ptr %3, align 4, !tbaa !12
  br label %25, !llvm.loop !15

43:                                               ; preds = %25
  %44 = call i32 (ptr, ...) @printf(ptr noundef @.str.54)
  %45 = call i32 (ptr, ...) @printf(ptr noundef @.str.110)
  store i32 0, ptr %3, align 4, !tbaa !12
  br label %46

46:                                               ; preds = %61, %43
  %47 = load i32, ptr %3, align 4, !tbaa !12
  %48 = load ptr, ptr %2, align 8, !tbaa !5
  %49 = getelementptr inbounds %struct.graph_s, ptr %48, i32 0, i32 0
  %50 = load i32, ptr %49, align 8, !tbaa !17
  %51 = icmp ult i32 %47, %50
  br i1 %51, label %52, label %64

52:                                               ; preds = %46
  %53 = load ptr, ptr %2, align 8, !tbaa !5
  %54 = getelementptr inbounds %struct.graph_s, ptr %53, i32 0, i32 42
  %55 = load ptr, ptr %54, align 8, !tbaa !18
  %56 = load i32, ptr %3, align 4, !tbaa !12
  %57 = zext i32 %56 to i64
  %58 = getelementptr inbounds i32, ptr %55, i64 %57
  %59 = load i32, ptr %58, align 4, !tbaa !12
  %60 = call i32 (ptr, ...) @printf(ptr noundef @.str.85, i32 noundef %59)
  br label %61

61:                                               ; preds = %52
  %62 = load i32, ptr %3, align 4, !tbaa !12
  %63 = add i32 %62, 1
  store i32 %63, ptr %3, align 4, !tbaa !12
  br label %46, !llvm.loop !19

64:                                               ; preds = %46
  %65 = call i32 (ptr, ...) @printf(ptr noundef @.str.54)
  store i32 0, ptr %5, align 4
  br label %66

66:                                               ; preds = %64, %12
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #3
  %67 = load i32, ptr %5, align 4
  switch i32 %67, label %69 [
    i32 0, label %68
    i32 1, label %68
  ]

68:                                               ; preds = %66, %66
  ret void

69:                                               ; preds = %66
  unreachable
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { 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 300}
!14 = !{!10, !6, i64 304}
!15 = distinct !{!15, !16}
!16 = !{!"llvm.loop.mustprogress"}
!17 = !{!10, !11, i64 0}
!18 = !{!10, !6, i64 288}
!19 = distinct !{!19, !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.54 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.85 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.106 = external hidden unnamed_addr constant [49 x i8], align 1
@.str.107 = external hidden unnamed_addr constant [42 x i8], align 1
@.str.108 = external hidden unnamed_addr constant [34 x i8], align 1
@.str.109 = external hidden unnamed_addr constant [20 x i8], align 1
@.str.110 = external hidden unnamed_addr constant [19 x i8], align 1

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

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

5:                                                ; preds = %1
  %6 = add i32 %3, 1
  %7 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.107, i32 noundef %6, i32 noundef %3)
  %8 = getelementptr inbounds i8, ptr %0, i64 300
  %9 = load i32, ptr %8, align 4, !tbaa !11
  %10 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.108, i32 noundef %9)
  %11 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.109)
  %12 = load i32, ptr %8, align 4, !tbaa !11
  %.not = icmp eq i32 %12, 0
  br i1 %.not, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %5
  %13 = getelementptr inbounds i8, ptr %0, i64 304
  br label %14

14:                                               ; preds = %.lr.ph, %14
  %indvars.iv = phi i64 [ 0, %.lr.ph ], [ %indvars.iv.next, %14 ]
  %15 = load ptr, ptr %13, align 8, !tbaa !12
  %16 = getelementptr inbounds i32, ptr %15, i64 %indvars.iv
  %17 = load i32, ptr %16, align 4, !tbaa !13
  %18 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.85, i32 noundef %17)
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %19 = load i32, ptr %8, align 4, !tbaa !11
  %20 = zext i32 %19 to i64
  %21 = icmp ult i64 %indvars.iv.next, %20
  br i1 %21, label %14, label %._crit_edge, !llvm.loop !14

._crit_edge:                                      ; preds = %14, %5
  %22 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.54)
  %23 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.110)
  %24 = load i32, ptr %0, align 8, !tbaa !16
  %.not20 = icmp eq i32 %24, 0
  br i1 %.not20, label %._crit_edge19, label %.lr.ph18

.lr.ph18:                                         ; preds = %._crit_edge
  %25 = getelementptr inbounds i8, ptr %0, i64 288
  br label %26

26:                                               ; preds = %.lr.ph18, %26
  %indvars.iv22 = phi i64 [ 0, %.lr.ph18 ], [ %indvars.iv.next23, %26 ]
  %27 = load ptr, ptr %25, align 8, !tbaa !17
  %28 = getelementptr inbounds i32, ptr %27, i64 %indvars.iv22
  %29 = load i32, ptr %28, align 4, !tbaa !13
  %30 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.85, i32 noundef %29)
  %indvars.iv.next23 = add nuw nsw i64 %indvars.iv22, 1
  %31 = load i32, ptr %0, align 8, !tbaa !16
  %32 = zext i32 %31 to i64
  %33 = icmp ult i64 %indvars.iv.next23, %32
  br i1 %33, label %26, label %._crit_edge19, !llvm.loop !18

._crit_edge19:                                    ; preds = %26, %._crit_edge, %1
  %.str.54.sink = phi ptr [ @.str.106, %1 ], [ @.str.54, %._crit_edge ], [ @.str.54, %26 ]
  %34 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) %.str.54.sink)
  ret void
}

attributes #0 = { 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 #1 = { nofree 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" }

!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 300}
!12 = !{!6, !10, i64 304}
!13 = !{!7, !7, i64 0}
!14 = distinct !{!14, !15}
!15 = !{!"llvm.loop.mustprogress"}
!16 = !{!6, !7, i64 0}
!17 = !{!6, !10, i64 288}
!18 = distinct !{!18, !15}


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