; LLVM IR from likle/cwalk :: src (cwalk)

; 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.cwk_segment_joined = type { %struct.cwk_segment, ptr, i64 }
%struct.cwk_segment = type { ptr, ptr, ptr, ptr, i64 }

; 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

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

; Function Attrs: nounwind uwtable
declare hidden zeroext i1 @cwk_path_is_string_equal(ptr noundef, ptr noundef, i64 noundef, i64 noundef) #1

; Function Attrs: nounwind uwtable
declare hidden zeroext i1 @cwk_path_is_root_absolute(ptr noundef, i64 noundef) #1

; Function Attrs: nounwind uwtable
declare hidden zeroext i1 @cwk_path_get_first_segment_joined(ptr noundef, ptr noundef) #1

; Function Attrs: nounwind uwtable
declare hidden zeroext i1 @cwk_path_segment_joined_skip_invisible(ptr noundef, i1 noundef zeroext) #1

; Function Attrs: nounwind uwtable
declare hidden zeroext i1 @cwk_path_get_next_segment_joined(ptr noundef) #1

; Function Attrs: nounwind uwtable
define dso_local i64 @cwk_path_get_intersection(ptr noundef %0, ptr noundef %1) #1 {
  %3 = alloca i64, align 8
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca i8, align 1
  %7 = alloca i64, align 8
  %8 = alloca i64, align 8
  %9 = alloca ptr, align 8
  %10 = alloca [2 x ptr], align 16
  %11 = alloca [2 x ptr], align 16
  %12 = alloca %struct.cwk_segment_joined, align 8
  %13 = alloca %struct.cwk_segment_joined, align 8
  %14 = alloca i32, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 1, ptr %6) #2
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #2
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #2
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #2
  call void @llvm.lifetime.start.p0(i64 16, ptr %10) #2
  call void @llvm.lifetime.start.p0(i64 16, ptr %11) #2
  call void @llvm.lifetime.start.p0(i64 56, ptr %12) #2
  call void @llvm.lifetime.start.p0(i64 56, ptr %13) #2
  %15 = load ptr, ptr %4, align 8, !tbaa !5
  call void @cwk_path_get_root(ptr noundef %15, ptr noundef %7)
  %16 = load ptr, ptr %5, align 8, !tbaa !5
  call void @cwk_path_get_root(ptr noundef %16, ptr noundef %8)
  %17 = load ptr, ptr %4, align 8, !tbaa !5
  %18 = load ptr, ptr %5, align 8, !tbaa !5
  %19 = load i64, ptr %7, align 8, !tbaa !9
  %20 = load i64, ptr %8, align 8, !tbaa !9
  %21 = call zeroext i1 @cwk_path_is_string_equal(ptr noundef %17, ptr noundef %18, i64 noundef %19, i64 noundef %20)
  br i1 %21, label %23, label %22

22:                                               ; preds = %2
  store i64 0, ptr %3, align 8
  store i32 1, ptr %14, align 4
  br label %90

23:                                               ; preds = %2
  %24 = load ptr, ptr %4, align 8, !tbaa !5
  %25 = getelementptr inbounds [2 x ptr], ptr %10, i64 0, i64 0
  store ptr %24, ptr %25, align 16, !tbaa !5
  %26 = getelementptr inbounds [2 x ptr], ptr %10, i64 0, i64 1
  store ptr null, ptr %26, align 8, !tbaa !5
  %27 = load ptr, ptr %5, align 8, !tbaa !5
  %28 = getelementptr inbounds [2 x ptr], ptr %11, i64 0, i64 0
  store ptr %27, ptr %28, align 16, !tbaa !5
  %29 = getelementptr inbounds [2 x ptr], ptr %11, i64 0, i64 1
  store ptr null, ptr %29, align 8, !tbaa !5
  %30 = getelementptr inbounds [2 x ptr], ptr %10, i64 0, i64 0
  %31 = call zeroext i1 @cwk_path_get_first_segment_joined(ptr noundef %30, ptr noundef %12)
  br i1 %31, label %32, label %35

32:                                               ; preds = %23
  %33 = getelementptr inbounds [2 x ptr], ptr %11, i64 0, i64 0
  %34 = call zeroext i1 @cwk_path_get_first_segment_joined(ptr noundef %33, ptr noundef %13)
  br i1 %34, label %37, label %35

