; 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
declare dso_local void @ush_autocomp_prepare_candidates(ptr noundef) #0

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

21:                                               ; preds = %1
  %22 = load ptr, ptr %2, align 8, !tbaa !5
  %23 = getelementptr inbounds %struct.ush_object, ptr %22, i32 0, i32 1
  store i32 26, ptr %23, align 8, !tbaa !19
  store i32 1, ptr %4, align 4
  br label %71

24:                                               ; preds = %1
  call void @llvm.lifetime.start.p0(i64 1, ptr %5) #3
  %25 = load ptr, ptr %2, align 8, !tbaa !5
  %26 = getelementptr inbounds %struct.ush_object, ptr %25, i32 0, i32 26
  %27 = load ptr, ptr %26, align 8, !tbaa !18
  %28 = load i64, ptr %3, align 8, !tbaa !17
  %29 = getelementptr inbounds i8, ptr %27, i64 %28
  %30 = load i8, ptr %29, align 1, !tbaa !20
  store i8 %30, ptr %5, align 1, !tbaa !20
  %31 = load i8, ptr %5, align 1, !tbaa !20
  %32 = load ptr, ptr %2, align 8, !tbaa !5
  %33 = getelementptr inbounds %struct.ush_object, ptr %32, i32 0, i32 0
  %34 = load ptr, ptr %33, align 8, !tbaa !21
  %35 = getelementptr inbounds %struct.ush_descriptor, ptr %34, i32 0, i32 1
  %36 = load ptr, ptr %35, align 8, !tbaa !22
  %37 = load ptr, ptr %2, align 8, !tbaa !5
  %38 = getelementptr inbounds %struct.ush_object, ptr %37, i32 0, i32 8
  %39 = load i64, ptr %38, align 8, !tbaa !24
  %40 = add i64 %39, 1
  store i64 %40, ptr %38, align 8, !tbaa !24
  %41 = getelementptr inbounds i8, ptr %36, i64 %39
  store i8 %31, ptr %41, align 1, !tbaa !20
  %42 = load ptr, ptr %2, align 8, !tbaa !5
  %43 = getelementptr inbounds %struct.ush_object, ptr %42, i32 0, i32 8
  %44 = load i64, ptr %43, align 8, !tbaa !24
  %45 = load ptr, ptr %2, align 8, !tbaa !5
  %46 = getelementptr inbounds %struct.ush_object, ptr %45, i32 0, i32 0
  %47 = load ptr, ptr %46, align 8, !tbaa !21
  %48 = getelementptr inbounds %struct.ush_descriptor, ptr %47, i32 0, i32 2
  %49 = load i64, ptr %48, align 8, !tbaa !25
  %50 = icmp uge i64 %44, %49
  br i1 %50, label %51, label %54

51:                                               ; preds = %24
  %52 = load ptr, ptr %2, align 8, !tbaa !5
  %53 = getelementptr inbounds %struct.ush_object, ptr %52, i32 0, i32 8
  store i64 0, ptr %53, align 8, !tbaa !24
  br label %54

54:                                               ; preds = %51, %24
  %55 = load ptr, ptr %2, align 8, !tbaa !5
  %56 = getelementptr inbounds %struct.ush_object, ptr %55, i32 0, i32 0
  %57 = load ptr, ptr %56, align 8, !tbaa !21
  %58 = getelementptr inbounds %struct.ush_descriptor, ptr %57, i32 0, i32 1
  %59 = load ptr, ptr %58, align 8, !tbaa !22
  %60 = load ptr, ptr %2, align 8, !tbaa !5
  %61 = getelementptr inbounds %struct.ush_object, ptr %60, i32 0, i32 8
  %62 = load i64, ptr %61, align 8, !tbaa !24
  %63 = getelementptr inbounds i8, ptr %59, i64 %62
  store i8 0, ptr %63, align 1, !tbaa !20
  %64 = load ptr, ptr %2, align 8, !tbaa !5
  %65 = getelementptr inbounds %struct.ush_object, ptr %64, i32 0, i32 30
  %66 = load i64, ptr %65, align 8, !tbaa !26
  %67 = add i64 %66, 1
  store i64 %67, ptr %65, align 8, !tbaa !26
  %68 = load ptr, ptr %2, align 8, !tbaa !5
  call void @ush_autocomp_prepare_candidates(ptr noundef %68)
  %69 = load ptr, ptr %2, align 8, !tbaa !5
  %70 = getelementptr inbounds %struct.ush_object, ptr %69, i32 0, i32 1
  store i32 20, ptr %70, align 8, !tbaa !19
  call void @llvm.lifetime.end.p0(i64 1, ptr %5) #3
  store i32 0, ptr %4, align 4
  br label %71

71:                                               ; preds = %54, %21
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #3
  %72 = load i32, ptr %4, align 4
  switch i32 %72, label %74 [
    i32 0, label %73
    i32 1, label %73
  ]

