; LLVM IR from Dev-XYS/Algorithms :: Persistent-Trie.ll (Z3dfsiii)

; 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.vertex = type { i32, i32, ptr }
%struct.edge = type { i32, i32 }

@V = external dso_local global [100010 x %struct.vertex], align 16
@E = external dso_local global [200010 x %struct.edge], align 16
@fa = external dso_local global [100010 x [18 x i32]], align 16
@str = external dso_local global [100010 x [12 x i8]], align 16

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z6insertRP4nodeS0_Pcii(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef, ptr noundef, i32 noundef, i32 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: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1

; Function Attrs: nounwind willreturn memory(read)
declare i64 @strlen(ptr noundef) #2

; Function Attrs: mustprogress uwtable
define dso_local void @_Z3dfsiii(i32 noundef %0, i32 noundef %1, i32 noundef %2) #0 {
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  store i32 %0, ptr %4, align 4, !tbaa !5
  store i32 %1, ptr %5, align 4, !tbaa !5
  store i32 %2, ptr %6, align 4, !tbaa !5
  %8 = load i32, ptr %5, align 4, !tbaa !5
  %9 = load i32, ptr %4, align 4, !tbaa !5
  %10 = sext i32 %9 to i64
  %11 = getelementptr inbounds [100010 x [18 x i32]], ptr @fa, i64 0, i64 %10
  %12 = getelementptr inbounds [18 x i32], ptr %11, i64 0, i64 0
  store i32 %8, ptr %12, align 8, !tbaa !5
  %13 = load i32, ptr %6, align 4, !tbaa !5
  %14 = load i32, ptr %4, align 4, !tbaa !5
  %15 = sext i32 %14 to i64
  %16 = getelementptr inbounds [100010 x %struct.vertex], ptr @V, i64 0, i64 %15
  %17 = getelementptr inbounds %struct.vertex, ptr %16, i32 0, i32 1
  store i32 %13, ptr %17, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #3
  %18 = load i32, ptr %4, align 4, !tbaa !5
  %19 = sext i32 %18 to i64
  %20 = getelementptr inbounds [100010 x %struct.vertex], ptr @V, i64 0, i64 %19
  %21 = getelementptr inbounds %struct.vertex, ptr %20, i32 0, i32 0
  %22 = load i32, ptr %21, align 16, !tbaa !12
  store i32 %22, ptr %7, align 4, !tbaa !5
  br label %23

23:                                               ; preds = %70, %3
  %24 = load i32, ptr %7, align 4, !tbaa !5
  %25 = icmp ne i32 %24, 0
  br i1 %25, label %27, label %26

26:                                               ; preds = %23
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #3
  br label %76

27:                                               ; preds = %23
  %28 = load i32, ptr %7, align 4, !tbaa !5
  %29 = sext i32 %28 to i64
  %30 = getelementptr inbounds [200010 x %struct.edge], ptr @E, i64 0, i64 %29
  %31 = getelementptr inbounds %struct.edge, ptr %30, i32 0, i32 0
  %32 = load i32, ptr %31, align 8, !tbaa !13
  %33 = load i32, ptr %5, align 4, !tbaa !5
  %34 = icmp ne i32 %32, %33
  br i1 %34, label %35, label %69

35:                                               ; preds = %27
  %36 = load i32, ptr %7, align 4, !tbaa !5
  %37 = sext i32 %36 to i64
  %38 = getelementptr inbounds [200010 x %struct.edge], ptr @E, i64 0, i64 %37
  %39 = getelementptr inbounds %struct.edge, ptr %38, i32 0, i32 0
  %40 = load i32, ptr %39, align 8, !tbaa !13
  %41 = sext i32 %40 to i64
  %42 = getelementptr inbounds [100010 x %struct.vertex], ptr @V, i64 0, i64 %41
  %43 = getelementptr inbounds %struct.vertex, ptr %42, i32 0, i32 2
  %44 = load i32, ptr %4, align 4, !tbaa !5
  %45 = sext i32 %44 to i64
  %46 = getelementptr inbounds [100010 x %struct.vertex], ptr @V, i64 0, i64 %45
  %47 = getelementptr inbounds %struct.vertex, ptr %46, i32 0, i32 2
  %48 = load ptr, ptr %47, align 8, !tbaa !15
  %49 = load i32, ptr %7, align 4, !tbaa !5
  %50 = ashr i32 %49, 1
  %51 = sext i32 %50 to i64
  %52 = getelementptr inbounds [100010 x [12 x i8]], ptr @str, i64 0, i64 %51
  %53 = getelementptr inbounds [12 x i8], ptr %52, i64 0, i64 0
  %54 = load i32, ptr %7, align 4, !tbaa !5
  %55 = ashr i32 %54, 1
  %56 = sext i32 %55 to i64
  %57 = getelementptr inbounds [100010 x [12 x i8]], ptr @str, i64 0, i64 %56
  %58 = getelementptr inbounds [12 x i8], ptr %57, i64 0, i64 0
  %59 = call i64 @strlen(ptr noundef %58) #4
  %60 = trunc i64 %59 to i32
  call void @_Z6insertRP4nodeS0_Pcii(ptr noundef nonnull align 8 dereferenceable(8) %43, ptr noundef %48, ptr noundef %53, i32 noundef %60, i32 noundef 0)
  %61 = load i32, ptr %7, align 4, !tbaa !5
  %62 = sext i32 %61 to i64
  %63 = getelementptr inbounds [200010 x %struct.edge], ptr @E, i64 0, i64 %62
  %64 = getelementptr inbounds %struct.edge, ptr %63, i32 0, i32 0
  %65 = load i32, ptr %64, align 8, !tbaa !13
  %66 = load i32, ptr %4, align 4, !tbaa !5
  %67 = load i32, ptr %6, align 4, !tbaa !5
  %68 = add nsw i32 %67, 1
  call void @_Z3dfsiii(i32 noundef %65, i32 noundef %66, i32 noundef %68)
  br label %69

69:                                               ; preds = %35, %27
  br label %70

70:                                               ; preds = %69
  %71 = load i32, ptr %7, align 4, !tbaa !5
  %72 = sext i32 %71 to i64
  %73 = getelementptr inbounds [200010 x %struct.edge], ptr @E, i64 0, i64 %72
  %74 = getelementptr inbounds %struct.edge, ptr %73, i32 0, i32 1
  %75 = load i32, ptr %74, align 4, !tbaa !16
  store i32 %75, ptr %7, align 4, !tbaa !5
  br label %23, !llvm.loop !17

76:                                               ; preds = %26
  ret void
}