35:                                               ; preds = %32, %23
  %36 = load i64, ptr %7, align 8, !tbaa !9
  store i64 %36, ptr %3, align 8
  store i32 1, ptr %14, align 4
  br label %90

37:                                               ; preds = %32
  %38 = load ptr, ptr %4, align 8, !tbaa !5
  %39 = load i64, ptr %7, align 8, !tbaa !9
  %40 = call zeroext i1 @cwk_path_is_root_absolute(ptr noundef %38, i64 noundef %39)
  %41 = zext i1 %40 to i8
  store i8 %41, ptr %6, align 1, !tbaa !11
  %42 = load ptr, ptr %4, align 8, !tbaa !5
  %43 = load i64, ptr %7, align 8, !tbaa !9
  %44 = getelementptr inbounds i8, ptr %42, i64 %43
  store ptr %44, ptr %9, align 8, !tbaa !5
  br label %45

45:                                               ; preds = %82, %37
  %46 = load i8, ptr %6, align 1, !tbaa !11, !range !13, !noundef !14
  %47 = trunc i8 %46 to i1
  %48 = call zeroext i1 @cwk_path_segment_joined_skip_invisible(ptr noundef %12, i1 noundef zeroext %47)
  br i1 %48, label %49, label %53

49:                                               ; preds = %45
  %50 = load i8, ptr %6, align 1, !tbaa !11, !range !13, !noundef !14
  %51 = trunc i8 %50 to i1
  %52 = call zeroext i1 @cwk_path_segment_joined_skip_invisible(ptr noundef %13, i1 noundef zeroext %51)
  br i1 %52, label %54, label %53

53:                                               ; preds = %49, %45
  br label %84

54:                                               ; preds = %49
  %55 = getelementptr inbounds %struct.cwk_segment_joined, ptr %12, i32 0, i32 0
  %56 = getelementptr inbounds %struct.cwk_segment, ptr %55, i32 0, i32 2
  %57 = load ptr, ptr %56, align 8, !tbaa !15
  %58 = getelementptr inbounds %struct.cwk_segment_joined, ptr %13, i32 0, i32 0
  %59 = getelementptr inbounds %struct.cwk_segment, ptr %58, i32 0, i32 2
  %60 = load ptr, ptr %59, align 8, !tbaa !15
  %61 = getelementptr inbounds %struct.cwk_segment_joined, ptr %12, i32 0, i32 0
  %62 = getelementptr inbounds %struct.cwk_segment, ptr %61, i32 0, i32 4
  %63 = load i64, ptr %62, align 8, !tbaa !18
  %64 = getelementptr inbounds %struct.cwk_segment_joined, ptr %13, i32 0, i32 0
  %65 = getelementptr inbounds %struct.cwk_segment, ptr %64, i32 0, i32 4
  %66 = load i64, ptr %65, align 8, !tbaa !18
  %67 = call zeroext i1 @cwk_path_is_string_equal(ptr noundef %57, ptr noundef %60, i64 noundef %63, i64 noundef %66)
  br i1 %67, label %74, label %68

68:                                               ; preds = %54
  %69 = load ptr, ptr %9, align 8, !tbaa !5
  %70 = load ptr, ptr %4, align 8, !tbaa !5
  %71 = ptrtoint ptr %69 to i64
  %72 = ptrtoint ptr %70 to i64
  %73 = sub i64 %71, %72
  store i64 %73, ptr %3, align 8
  store i32 1, ptr %14, align 4
  br label %90

74:                                               ; preds = %54
  %75 = getelementptr inbounds %struct.cwk_segment_joined, ptr %12, i32 0, i32 0
  %76 = getelementptr inbounds %struct.cwk_segment, ptr %75, i32 0, i32 3
  %77 = load ptr, ptr %76, align 8, !tbaa !19
  store ptr %77, ptr %9, align 8, !tbaa !5
  br label %78

78:                                               ; preds = %74
  %79 = call zeroext i1 @cwk_path_get_next_segment_joined(ptr noundef %12)
  br i1 %79, label %80, label %82

80:                                               ; preds = %78
  %81 = call zeroext i1 @cwk_path_get_next_segment_joined(ptr noundef %13)
  br label %82

