; LLVM IR from pavlosdais/Abstract-Data-Types :: modules/Graph/DirectedGraph (DirectedGraph)

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

@.str.1 = external hidden unnamed_addr constant [108 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [16 x i8], align 1
@__PRETTY_FUNCTION__.dg_scc = external hidden unnamed_addr constant [29 x i8], align 1

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

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

; Function Attrs: nounwind allocsize(0,1)
declare noalias ptr @calloc(i64 noundef, i64 noundef) #2

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

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

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

; Function Attrs: nounwind uwtable
declare dso_local ptr @dg_reverse(ptr noundef) #5

; Function Attrs: nounwind uwtable
define dso_local void @dg_scc(ptr noundef %0) #5 {
  %2 = alloca ptr, align 8
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  store ptr %0, ptr %2, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #6
  %9 = load ptr, ptr %2, align 8, !tbaa !5
  %10 = getelementptr inbounds %struct._dir_graph, ptr %9, i32 0, i32 0
  %11 = load i32, ptr %10, align 8, !tbaa !9
  %12 = zext i32 %11 to i64
  %13 = call noalias ptr @calloc(i64 noundef 4, i64 noundef %12) #7
  store ptr %13, ptr %3, align 8, !tbaa !5
  %14 = load ptr, ptr %3, align 8, !tbaa !5
  %15 = icmp ne ptr %14, null
  br i1 %15, label %16, label %17

16:                                               ; preds = %1
  br label %18

17:                                               ; preds = %1
  call void @__assert_fail(ptr noundef @.str.8, ptr noundef @.str.1, i32 noundef 314, ptr noundef @__PRETTY_FUNCTION__.dg_scc) #8
  unreachable

18:                                               ; preds = %16
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #6
  %19 = call ptr @stack_create(ptr noundef @free)
  store ptr %19, ptr %4, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #6
  store i32 0, ptr %5, align 4, !tbaa !12
  br label %20

20:                                               ; preds = %40, %18
  %21 = load i32, ptr %5, align 4, !tbaa !12
  %22 = load ptr, ptr %2, align 8, !tbaa !5
  %23 = getelementptr inbounds %struct._dir_graph, ptr %22, i32 0, i32 0
  %24 = load i32, ptr %23, align 8, !tbaa !9
  %25 = icmp ult i32 %21, %24
  br i1 %25, label %27, label %26

26:                                               ; preds = %20
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #6
  br label %43

27:                                               ; preds = %20
  %28 = load ptr, ptr %3, align 8, !tbaa !5
  %29 = load i32, ptr %5, 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 = icmp ne i32 %32, 0
  br i1 %33, label %39, label %34

34:                                               ; preds = %27
  %35 = load ptr, ptr %2, align 8, !tbaa !5
  %36 = load i32, ptr %5, align 4, !tbaa !12
  %37 = load ptr, ptr %3, align 8, !tbaa !5
  %38 = load ptr, ptr %4, align 8, !tbaa !5
  call void @Visit(ptr noundef %35, i32 noundef %36, ptr noundef %37, ptr noundef %38)
  br label %39

39:                                               ; preds = %34, %27
  br label %40

40:                                               ; preds = %39
  %41 = load i32, ptr %5, align 4, !tbaa !12
  %42 = add i32 %41, 1
  store i32 %42, ptr %5, align 4, !tbaa !12
  br label %20, !llvm.loop !13

43:                                               ; preds = %26
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #6
  store i32 0, ptr %6, align 4, !tbaa !12
  br label %44

44:                                               ; preds = %56, %43
  %45 = load i32, ptr %6, align 4, !tbaa !12
  %46 = load ptr, ptr %2, align 8, !tbaa !5
  %47 = getelementptr inbounds %struct._dir_graph, ptr %46, i32 0, i32 0
  %48 = load i32, ptr %47, align 8, !tbaa !9
  %49 = icmp ult i32 %45, %48
  br i1 %49, label %51, label %50

50:                                               ; preds = %44
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #6
  br label %59

51:                                               ; preds = %44
  %52 = load ptr, ptr %3, align 8, !tbaa !5
  %53 = load i32, ptr %6, align 4, !tbaa !12
  %54 = zext i32 %53 to i64
  %55 = getelementptr inbounds i32, ptr %52, i64 %54
  store i32 0, ptr %55, align 4, !tbaa !12
  br label %56

56:                                               ; preds = %51
  %57 = load i32, ptr %6, align 4, !tbaa !12
  %58 = add i32 %57, 1
  store i32 %58, ptr %6, align 4, !tbaa !12
  br label %44, !llvm.loop !15

59:                                               ; preds = %50
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #6
  %60 = load ptr, ptr %2, align 8, !tbaa !5
  %61 = call ptr @dg_reverse(ptr noundef %60)
  store ptr %61, ptr %7, align 8, !tbaa !5
  br label %62

62:                                               ; preds = %82, %59
  %63 = load ptr, ptr %4, align 8, !tbaa !5
  %64 = call zeroext i1 @is_stack_empty(ptr noundef %63)
  %65 = xor i1 %64, true
  br i1 %65, label %66, label %84

66:                                               ; preds = %62
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #6
  %67 = load ptr, ptr %4, align 8, !tbaa !5
  %68 = call ptr @stack_pop(ptr noundef %67)
  store ptr %68, ptr %8, align 8, !tbaa !5
  %69 = load ptr, ptr %3, align 8, !tbaa !5
  %70 = load ptr, ptr %8, align 8, !tbaa !5
  %71 = load i32, ptr %70, align 4, !tbaa !12
  %72 = zext i32 %71 to i64
  %73 = getelementptr inbounds i32, ptr %69, i64 %72
  %74 = load i32, ptr %73, align 4, !tbaa !12
  %75 = icmp ne i32 %74, 0
  br i1 %75, label %82, label %76

76:                                               ; preds = %66
  %77 = load ptr, ptr %7, align 8, !tbaa !5
  %78 = load ptr, ptr %8, align 8, !tbaa !5
  %79 = load i32, ptr %78, align 4, !tbaa !12
  %80 = load ptr, ptr %3, align 8, !tbaa !5
  call void @Assign(ptr noundef %77, i32 noundef %79, ptr noundef %80)
  %81 = call i32 (ptr, ...) @printf(ptr noundef @.str.7)
  br label %82

82:                                               ; preds = %76, %66
  %83 = load ptr, ptr %8, align 8, !tbaa !5
  call void @free(ptr noundef %83) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #6
  br label %62, !llvm.loop !16

84:                                               ; preds = %62
  %85 = load ptr, ptr %4, align 8, !tbaa !5
  call void @stack_destroy(ptr noundef %85)
  %86 = load ptr, ptr %3, align 8, !tbaa !5
  call void @free(ptr noundef %86) #6
  %87 = load ptr, ptr %7, align 8, !tbaa !5
  call void @dg_destroy(ptr noundef %87)
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #6
  ret void
}

