; LLVM IR from marcinbor85/microshell :: src/src (ush_node)

; 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.ush_object = type { ptr, i32, i32, i32, ptr, i64, i64, i32, i64, i64, i64, i8, ptr, ptr, ptr, %struct.ush_node_object, ptr, ptr, ptr, i64, i64, ptr, i64, i32, i32, ptr, ptr, ptr, i64, i64, i64 }
%struct.ush_node_object = type { ptr, i64, ptr, ptr, ptr, ptr }
%struct.ush_descriptor = type { ptr, ptr, i64, ptr, i64, i64, ptr, ptr }

; Function Attrs: nounwind uwtable
define dso_local ptr @ush_node_get_by_path(ptr noundef %0, ptr noundef %1) #0 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca i64, align 8
  %8 = alloca i64, align 8
  %9 = alloca i32, align 4
  %10 = alloca ptr, align 8
  %11 = alloca i64, align 8
  %12 = alloca i8, align 1
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  %13 = load ptr, ptr %4, align 8, !tbaa !5
  %14 = getelementptr inbounds %struct.ush_object, ptr %13, i32 0, i32 0
  %15 = load ptr, ptr %14, align 8, !tbaa !9
  %16 = getelementptr inbounds %struct.ush_descriptor, ptr %15, i32 0, i32 5
  %17 = load i64, ptr %16, align 8, !tbaa !15
  %18 = call ptr @llvm.stacksave.p0()
  store ptr %18, ptr %6, align 8
  %19 = alloca i8, i64 %17, align 16
  store i64 %17, ptr %7, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #5
  %20 = load ptr, ptr %5, align 8, !tbaa !5
  %21 = call i64 @ush_utils_get_path_levels_count(ptr noundef %20)
  store i64 %21, ptr %8, align 8, !tbaa !17
  %22 = load i64, ptr %8, align 8, !tbaa !17
  %23 = icmp eq i64 %22, 0
  br i1 %23, label %24, label %28

24:                                               ; preds = %2
  %25 = load ptr, ptr %4, align 8, !tbaa !5
  %26 = getelementptr inbounds %struct.ush_object, ptr %25, i32 0, i32 13
  %27 = load ptr, ptr %26, align 8, !tbaa !18
  store ptr %27, ptr %3, align 8
  store i32 1, ptr %9, align 4
  br label %88

28:                                               ; preds = %2
  %29 = load ptr, ptr %4, align 8, !tbaa !5
  %30 = getelementptr inbounds %struct.ush_object, ptr %29, i32 0, i32 13
  %31 = load ptr, ptr %30, align 8, !tbaa !18
  %32 = icmp eq ptr %31, null
  br i1 %32, label %33, label %34

33:                                               ; preds = %28
  store ptr null, ptr %3, align 8
  store i32 1, ptr %9, align 4
  br label %88

34:                                               ; preds = %28
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #5
  %35 = load ptr, ptr %4, align 8, !tbaa !5
  %36 = getelementptr inbounds %struct.ush_object, ptr %35, i32 0, i32 13
  %37 = load ptr, ptr %36, align 8, !tbaa !18
  %38 = getelementptr inbounds %struct.ush_node_object, ptr %37, i32 0, i32 4
  %39 = load ptr, ptr %38, align 8, !tbaa !19
  store ptr %39, ptr %10, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #5
  store i64 1, ptr %11, align 8, !tbaa !17
  br label %40

40:                                               ; preds = %81, %34
  %41 = load i64, ptr %11, align 8, !tbaa !17
  %42 = load i64, ptr %8, align 8, !tbaa !17
  %43 = icmp ule i64 %41, %42
  br i1 %43, label %45, label %44

44:                                               ; preds = %40
  store i32 2, ptr %9, align 4
  br label %84

45:                                               ; preds = %40
  %46 = load i64, ptr %11, align 8, !tbaa !17
  %47 = load ptr, ptr %5, align 8, !tbaa !5
  call void @ush_utils_get_path_level(i64 noundef %46, ptr noundef %47, ptr noundef %19)
  call void @llvm.lifetime.start.p0(i64 1, ptr %12) #5
  store i8 0, ptr %12, align 1, !tbaa !20
  br label %48

48:                                               ; preds = %58, %45
  %49 = load ptr, ptr %10, align 8, !tbaa !5
  %50 = icmp ne ptr %49, null
  br i1 %50, label %51, label %62

51:                                               ; preds = %48
  %52 = load ptr, ptr %10, align 8, !tbaa !5
  %53 = getelementptr inbounds %struct.ush_node_object, ptr %52, i32 0, i32 2
  %54 = load ptr, ptr %53, align 8, !tbaa !21
  %55 = call i32 @strcmp(ptr noundef %54, ptr noundef %19) #6
  %56 = icmp eq i32 %55, 0
  br i1 %56, label %57, label %58

57:                                               ; preds = %51
  store i8 1, ptr %12, align 1, !tbaa !20
  br label %62