73:                                               ; preds = %71, %71
  ret void

74:                                               ; preds = %71
  unreachable
}

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

; Function Attrs: nounwind willreturn memory(read)
declare i64 @strlen(ptr noundef) #2

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #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 memory(argmem: readwrite) }
attributes #2 = { 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 #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, !6, i64 0}
!6 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !12, i64 248}
!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 = !{!10, !12, i64 256}
!16 = !{!10, !6, i64 224}
!17 = !{!12, !12, i64 0}
!18 = !{!10, !6, i64 232}
!19 = !{!10, !11, i64 8}
!20 = !{!7, !7, i64 0}
!21 = !{!10, !6, i64 0}
!22 = !{!23, !6, i64 8}
!23 = !{!"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}
!24 = !{!10, !12, i64 56}
!25 = !{!23, !12, i64 16}
!26 = !{!10, !12, i64 264}


; 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
declare dso_local void @ush_autocomp_prepare_candidates(ptr noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local void @ush_autocomp_optimize_continue(ptr noundef %0) local_unnamed_addr #0 {
  %2 = getelementptr inbounds i8, ptr %0, i64 248
  %3 = load i64, ptr %2, align 8, !tbaa !5
  %4 = getelementptr inbounds i8, ptr %0, i64 256
  store i64 %3, ptr %4, align 8, !tbaa !14
  %5 = getelementptr inbounds i8, ptr %0, i64 224
  %6 = load ptr, ptr %5, align 8, !tbaa !15
  %7 = tail call i64 @strlen(ptr noundef nonnull dereferenceable(1) %6) #2
  %8 = getelementptr inbounds i8, ptr %0, i64 232
  %9 = load ptr, ptr %8, align 8, !tbaa !16
  %10 = tail call i64 @strlen(ptr noundef nonnull dereferenceable(1) %9) #2
  %.not = icmp ult i64 %7, %10
  br i1 %.not, label %11, label %34

11:                                               ; preds = %1
  %12 = getelementptr inbounds i8, ptr %9, i64 %7
  %13 = load i8, ptr %12, align 1, !tbaa !17
  %14 = load ptr, ptr %0, align 8, !tbaa !18
  %15 = getelementptr inbounds i8, ptr %14, i64 8
  %16 = load ptr, ptr %15, align 8, !tbaa !19
  %17 = getelementptr inbounds i8, ptr %0, i64 56
  %18 = load i64, ptr %17, align 8, !tbaa !21
  %19 = add i64 %18, 1
  store i64 %19, ptr %17, align 8, !tbaa !21
  %20 = getelementptr inbounds i8, ptr %16, i64 %18
  store i8 %13, ptr %20, align 1, !tbaa !17
  %21 = load i64, ptr %17, align 8, !tbaa !21
  %22 = load ptr, ptr %0, align 8, !tbaa !18
  %23 = getelementptr inbounds i8, ptr %22, i64 16
  %24 = load i64, ptr %23, align 8, !tbaa !22
  %.not18 = icmp ult i64 %21, %24
  br i1 %.not18, label %26, label %25

25:                                               ; preds = %11
  store i64 0, ptr %17, align 8, !tbaa !21
  br label %26

26:                                               ; preds = %25, %11
  %27 = phi i64 [ 0, %25 ], [ %21, %11 ]
  %28 = getelementptr inbounds i8, ptr %22, i64 8
  %29 = load ptr, ptr %28, align 8, !tbaa !19
  %30 = getelementptr inbounds i8, ptr %29, i64 %27
  store i8 0, ptr %30, align 1, !tbaa !17
  %31 = getelementptr inbounds i8, ptr %0, i64 264
  %32 = load i64, ptr %31, align 8, !tbaa !23
  %33 = add i64 %32, 1
  store i64 %33, ptr %31, align 8, !tbaa !23
  tail call void @ush_autocomp_prepare_candidates(ptr noundef nonnull %0)
  br label %34

34:                                               ; preds = %1, %26
  %.sink = phi i32 [ 20, %26 ], [ 26, %1 ]
  %35 = getelementptr inbounds i8, ptr %0, i64 8
  store i32 %.sink, ptr %35, align 8, !tbaa !24
  ret void
}

; Function Attrs: mustprogress nofree nounwind willreturn memory(argmem: read)
declare i64 @strlen(ptr nocapture noundef) local_unnamed_addr #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 = { 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 #2 = { 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, !11, i64 248}
!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 = !{!6, !11, i64 256}
!15 = !{!6, !7, i64 224}
!16 = !{!6, !7, i64 232}
!17 = !{!8, !8, i64 0}
!18 = !{!6, !7, i64 0}
!19 = !{!20, !7, i64 8}
!20 = !{!"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}
!21 = !{!6, !11, i64 56}
!22 = !{!20, !11, i64 16}
!23 = !{!6, !11, i64 264}
!24 = !{!6, !10, i64 8}


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