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

; 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_txpim_pkt_ex_st = type { %struct.quic_txpim_pkt_st, ptr, ptr, ptr, i64, i64, i8 }
%struct.quic_txpim_pkt_st = type { %struct.ossl_ackm_tx_pkt_st, ptr, ptr, i8 }
%struct.ossl_ackm_tx_pkt_st = type { i64, i64, %struct.OSSL_TIME, i64, i8, ptr, ptr, ptr, ptr, %struct.anon, ptr, ptr }
%struct.OSSL_TIME = type { i64 }
%struct.anon = type { ptr, ptr, ptr }
%struct.quic_txpim_chunk_st = type { i64, i64, i64, i8 }

@.str = external hidden unnamed_addr constant [74 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: nounwind uwtable
define dso_local i32 @ossl_quic_txpim_pkt_append_chunk(ptr noundef %0, ptr noundef %1) #1 {
  %3 = alloca i32, align 4
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca i64, align 8
  %9 = alloca i32, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #4
  %10 = load ptr, ptr %4, align 8, !tbaa !5
  store ptr %10, ptr %6, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #4
  %11 = load ptr, ptr %6, align 8, !tbaa !5
  %12 = getelementptr inbounds %struct.quic_txpim_pkt_ex_st, ptr %11, i32 0, i32 5
  %13 = load i64, ptr %12, align 8, !tbaa !9
  store i64 %13, ptr %8, align 8, !tbaa !17
  %14 = load ptr, ptr %6, align 8, !tbaa !5
  %15 = getelementptr inbounds %struct.quic_txpim_pkt_ex_st, ptr %14, i32 0, i32 4
  %16 = load i64, ptr %15, align 8, !tbaa !18
  %17 = load ptr, ptr %6, align 8, !tbaa !5
  %18 = getelementptr inbounds %struct.quic_txpim_pkt_ex_st, ptr %17, i32 0, i32 5
  %19 = load i64, ptr %18, align 8, !tbaa !9
  %20 = icmp eq i64 %16, %19
  br i1 %20, label %21, label %62

21:                                               ; preds = %2
  %22 = load ptr, ptr %6, align 8, !tbaa !5
  %23 = getelementptr inbounds %struct.quic_txpim_pkt_ex_st, ptr %22, i32 0, i32 5
  %24 = load i64, ptr %23, align 8, !tbaa !9
  %25 = icmp eq i64 %24, 0
  br i1 %25, label %26, label %27

26:                                               ; preds = %21
  br label %33

27:                                               ; preds = %21
  %28 = load ptr, ptr %6, align 8, !tbaa !5
  %29 = getelementptr inbounds %struct.quic_txpim_pkt_ex_st, ptr %28, i32 0, i32 5
  %30 = load i64, ptr %29, align 8, !tbaa !9
  %31 = mul i64 %30, 8
  %32 = udiv i64 %31, 5
  br label %33

33:                                               ; preds = %27, %26
  %34 = phi i64 [ 4, %26 ], [ %32, %27 ]
  store i64 %34, ptr %8, align 8, !tbaa !17
  %35 = load i64, ptr %8, align 8, !tbaa !17
  %36 = icmp ugt i64 %35, 512
  br i1 %36, label %37, label %38

37:                                               ; preds = %33
  store i64 512, ptr %8, align 8, !tbaa !17
  br label %38

38:                                               ; preds = %37, %33
  %39 = load ptr, ptr %6, align 8, !tbaa !5
  %40 = getelementptr inbounds %struct.quic_txpim_pkt_ex_st, ptr %39, i32 0, i32 4
  %41 = load i64, ptr %40, align 8, !tbaa !18
  %42 = load i64, ptr %8, align 8, !tbaa !17
  %43 = icmp eq i64 %41, %42
  br i1 %43, label %44, label %45

44:                                               ; preds = %38
  store i32 0, ptr %3, align 4
  store i32 1, ptr %9, align 4
  br label %77

45:                                               ; preds = %38
  %46 = load ptr, ptr %6, align 8, !tbaa !5
  %47 = getelementptr inbounds %struct.quic_txpim_pkt_ex_st, ptr %46, i32 0, i32 3
  %48 = load ptr, ptr %47, align 8, !tbaa !19
  %49 = load i64, ptr %8, align 8, !tbaa !17
  %50 = mul i64 %49, 32
  %51 = call ptr @CRYPTO_realloc(ptr noundef %48, i64 noundef %50, ptr noundef @.str, i32 noundef 173)
  store ptr %51, ptr %7, align 8, !tbaa !5
  %52 = load ptr, ptr %7, align 8, !tbaa !5
  %53 = icmp eq ptr %52, null
  br i1 %53, label %54, label %55

54:                                               ; preds = %45
  store i32 0, ptr %3, align 4
  store i32 1, ptr %9, align 4
  br label %77

55:                                               ; preds = %45
  %56 = load ptr, ptr %7, align 8, !tbaa !5
  %57 = load ptr, ptr %6, align 8, !tbaa !5
  %58 = getelementptr inbounds %struct.quic_txpim_pkt_ex_st, ptr %57, i32 0, i32 3
  store ptr %56, ptr %58, align 8, !tbaa !19
  %59 = load i64, ptr %8, align 8, !tbaa !17
  %60 = load ptr, ptr %6, align 8, !tbaa !5
  %61 = getelementptr inbounds %struct.quic_txpim_pkt_ex_st, ptr %60, i32 0, i32 5
  store i64 %59, ptr %61, align 8, !tbaa !9
  br label %62

62:                                               ; preds = %55, %2
  %63 = load ptr, ptr %6, align 8, !tbaa !5
  %64 = getelementptr inbounds %struct.quic_txpim_pkt_ex_st, ptr %63, i32 0, i32 3
  %65 = load ptr, ptr %64, align 8, !tbaa !19
  %66 = load ptr, ptr %6, align 8, !tbaa !5
  %67 = getelementptr inbounds %struct.quic_txpim_pkt_ex_st, ptr %66, i32 0, i32 4
  %68 = load i64, ptr %67, align 8, !tbaa !18
  %69 = add i64 %68, 1
  store i64 %69, ptr %67, align 8, !tbaa !18
  %70 = getelementptr inbounds %struct.quic_txpim_chunk_st, ptr %65, i64 %68
  %71 = load ptr, ptr %5, align 8, !tbaa !5
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %70, ptr align 8 %71, i64 32, i1 false), !tbaa.struct !20
  %72 = load ptr, ptr %6, align 8, !tbaa !5
  %73 = getelementptr inbounds %struct.quic_txpim_pkt_ex_st, ptr %72, i32 0, i32 6
  %74 = load i8, ptr %73, align 8
  %75 = and i8 %74, -2
  %76 = or i8 %75, 1
  store i8 %76, ptr %73, align 8
  store i32 1, ptr %3, align 4
  store i32 1, ptr %9, align 4
  br label %77

