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

; 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 void @ush_autocomp_check_for_finish(ptr noundef %0) #0 {
  %2 = alloca ptr, align 8
  %3 = alloca ptr, align 8
  %4 = alloca i64, align 8
  store ptr %0, ptr %2, align 8, !tbaa !5
  %5 = load ptr, ptr %2, align 8, !tbaa !5
  %6 = getelementptr inbounds %struct.ush_object, ptr %5, i32 0, i32 0
  %7 = load ptr, ptr %6, align 8, !tbaa !9
  %8 = getelementptr inbounds %struct.ush_descriptor, ptr %7, i32 0, i32 5
  %9 = load i64, ptr %8, align 8, !tbaa !15
  %10 = call ptr @llvm.stacksave.p0()
  store ptr %10, ptr %3, align 8
  %11 = alloca i8, i64 %9, align 16
  store i64 %9, ptr %4, align 8
  %12 = load ptr, ptr %2, align 8, !tbaa !5
  %13 = getelementptr inbounds %struct.ush_object, ptr %12, i32 0, i32 23
  %14 = load i32, ptr %13, align 8, !tbaa !17
  %15 = icmp eq i32 %14, 0
  br i1 %15, label %16, label %28

16:                                               ; preds = %1
  %17 = load ptr, ptr %2, align 8, !tbaa !5
  %18 = getelementptr inbounds %struct.ush_object, ptr %17, i32 0, i32 14
  %19 = load ptr, ptr %18, align 8, !tbaa !18
  %20 = load ptr, ptr %2, align 8, !tbaa !5
  %21 = getelementptr inbounds %struct.ush_object, ptr %20, i32 0, i32 16
  store ptr %19, ptr %21, align 8, !tbaa !19
  %22 = load ptr, ptr %2, align 8, !tbaa !5
  %23 = getelementptr inbounds %struct.ush_object, ptr %22, i32 0, i32 19
  store i64 0, ptr %23, align 8, !tbaa !20
  %24 = load ptr, ptr %2, align 8, !tbaa !5
  %25 = getelementptr inbounds %struct.ush_object, ptr %24, i32 0, i32 20
  store i64 0, ptr %25, align 8, !tbaa !21
  %26 = load ptr, ptr %2, align 8, !tbaa !5
  %27 = getelementptr inbounds %struct.ush_object, ptr %26, i32 0, i32 23
  store i32 1, ptr %27, align 8, !tbaa !17
  br label %97

28:                                               ; preds = %1
  %29 = load ptr, ptr %2, align 8, !tbaa !5
  %30 = getelementptr inbounds %struct.ush_object, ptr %29, i32 0, i32 23
  %31 = load i32, ptr %30, align 8, !tbaa !17
  %32 = icmp eq i32 %31, 1
  br i1 %32, label %33, label %81

33:                                               ; preds = %28
  %34 = load ptr, ptr %2, align 8, !tbaa !5
  %35 = load ptr, ptr %2, align 8, !tbaa !5
  %36 = getelementptr inbounds %struct.ush_object, ptr %35, i32 0, i32 25
  %37 = load ptr, ptr %36, align 8, !tbaa !22
  call void @ush_node_get_absolute_path(ptr noundef %34, ptr noundef %37, ptr noundef %11)
  %38 = load ptr, ptr %2, align 8, !tbaa !5
  %39 = getelementptr inbounds %struct.ush_object, ptr %38, i32 0, i32 25
  %40 = load ptr, ptr %39, align 8, !tbaa !22
  %41 = getelementptr inbounds i8, ptr %40, i64 0
  %42 = load i8, ptr %41, align 1, !tbaa !23
  %43 = sext i8 %42 to i32
  %44 = icmp eq i32 %43, 0
  br i1 %44, label %45, label %51

45:                                               ; preds = %33
  %46 = load ptr, ptr %2, align 8, !tbaa !5
  %47 = getelementptr inbounds %struct.ush_object, ptr %46, i32 0, i32 14
  %48 = load ptr, ptr %47, align 8, !tbaa !18
  %49 = load ptr, ptr %2, align 8, !tbaa !5
  %50 = getelementptr inbounds %struct.ush_object, ptr %49, i32 0, i32 16
  store ptr %48, ptr %50, align 8, !tbaa !19
  br label %67