attributes #0 = { mustprogress 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 #1 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { nounwind willreturn memory(read) "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 }
attributes #4 = { nounwind willreturn memory(read) }

!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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !6, i64 4}
!10 = !{!"_ZTS6vertex", !6, i64 0, !6, i64 4, !11, i64 8}
!11 = !{!"any pointer", !7, i64 0}
!12 = !{!10, !6, i64 0}
!13 = !{!14, !6, i64 0}
!14 = !{!"_ZTS4edge", !6, i64 0, !6, i64 4}
!15 = !{!10, !11, i64 8}
!16 = !{!14, !6, i64 4}
!17 = distinct !{!17, !18}
!18 = !{!"llvm.loop.mustprogress"}


; 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.vertex = type { i32, i32, ptr }
%struct.edge = type { i32, i32 }

@V = external dso_local global [100010 x %struct.vertex], align 16
@E = external dso_local local_unnamed_addr global [200010 x %struct.edge], align 16
@fa = external dso_local local_unnamed_addr global [100010 x [18 x i32]], align 16
@str = external dso_local global [100010 x [12 x i8]], align 16

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z6insertRP4nodeS0_Pcii(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef, ptr noundef, i32 noundef, i32 noundef) local_unnamed_addr #0

; Function Attrs: mustprogress nofree nounwind willreturn memory(argmem: read)
declare i64 @strlen(ptr nocapture noundef) local_unnamed_addr #1

; Function Attrs: mustprogress uwtable
define dso_local void @_Z3dfsiii(i32 noundef %0, i32 noundef %1, i32 noundef %2) local_unnamed_addr #0 {
  %4 = sext i32 %0 to i64
  %5 = getelementptr inbounds [100010 x [18 x i32]], ptr @fa, i64 0, i64 %4
  store i32 %1, ptr %5, align 8, !tbaa !5
  %6 = getelementptr inbounds [100010 x %struct.vertex], ptr @V, i64 0, i64 %4
  %7 = getelementptr inbounds i8, ptr %6, i64 4
  store i32 %2, ptr %7, align 4, !tbaa !9
  %.018 = load i32, ptr %6, align 16, !tbaa !5
  %.not19 = icmp eq i32 %.018, 0
  br i1 %.not19, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %3
  %8 = getelementptr inbounds i8, ptr %6, i64 8
  %9 = add nsw i32 %2, 1
  br label %10

._crit_edge:                                      ; preds = %24, %3
  ret void

10:                                               ; preds = %.lr.ph, %24
  %.020 = phi i32 [ %.018, %.lr.ph ], [ %.0, %24 ]
  %11 = sext i32 %.020 to i64
  %12 = getelementptr inbounds [200010 x %struct.edge], ptr @E, i64 0, i64 %11
  %13 = load i32, ptr %12, align 8, !tbaa !12
  %.not17 = icmp eq i32 %13, %1
  br i1 %.not17, label %24, label %14

14:                                               ; preds = %10
  %15 = sext i32 %13 to i64
  %16 = getelementptr inbounds [100010 x %struct.vertex], ptr @V, i64 0, i64 %15, i32 2
  %17 = load ptr, ptr %8, align 8, !tbaa !14
  %18 = ashr i32 %.020, 1
  %19 = sext i32 %18 to i64
  %20 = getelementptr inbounds [100010 x [12 x i8]], ptr @str, i64 0, i64 %19
  %21 = tail call i64 @strlen(ptr noundef nonnull dereferenceable(1) %20) #2
  %22 = trunc i64 %21 to i32
  tail call void @_Z6insertRP4nodeS0_Pcii(ptr noundef nonnull align 8 dereferenceable(8) %16, ptr noundef %17, ptr noundef nonnull %20, i32 noundef %22, i32 noundef 0)
  %23 = load i32, ptr %12, align 8, !tbaa !12
  tail call void @_Z3dfsiii(i32 noundef %23, i32 noundef %0, i32 noundef %9)
  br label %24

24:                                               ; preds = %10, %14
  %25 = getelementptr inbounds i8, ptr %12, i64 4
  %.0 = load i32, ptr %25, align 4, !tbaa !5
  %.not = icmp eq i32 %.0, 0
  br i1 %.not, label %._crit_edge, label %10, !llvm.loop !15
}

attributes #0 = { mustprogress 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 #1 = { mustprogress nofree nounwind willreturn memory(argmem: read) "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 willreturn memory(read) }

!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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !6, i64 4}
!10 = !{!"_ZTS6vertex", !6, i64 0, !6, i64 4, !11, i64 8}
!11 = !{!"any pointer", !7, i64 0}
!12 = !{!13, !6, i64 0}
!13 = !{!"_ZTS4edge", !6, i64 0, !6, i64 4}
!14 = !{!10, !11, i64 8}
!15 = distinct !{!15, !16}
!16 = !{!"llvm.loop.mustprogress"}


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