77:                                               ; preds = %62, %54, %44
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #4
  %78 = load i32, ptr %3, align 4
  ret i32 %78
}

declare ptr @CRYPTO_realloc(ptr noundef, i64 noundef, ptr noundef, i32 noundef) #2

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #3

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 = { "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 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #4 = { 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, !13, i64 168}
!10 = !{!"quic_txpim_pkt_ex_st", !11, i64 0, !6, i64 136, !6, i64 144, !6, i64 152, !13, i64 160, !13, i64 168, !15, i64 176}
!11 = !{!"quic_txpim_pkt_st", !12, i64 0, !6, i64 112, !6, i64 120, !15, i64 128, !15, i64 128, !15, i64 128, !15, i64 128, !15, i64 128, !15, i64 128}
!12 = !{!"ossl_ackm_tx_pkt_st", !13, i64 0, !13, i64 8, !14, i64 16, !13, i64 24, !15, i64 32, !15, i64 32, !15, i64 32, !15, i64 32, !15, i64 32, !6, i64 40, !6, i64 48, !6, i64 56, !6, i64 64, !16, i64 72, !6, i64 96, !6, i64 104}
!13 = !{!"long", !7, i64 0}
!14 = !{!"", !13, i64 0}
!15 = !{!"int", !7, i64 0}
!16 = !{!"", !6, i64 0, !6, i64 8, !6, i64 16}
!17 = !{!13, !13, i64 0}
!18 = !{!10, !13, i64 160}
!19 = !{!10, !6, i64 152}
!20 = !{i64 0, i64 8, !17, i64 8, i64 8, !17, i64 16, i64 8, !17, i64 24, i64 1, !21}
!21 = !{!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"

%struct.quic_txpim_chunk_st = type { i64, i64, i64, i8 }

@.str = external hidden unnamed_addr constant [74 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local range(i32 0, 2) i32 @ossl_quic_txpim_pkt_append_chunk(ptr nocapture noundef %0, ptr nocapture noundef readonly %1) local_unnamed_addr #0 {
  %3 = getelementptr inbounds i8, ptr %0, i64 168
  %4 = getelementptr inbounds i8, ptr %0, i64 160
  %5 = load i64, ptr %4, align 8, !tbaa !5
  %6 = load i64, ptr %3, align 8, !tbaa !16
  %7 = icmp eq i64 %5, %6
  br i1 %7, label %8, label %._crit_edge

._crit_edge:                                      ; preds = %2
  %.phi.trans.insert = getelementptr inbounds i8, ptr %0, i64 152
  %.pre = load ptr, ptr %.phi.trans.insert, align 8, !tbaa !17
  br label %23

8:                                                ; preds = %2
  %9 = icmp eq i64 %5, 0
  br i1 %9, label %13, label %10

10:                                               ; preds = %8
  %11 = shl i64 %5, 3
  %12 = udiv i64 %11, 5
  br label %13

13:                                               ; preds = %8, %10
  %14 = phi i64 [ %12, %10 ], [ 4, %8 ]
  %spec.store.select = tail call i64 @llvm.umin.i64(i64 %14, i64 512)
  %15 = icmp eq i64 %5, %spec.store.select
  br i1 %15, label %31, label %16

16:                                               ; preds = %13
  %17 = getelementptr inbounds i8, ptr %0, i64 152
  %18 = load ptr, ptr %17, align 8, !tbaa !17
  %19 = shl nuw nsw i64 %spec.store.select, 5
  %20 = tail call ptr @CRYPTO_realloc(ptr noundef %18, i64 noundef %19, ptr noundef nonnull @.str, i32 noundef 173) #4
  %21 = icmp eq ptr %20, null
  br i1 %21, label %31, label %22

22:                                               ; preds = %16
  store ptr %20, ptr %17, align 8, !tbaa !17
  store i64 %spec.store.select, ptr %3, align 8, !tbaa !16
  %.pre22 = load i64, ptr %4, align 8, !tbaa !5
  br label %23

23:                                               ; preds = %._crit_edge, %22
  %24 = phi i64 [ %5, %._crit_edge ], [ %.pre22, %22 ]
  %25 = phi ptr [ %.pre, %._crit_edge ], [ %20, %22 ]
  %26 = add i64 %24, 1
  store i64 %26, ptr %4, align 8, !tbaa !5
  %27 = getelementptr inbounds %struct.quic_txpim_chunk_st, ptr %25, i64 %24
  tail call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 8 dereferenceable(32) %27, ptr noundef nonnull align 8 dereferenceable(32) %1, i64 32, i1 false), !tbaa.struct !18
  %28 = getelementptr inbounds i8, ptr %0, i64 176
  %29 = load i8, ptr %28, align 8
  %30 = or i8 %29, 1
  store i8 %30, ptr %28, align 8
  br label %31

31:                                               ; preds = %16, %13, %23
  %.0 = phi i32 [ 1, %23 ], [ 0, %13 ], [ 0, %16 ]
  ret i32 %.0
}

declare ptr @CRYPTO_realloc(ptr noundef, i64 noundef, ptr noundef, i32 noundef) local_unnamed_addr #1

; Function Attrs: mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #2

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i64 @llvm.umin.i64(i64, i64) #3

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 = { "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 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #4 = { 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, !9, i64 160}
!6 = !{!"quic_txpim_pkt_ex_st", !7, i64 0, !14, i64 136, !14, i64 144, !14, i64 152, !9, i64 160, !9, i64 168, !13, i64 176}
!7 = !{!"quic_txpim_pkt_st", !8, i64 0, !14, i64 112, !14, i64 120, !13, i64 128, !13, i64 128, !13, i64 128, !13, i64 128, !13, i64 128, !13, i64 128}
!8 = !{!"ossl_ackm_tx_pkt_st", !9, i64 0, !9, i64 8, !12, i64 16, !9, i64 24, !13, i64 32, !13, i64 32, !13, i64 32, !13, i64 32, !13, i64 32, !14, i64 40, !14, i64 48, !14, i64 56, !14, i64 64, !15, i64 72, !14, i64 96, !14, i64 104}
!9 = !{!"long", !10, i64 0}
!10 = !{!"omnipotent char", !11, i64 0}
!11 = !{!"Simple C/C++ TBAA"}
!12 = !{!"", !9, i64 0}
!13 = !{!"int", !10, i64 0}
!14 = !{!"any pointer", !10, i64 0}
!15 = !{!"", !14, i64 0, !14, i64 8, !14, i64 16}
!16 = !{!6, !9, i64 168}
!17 = !{!6, !14, i64 152}
!18 = !{i64 0, i64 8, !19, i64 8, i64 8, !19, i64 16, i64 8, !19, i64 24, i64 1, !20}
!19 = !{!9, !9, i64 0}
!20 = !{!10, !10, i64 0}


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