58:                                               ; preds = %51
  %59 = load ptr, ptr %10, align 8, !tbaa !5
  %60 = getelementptr inbounds %struct.ush_node_object, ptr %59, i32 0, i32 5
  %61 = load ptr, ptr %60, align 8, !tbaa !22
  store ptr %61, ptr %10, align 8, !tbaa !5
  br label %48, !llvm.loop !23

62:                                               ; preds = %57, %48
  %63 = load i8, ptr %12, align 1, !tbaa !20, !range !25, !noundef !26
  %64 = trunc i8 %63 to i1
  %65 = zext i1 %64 to i32
  %66 = icmp eq i32 %65, 0
  br i1 %66, label %67, label %68

67:                                               ; preds = %62
  store i32 2, ptr %9, align 4
  br label %78

68:                                               ; preds = %62
  %69 = load i64, ptr %11, align 8, !tbaa !17
  %70 = load i64, ptr %8, align 8, !tbaa !17
  %71 = icmp eq i64 %69, %70
  br i1 %71, label %72, label %74

72:                                               ; preds = %68
  %73 = load ptr, ptr %10, align 8, !tbaa !5
  store ptr %73, ptr %3, align 8
  store i32 1, ptr %9, align 4
  br label %78

74:                                               ; preds = %68
  %75 = load ptr, ptr %10, align 8, !tbaa !5
  %76 = getelementptr inbounds %struct.ush_node_object, ptr %75, i32 0, i32 4
  %77 = load ptr, ptr %76, align 8, !tbaa !19
  store ptr %77, ptr %10, align 8, !tbaa !5
  store i32 0, ptr %9, align 4
  br label %78

78:                                               ; preds = %74, %72, %67
  call void @llvm.lifetime.end.p0(i64 1, ptr %12) #5
  %79 = load i32, ptr %9, align 4
  switch i32 %79, label %84 [
    i32 0, label %80
  ]

80:                                               ; preds = %78
  br label %81

81:                                               ; preds = %80
  %82 = load i64, ptr %11, align 8, !tbaa !17
  %83 = add i64 %82, 1
  store i64 %83, ptr %11, align 8, !tbaa !17
  br label %40, !llvm.loop !27

84:                                               ; preds = %78, %44
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #5
  %85 = load i32, ptr %9, align 4
  switch i32 %85, label %87 [
    i32 2, label %86
  ]

86:                                               ; preds = %84
  store ptr null, ptr %3, align 8
  store i32 1, ptr %9, align 4
  br label %87

87:                                               ; preds = %86, %84
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #5
  br label %88

88:                                               ; preds = %87, %33, %24
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #5
  %89 = load ptr, ptr %6, align 8
  call void @llvm.stackrestore.p0(ptr %89)
  %90 = load ptr, ptr %3, align 8
  ret ptr %90
}

; Function Attrs: nocallback nofree nosync nounwind willreturn
declare ptr @llvm.stacksave.p0() #1

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

declare i64 @ush_utils_get_path_levels_count(ptr noundef) #3

declare void @ush_utils_get_path_level(i64 noundef, ptr noundef, ptr noundef) #3

; Function Attrs: nounwind willreturn memory(read)
declare i32 @strcmp(ptr noundef, ptr noundef) #4

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

; Function Attrs: nocallback nofree nosync nounwind willreturn
declare void @llvm.stackrestore.p0(ptr) #1

attributes #0 = { 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 #1 = { nocallback nofree nosync nounwind willreturn }
attributes #2 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 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 #5 = { nounwind }
attributes #6 = { 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 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !6, i64 0}
!10 = !{!"ush_object", !6, i64 0, !11, i64 8, !11, i64 12, !11, i64 16, !6, i64 24, !12, i64 32, !12, i64 40, !11, i64 48, !12, i64 56, !12, i64 64, !12, i64 72, !13, i64 80, !6, i64 88, !6, i64 96, !6, i64 104, !14, i64 112, !6, i64 160, !6, i64 168, !6, i64 176, !12, i64 184, !12, i64 192, !6, i64 200, !12, i64 208, !11, i64 216, !11, i64 220, !6, i64 224, !6, i64 232, !6, i64 240, !12, i64 248, !12, i64 256, !12, i64 264}
!11 = !{!"int", !7, i64 0}
!12 = !{!"long", !7, i64 0}
!13 = !{!"_Bool", !7, i64 0}
!14 = !{!"ush_node_object", !6, i64 0, !12, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !6, i64 40}
!15 = !{!16, !12, i64 40}
!16 = !{!"ush_descriptor", !6, i64 0, !6, i64 8, !12, i64 16, !6, i64 24, !12, i64 32, !12, i64 40, !6, i64 48, !6, i64 56}
!17 = !{!12, !12, i64 0}
!18 = !{!10, !6, i64 96}
!19 = !{!14, !6, i64 32}
!20 = !{!13, !13, i64 0}
!21 = !{!14, !6, i64 16}
!22 = !{!14, !6, i64 40}
!23 = distinct !{!23, !24}
!24 = !{!"llvm.loop.mustprogress"}
!25 = !{i8 0, i8 2}
!26 = !{}
!27 = distinct !{!27, !24}


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

