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

; 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: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #0

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

declare void @ush_write_pointer(ptr noundef, ptr noundef, i32 noundef) #2

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

; Function Attrs: nounwind uwtable
define dso_local void @ush_autocomp_state_candidates_finish(ptr noundef %0) #3 {
  %2 = alloca ptr, align 8
  %3 = alloca ptr, align 8
  store ptr %0, ptr %2, align 8, !tbaa !5
  %4 = load ptr, ptr %2, align 8, !tbaa !5
  %5 = getelementptr inbounds %struct.ush_object, ptr %4, i32 0, i32 24
  %6 = load i32, ptr %5, align 4, !tbaa !9
  %7 = icmp eq i32 %6, 21
  br i1 %7, label %8, label %11

8:                                                ; preds = %1
  %9 = load ptr, ptr %2, align 8, !tbaa !5
  %10 = getelementptr inbounds %struct.ush_object, ptr %9, i32 0, i32 1
  store i32 24, ptr %10, align 8, !tbaa !15
  br label %98

11:                                               ; preds = %1
  %12 = load ptr, ptr %2, align 8, !tbaa !5
  %13 = getelementptr inbounds %struct.ush_object, ptr %12, i32 0, i32 24
  %14 = load i32, ptr %13, align 4, !tbaa !9
  %15 = icmp eq i32 %14, 19
  br i1 %15, label %16, label %54

16:                                               ; preds = %11
  %17 = load ptr, ptr %2, align 8, !tbaa !5
  %18 = getelementptr inbounds %struct.ush_object, ptr %17, i32 0, i32 28
  %19 = load i64, ptr %18, align 8, !tbaa !16
  switch i64 %19, label %49 [
    i64 0, label %20
    i64 1, label %23
  ]

20:                                               ; preds = %16
  %21 = load ptr, ptr %2, align 8, !tbaa !5
  %22 = getelementptr inbounds %struct.ush_object, ptr %21, i32 0, i32 1
  store i32 8, ptr %22, align 8, !tbaa !15
  br label %53

23:                                               ; preds = %16
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #5
  %24 = load ptr, ptr %2, align 8, !tbaa !5
  %25 = getelementptr inbounds %struct.ush_object, ptr %24, i32 0, i32 25
  %26 = load ptr, ptr %25, align 8, !tbaa !17
  %27 = load ptr, ptr %2, align 8, !tbaa !5
  %28 = getelementptr inbounds %struct.ush_object, ptr %27, i32 0, i32 25
  %29 = load ptr, ptr %28, align 8, !tbaa !17
  %30 = call i64 @strlen(ptr noundef %29) #6
  %31 = getelementptr inbounds i8, ptr %26, i64 %30
  store ptr %31, ptr %3, align 8, !tbaa !5
  %32 = load ptr, ptr %2, align 8, !tbaa !5
  %33 = getelementptr inbounds %struct.ush_object, ptr %32, i32 0, i32 25
  %34 = load ptr, ptr %33, align 8, !tbaa !17
  %35 = load ptr, ptr %2, align 8, !tbaa !5
  %36 = getelementptr inbounds %struct.ush_object, ptr %35, i32 0, i32 26
  %37 = load ptr, ptr %36, align 8, !tbaa !18
  %38 = call ptr @strcpy(ptr noundef %34, ptr noundef %37) #5
  %39 = load ptr, ptr %2, align 8, !tbaa !5
  %40 = getelementptr inbounds %struct.ush_object, ptr %39, i32 0, i32 0
  %41 = load ptr, ptr %40, align 8, !tbaa !19
  %42 = getelementptr inbounds %struct.ush_descriptor, ptr %41, i32 0, i32 1
  %43 = load ptr, ptr %42, align 8, !tbaa !20
  %44 = call i64 @strlen(ptr noundef %43) #6
  %45 = load ptr, ptr %2, align 8, !tbaa !5
  %46 = getelementptr inbounds %struct.ush_object, ptr %45, i32 0, i32 8
  store i64 %44, ptr %46, align 8, !tbaa !22
  %47 = load ptr, ptr %2, align 8, !tbaa !5
  %48 = load ptr, ptr %3, align 8, !tbaa !5
  call void @ush_write_pointer(ptr noundef %47, ptr noundef %48, i32 noundef 8)
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #5
  br label %53

49:                                               ; preds = %16
  %50 = load ptr, ptr %2, align 8, !tbaa !5
  %51 = getelementptr inbounds %struct.ush_object, ptr %50, i32 0, i32 30
  store i64 0, ptr %51, align 8, !tbaa !23
  %52 = load ptr, ptr %2, align 8, !tbaa !5
  call void @ush_autocomp_optimize_continue(ptr noundef %52)
  br label %53

53:                                               ; preds = %49, %23, %20
  br label %97

