; LLVM IR from openssl/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_heap_st = type { ptr, i64 }
%struct.pq_elem_st = type { i64, i32 }

@.str = external hidden unnamed_addr constant [37 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [70 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [42 x i8], align 1
@__PRETTY_FUNCTION__.ossl_pqueue_pop = external hidden unnamed_addr constant [37 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
define dso_local ptr @ossl_pqueue_pop(ptr noundef %0) #2 {
  %2 = alloca ptr, align 8
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca i64, align 8
  %6 = alloca i32, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #4
  %7 = load ptr, ptr %3, align 8, !tbaa !5
  %8 = icmp eq ptr %7, null
  br i1 %8, label %14, label %9

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

14:                                               ; preds = %9, %1
  store ptr null, ptr %2, align 8
  store i32 1, ptr %6, align 4
  br label %89

15:                                               ; preds = %9
  %16 = load ptr, ptr %3, align 8, !tbaa !5
  %17 = getelementptr inbounds %struct.ossl_pqueue_st, ptr %16, i32 0, i32 1
  %18 = load ptr, ptr %17, align 8, !tbaa !12
  %19 = load ptr, ptr %3, align 8, !tbaa !5
  %20 = getelementptr inbounds %struct.ossl_pqueue_st, ptr %19, i32 0, i32 0
  %21 = load ptr, ptr %20, align 8, !tbaa !13
  %22 = getelementptr inbounds %struct.pq_heap_st, ptr %21, i64 0
  %23 = getelementptr inbounds %struct.pq_heap_st, ptr %22, i32 0, i32 1
  %24 = load i64, ptr %23, align 8, !tbaa !14
  %25 = getelementptr inbounds %struct.pq_elem_st, ptr %18, i64 %24
  %26 = getelementptr inbounds %struct.pq_elem_st, ptr %25, i32 0, i32 1
  %27 = load i32, ptr %26, align 8, !tbaa !16
  %28 = icmp ne i32 %27, 0
  br i1 %28, label %29, label %30

29:                                               ; preds = %15
  br label %31

30:                                               ; preds = %15
  call void @__assert_fail(ptr noundef @.str, ptr noundef @.str.1, i32 noundef 238, ptr noundef @__PRETTY_FUNCTION__.ossl_pqueue_pop) #5
  unreachable

31:                                               ; preds = %29
  %32 = load ptr, ptr %3, align 8, !tbaa !5
  %33 = getelementptr inbounds %struct.ossl_pqueue_st, ptr %32, i32 0, i32 1
  %34 = load ptr, ptr %33, align 8, !tbaa !12
  %35 = load ptr, ptr %3, align 8, !tbaa !5
  %36 = getelementptr inbounds %struct.ossl_pqueue_st, ptr %35, i32 0, i32 0
  %37 = load ptr, ptr %36, align 8, !tbaa !13
  %38 = getelementptr inbounds %struct.pq_heap_st, ptr %37, i64 0
  %39 = getelementptr inbounds %struct.pq_heap_st, ptr %38, i32 0, i32 1
  %40 = load i64, ptr %39, align 8, !tbaa !14
  %41 = getelementptr inbounds %struct.pq_elem_st, ptr %34, i64 %40
  %42 = getelementptr inbounds %struct.pq_elem_st, ptr %41, i32 0, i32 0
  %43 = load i64, ptr %42, align 8, !tbaa !19
  %44 = icmp eq i64 %43, 0
  br i1 %44, label %45, label %46

45:                                               ; preds = %31
  br label %47

46:                                               ; preds = %31
  call void @__assert_fail(ptr noundef @.str.2, ptr noundef @.str.1, i32 noundef 238, ptr noundef @__PRETTY_FUNCTION__.ossl_pqueue_pop) #5
  unreachable

47:                                               ; preds = %45
  %48 = load ptr, ptr %3, align 8, !tbaa !5
  %49 = getelementptr inbounds %struct.ossl_pqueue_st, ptr %48, i32 0, i32 0
  %50 = load ptr, ptr %49, align 8, !tbaa !13
  %51 = getelementptr inbounds %struct.pq_heap_st, ptr %50, i32 0, i32 0
  %52 = load ptr, ptr %51, align 8, !tbaa !20
  store ptr %52, ptr %4, align 8, !tbaa !5
  %53 = load ptr, ptr %3, align 8, !tbaa !5
  %54 = getelementptr inbounds %struct.ossl_pqueue_st, ptr %53, i32 0, i32 0
  %55 = load ptr, ptr %54, align 8, !tbaa !13
  %56 = getelementptr inbounds %struct.pq_heap_st, ptr %55, i32 0, i32 1
  %57 = load i64, ptr %56, align 8, !tbaa !14
  store i64 %57, ptr %5, align 8, !tbaa !21
  %58 = load ptr, ptr %3, align 8, !tbaa !5
  %59 = getelementptr inbounds %struct.ossl_pqueue_st, ptr %58, i32 0, i32 3
  %60 = load i64, ptr %59, align 8, !tbaa !9
  %61 = add i64 %60, -1
  store i64 %61, ptr %59, align 8, !tbaa !9
  %62 = icmp ne i64 %61, 0
  br i1 %62, label %63, label %69

63:                                               ; preds = %47
  %64 = load ptr, ptr %3, align 8, !tbaa !5
  %65 = load ptr, ptr %3, align 8, !tbaa !5
  %66 = getelementptr inbounds %struct.ossl_pqueue_st, ptr %65, i32 0, i32 3
  %67 = load i64, ptr %66, align 8, !tbaa !9
  call void @pqueue_move_elem(ptr noundef %64, i64 noundef %67, i64 noundef 0)
  %68 = load ptr, ptr %3, align 8, !tbaa !5
  call void @pqueue_move_up(ptr noundef %68, i64 noundef 0)
  br label %69

69:                                               ; preds = %63, %47
  %70 = load ptr, ptr %3, align 8, !tbaa !5
  %71 = getelementptr inbounds %struct.ossl_pqueue_st, ptr %70, i32 0, i32 5
  %72 = load i64, ptr %71, align 8, !tbaa !22
  %73 = load ptr, ptr %3, align 8, !tbaa !5
  %74 = getelementptr inbounds %struct.ossl_pqueue_st, ptr %73, i32 0, i32 1
  %75 = load ptr, ptr %74, align 8, !tbaa !12
  %76 = load i64, ptr %5, align 8, !tbaa !21
  %77 = getelementptr inbounds %struct.pq_elem_st, ptr %75, i64 %76
  %78 = getelementptr inbounds %struct.pq_elem_st, ptr %77, i32 0, i32 0
  store i64 %72, ptr %78, align 8, !tbaa !19
  %79 = load i64, ptr %5, align 8, !tbaa !21
  %80 = load ptr, ptr %3, align 8, !tbaa !5
  %81 = getelementptr inbounds %struct.ossl_pqueue_st, ptr %80, i32 0, i32 5
  store i64 %79, ptr %81, align 8, !tbaa !22
  %82 = load ptr, ptr %3, align 8, !tbaa !5
  %83 = getelementptr inbounds %struct.ossl_pqueue_st, ptr %82, i32 0, i32 1
  %84 = load ptr, ptr %83, align 8, !tbaa !12
  %85 = load i64, ptr %5, align 8, !tbaa !21
  %86 = getelementptr inbounds %struct.pq_elem_st, ptr %84, i64 %85
  %87 = getelementptr inbounds %struct.pq_elem_st, ptr %86, i32 0, i32 1
  store i32 0, ptr %87, align 8, !tbaa !16
  %88 = load ptr, ptr %4, align 8, !tbaa !5
  store ptr %88, ptr %2, align 8
  store i32 1, ptr %6, align 4
  br label %89

89:                                               ; preds = %69, %14
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #4
  %90 = load ptr, ptr %2, align 8
  ret ptr %90
}

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

; Function Attrs: inlinehint nounwind uwtable
declare hidden void @pqueue_move_up(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, !11, i64 24}
!10 = !{!"ossl_pqueue_st", !6, i64 0, !6, i64 8, !6, i64 16, !11, i64 24, !11, i64 32, !11, i64 40}
!11 = !{!"long", !7, i64 0}
!12 = !{!10, !6, i64 8}
!13 = !{!10, !6, i64 0}
!14 = !{!15, !11, i64 8}
!15 = !{!"pq_heap_st", !6, i64 0, !11, i64 8}
!16 = !{!17, !18, i64 8}
!17 = !{!"pq_elem_st", !11, i64 0, !18, i64 8}
!18 = !{!"int", !7, i64 0}
!19 = !{!17, !11, i64 0}
!20 = !{!15, !6, i64 0}
!21 = !{!11, !11, i64 0}
!22 = !{!10, !11, i64 40}


; 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 }

@.str = external hidden unnamed_addr constant [37 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [70 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [42 x i8], align 1
@__PRETTY_FUNCTION__.ossl_pqueue_pop = external hidden unnamed_addr constant [37 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
define dso_local ptr @ossl_pqueue_pop(ptr noundef %0) local_unnamed_addr #1 {
  %2 = icmp eq ptr %0, null
  br i1 %2, label %31, label %3

3:                                                ; preds = %1
  %4 = getelementptr inbounds i8, ptr %0, i64 24
  %5 = load i64, ptr %4, align 8, !tbaa !5
  %6 = icmp eq i64 %5, 0
  br i1 %6, label %31, label %7

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

16:                                               ; preds = %7
  tail call void @__assert_fail(ptr noundef nonnull @.str, ptr noundef nonnull @.str.1, i32 noundef 238, ptr noundef nonnull @__PRETTY_FUNCTION__.ossl_pqueue_pop) #3
  unreachable

17:                                               ; preds = %7
  %18 = load i64, ptr %13, align 8, !tbaa !18
  %19 = icmp eq i64 %18, 0
  br i1 %19, label %21, label %20

20:                                               ; preds = %17
  tail call void @__assert_fail(ptr noundef nonnull @.str.2, ptr noundef nonnull @.str.1, i32 noundef 238, ptr noundef nonnull @__PRETTY_FUNCTION__.ossl_pqueue_pop) #3
  unreachable

21:                                               ; preds = %17
  %22 = load ptr, ptr %10, align 8, !tbaa !19
  %23 = add i64 %5, -1
  store i64 %23, ptr %4, align 8, !tbaa !5
  %.not23 = icmp eq i64 %23, 0
  br i1 %.not23, label %25, label %24

24:                                               ; preds = %21
  tail call void @pqueue_move_elem(ptr noundef nonnull %0, i64 noundef %23, i64 noundef 0)
  tail call void @pqueue_move_up(ptr noundef nonnull %0, i64 noundef 0)
  %.pre = load ptr, ptr %8, align 8, !tbaa !11
  br label %25

25:                                               ; preds = %24, %21
  %26 = phi ptr [ %.pre, %24 ], [ %9, %21 ]
  %27 = getelementptr inbounds i8, ptr %0, i64 40
  %28 = load i64, ptr %27, align 8, !tbaa !20
  %29 = getelementptr inbounds %struct.pq_elem_st, ptr %26, i64 %12
  store i64 %28, ptr %29, align 8, !tbaa !18
  store i64 %12, ptr %27, align 8, !tbaa !20
  %30 = getelementptr inbounds %struct.pq_elem_st, ptr %26, i64 %12, i32 1
  store i32 0, ptr %30, align 8, !tbaa !15
  br label %31

31:                                               ; preds = %1, %3, %25
  %.0 = phi ptr [ %22, %25 ], [ null, %3 ], [ null, %1 ]
  ret ptr %.0
}

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

; Function Attrs: inlinehint nounwind uwtable
declare hidden void @pqueue_move_up(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 24}
!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, !7, i64 8}
!12 = !{!6, !7, i64 0}
!13 = !{!14, !10, i64 8}
!14 = !{!"pq_heap_st", !7, i64 0, !10, i64 8}
!15 = !{!16, !17, i64 8}
!16 = !{!"pq_elem_st", !10, i64 0, !17, i64 8}
!17 = !{!"int", !8, i64 0}
!18 = !{!16, !10, i64 0}
!19 = !{!14, !7, i64 0}
!20 = !{!6, !10, i64 40}


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