; 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_node_object = type { ptr, i64, ptr, ptr, ptr, ptr }
%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 }

@.str = external hidden unnamed_addr constant [2 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local i32 @ush_node_mount(ptr noundef %0, ptr noundef %1, ptr noundef %2, ptr noundef %3, i64 noundef %4) #0 {
  %6 = alloca i32, align 4
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  %10 = alloca ptr, align 8
  %11 = alloca i64, align 8
  %12 = alloca i64, align 8
  %13 = alloca ptr, align 8
  %14 = alloca i32, align 4
  %15 = alloca ptr, align 8
  store ptr %0, ptr %7, align 8, !tbaa !5
  store ptr %1, ptr %8, align 8, !tbaa !5
  store ptr %2, ptr %9, align 8, !tbaa !5
  store ptr %3, ptr %10, align 8, !tbaa !5
  store i64 %4, ptr %11, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #4
  store i64 0, ptr %12, align 8, !tbaa !9
  br label %16

16:                                               ; preds = %22, %5
  %17 = load i64, ptr %12, align 8, !tbaa !9
  %18 = load i64, ptr %11, align 8, !tbaa !9
  %19 = icmp ult i64 %17, %18
  br i1 %19, label %21, label %20

20:                                               ; preds = %16
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #4
  br label %25

21:                                               ; preds = %16
  br label %22

22:                                               ; preds = %21
  %23 = load i64, ptr %12, align 8, !tbaa !9
  %24 = add i64 %23, 1
  store i64 %24, ptr %12, align 8, !tbaa !9
  br label %16, !llvm.loop !11

25:                                               ; preds = %20
  %26 = load ptr, ptr %10, align 8, !tbaa !5
  %27 = load ptr, ptr %9, align 8, !tbaa !5
  %28 = getelementptr inbounds %struct.ush_node_object, ptr %27, i32 0, i32 0
  store ptr %26, ptr %28, align 8, !tbaa !13
  %29 = load i64, ptr %11, align 8, !tbaa !9
  %30 = load ptr, ptr %9, align 8, !tbaa !5
  %31 = getelementptr inbounds %struct.ush_node_object, ptr %30, i32 0, i32 1
  store i64 %29, ptr %31, align 8, !tbaa !15
  %32 = load ptr, ptr %8, align 8, !tbaa !5
  %33 = load ptr, ptr %9, align 8, !tbaa !5
  %34 = getelementptr inbounds %struct.ush_node_object, ptr %33, i32 0, i32 2
  store ptr %32, ptr %34, align 8, !tbaa !16
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #4
  %35 = load ptr, ptr %7, align 8, !tbaa !5
  %36 = load ptr, ptr %8, align 8, !tbaa !5
  %37 = call ptr @ush_node_get_by_path(ptr noundef %35, ptr noundef %36)
  store ptr %37, ptr %13, align 8, !tbaa !5
  %38 = load ptr, ptr %13, align 8, !tbaa !5
  %39 = icmp ne ptr %38, null
  br i1 %39, label %40, label %41

40:                                               ; preds = %25
  store i32 4, ptr %6, align 4
  store i32 1, ptr %14, align 4
  br label %78

41:                                               ; preds = %25
  call void @llvm.lifetime.start.p0(i64 8, ptr %15) #4
  %42 = load ptr, ptr %7, align 8, !tbaa !5
  %43 = load ptr, ptr %8, align 8, !tbaa !5
  %44 = call ptr @ush_node_get_parent_by_path(ptr noundef %42, ptr noundef %43)
  store ptr %44, ptr %15, align 8, !tbaa !5
  %45 = load ptr, ptr %15, align 8, !tbaa !5
  %46 = icmp ne ptr %45, null
  br i1 %46, label %47, label %59

47:                                               ; preds = %41
  %48 = load ptr, ptr %15, align 8, !tbaa !5
  %49 = getelementptr inbounds %struct.ush_node_object, ptr %48, i32 0, i32 4
  %50 = load ptr, ptr %49, align 8, !tbaa !17
  %51 = load ptr, ptr %9, align 8, !tbaa !5
  %52 = getelementptr inbounds %struct.ush_node_object, ptr %51, i32 0, i32 5
  store ptr %50, ptr %52, align 8, !tbaa !18
  %53 = load ptr, ptr %9, align 8, !tbaa !5
  %54 = load ptr, ptr %15, align 8, !tbaa !5
  %55 = getelementptr inbounds %struct.ush_node_object, ptr %54, i32 0, i32 4
  store ptr %53, ptr %55, align 8, !tbaa !17
  %56 = load ptr, ptr %15, align 8, !tbaa !5
  %57 = load ptr, ptr %9, align 8, !tbaa !5
  %58 = getelementptr inbounds %struct.ush_node_object, ptr %57, i32 0, i32 3
  store ptr %56, ptr %58, align 8, !tbaa !19
  store i32 0, ptr %6, align 4
  store i32 1, ptr %14, align 4
  br label %77

59:                                               ; preds = %41
  %60 = load ptr, ptr %8, align 8, !tbaa !5
  %61 = call i32 @strcmp(ptr noundef %60, ptr noundef @.str) #5
  %62 = icmp eq i32 %61, 0
  br i1 %62, label %63, label %76

63:                                               ; preds = %59
  %64 = load ptr, ptr %9, align 8, !tbaa !5
  %65 = getelementptr inbounds %struct.ush_node_object, ptr %64, i32 0, i32 5
  store ptr null, ptr %65, align 8, !tbaa !18
  %66 = load ptr, ptr %9, align 8, !tbaa !5
  %67 = load ptr, ptr %7, align 8, !tbaa !5
  %68 = getelementptr inbounds %struct.ush_object, ptr %67, i32 0, i32 13
  store ptr %66, ptr %68, align 8, !tbaa !20
  %69 = load ptr, ptr %7, align 8, !tbaa !5
  %70 = getelementptr inbounds %struct.ush_object, ptr %69, i32 0, i32 13
  %71 = load ptr, ptr %70, align 8, !tbaa !20
  %72 = load ptr, ptr %7, align 8, !tbaa !5
  %73 = getelementptr inbounds %struct.ush_object, ptr %72, i32 0, i32 14
  store ptr %71, ptr %73, align 8, !tbaa !24
  %74 = load ptr, ptr %9, align 8, !tbaa !5
  %75 = getelementptr inbounds %struct.ush_node_object, ptr %74, i32 0, i32 3
  store ptr null, ptr %75, align 8, !tbaa !19
  store i32 0, ptr %6, align 4
  store i32 1, ptr %14, align 4
  br label %77

76:                                               ; preds = %59
  store i32 3, ptr %6, align 4
  store i32 1, ptr %14, align 4
  br label %77

77:                                               ; preds = %76, %63, %47
  call void @llvm.lifetime.end.p0(i64 8, ptr %15) #4
  br label %78

78:                                               ; preds = %77, %40
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #4
  %79 = load i32, ptr %6, align 4
  ret i32 %79
}