54:                                               ; preds = %11
  %55 = load ptr, ptr %2, align 8, !tbaa !5
  %56 = getelementptr inbounds %struct.ush_object, ptr %55, i32 0, i32 24
  %57 = load i32, ptr %56, align 4, !tbaa !9
  %58 = icmp eq i32 %57, 20
  br i1 %58, label %59, label %95

59:                                               ; preds = %54
  %60 = load ptr, ptr %2, align 8, !tbaa !5
  %61 = getelementptr inbounds %struct.ush_object, ptr %60, i32 0, i32 28
  %62 = load i64, ptr %61, align 8, !tbaa !16
  %63 = load ptr, ptr %2, align 8, !tbaa !5
  %64 = getelementptr inbounds %struct.ush_object, ptr %63, i32 0, i32 29
  %65 = load i64, ptr %64, align 8, !tbaa !24
  %66 = icmp ult i64 %62, %65
  br i1 %66, label %67, label %93

67:                                               ; preds = %59
  %68 = load ptr, ptr %2, align 8, !tbaa !5
  %69 = getelementptr inbounds %struct.ush_object, ptr %68, i32 0, i32 8
  %70 = load i64, ptr %69, align 8, !tbaa !22
  %71 = icmp ugt i64 %70, 0
  br i1 %71, label %72, label %77

72:                                               ; preds = %67
  %73 = load ptr, ptr %2, align 8, !tbaa !5
  %74 = getelementptr inbounds %struct.ush_object, ptr %73, i32 0, i32 8
  %75 = load i64, ptr %74, align 8, !tbaa !22
  %76 = add i64 %75, -1
  store i64 %76, ptr %74, align 8, !tbaa !22
  br label %77

77:                                               ; preds = %72, %67
  %78 = load ptr, ptr %2, align 8, !tbaa !5
  %79 = getelementptr inbounds %struct.ush_object, ptr %78, i32 0, i32 0
  %80 = load ptr, ptr %79, align 8, !tbaa !19
  %81 = getelementptr inbounds %struct.ush_descriptor, ptr %80, i32 0, i32 1
  %82 = load ptr, ptr %81, align 8, !tbaa !20
  %83 = load ptr, ptr %2, align 8, !tbaa !5
  %84 = getelementptr inbounds %struct.ush_object, ptr %83, i32 0, i32 8
  %85 = load i64, ptr %84, align 8, !tbaa !22
  %86 = getelementptr inbounds i8, ptr %82, i64 %85
  store i8 0, ptr %86, align 1, !tbaa !25
  %87 = load ptr, ptr %2, align 8, !tbaa !5
  %88 = getelementptr inbounds %struct.ush_object, ptr %87, i32 0, i32 30
  %89 = load i64, ptr %88, align 8, !tbaa !23
  %90 = add i64 %89, -1
  store i64 %90, ptr %88, align 8, !tbaa !23
  %91 = load ptr, ptr %2, align 8, !tbaa !5
  %92 = getelementptr inbounds %struct.ush_object, ptr %91, i32 0, i32 1
  store i32 26, ptr %92, align 8, !tbaa !15
  br label %98

93:                                               ; preds = %59
  %94 = load ptr, ptr %2, align 8, !tbaa !5
  call void @ush_autocomp_optimize_continue(ptr noundef %94)
  br label %96

95:                                               ; preds = %54
  br label %96

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

97:                                               ; preds = %96, %53
  br label %98

98:                                               ; preds = %97, %77, %8
  ret void
}

; Function Attrs: nounwind
declare ptr @strcpy(ptr noundef, ptr noundef) #4

