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

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

; 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 ptr @ush_node_get_by_path(ptr noundef, ptr noundef) #1

declare ptr @ush_node_get_parent_by_path(ptr noundef, ptr noundef) #1

; Function Attrs: nounwind uwtable
define dso_local i32 @ush_node_unmount(ptr noundef %0, ptr noundef %1) #2 {
  %3 = alloca i32, align 4
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca i32, align 4
  %9 = alloca ptr, align 8
  %10 = alloca ptr, align 8
  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 8, ptr %6) #3
  %11 = load ptr, ptr %4, align 8, !tbaa !5
  %12 = load ptr, ptr %5, align 8, !tbaa !5
  %13 = call ptr @ush_node_get_parent_by_path(ptr noundef %11, ptr noundef %12)
  store ptr %13, ptr %6, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #3
  %14 = load ptr, ptr %4, align 8, !tbaa !5
  %15 = load ptr, ptr %5, align 8, !tbaa !5
  %16 = call ptr @ush_node_get_by_path(ptr noundef %14, ptr noundef %15)
  store ptr %16, ptr %7, align 8, !tbaa !5
  %17 = load ptr, ptr %7, align 8, !tbaa !5
  %18 = icmp eq ptr %17, null
  br i1 %18, label %28, label %19

19:                                               ; preds = %2
  %20 = load ptr, ptr %7, align 8, !tbaa !5
  %21 = load ptr, ptr %4, align 8, !tbaa !5
  %22 = getelementptr inbounds %struct.ush_object, ptr %21, i32 0, i32 13
  %23 = load ptr, ptr %22, align 8, !tbaa !9
  %24 = icmp ne ptr %20, %23
  br i1 %24, label %25, label %29

25:                                               ; preds = %19
  %26 = load ptr, ptr %6, align 8, !tbaa !5
  %27 = icmp eq ptr %26, null
  br i1 %27, label %28, label %29

28:                                               ; preds = %25, %2
  store i32 1, ptr %3, align 4
  store i32 1, ptr %8, align 4
  br label %75

29:                                               ; preds = %25, %19
  %30 = load ptr, ptr %7, align 8, !tbaa !5
  %31 = getelementptr inbounds %struct.ush_node_object, ptr %30, i32 0, i32 4
  %32 = load ptr, ptr %31, align 8, !tbaa !15
  %33 = icmp ne ptr %32, null
  br i1 %33, label %34, label %35

34:                                               ; preds = %29
  store i32 2, ptr %3, align 4
  store i32 1, ptr %8, align 4
  br label %75

35:                                               ; preds = %29
  %36 = load ptr, ptr %6, align 8, !tbaa !5
  %37 = icmp eq ptr %36, null
  br i1 %37, label %38, label %41

38:                                               ; preds = %35
  %39 = load ptr, ptr %4, align 8, !tbaa !5
  %40 = getelementptr inbounds %struct.ush_object, ptr %39, i32 0, i32 13
  store ptr null, ptr %40, align 8, !tbaa !9
  store i32 0, ptr %3, align 4
  store i32 1, ptr %8, align 4
  br label %75

41:                                               ; preds = %35
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #3
  store ptr null, ptr %9, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #3
  %42 = load ptr, ptr %6, align 8, !tbaa !5
  %43 = getelementptr inbounds %struct.ush_node_object, ptr %42, i32 0, i32 4
  %44 = load ptr, ptr %43, align 8, !tbaa !15
  store ptr %44, ptr %10, align 8, !tbaa !5
  br label %45

45:                                               ; preds = %52, %41
  %46 = load ptr, ptr %10, align 8, !tbaa !5
  %47 = icmp ne ptr %46, null
  br i1 %47, label %48, label %73

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

52:                                               ; preds = %48
  %53 = load ptr, ptr %10, align 8, !tbaa !5
  store ptr %53, ptr %9, align 8, !tbaa !5
  %54 = load ptr, ptr %10, align 8, !tbaa !5
  %55 = getelementptr inbounds %struct.ush_node_object, ptr %54, i32 0, i32 5
  %56 = load ptr, ptr %55, align 8, !tbaa !16
  store ptr %56, ptr %10, align 8, !tbaa !5
  br label %45, !llvm.loop !17

57:                                               ; preds = %48
  %58 = load ptr, ptr %9, align 8, !tbaa !5
  %59 = icmp eq ptr %58, null
  br i1 %59, label %60, label %66

60:                                               ; preds = %57
  %61 = load ptr, ptr %7, align 8, !tbaa !5
  %62 = getelementptr inbounds %struct.ush_node_object, ptr %61, i32 0, i32 5
  %63 = load ptr, ptr %62, align 8, !tbaa !16
  %64 = load ptr, ptr %6, align 8, !tbaa !5
  %65 = getelementptr inbounds %struct.ush_node_object, ptr %64, i32 0, i32 4
  store ptr %63, ptr %65, align 8, !tbaa !15
  br label %72