51:                                               ; preds = %33
  %52 = load ptr, ptr %2, align 8, !tbaa !5
  %53 = call ptr @ush_node_get_parent_by_path(ptr noundef %52, ptr noundef %11)
  %54 = load ptr, ptr %2, align 8, !tbaa !5
  %55 = getelementptr inbounds %struct.ush_object, ptr %54, i32 0, i32 16
  store ptr %53, ptr %55, align 8, !tbaa !19
  %56 = load ptr, ptr %2, align 8, !tbaa !5
  %57 = getelementptr inbounds %struct.ush_object, ptr %56, i32 0, i32 16
  %58 = load ptr, ptr %57, align 8, !tbaa !19
  %59 = icmp eq ptr %58, null
  br i1 %59, label %60, label %66

60:                                               ; preds = %51
  %61 = load ptr, ptr %2, align 8, !tbaa !5
  %62 = getelementptr inbounds %struct.ush_object, ptr %61, i32 0, i32 14
  %63 = load ptr, ptr %62, align 8, !tbaa !18
  %64 = load ptr, ptr %2, align 8, !tbaa !5
  %65 = getelementptr inbounds %struct.ush_object, ptr %64, i32 0, i32 16
  store ptr %63, ptr %65, align 8, !tbaa !19
  br label %66

66:                                               ; preds = %60, %51
  br label %67

67:                                               ; preds = %66, %45
  %68 = load ptr, ptr %2, align 8, !tbaa !5
  %69 = getelementptr inbounds %struct.ush_object, ptr %68, i32 0, i32 16
  %70 = load ptr, ptr %69, align 8, !tbaa !19
  %71 = getelementptr inbounds %struct.ush_node_object, ptr %70, i32 0, i32 4
  %72 = load ptr, ptr %71, align 8, !tbaa !24
  %73 = load ptr, ptr %2, align 8, !tbaa !5
  %74 = getelementptr inbounds %struct.ush_object, ptr %73, i32 0, i32 16
  store ptr %72, ptr %74, align 8, !tbaa !19
  %75 = load ptr, ptr %2, align 8, !tbaa !5
  %76 = getelementptr inbounds %struct.ush_object, ptr %75, i32 0, i32 19
  store i64 0, ptr %76, align 8, !tbaa !20
  %77 = load ptr, ptr %2, align 8, !tbaa !5
  %78 = getelementptr inbounds %struct.ush_object, ptr %77, i32 0, i32 20
  store i64 0, ptr %78, align 8, !tbaa !21
  %79 = load ptr, ptr %2, align 8, !tbaa !5
  %80 = getelementptr inbounds %struct.ush_object, ptr %79, i32 0, i32 23
  store i32 2, ptr %80, align 8, !tbaa !17
  br label %96

81:                                               ; preds = %28
  %82 = load ptr, ptr %2, align 8, !tbaa !5
  %83 = getelementptr inbounds %struct.ush_object, ptr %82, i32 0, i32 23
  %84 = load i32, ptr %83, align 8, !tbaa !17
  %85 = icmp eq i32 %84, 2
  br i1 %85, label %86, label %94

86:                                               ; preds = %81
  %87 = load ptr, ptr %2, align 8, !tbaa !5
  %88 = getelementptr inbounds %struct.ush_object, ptr %87, i32 0, i32 1
  %89 = load i32, ptr %88, align 8, !tbaa !25
  %90 = load ptr, ptr %2, align 8, !tbaa !5
  %91 = getelementptr inbounds %struct.ush_object, ptr %90, i32 0, i32 24
  store i32 %89, ptr %91, align 4, !tbaa !26
  %92 = load ptr, ptr %2, align 8, !tbaa !5
  %93 = getelementptr inbounds %struct.ush_object, ptr %92, i32 0, i32 1
  store i32 22, ptr %93, align 8, !tbaa !25
  br label %95

94:                                               ; preds = %81
  br label %95

95:                                               ; preds = %94, %86
  br label %96

96:                                               ; preds = %95, %67
  br label %97

97:                                               ; preds = %96, %16
  %98 = load ptr, ptr %3, align 8
  call void @llvm.stackrestore.p0(ptr %98)
  ret void
}

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

declare void @ush_node_get_absolute_path(ptr noundef, ptr noundef, ptr noundef) #2

declare ptr @ush_node_get_parent_by_path(ptr noundef, ptr noundef) #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 = { "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" }