declare void @ush_autocomp_optimize_continue(ptr noundef) #2

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #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 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 #4 = { nounwind "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, !11, i64 220}
!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, !11, i64 8}
!16 = !{!10, !12, i64 248}
!17 = !{!10, !6, i64 224}
!18 = !{!10, !6, i64 232}
!19 = !{!10, !6, i64 0}
!20 = !{!21, !6, i64 8}
!21 = !{!"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}
!22 = !{!10, !12, i64 56}
!23 = !{!10, !12, i64 264}
!24 = !{!10, !12, i64 256}
!25 = !{!7, !7, i64 0}


; 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: mustprogress nofree nounwind willreturn memory(argmem: read)
declare i64 @strlen(ptr nocapture noundef) local_unnamed_addr #0

declare void @ush_write_pointer(ptr noundef, ptr noundef, i32 noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
define dso_local void @ush_autocomp_state_candidates_finish(ptr noundef %0) local_unnamed_addr #2 {
  %2 = getelementptr inbounds i8, ptr %0, i64 220
  %3 = load i32, ptr %2, align 4, !tbaa !5
  switch i32 %3, label %48 [
    i32 21, label %4
    i32 19, label %6
    i32 20, label %26
  ]

4:                                                ; preds = %1
  %5 = getelementptr inbounds i8, ptr %0, i64 8
  store i32 24, ptr %5, align 8, !tbaa !14
  br label %48

6:                                                ; preds = %1
  %7 = getelementptr inbounds i8, ptr %0, i64 248
  %8 = load i64, ptr %7, align 8, !tbaa !15
  switch i64 %8, label %24 [
    i64 0, label %9
    i64 1, label %11
  ]

9:                                                ; preds = %6
  %10 = getelementptr inbounds i8, ptr %0, i64 8
  store i32 8, ptr %10, align 8, !tbaa !14
  br label %48

11:                                               ; preds = %6
  %12 = getelementptr inbounds i8, ptr %0, i64 224
  %13 = load ptr, ptr %12, align 8, !tbaa !16
  %14 = tail call i64 @strlen(ptr noundef nonnull dereferenceable(1) %13) #4
  %15 = getelementptr inbounds i8, ptr %13, i64 %14
  %16 = getelementptr inbounds i8, ptr %0, i64 232
  %17 = load ptr, ptr %16, align 8, !tbaa !17
  %18 = tail call ptr @strcpy(ptr noundef nonnull dereferenceable(1) %13, ptr noundef nonnull dereferenceable(1) %17) #5
  %19 = load ptr, ptr %0, align 8, !tbaa !18
  %20 = getelementptr inbounds i8, ptr %19, i64 8
  %21 = load ptr, ptr %20, align 8, !tbaa !19
  %22 = tail call i64 @strlen(ptr noundef nonnull dereferenceable(1) %21) #4
  %23 = getelementptr inbounds i8, ptr %0, i64 56
  store i64 %22, ptr %23, align 8, !tbaa !21
  tail call void @ush_write_pointer(ptr noundef nonnull %0, ptr noundef %15, i32 noundef 8) #5
  br label %48

24:                                               ; preds = %6
  %25 = getelementptr inbounds i8, ptr %0, i64 264
  store i64 0, ptr %25, align 8, !tbaa !22
  tail call void @ush_autocomp_optimize_continue(ptr noundef nonnull %0) #5
  br label %48

26:                                               ; preds = %1
  %27 = getelementptr inbounds i8, ptr %0, i64 248
  %28 = load i64, ptr %27, align 8, !tbaa !15
  %29 = getelementptr inbounds i8, ptr %0, i64 256
  %30 = load i64, ptr %29, align 8, !tbaa !23
  %31 = icmp ult i64 %28, %30
  br i1 %31, label %32, label %47

32:                                               ; preds = %26
  %33 = getelementptr inbounds i8, ptr %0, i64 56
  %34 = load i64, ptr %33, align 8, !tbaa !21
  %.not = icmp eq i64 %34, 0
  br i1 %.not, label %37, label %35

35:                                               ; preds = %32
  %36 = add i64 %34, -1
  store i64 %36, ptr %33, align 8, !tbaa !21
  br label %37

37:                                               ; preds = %35, %32
  %38 = phi i64 [ %36, %35 ], [ 0, %32 ]
  %39 = load ptr, ptr %0, align 8, !tbaa !18
  %40 = getelementptr inbounds i8, ptr %39, i64 8
  %41 = load ptr, ptr %40, align 8, !tbaa !19
  %42 = getelementptr inbounds i8, ptr %41, i64 %38
  store i8 0, ptr %42, align 1, !tbaa !24
  %43 = getelementptr inbounds i8, ptr %0, i64 264
  %44 = load i64, ptr %43, align 8, !tbaa !22
  %45 = add i64 %44, -1
  store i64 %45, ptr %43, align 8, !tbaa !22
  %46 = getelementptr inbounds i8, ptr %0, i64 8
  store i32 26, ptr %46, align 8, !tbaa !14
  br label %48

47:                                               ; preds = %26
  tail call void @ush_autocomp_optimize_continue(ptr noundef nonnull %0) #5
  br label %48

48:                                               ; preds = %1, %24, %11, %9, %47, %37, %4
  ret void
}

; Function Attrs: mustprogress nofree nounwind willreturn memory(argmem: readwrite)
declare ptr @strcpy(ptr noalias noundef returned writeonly, ptr noalias nocapture noundef readonly) local_unnamed_addr #3

declare void @ush_autocomp_optimize_continue(ptr noundef) local_unnamed_addr #1

attributes #0 = { 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 #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 = { mustprogress nofree nounwind willreturn memory(argmem: readwrite) "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) }
attributes #5 = { 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, !10, i64 220}
!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, !10, i64 8}
!15 = !{!6, !11, i64 248}
!16 = !{!6, !7, i64 224}
!17 = !{!6, !7, i64 232}
!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 = !{!6, !11, i64 264}
!23 = !{!6, !11, i64 256}
!24 = !{!8, !8, i64 0}


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