66:                                               ; preds = %57
  %67 = load ptr, ptr %7, align 8, !tbaa !5
  %68 = getelementptr inbounds %struct.ush_node_object, ptr %67, i32 0, i32 5
  %69 = load ptr, ptr %68, align 8, !tbaa !16
  %70 = load ptr, ptr %9, align 8, !tbaa !5
  %71 = getelementptr inbounds %struct.ush_node_object, ptr %70, i32 0, i32 5
  store ptr %69, ptr %71, align 8, !tbaa !16
  br label %72

72:                                               ; preds = %66, %60
  store i32 0, ptr %3, align 4
  store i32 1, ptr %8, align 4
  br label %74

73:                                               ; preds = %45
  store i32 1, ptr %3, align 4
  store i32 1, ptr %8, align 4
  br label %74

74:                                               ; preds = %73, %72
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #3
  br label %75

75:                                               ; preds = %74, %38, %34, %28
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #3
  %76 = load i32, ptr %3, align 4
  ret i32 %76
}

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, !6, i64 96}
!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 = !{!14, !6, i64 32}
!16 = !{!14, !6, i64 40}
!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"

declare ptr @ush_node_get_by_path(ptr noundef, ptr noundef) local_unnamed_addr #0

declare ptr @ush_node_get_parent_by_path(ptr noundef, ptr noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local range(i32 0, 3) i32 @ush_node_unmount(ptr noundef %0, ptr noundef %1) local_unnamed_addr #1 {
  %3 = tail call ptr @ush_node_get_parent_by_path(ptr noundef %0, ptr noundef %1) #2
  %4 = tail call ptr @ush_node_get_by_path(ptr noundef %0, ptr noundef %1) #2
  %5 = icmp eq ptr %4, null
  br i1 %5, label %.loopexit, label %6

6:                                                ; preds = %2
  %7 = getelementptr inbounds i8, ptr %0, i64 96
  %8 = load ptr, ptr %7, align 8, !tbaa !5
  %9 = icmp ne ptr %4, %8
  %10 = icmp eq ptr %3, null
  %or.cond = select i1 %9, i1 %10, i1 false
  br i1 %or.cond, label %.loopexit, label %11

11:                                               ; preds = %6
  %12 = getelementptr inbounds i8, ptr %4, i64 32
  %13 = load ptr, ptr %12, align 8, !tbaa !14
  %.not = icmp eq ptr %13, null
  br i1 %.not, label %14, label %.loopexit

14:                                               ; preds = %11
  br i1 %10, label %15, label %16

15:                                               ; preds = %14
  store ptr null, ptr %7, align 8, !tbaa !5
  br label %.loopexit

16:                                               ; preds = %14
  %17 = getelementptr inbounds i8, ptr %3, i64 32
  %.030 = load ptr, ptr %17, align 8, !tbaa !15
  %.not2731 = icmp eq ptr %.030, null
  br i1 %.not2731, label %.loopexit, label %.lr.ph.preheader

.lr.ph.preheader:                                 ; preds = %16
  %.not2837 = icmp eq ptr %.030, %4
  br i1 %.not2837, label %.lr.ph._crit_edge, label %.lr.ph39

.lr.ph39:                                         ; preds = %.lr.ph.preheader, %.lr.ph
  %.03338 = phi ptr [ %.0, %.lr.ph ], [ %.030, %.lr.ph.preheader ]
  %18 = getelementptr inbounds i8, ptr %.03338, i64 40
  %.0 = load ptr, ptr %18, align 8, !tbaa !15
  %.not27 = icmp eq ptr %.0, null
  br i1 %.not27, label %.loopexit, label %.lr.ph, !llvm.loop !16

.lr.ph:                                           ; preds = %.lr.ph39
  %.not28 = icmp eq ptr %.0, %4
  br i1 %.not28, label %.lr.ph._crit_edge, label %.lr.ph39, !llvm.loop !16

.lr.ph._crit_edge:                                ; preds = %.lr.ph, %.lr.ph.preheader
  %.02332.lcssa = phi ptr [ null, %.lr.ph.preheader ], [ %.03338, %.lr.ph ]
  %19 = icmp eq ptr %.02332.lcssa, null
  %20 = getelementptr inbounds i8, ptr %4, i64 40
  %21 = load ptr, ptr %20, align 8, !tbaa !18
  br i1 %19, label %22, label %23

22:                                               ; preds = %.lr.ph._crit_edge
  store ptr %21, ptr %17, align 8, !tbaa !14
  br label %.loopexit

23:                                               ; preds = %.lr.ph._crit_edge
  %24 = getelementptr inbounds i8, ptr %.02332.lcssa, i64 40
  store ptr %21, ptr %24, align 8, !tbaa !18
  br label %.loopexit

.loopexit:                                        ; preds = %.lr.ph39, %16, %23, %22, %11, %2, %6, %15
  %.1 = phi i32 [ 0, %15 ], [ 1, %6 ], [ 1, %2 ], [ 2, %11 ], [ 0, %23 ], [ 0, %22 ], [ 1, %16 ], [ 1, %.lr.ph39 ]
  ret i32 %.1
}

attributes #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 = { 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, !7, i64 96}
!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 = !{!13, !7, i64 32}
!15 = !{!7, !7, i64 0}
!16 = distinct !{!16, !17}
!17 = !{!"llvm.loop.mustprogress"}
!18 = !{!13, !7, i64 40}


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