; Function Attrs: nounwind uwtable
define dso_local ptr @ush_node_get_by_path(ptr nocapture noundef readonly %0, ptr noundef %1) local_unnamed_addr #0 {
  %3 = load ptr, ptr %0, align 8, !tbaa !5
  %4 = getelementptr inbounds i8, ptr %3, i64 40
  %5 = load i64, ptr %4, align 8, !tbaa !14
  %6 = alloca i8, i64 %5, align 16
  %7 = tail call i64 @ush_utils_get_path_levels_count(ptr noundef %1) #3
  %8 = icmp eq i64 %7, 0
  %9 = getelementptr inbounds i8, ptr %0, i64 96
  %10 = load ptr, ptr %9, align 8, !tbaa !16
  br i1 %8, label %.thread, label %11

11:                                               ; preds = %2
  %12 = icmp eq ptr %10, null
  br i1 %12, label %.thread, label %.lr.ph52

13:                                               ; preds = %22
  %14 = add i64 %.02351, 1
  %.not = icmp ugt i64 %14, %7
  br i1 %.not, label %.thread, label %.lr.ph52, !llvm.loop !17

.lr.ph52:                                         ; preds = %11, %13
  %.02351 = phi i64 [ %14, %13 ], [ 1, %11 ]
  %.pn50 = phi ptr [ %.147, %13 ], [ %10, %11 ]
  %.024.in = getelementptr inbounds i8, ptr %.pn50, i64 32
  %.024 = load ptr, ptr %.024.in, align 8, !tbaa !19
  call void @ush_utils_get_path_level(i64 noundef %.02351, ptr noundef %1, ptr noundef nonnull %6) #3
  %.not32.not46 = icmp eq ptr %.024, null
  br i1 %.not32.not46, label %.thread, label %.lr.ph

.lr.ph:                                           ; preds = %.lr.ph52, %19
  %.147 = phi ptr [ %21, %19 ], [ %.024, %.lr.ph52 ]
  %15 = getelementptr inbounds i8, ptr %.147, i64 16
  %16 = load ptr, ptr %15, align 8, !tbaa !20
  %17 = call i32 @strcmp(ptr noundef nonnull dereferenceable(1) %16, ptr noundef nonnull dereferenceable(1) %6) #4
  %18 = icmp eq i32 %17, 0
  br i1 %18, label %22, label %19

19:                                               ; preds = %.lr.ph
  %20 = getelementptr inbounds i8, ptr %.147, i64 40
  %21 = load ptr, ptr %20, align 8, !tbaa !21
  %.not32.not = icmp eq ptr %21, null
  br i1 %.not32.not, label %.thread, label %.lr.ph, !llvm.loop !22

22:                                               ; preds = %.lr.ph
  %23 = icmp eq i64 %.02351, %7
  br i1 %23, label %.thread, label %13

.thread:                                          ; preds = %22, %13, %.lr.ph52, %19, %2, %11
  %.4 = phi ptr [ null, %11 ], [ %10, %2 ], [ null, %19 ], [ null, %.lr.ph52 ], [ %.147, %22 ], [ null, %13 ]
  ret ptr %.4
}

declare i64 @ush_utils_get_path_levels_count(ptr noundef) local_unnamed_addr #1

declare void @ush_utils_get_path_level(i64 noundef, ptr noundef, ptr noundef) local_unnamed_addr #1

; Function Attrs: mustprogress nofree nounwind willreturn memory(argmem: read)
declare i32 @strcmp(ptr nocapture noundef, ptr nocapture noundef) local_unnamed_addr #2

attributes #0 = { 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 #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 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 #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, !7, i64 0}
!6 = !{!"ush_object", !7, i64 0, !10, i64 8, !10, i64 12, !10, i64 16, !7, i64 24, !11, i64 32, !11, i64 40, !10, i64 48, !11, i64 56, !11, i64 64, !11, i64 72, !12, i64 80, !7, i64 88, !7, i64 96, !7, i64 104, !13, i64 112, !7, i64 160, !7, i64 168, !7, i64 176, !11, i64 184, !11, i64 192, !7, i64 200, !11, i64 208, !10, i64 216, !10, i64 220, !7, i64 224, !7, i64 232, !7, i64 240, !11, i64 248, !11, i64 256, !11, i64 264}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"int", !8, i64 0}
!11 = !{!"long", !8, i64 0}
!12 = !{!"_Bool", !8, i64 0}
!13 = !{!"ush_node_object", !7, i64 0, !11, i64 8, !7, i64 16, !7, i64 24, !7, i64 32, !7, i64 40}
!14 = !{!15, !11, i64 40}
!15 = !{!"ush_descriptor", !7, i64 0, !7, i64 8, !11, i64 16, !7, i64 24, !11, i64 32, !11, i64 40, !7, i64 48, !7, i64 56}
!16 = !{!6, !7, i64 96}
!17 = distinct !{!17, !18}
!18 = !{!"llvm.loop.mustprogress"}
!19 = !{!13, !7, i64 32}
!20 = !{!13, !7, i64 16}
!21 = !{!13, !7, i64 40}
!22 = distinct !{!22, !18}


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