; 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

declare ptr @ush_node_get_by_path(ptr noundef, ptr noundef) #2

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

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

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 memory(argmem: readwrite) }
attributes #2 = { "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 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 #4 = { nounwind }
attributes #5 = { 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, !10, i64 0}
!10 = !{!"long", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = !{!14, !6, i64 0}
!14 = !{!"ush_node_object", !6, i64 0, !10, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !6, i64 40}
!15 = !{!14, !10, i64 8}
!16 = !{!14, !6, i64 16}
!17 = !{!14, !6, i64 32}
!18 = !{!14, !6, i64 40}
!19 = !{!14, !6, i64 24}
!20 = !{!21, !6, i64 96}
!21 = !{!"ush_object", !6, i64 0, !22, i64 8, !22, i64 12, !22, i64 16, !6, i64 24, !10, i64 32, !10, i64 40, !22, i64 48, !10, i64 56, !10, i64 64, !10, i64 72, !23, i64 80, !6, i64 88, !6, i64 96, !6, i64 104, !14, i64 112, !6, i64 160, !6, i64 168, !6, i64 176, !10, i64 184, !10, i64 192, !6, i64 200, !10, i64 208, !22, i64 216, !22, i64 220, !6, i64 224, !6, i64 232, !6, i64 240, !10, i64 248, !10, i64 256, !10, i64 264}
!22 = !{!"int", !7, i64 0}
!23 = !{!"_Bool", !7, i64 0}
!24 = !{!21, !6, i64 104}


; 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 = external hidden unnamed_addr constant [2 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local range(i32 0, 5) i32 @ush_node_mount(ptr noundef %0, ptr noundef %1, ptr noundef %2, ptr noundef %3, i64 noundef %4) local_unnamed_addr #0 {
  store ptr %3, ptr %2, align 8, !tbaa !5
  %6 = getelementptr inbounds i8, ptr %2, i64 8
  store i64 %4, ptr %6, align 8, !tbaa !11
  %7 = getelementptr inbounds i8, ptr %2, i64 16
  store ptr %1, ptr %7, align 8, !tbaa !12
  %8 = tail call ptr @ush_node_get_by_path(ptr noundef %0, ptr noundef %1) #3
  %.not = icmp eq ptr %8, null
  br i1 %.not, label %9, label %23

9:                                                ; preds = %5
  %10 = tail call ptr @ush_node_get_parent_by_path(ptr noundef %0, ptr noundef %1) #3
  %.not31 = icmp eq ptr %10, null
  br i1 %.not31, label %15, label %11

11:                                               ; preds = %9
  %12 = getelementptr inbounds i8, ptr %10, i64 32
  %13 = load ptr, ptr %12, align 8, !tbaa !13
  %14 = getelementptr inbounds i8, ptr %2, i64 40
  store ptr %13, ptr %14, align 8, !tbaa !14
  br label %.sink.split

15:                                               ; preds = %9
  %16 = tail call i32 @strcmp(ptr noundef nonnull dereferenceable(1) %1, ptr noundef nonnull dereferenceable(1) @.str) #4
  %17 = icmp eq i32 %16, 0
  br i1 %17, label %18, label %23

18:                                               ; preds = %15
  %19 = getelementptr inbounds i8, ptr %2, i64 40
  store ptr null, ptr %19, align 8, !tbaa !14
  %20 = getelementptr inbounds i8, ptr %0, i64 96
  store ptr %2, ptr %20, align 8, !tbaa !15
  %21 = getelementptr inbounds i8, ptr %0, i64 104
  br label %.sink.split

.sink.split:                                      ; preds = %18, %11
  %.sink33 = phi ptr [ %12, %11 ], [ %21, %18 ]
  %.sink = phi ptr [ %10, %11 ], [ null, %18 ]
  store ptr %2, ptr %.sink33, align 8, !tbaa !19
  %22 = getelementptr inbounds i8, ptr %2, i64 24
  store ptr %.sink, ptr %22, align 8, !tbaa !20
  br label %23

23:                                               ; preds = %.sink.split, %15, %5
  %.1 = phi i32 [ 4, %5 ], [ 3, %15 ], [ 0, %.sink.split ]
  ret i32 %.1
}

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

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


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,LoopRotatePass,SROAPass,SimplifyCFGPass,TailCallElimPass