declare ptr @stack_create(ptr noundef) #3

; Function Attrs: nounwind uwtable
declare hidden void @Visit(ptr noundef, i32 noundef, ptr noundef, ptr noundef) #5

declare zeroext i1 @is_stack_empty(ptr noundef) #3

declare ptr @stack_pop(ptr noundef) #3

; Function Attrs: nounwind uwtable
declare hidden void @Assign(ptr noundef, i32 noundef, ptr noundef) #5

declare void @stack_destroy(ptr noundef) #3

; Function Attrs: nounwind uwtable
declare dso_local void @dg_destroy(ptr noundef) #5

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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { nounwind allocsize(0,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 #3 = { "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 "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 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 #6 = { nounwind }
attributes #7 = { nounwind allocsize(0,1) }
attributes #8 = { 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 0}
!10 = !{!"_dir_graph", !11, i64 0, !6, i64 8, !6, i64 16}
!11 = !{!"int", !7, i64 0}
!12 = !{!11, !11, i64 0}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}
!15 = distinct !{!15, !14}
!16 = distinct !{!16, !14}


; 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 [108 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [16 x i8], align 1
@__PRETTY_FUNCTION__.dg_scc = external hidden unnamed_addr constant [29 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: mustprogress nofree nounwind willreturn allockind("alloc,zeroed") allocsize(0,1) memory(inaccessiblemem: readwrite)
declare noalias noundef ptr @calloc(i64 noundef, i64 noundef) local_unnamed_addr #1

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

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

; Function Attrs: nounwind uwtable
declare dso_local ptr @dg_reverse(ptr noundef) local_unnamed_addr #4

; Function Attrs: nounwind uwtable
define dso_local void @dg_scc(ptr noundef %0) local_unnamed_addr #4 {
  %2 = load i32, ptr %0, align 8, !tbaa !5
  %3 = zext i32 %2 to i64
  %4 = tail call noalias ptr @calloc(i64 noundef 4, i64 noundef %3) #7
  %.not = icmp eq ptr %4, null
  br i1 %.not, label %5, label %6

5:                                                ; preds = %1
  tail call void @__assert_fail(ptr noundef nonnull @.str.8, ptr noundef nonnull @.str.1, i32 noundef 314, ptr noundef nonnull @__PRETTY_FUNCTION__.dg_scc) #8
  unreachable

6:                                                ; preds = %1
  %7 = tail call ptr @stack_create(ptr noundef nonnull @free) #9
  %8 = load i32, ptr %0, align 8, !tbaa !5
  %.not37 = icmp eq i32 %8, 0
  br i1 %.not37, label %._crit_edge, label %.lr.ph

.preheader:                                       ; preds = %16
  %.not38 = icmp eq i32 %17, 0
  br i1 %.not38, label %._crit_edge, label %.lr.ph33.preheader

.lr.ph33.preheader:                               ; preds = %.preheader
  %9 = zext i32 %17 to i64
  %10 = shl nuw nsw i64 %9, 2
  tail call void @llvm.memset.p0.i64(ptr nonnull align 4 %4, i8 0, i64 %10, i1 false), !tbaa !11
  br label %._crit_edge

.lr.ph:                                           ; preds = %6, %16
  %11 = phi i32 [ %17, %16 ], [ %8, %6 ]
  %indvars.iv = phi i64 [ %indvars.iv.next, %16 ], [ 0, %6 ]
  %12 = getelementptr inbounds i32, ptr %4, i64 %indvars.iv
  %13 = load i32, ptr %12, align 4, !tbaa !11
  %.not30 = icmp eq i32 %13, 0
  br i1 %.not30, label %14, label %16

14:                                               ; preds = %.lr.ph
  %15 = trunc nuw i64 %indvars.iv to i32
  tail call void @Visit(ptr noundef nonnull %0, i32 noundef %15, ptr noundef nonnull %4, ptr noundef %7)
  %.pre = load i32, ptr %0, align 8, !tbaa !5
  br label %16

16:                                               ; preds = %.lr.ph, %14
  %17 = phi i32 [ %11, %.lr.ph ], [ %.pre, %14 ]
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %18 = zext i32 %17 to i64
  %19 = icmp ult i64 %indvars.iv.next, %18
  br i1 %19, label %.lr.ph, label %.preheader, !llvm.loop !12

._crit_edge:                                      ; preds = %6, %.lr.ph33.preheader, %.preheader
  %20 = tail call ptr @dg_reverse(ptr noundef nonnull %0)
  %21 = tail call zeroext i1 @is_stack_empty(ptr noundef %7) #9
  br i1 %21, label %._crit_edge36, label %.lr.ph35

.lr.ph35:                                         ; preds = %._crit_edge, %29
  %22 = tail call ptr @stack_pop(ptr noundef %7) #9
  %23 = load i32, ptr %22, align 4, !tbaa !11
  %24 = zext i32 %23 to i64
  %25 = getelementptr inbounds i32, ptr %4, i64 %24
  %26 = load i32, ptr %25, align 4, !tbaa !11
  %.not29 = icmp eq i32 %26, 0
  br i1 %.not29, label %27, label %29

27:                                               ; preds = %.lr.ph35
  tail call void @Assign(ptr noundef %20, i32 noundef %23, ptr noundef nonnull %4)
  %28 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.7)
  br label %29

29:                                               ; preds = %27, %.lr.ph35
  tail call void @free(ptr noundef nonnull %22) #9
  %30 = tail call zeroext i1 @is_stack_empty(ptr noundef %7) #9
  br i1 %30, label %._crit_edge36, label %.lr.ph35, !llvm.loop !14

._crit_edge36:                                    ; preds = %29, %._crit_edge
  tail call void @stack_destroy(ptr noundef %7) #9
  tail call void @free(ptr noundef nonnull %4) #9
  tail call void @dg_destroy(ptr noundef %20)
  ret void
}

declare ptr @stack_create(ptr noundef) local_unnamed_addr #5

; Function Attrs: nounwind uwtable
declare hidden void @Visit(ptr noundef, i32 noundef, ptr noundef, ptr noundef) local_unnamed_addr #4

declare zeroext i1 @is_stack_empty(ptr noundef) local_unnamed_addr #5

declare ptr @stack_pop(ptr noundef) local_unnamed_addr #5

; Function Attrs: nounwind uwtable
declare hidden void @Assign(ptr noundef, i32 noundef, ptr noundef) local_unnamed_addr #4

declare void @stack_destroy(ptr noundef) local_unnamed_addr #5

; Function Attrs: nounwind uwtable
declare dso_local void @dg_destroy(ptr noundef) local_unnamed_addr #4

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #6

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 = { mustprogress nofree nounwind willreturn allockind("alloc,zeroed") allocsize(0,1) memory(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 #2 = { 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 #3 = { 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 #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 = { "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 #6 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #7 = { nounwind allocsize(0,1) }
attributes #8 = { noreturn nounwind }
attributes #9 = { 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 0}
!6 = !{!"_dir_graph", !7, i64 0, !10, i64 8, !10, i64 16}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"any pointer", !8, i64 0}
!11 = !{!7, !7, i64 0}
!12 = distinct !{!12, !13}
!13 = !{!"llvm.loop.mustprogress"}
!14 = distinct !{!14, !13}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LoopIdiomRecognizePass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,SROAPass,SimplifyCFGPass,TailCallElimPass