; LLVM IR from openanolis/openssl :: ssl (priority_queue)

; 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.ossl_pqueue_st = type { ptr, ptr, ptr, i64, i64, i64 }
%struct.pq_elem_st = type { i64, i32 }
%struct.pq_heap_st = type { ptr, i64 }

@.str.1 = external hidden unnamed_addr constant [73 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [24 x i8], align 1
@__PRETTY_FUNCTION__.ossl_pqueue_remove = external hidden unnamed_addr constant [48 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [37 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [42 x i8], align 1

; 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

; Function Attrs: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) #1

; Function Attrs: nounwind uwtable
declare dso_local ptr @ossl_pqueue_pop(ptr noundef) #2

; Function Attrs: nounwind uwtable
define dso_local ptr @ossl_pqueue_remove(ptr noundef %0, i64 noundef %1) #2 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca i64, align 8
  %6 = alloca i64, align 8
  %7 = alloca i32, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  store i64 %1, ptr %5, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #4
  %8 = load ptr, ptr %4, align 8, !tbaa !5
  %9 = icmp eq ptr %8, null
  br i1 %9, label %21, label %10

10:                                               ; preds = %2
  %11 = load i64, ptr %5, align 8, !tbaa !9
  %12 = load ptr, ptr %4, align 8, !tbaa !5
  %13 = getelementptr inbounds %struct.ossl_pqueue_st, ptr %12, i32 0, i32 4
  %14 = load i64, ptr %13, align 8, !tbaa !11
  %15 = icmp uge i64 %11, %14
  br i1 %15, label %21, label %16

16:                                               ; preds = %10
  %17 = load ptr, ptr %4, align 8, !tbaa !5
  %18 = getelementptr inbounds %struct.ossl_pqueue_st, ptr %17, i32 0, i32 3
  %19 = load i64, ptr %18, align 8, !tbaa !13
  %20 = icmp eq i64 %19, 0
  br i1 %20, label %21, label %22

21:                                               ; preds = %16, %10, %2
  store ptr null, ptr %3, align 8
  store i32 1, ptr %7, align 4
  br label %102

22:                                               ; preds = %16
  %23 = load ptr, ptr %4, align 8, !tbaa !5
  %24 = getelementptr inbounds %struct.ossl_pqueue_st, ptr %23, i32 0, i32 1
  %25 = load ptr, ptr %24, align 8, !tbaa !14
  %26 = load i64, ptr %5, align 8, !tbaa !9
  %27 = getelementptr inbounds %struct.pq_elem_st, ptr %25, i64 %26
  %28 = getelementptr inbounds %struct.pq_elem_st, ptr %27, i32 0, i32 1
  %29 = load i32, ptr %28, align 8, !tbaa !15
  %30 = icmp ne i32 %29, 0
  br i1 %30, label %31, label %32

31:                                               ; preds = %22
  br label %33

32:                                               ; preds = %22
  call void @__assert_fail(ptr noundef @.str.3, ptr noundef @.str.1, i32 noundef 263, ptr noundef @__PRETTY_FUNCTION__.ossl_pqueue_remove) #5
  unreachable

33:                                               ; preds = %31
  %34 = load ptr, ptr %4, align 8, !tbaa !5
  %35 = getelementptr inbounds %struct.ossl_pqueue_st, ptr %34, i32 0, i32 1
  %36 = load ptr, ptr %35, align 8, !tbaa !14
  %37 = load i64, ptr %5, align 8, !tbaa !9
  %38 = getelementptr inbounds %struct.pq_elem_st, ptr %36, i64 %37
  %39 = getelementptr inbounds %struct.pq_elem_st, ptr %38, i32 0, i32 0
  %40 = load i64, ptr %39, align 8, !tbaa !18
  store i64 %40, ptr %6, align 8, !tbaa !9
  %41 = load ptr, ptr %4, align 8, !tbaa !5
  %42 = getelementptr inbounds %struct.ossl_pqueue_st, ptr %41, i32 0, i32 1
  %43 = load ptr, ptr %42, align 8, !tbaa !14
  %44 = load ptr, ptr %4, align 8, !tbaa !5
  %45 = getelementptr inbounds %struct.ossl_pqueue_st, ptr %44, i32 0, i32 0
  %46 = load ptr, ptr %45, align 8, !tbaa !19
  %47 = load i64, ptr %6, align 8, !tbaa !9
  %48 = getelementptr inbounds %struct.pq_heap_st, ptr %46, i64 %47
  %49 = getelementptr inbounds %struct.pq_heap_st, ptr %48, i32 0, i32 1
  %50 = load i64, ptr %49, align 8, !tbaa !20
  %51 = getelementptr inbounds %struct.pq_elem_st, ptr %43, i64 %50
  %52 = getelementptr inbounds %struct.pq_elem_st, ptr %51, i32 0, i32 1
  %53 = load i32, ptr %52, align 8, !tbaa !15
  %54 = icmp ne i32 %53, 0
  br i1 %54, label %55, label %56

55:                                               ; preds = %33
  br label %57

56:                                               ; preds = %33
  call void @__assert_fail(ptr noundef @.str.4, ptr noundef @.str.1, i32 noundef 266, ptr noundef @__PRETTY_FUNCTION__.ossl_pqueue_remove) #5
  unreachable

57:                                               ; preds = %55
  %58 = load ptr, ptr %4, align 8, !tbaa !5
  %59 = getelementptr inbounds %struct.ossl_pqueue_st, ptr %58, i32 0, i32 1
  %60 = load ptr, ptr %59, align 8, !tbaa !14
  %61 = load ptr, ptr %4, align 8, !tbaa !5
  %62 = getelementptr inbounds %struct.ossl_pqueue_st, ptr %61, i32 0, i32 0
  %63 = load ptr, ptr %62, align 8, !tbaa !19
  %64 = load i64, ptr %6, align 8, !tbaa !9
  %65 = getelementptr inbounds %struct.pq_heap_st, ptr %63, i64 %64
  %66 = getelementptr inbounds %struct.pq_heap_st, ptr %65, i32 0, i32 1
  %67 = load i64, ptr %66, align 8, !tbaa !20
  %68 = getelementptr inbounds %struct.pq_elem_st, ptr %60, i64 %67
  %69 = getelementptr inbounds %struct.pq_elem_st, ptr %68, i32 0, i32 0
  %70 = load i64, ptr %69, align 8, !tbaa !18
  %71 = load i64, ptr %6, align 8, !tbaa !9
  %72 = icmp eq i64 %70, %71
  br i1 %72, label %73, label %74

73:                                               ; preds = %57
  br label %75

74:                                               ; preds = %57
  call void @__assert_fail(ptr noundef @.str.5, ptr noundef @.str.1, i32 noundef 266, ptr noundef @__PRETTY_FUNCTION__.ossl_pqueue_remove) #5
  unreachable

75:                                               ; preds = %73
  %76 = load i64, ptr %6, align 8, !tbaa !9
  %77 = load ptr, ptr %4, align 8, !tbaa !5
  %78 = getelementptr inbounds %struct.ossl_pqueue_st, ptr %77, i32 0, i32 3
  %79 = load i64, ptr %78, align 8, !tbaa !13
  %80 = sub i64 %79, 1
  %81 = icmp eq i64 %76, %80
  br i1 %81, label %82, label %93

82:                                               ; preds = %75
  %83 = load ptr, ptr %4, align 8, !tbaa !5
  %84 = getelementptr inbounds %struct.ossl_pqueue_st, ptr %83, i32 0, i32 0
  %85 = load ptr, ptr %84, align 8, !tbaa !19
  %86 = load ptr, ptr %4, align 8, !tbaa !5
  %87 = getelementptr inbounds %struct.ossl_pqueue_st, ptr %86, i32 0, i32 3
  %88 = load i64, ptr %87, align 8, !tbaa !13
  %89 = add i64 %88, -1
  store i64 %89, ptr %87, align 8, !tbaa !13
  %90 = getelementptr inbounds %struct.pq_heap_st, ptr %85, i64 %89
  %91 = getelementptr inbounds %struct.pq_heap_st, ptr %90, i32 0, i32 0
  %92 = load ptr, ptr %91, align 8, !tbaa !22
  store ptr %92, ptr %3, align 8
  store i32 1, ptr %7, align 4
  br label %102

93:                                               ; preds = %75
  %94 = load i64, ptr %6, align 8, !tbaa !9
  %95 = icmp ugt i64 %94, 0
  br i1 %95, label %96, label %99

96:                                               ; preds = %93
  %97 = load ptr, ptr %4, align 8, !tbaa !5
  %98 = load i64, ptr %6, align 8, !tbaa !9
  call void @pqueue_force_bottom(ptr noundef %97, i64 noundef %98)
  br label %99

99:                                               ; preds = %96, %93
  %100 = load ptr, ptr %4, align 8, !tbaa !5
  %101 = call ptr @ossl_pqueue_pop(ptr noundef %100)
  store ptr %101, ptr %3, align 8
  store i32 1, ptr %7, align 4
  br label %102

102:                                              ; preds = %99, %82, %21
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #4
  %103 = load ptr, ptr %3, align 8
  ret ptr %103
}

; Function Attrs: inlinehint nounwind uwtable
declare hidden void @pqueue_force_bottom(ptr noundef, i64 noundef) #3

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { noreturn 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 #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 = { inlinehint 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 }
attributes #5 = { noreturn 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, !10, i64 0}
!10 = !{!"long", !7, i64 0}
!11 = !{!12, !10, i64 32}
!12 = !{!"ossl_pqueue_st", !6, i64 0, !6, i64 8, !6, i64 16, !10, i64 24, !10, i64 32, !10, i64 40}
!13 = !{!12, !10, i64 24}
!14 = !{!12, !6, i64 8}
!15 = !{!16, !17, i64 8}
!16 = !{!"pq_elem_st", !10, i64 0, !17, i64 8}
!17 = !{!"int", !7, i64 0}
!18 = !{!16, !10, i64 0}
!19 = !{!12, !6, i64 0}
!20 = !{!21, !10, i64 8}
!21 = !{!"pq_heap_st", !6, i64 0, !10, i64 8}
!22 = !{!21, !6, 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"

%struct.pq_elem_st = type { i64, i32 }
%struct.pq_heap_st = type { ptr, i64 }

@.str.1 = external hidden unnamed_addr constant [73 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [24 x i8], align 1
@__PRETTY_FUNCTION__.ossl_pqueue_remove = external hidden unnamed_addr constant [48 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [37 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [42 x i8], align 1

; Function Attrs: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare dso_local ptr @ossl_pqueue_pop(ptr noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
define dso_local ptr @ossl_pqueue_remove(ptr noundef %0, i64 noundef %1) local_unnamed_addr #1 {
  %3 = icmp eq ptr %0, null
  br i1 %3, label %41, label %4

4:                                                ; preds = %2
  %5 = getelementptr inbounds i8, ptr %0, i64 32
  %6 = load i64, ptr %5, align 8, !tbaa !5
  %.not = icmp ugt i64 %6, %1
  br i1 %.not, label %7, label %41

7:                                                ; preds = %4
  %8 = getelementptr inbounds i8, ptr %0, i64 24
  %9 = load i64, ptr %8, align 8, !tbaa !11
  %10 = icmp eq i64 %9, 0
  br i1 %10, label %41, label %11

11:                                               ; preds = %7
  %12 = getelementptr inbounds i8, ptr %0, i64 8
  %13 = load ptr, ptr %12, align 8, !tbaa !12
  %14 = getelementptr inbounds %struct.pq_elem_st, ptr %13, i64 %1
  %15 = getelementptr inbounds i8, ptr %14, i64 8
  %16 = load i32, ptr %15, align 8, !tbaa !13
  %.not27 = icmp eq i32 %16, 0
  br i1 %.not27, label %17, label %18

17:                                               ; preds = %11
  tail call void @__assert_fail(ptr noundef nonnull @.str.3, ptr noundef nonnull @.str.1, i32 noundef 263, ptr noundef nonnull @__PRETTY_FUNCTION__.ossl_pqueue_remove) #3
  unreachable

18:                                               ; preds = %11
  %19 = load i64, ptr %14, align 8, !tbaa !16
  %20 = load ptr, ptr %0, align 8, !tbaa !17
  %21 = getelementptr inbounds %struct.pq_heap_st, ptr %20, i64 %19, i32 1
  %22 = load i64, ptr %21, align 8, !tbaa !18
  %23 = getelementptr inbounds %struct.pq_elem_st, ptr %13, i64 %22
  %24 = getelementptr inbounds i8, ptr %23, i64 8
  %25 = load i32, ptr %24, align 8, !tbaa !13
  %.not28 = icmp eq i32 %25, 0
  br i1 %.not28, label %26, label %27

26:                                               ; preds = %18
  tail call void @__assert_fail(ptr noundef nonnull @.str.4, ptr noundef nonnull @.str.1, i32 noundef 266, ptr noundef nonnull @__PRETTY_FUNCTION__.ossl_pqueue_remove) #3
  unreachable

27:                                               ; preds = %18
  %28 = load i64, ptr %23, align 8, !tbaa !16
  %29 = icmp eq i64 %28, %19
  br i1 %29, label %31, label %30

30:                                               ; preds = %27
  tail call void @__assert_fail(ptr noundef nonnull @.str.5, ptr noundef nonnull @.str.1, i32 noundef 266, ptr noundef nonnull @__PRETTY_FUNCTION__.ossl_pqueue_remove) #3
  unreachable

31:                                               ; preds = %27
  %32 = add i64 %9, -1
  %33 = icmp eq i64 %19, %32
  br i1 %33, label %34, label %37

34:                                               ; preds = %31
  store i64 %19, ptr %8, align 8, !tbaa !11
  %35 = getelementptr inbounds %struct.pq_heap_st, ptr %20, i64 %19
  %36 = load ptr, ptr %35, align 8, !tbaa !20
  br label %41

37:                                               ; preds = %31
  %.not29 = icmp eq i64 %19, 0
  br i1 %.not29, label %39, label %38

38:                                               ; preds = %37
  tail call void @pqueue_force_bottom(ptr noundef nonnull %0, i64 noundef %19)
  br label %39

39:                                               ; preds = %38, %37
  %40 = tail call ptr @ossl_pqueue_pop(ptr noundef nonnull %0)
  br label %41

41:                                               ; preds = %2, %4, %7, %39, %34
  %.0 = phi ptr [ %36, %34 ], [ %40, %39 ], [ null, %7 ], [ null, %4 ], [ null, %2 ]
  ret ptr %.0
}

; Function Attrs: inlinehint nounwind uwtable
declare hidden void @pqueue_force_bottom(ptr noundef, i64 noundef) local_unnamed_addr #2

attributes #0 = { noreturn 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 #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 = { inlinehint 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 = { noreturn 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 32}
!6 = !{!"ossl_pqueue_st", !7, i64 0, !7, i64 8, !7, i64 16, !10, i64 24, !10, i64 32, !10, 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 24}
!12 = !{!6, !7, i64 8}
!13 = !{!14, !15, i64 8}
!14 = !{!"pq_elem_st", !10, i64 0, !15, i64 8}
!15 = !{!"int", !8, i64 0}
!16 = !{!14, !10, i64 0}
!17 = !{!6, !7, i64 0}
!18 = !{!19, !10, i64 8}
!19 = !{!"pq_heap_st", !7, i64 0, !10, i64 8}
!20 = !{!19, !7, i64 0}


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