82:                                               ; preds = %80, %78
  %83 = phi i1 [ false, %78 ], [ %81, %80 ]
  br i1 %83, label %45, label %84, !llvm.loop !20

84:                                               ; preds = %82, %53
  %85 = load ptr, ptr %9, align 8, !tbaa !5
  %86 = load ptr, ptr %4, align 8, !tbaa !5
  %87 = ptrtoint ptr %85 to i64
  %88 = ptrtoint ptr %86 to i64
  %89 = sub i64 %87, %88
  store i64 %89, ptr %3, align 8
  store i32 1, ptr %14, align 4
  br label %90

90:                                               ; preds = %84, %68, %35, %22
  call void @llvm.lifetime.end.p0(i64 56, ptr %13) #2
  call void @llvm.lifetime.end.p0(i64 56, ptr %12) #2
  call void @llvm.lifetime.end.p0(i64 16, ptr %11) #2
  call void @llvm.lifetime.end.p0(i64 16, ptr %10) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #2
  call void @llvm.lifetime.end.p0(i64 1, ptr %6) #2
  %91 = load i64, ptr %3, align 8
  ret i64 %91
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { 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 = !{!"long", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"_Bool", !7, i64 0}
!13 = !{i8 0, i8 2}
!14 = !{}
!15 = !{!16, !6, i64 16}
!16 = !{!"cwk_segment_joined", !17, i64 0, !6, i64 40, !10, i64 48}
!17 = !{!"cwk_segment", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !10, i64 32}
!18 = !{!16, !10, i64 32}
!19 = !{!16, !6, i64 24}
!20 = distinct !{!20, !21}
!21 = !{!"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.cwk_segment_joined = type { %struct.cwk_segment, ptr, i64 }
%struct.cwk_segment = type { ptr, ptr, ptr, ptr, i64 }

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

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

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

; Function Attrs: nounwind uwtable
declare hidden zeroext i1 @cwk_path_is_string_equal(ptr noundef, ptr noundef, i64 noundef, i64 noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
declare hidden zeroext i1 @cwk_path_is_root_absolute(ptr noundef, i64 noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
declare hidden zeroext i1 @cwk_path_get_first_segment_joined(ptr noundef, ptr noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
declare hidden zeroext i1 @cwk_path_segment_joined_skip_invisible(ptr noundef, i1 noundef zeroext) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
declare hidden zeroext i1 @cwk_path_get_next_segment_joined(ptr noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
define dso_local i64 @cwk_path_get_intersection(ptr noundef %0, ptr noundef %1) local_unnamed_addr #1 {
  %3 = alloca i64, align 8
  %4 = alloca i64, align 8
  %5 = alloca [2 x ptr], align 16
  %6 = alloca [2 x ptr], align 16
  %7 = alloca %struct.cwk_segment_joined, align 8
  %8 = alloca %struct.cwk_segment_joined, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %3) #2
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %4) #2
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %5) #2
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %6) #2
  call void @llvm.lifetime.start.p0(i64 56, ptr nonnull %7) #2
  call void @llvm.lifetime.start.p0(i64 56, ptr nonnull %8) #2
  call void @cwk_path_get_root(ptr noundef %0, ptr noundef nonnull %3)
  call void @cwk_path_get_root(ptr noundef %1, ptr noundef nonnull %4)
  %9 = load i64, ptr %3, align 8, !tbaa !5
  %10 = load i64, ptr %4, align 8, !tbaa !5
  %11 = call zeroext i1 @cwk_path_is_string_equal(ptr noundef %0, ptr noundef %1, i64 noundef %9, i64 noundef %10)
  br i1 %11, label %12, label %52

12:                                               ; preds = %2
  store ptr %0, ptr %5, align 16, !tbaa !9
  %13 = getelementptr inbounds i8, ptr %5, i64 8
  store ptr null, ptr %13, align 8, !tbaa !9
  store ptr %1, ptr %6, align 16, !tbaa !9
  %14 = getelementptr inbounds i8, ptr %6, i64 8
  store ptr null, ptr %14, align 8, !tbaa !9
  %15 = call zeroext i1 @cwk_path_get_first_segment_joined(ptr noundef nonnull %5, ptr noundef nonnull %7)
  br i1 %15, label %16, label %18

16:                                               ; preds = %12
  %17 = call zeroext i1 @cwk_path_get_first_segment_joined(ptr noundef nonnull %6, ptr noundef nonnull %8)
  br i1 %17, label %20, label %18

18:                                               ; preds = %16, %12
  %19 = load i64, ptr %3, align 8, !tbaa !5
  br label %52

20:                                               ; preds = %16
  %21 = load i64, ptr %3, align 8, !tbaa !5
  %22 = call zeroext i1 @cwk_path_is_root_absolute(ptr noundef %0, i64 noundef %21)
  %23 = load i64, ptr %3, align 8, !tbaa !5
  %24 = getelementptr inbounds i8, ptr %0, i64 %23
  %25 = getelementptr inbounds i8, ptr %7, i64 16
  %26 = getelementptr inbounds i8, ptr %8, i64 16
  %27 = getelementptr inbounds i8, ptr %7, i64 32
  %28 = getelementptr inbounds i8, ptr %8, i64 32
  %29 = getelementptr inbounds i8, ptr %7, i64 24
  br label %30

30:                                               ; preds = %47, %20
  %.0 = phi ptr [ %24, %20 ], [ %45, %47 ]
  %31 = call zeroext i1 @cwk_path_segment_joined_skip_invisible(ptr noundef nonnull %7, i1 noundef zeroext %22)
  br i1 %31, label %32, label %.critedge

32:                                               ; preds = %30
  %33 = call zeroext i1 @cwk_path_segment_joined_skip_invisible(ptr noundef nonnull %8, i1 noundef zeroext %22)
  br i1 %33, label %34, label %.critedge

34:                                               ; preds = %32
  %35 = load ptr, ptr %25, align 8, !tbaa !11
  %36 = load ptr, ptr %26, align 8, !tbaa !11
  %37 = load i64, ptr %27, align 8, !tbaa !14
  %38 = load i64, ptr %28, align 8, !tbaa !14
  %39 = call zeroext i1 @cwk_path_is_string_equal(ptr noundef %35, ptr noundef %36, i64 noundef %37, i64 noundef %38)
  br i1 %39, label %44, label %40

40:                                               ; preds = %34
  %41 = ptrtoint ptr %.0 to i64
  %42 = ptrtoint ptr %0 to i64
  %43 = sub i64 %41, %42
  br label %52

44:                                               ; preds = %34
  %45 = load ptr, ptr %29, align 8, !tbaa !15
  %46 = call zeroext i1 @cwk_path_get_next_segment_joined(ptr noundef nonnull %7)
  br i1 %46, label %47, label %.critedge

47:                                               ; preds = %44
  %48 = call zeroext i1 @cwk_path_get_next_segment_joined(ptr noundef nonnull %8)
  br i1 %48, label %30, label %.critedge, !llvm.loop !16

.critedge:                                        ; preds = %44, %30, %32, %47
  %.1 = phi ptr [ %45, %47 ], [ %45, %44 ], [ %.0, %32 ], [ %.0, %30 ]
  %49 = ptrtoint ptr %.1 to i64
  %50 = ptrtoint ptr %0 to i64
  %51 = sub i64 %49, %50
  br label %52

52:                                               ; preds = %2, %.critedge, %40, %18
  %.014 = phi i64 [ %51, %.critedge ], [ %43, %40 ], [ %19, %18 ], [ 0, %2 ]
  call void @llvm.lifetime.end.p0(i64 56, ptr nonnull %8) #2
  call void @llvm.lifetime.end.p0(i64 56, ptr nonnull %7) #2
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %6) #2
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %5) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %4) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %3) #2
  ret i64 %.014
}

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { 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 = !{!"long", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"any pointer", !7, i64 0}
!11 = !{!12, !10, i64 16}
!12 = !{!"cwk_segment_joined", !13, i64 0, !10, i64 40, !6, i64 48}
!13 = !{!"cwk_segment", !10, i64 0, !10, i64 8, !10, i64 16, !10, i64 24, !6, i64 32}
!14 = !{!12, !6, i64 32}
!15 = !{!12, !10, i64 24}
!16 = distinct !{!16, !17}
!17 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,LCSSAPass,LICMPass,LoopUnrollPass,SROAPass,SimplifyCFGPass