!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 = !{!10, !11, i64 216}
!18 = !{!10, !6, i64 104}
!19 = !{!10, !6, i64 160}
!20 = !{!10, !12, i64 184}
!21 = !{!10, !12, i64 192}
!22 = !{!10, !6, i64 224}
!23 = !{!7, !7, i64 0}
!24 = !{!14, !6, i64 32}
!25 = !{!10, !11, i64 8}
!26 = !{!10, !11, i64 220}


; 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 void @ush_autocomp_check_for_finish(ptr noundef %0) local_unnamed_addr #0 {
  %2 = load ptr, ptr %0, align 8, !tbaa !5
  %3 = getelementptr inbounds i8, ptr %2, i64 40
  %4 = load i64, ptr %3, align 8, !tbaa !14
  %5 = alloca i8, i64 %4, align 16
  %6 = getelementptr inbounds i8, ptr %0, i64 216
  %7 = load i32, ptr %6, align 8, !tbaa !16
  switch i32 %7, label %34 [
    i32 0, label %8
    i32 1, label %13
    i32 2, label %30
  ]

8:                                                ; preds = %1
  %9 = getelementptr inbounds i8, ptr %0, i64 104
  %10 = load ptr, ptr %9, align 8, !tbaa !17
  %11 = getelementptr inbounds i8, ptr %0, i64 160
  store ptr %10, ptr %11, align 8, !tbaa !18
  %12 = getelementptr inbounds i8, ptr %0, i64 184
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(16) %12, i8 0, i64 16, i1 false)
  store i32 1, ptr %6, align 8, !tbaa !16
  br label %34

13:                                               ; preds = %1
  %14 = getelementptr inbounds i8, ptr %0, i64 224
  %15 = load ptr, ptr %14, align 8, !tbaa !19
  call void @ush_node_get_absolute_path(ptr noundef nonnull %0, ptr noundef %15, ptr noundef nonnull %5) #3
  %16 = load ptr, ptr %14, align 8, !tbaa !19
  %17 = load i8, ptr %16, align 1, !tbaa !20
  %18 = icmp eq i8 %17, 0
  br i1 %18, label %.sink.split, label %19

19:                                               ; preds = %13
  %20 = call ptr @ush_node_get_parent_by_path(ptr noundef nonnull %0, ptr noundef nonnull %5) #3
  %21 = icmp eq ptr %20, null
  br i1 %21, label %.sink.split, label %24

.sink.split:                                      ; preds = %19, %13
  %22 = getelementptr inbounds i8, ptr %0, i64 104
  %23 = load ptr, ptr %22, align 8, !tbaa !17
  br label %24

24:                                               ; preds = %.sink.split, %19
  %25 = phi ptr [ %20, %19 ], [ %23, %.sink.split ]
  %26 = getelementptr inbounds i8, ptr %0, i64 160
  %27 = getelementptr inbounds i8, ptr %25, i64 32
  %28 = load ptr, ptr %27, align 8, !tbaa !21
  store ptr %28, ptr %26, align 8, !tbaa !18
  %29 = getelementptr inbounds i8, ptr %0, i64 184
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(16) %29, i8 0, i64 16, i1 false)
  store i32 2, ptr %6, align 8, !tbaa !16
  br label %34

30:                                               ; preds = %1
  %31 = getelementptr inbounds i8, ptr %0, i64 8
  %32 = load i32, ptr %31, align 8, !tbaa !22
  %33 = getelementptr inbounds i8, ptr %0, i64 220
  store i32 %32, ptr %33, align 4, !tbaa !23
  store i32 22, ptr %31, align 8, !tbaa !22
  br label %34

34:                                               ; preds = %1, %24, %30, %8
  ret void
}

declare void @ush_node_get_absolute_path(ptr noundef, 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: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #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 = { nocallback nofree nounwind willreturn memory(argmem: write) }
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, !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, !10, i64 216}
!17 = !{!6, !7, i64 104}
!18 = !{!6, !7, i64 160}
!19 = !{!6, !7, i64 224}
!20 = !{!8, !8, i64 0}
!21 = !{!13, !7, i64 32}
!22 = !{!6, !10, i64 8}
!23 = !{!6, !10, i64 220}


; Effective O3 passes: DSEPass,EarlyCSEPass,GVNPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,MemCpyOptPass,SROAPass,SimplifyCFGPass,TailCallElimPass