; LLVM IR from openanolis/openssl :: ssl/quic (quic_cfq)

; 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.quic_cfq_st = type { %struct.quic_cfq_item_list_st, %struct.quic_cfq_item_list_st, %struct.quic_cfq_item_list_st }
%struct.quic_cfq_item_list_st = type { ptr, ptr }
%struct.quic_cfq_item_ex_st = type { %struct.quic_cfq_item_st, ptr, ptr, ptr, ptr, ptr, i64, i64, i32, i32, i32, i32 }
%struct.quic_cfq_item_st = type { 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: 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 ptr @ossl_quic_cfq_get_priority_head(ptr noundef %0, i32 noundef %1) #1 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca i32, align 4
  %6 = alloca ptr, align 8
  %7 = alloca i32, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  store i32 %1, ptr %5, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #2
  %8 = load ptr, ptr %4, align 8, !tbaa !5
  %9 = getelementptr inbounds %struct.quic_cfq_st, ptr %8, i32 0, i32 0
  %10 = getelementptr inbounds %struct.quic_cfq_item_list_st, ptr %9, i32 0, i32 0
  %11 = load ptr, ptr %10, align 8, !tbaa !11
  store ptr %11, ptr %6, align 8, !tbaa !5
  br label %12

12:                                               ; preds = %24, %2
  %13 = load ptr, ptr %6, align 8, !tbaa !5
  %14 = icmp ne ptr %13, null
  br i1 %14, label %15, label %21

15:                                               ; preds = %12
  %16 = load ptr, ptr %6, align 8, !tbaa !5
  %17 = getelementptr inbounds %struct.quic_cfq_item_ex_st, ptr %16, i32 0, i32 9
  %18 = load i32, ptr %17, align 4, !tbaa !14
  %19 = load i32, ptr %5, align 4, !tbaa !9
  %20 = icmp ne i32 %18, %19
  br label %21

21:                                               ; preds = %15, %12
  %22 = phi i1 [ false, %12 ], [ %20, %15 ]
  br i1 %22, label %23, label %28

23:                                               ; preds = %21
  br label %24

24:                                               ; preds = %23
  %25 = load ptr, ptr %6, align 8, !tbaa !5
  %26 = getelementptr inbounds %struct.quic_cfq_item_ex_st, ptr %25, i32 0, i32 2
  %27 = load ptr, ptr %26, align 8, !tbaa !18
  store ptr %27, ptr %6, align 8, !tbaa !5
  br label %12, !llvm.loop !19

28:                                               ; preds = %21
  %29 = load ptr, ptr %6, align 8, !tbaa !5
  %30 = icmp eq ptr %29, null
  br i1 %30, label %31, label %32

31:                                               ; preds = %28
  store ptr null, ptr %3, align 8
  store i32 1, ptr %7, align 4
  br label %35

32:                                               ; preds = %28
  %33 = load ptr, ptr %6, align 8, !tbaa !5
  %34 = getelementptr inbounds %struct.quic_cfq_item_ex_st, ptr %33, i32 0, i32 0
  store ptr %34, ptr %3, align 8
  store i32 1, ptr %7, align 4
  br label %35

35:                                               ; preds = %32, %31
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #2
  %36 = load ptr, ptr %3, align 8
  ret ptr %36
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { 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 = !{!"int", !7, i64 0}
!11 = !{!12, !6, i64 0}
!12 = !{!"quic_cfq_st", !13, i64 0, !13, i64 16, !13, i64 32}
!13 = !{!"quic_cfq_item_list_st", !6, i64 0, !6, i64 8}
!14 = !{!15, !10, i64 76}
!15 = !{!"quic_cfq_item_ex_st", !16, i64 0, !6, i64 16, !6, i64 24, !6, i64 32, !6, i64 40, !6, i64 48, !17, i64 56, !17, i64 64, !10, i64 72, !10, i64 76, !10, i64 80, !10, i64 84}
!16 = !{!"quic_cfq_item_st", !6, i64 0, !6, i64 8}
!17 = !{!"long", !7, i64 0}
!18 = !{!15, !6, i64 24}
!19 = distinct !{!19, !20}
!20 = !{!"llvm.loop.mustprogress"}


; 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: nofree norecurse nosync nounwind memory(read, inaccessiblemem: none) uwtable
define dso_local ptr @ossl_quic_cfq_get_priority_head(ptr nocapture noundef readonly %0, i32 noundef %1) local_unnamed_addr #0 {
  %.09 = load ptr, ptr %0, align 8, !tbaa !5
  %cond10 = icmp eq ptr %.09, null
  br i1 %cond10, label %.critedge, label %.lr.ph

.lr.ph:                                           ; preds = %2, %5
  %.011 = phi ptr [ %.0, %5 ], [ %.09, %2 ]
  %3 = getelementptr inbounds i8, ptr %.011, i64 76
  %4 = load i32, ptr %3, align 4, !tbaa !9
  %.not8 = icmp eq i32 %4, %1
  br i1 %.not8, label %.critedge, label %5

5:                                                ; preds = %.lr.ph
  %6 = getelementptr inbounds i8, ptr %.011, i64 24
  %.0 = load ptr, ptr %6, align 8, !tbaa !5
  %cond = icmp eq ptr %.0, null
  br i1 %cond, label %.critedge, label %.lr.ph, !llvm.loop !14

.critedge:                                        ; preds = %5, %.lr.ph, %2
  %.07 = phi ptr [ null, %2 ], [ %.011, %.lr.ph ], [ null, %5 ]
  ret ptr %.07
}

attributes #0 = { nofree norecurse nosync nounwind memory(read, inaccessiblemem: none) 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" }

!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, !13, i64 76}
!10 = !{!"quic_cfq_item_ex_st", !11, i64 0, !6, i64 16, !6, i64 24, !6, i64 32, !6, i64 40, !6, i64 48, !12, i64 56, !12, i64 64, !13, i64 72, !13, i64 76, !13, i64 80, !13, i64 84}
!11 = !{!"quic_cfq_item_st", !6, i64 0, !6, i64 8}
!12 = !{!"long", !7, i64 0}
!13 = !{!"int", !7, i64 0}
!14 = distinct !{!14, !15}
!15 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass