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

; 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_hdr_protector_st = type { ptr, ptr, ptr, ptr, i32 }

@.str = external hidden unnamed_addr constant [12 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [12 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [9 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [77 x i8], align 1
@__func__.ossl_quic_hdr_protector_init = external hidden unnamed_addr constant [29 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local i32 @ossl_quic_hdr_protector_init(ptr noundef %0, ptr noundef %1, ptr noundef %2, i32 noundef %3, ptr noundef %4, i64 noundef %5) #0 {
  %7 = alloca i32, align 4
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  %10 = alloca ptr, align 8
  %11 = alloca i32, align 4
  %12 = alloca ptr, align 8
  %13 = alloca i64, align 8
  %14 = alloca ptr, align 8
  %15 = alloca i32, align 4
  store ptr %0, ptr %8, align 8, !tbaa !5
  store ptr %1, ptr %9, align 8, !tbaa !5
  store ptr %2, ptr %10, align 8, !tbaa !5
  store i32 %3, ptr %11, align 4, !tbaa !9
  store ptr %4, ptr %12, align 8, !tbaa !5
  store i64 %5, ptr %13, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #3
  store ptr null, ptr %14, align 8, !tbaa !5
  %16 = load i32, ptr %11, align 4, !tbaa !9
  switch i32 %16, label %20 [
    i32 1, label %17
    i32 2, label %18
    i32 3, label %19
  ]

17:                                               ; preds = %6
  store ptr @.str, ptr %14, align 8, !tbaa !5
  br label %21

18:                                               ; preds = %6
  store ptr @.str.1, ptr %14, align 8, !tbaa !5
  br label %21

19:                                               ; preds = %6
  store ptr @.str.2, ptr %14, align 8, !tbaa !5
  br label %21

20:                                               ; preds = %6
  call void @ERR_new()
  call void @ERR_set_debug(ptr noundef @.str.3, i32 noundef 34, ptr noundef @__func__.ossl_quic_hdr_protector_init)
  call void (i32, i32, ptr, ...) @ERR_set_error(i32 noundef 20, i32 noundef 524556, ptr noundef null)
  store i32 0, ptr %7, align 4
  store i32 1, ptr %15, align 4
  br label %73

21:                                               ; preds = %19, %18, %17
  %22 = call ptr @EVP_CIPHER_CTX_new()
  %23 = load ptr, ptr %8, align 8, !tbaa !5
  %24 = getelementptr inbounds %struct.quic_hdr_protector_st, ptr %23, i32 0, i32 2
  store ptr %22, ptr %24, align 8, !tbaa !13
  %25 = load ptr, ptr %8, align 8, !tbaa !5
  %26 = getelementptr inbounds %struct.quic_hdr_protector_st, ptr %25, i32 0, i32 2
  %27 = load ptr, ptr %26, align 8, !tbaa !13
  %28 = icmp eq ptr %27, null
  br i1 %28, label %29, label %30

29:                                               ; preds = %21
  call void @ERR_new()
  call void @ERR_set_debug(ptr noundef @.str.3, i32 noundef 40, ptr noundef @__func__.ossl_quic_hdr_protector_init)
  call void (i32, i32, ptr, ...) @ERR_set_error(i32 noundef 20, i32 noundef 524294, ptr noundef null)
  store i32 0, ptr %7, align 4
  store i32 1, ptr %15, align 4
  br label %73

30:                                               ; preds = %21
  %31 = load ptr, ptr %9, align 8, !tbaa !5
  %32 = load ptr, ptr %14, align 8, !tbaa !5
  %33 = load ptr, ptr %10, align 8, !tbaa !5
  %34 = call ptr @EVP_CIPHER_fetch(ptr noundef %31, ptr noundef %32, ptr noundef %33)
  %35 = load ptr, ptr %8, align 8, !tbaa !5
  %36 = getelementptr inbounds %struct.quic_hdr_protector_st, ptr %35, i32 0, i32 3
  store ptr %34, ptr %36, align 8, !tbaa !15
  %37 = load ptr, ptr %8, align 8, !tbaa !5
  %38 = getelementptr inbounds %struct.quic_hdr_protector_st, ptr %37, i32 0, i32 3
  %39 = load ptr, ptr %38, align 8, !tbaa !15
  %40 = icmp eq ptr %39, null
  br i1 %40, label %49, label %41

41:                                               ; preds = %30
  %42 = load i64, ptr %13, align 8, !tbaa !11
  %43 = load ptr, ptr %8, align 8, !tbaa !5
  %44 = getelementptr inbounds %struct.quic_hdr_protector_st, ptr %43, i32 0, i32 3
  %45 = load ptr, ptr %44, align 8, !tbaa !15
  %46 = call i32 @EVP_CIPHER_get_key_length(ptr noundef %45)
  %47 = sext i32 %46 to i64
  %48 = icmp ne i64 %42, %47
  br i1 %48, label %49, label %50

49:                                               ; preds = %41, %30
  call void @ERR_new()
  call void @ERR_set_debug(ptr noundef @.str.3, i32 noundef 47, ptr noundef @__func__.ossl_quic_hdr_protector_init)
  call void (i32, i32, ptr, ...) @ERR_set_error(i32 noundef 20, i32 noundef 524294, ptr noundef null)
  br label %71

50:                                               ; preds = %41
  %51 = load ptr, ptr %8, align 8, !tbaa !5
  %52 = getelementptr inbounds %struct.quic_hdr_protector_st, ptr %51, i32 0, i32 2
  %53 = load ptr, ptr %52, align 8, !tbaa !13
  %54 = load ptr, ptr %8, align 8, !tbaa !5
  %55 = getelementptr inbounds %struct.quic_hdr_protector_st, ptr %54, i32 0, i32 3
  %56 = load ptr, ptr %55, align 8, !tbaa !15
  %57 = load ptr, ptr %12, align 8, !tbaa !5
  %58 = call i32 @EVP_CipherInit_ex(ptr noundef %53, ptr noundef %56, ptr noundef null, ptr noundef %57, ptr noundef null, i32 noundef 1)
  %59 = icmp ne i32 %58, 0
  br i1 %59, label %61, label %60

60:                                               ; preds = %50
  call void @ERR_new()
  call void @ERR_set_debug(ptr noundef @.str.3, i32 noundef 53, ptr noundef @__func__.ossl_quic_hdr_protector_init)
  call void (i32, i32, ptr, ...) @ERR_set_error(i32 noundef 20, i32 noundef 524294, ptr noundef null)
  br label %71

61:                                               ; preds = %50
  %62 = load ptr, ptr %9, align 8, !tbaa !5
  %63 = load ptr, ptr %8, align 8, !tbaa !5
  %64 = getelementptr inbounds %struct.quic_hdr_protector_st, ptr %63, i32 0, i32 0
  store ptr %62, ptr %64, align 8, !tbaa !16
  %65 = load ptr, ptr %10, align 8, !tbaa !5
  %66 = load ptr, ptr %8, align 8, !tbaa !5
  %67 = getelementptr inbounds %struct.quic_hdr_protector_st, ptr %66, i32 0, i32 1
  store ptr %65, ptr %67, align 8, !tbaa !17
  %68 = load i32, ptr %11, align 4, !tbaa !9
  %69 = load ptr, ptr %8, align 8, !tbaa !5
  %70 = getelementptr inbounds %struct.quic_hdr_protector_st, ptr %69, i32 0, i32 4
  store i32 %68, ptr %70, align 8, !tbaa !18
  store i32 1, ptr %7, align 4
  store i32 1, ptr %15, align 4
  br label %73

71:                                               ; preds = %60, %49
  %72 = load ptr, ptr %8, align 8, !tbaa !5
  call void @ossl_quic_hdr_protector_cleanup(ptr noundef %72)
  store i32 0, ptr %7, align 4
  store i32 1, ptr %15, align 4
  br label %73

73:                                               ; preds = %71, %61, %29, %20
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #3
  %74 = load i32, ptr %7, align 4
  ret i32 %74
}

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

declare void @ERR_new() #2

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

declare void @ERR_set_error(i32 noundef, i32 noundef, ptr noundef, ...) #2

declare ptr @EVP_CIPHER_CTX_new() #2

declare ptr @EVP_CIPHER_fetch(ptr noundef, ptr noundef, ptr noundef) #2

declare i32 @EVP_CIPHER_get_key_length(ptr noundef) #2

declare i32 @EVP_CipherInit_ex(ptr noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef, i32 noundef) #2

; Function Attrs: nounwind uwtable
declare dso_local void @ossl_quic_hdr_protector_cleanup(ptr noundef) #0

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

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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 }

!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, !12, i64 0}
!12 = !{!"long", !7, i64 0}
!13 = !{!14, !6, i64 16}
!14 = !{!"quic_hdr_protector_st", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !10, i64 32}
!15 = !{!14, !6, i64 24}
!16 = !{!14, !6, i64 0}
!17 = !{!14, !6, i64 8}
!18 = !{!14, !10, i64 32}


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

@.str = external hidden unnamed_addr constant [12 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [12 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [9 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [77 x i8], align 1
@__func__.ossl_quic_hdr_protector_init = external hidden unnamed_addr constant [29 x i8], align 1
@switch.table.ossl_quic_hdr_protector_init = private unnamed_addr constant [3 x ptr] [ptr @.str, ptr @.str.1, ptr @.str.2], align 8

; Function Attrs: nounwind uwtable
define dso_local range(i32 0, 2) i32 @ossl_quic_hdr_protector_init(ptr noundef %0, ptr noundef %1, ptr noundef %2, i32 noundef %3, ptr noundef %4, i64 noundef %5) local_unnamed_addr #0 {
  %switch.tableidx = add i32 %3, -1
  %7 = icmp ult i32 %switch.tableidx, 3
  br i1 %7, label %switch.lookup, label %8

8:                                                ; preds = %6
  tail call void @ERR_new() #2
  tail call void @ERR_set_debug(ptr noundef nonnull @.str.3, i32 noundef 34, ptr noundef nonnull @__func__.ossl_quic_hdr_protector_init) #2
  tail call void (i32, i32, ptr, ...) @ERR_set_error(i32 noundef 20, i32 noundef 524556, ptr noundef null) #2
  br label %29

switch.lookup:                                    ; preds = %6
  %9 = zext nneg i32 %switch.tableidx to i64
  %switch.gep = getelementptr inbounds [3 x ptr], ptr @switch.table.ossl_quic_hdr_protector_init, i64 0, i64 %9
  %switch.load = load ptr, ptr %switch.gep, align 8
  %10 = tail call ptr @EVP_CIPHER_CTX_new() #2
  %11 = getelementptr inbounds i8, ptr %0, i64 16
  store ptr %10, ptr %11, align 8, !tbaa !5
  %12 = icmp eq ptr %10, null
  br i1 %12, label %13, label %14

13:                                               ; preds = %switch.lookup
  tail call void @ERR_new() #2
  tail call void @ERR_set_debug(ptr noundef nonnull @.str.3, i32 noundef 40, ptr noundef nonnull @__func__.ossl_quic_hdr_protector_init) #2
  tail call void (i32, i32, ptr, ...) @ERR_set_error(i32 noundef 20, i32 noundef 524294, ptr noundef null) #2
  br label %29

14:                                               ; preds = %switch.lookup
  %15 = tail call ptr @EVP_CIPHER_fetch(ptr noundef %1, ptr noundef nonnull %switch.load, ptr noundef %2) #2
  %16 = getelementptr inbounds i8, ptr %0, i64 24
  store ptr %15, ptr %16, align 8, !tbaa !11
  %17 = icmp eq ptr %15, null
  br i1 %17, label %28, label %18

18:                                               ; preds = %14
  %19 = tail call i32 @EVP_CIPHER_get_key_length(ptr noundef nonnull %15) #2
  %20 = sext i32 %19 to i64
  %.not = icmp eq i64 %20, %5
  br i1 %.not, label %21, label %28

21:                                               ; preds = %18
  %22 = load ptr, ptr %11, align 8, !tbaa !5
  %23 = load ptr, ptr %16, align 8, !tbaa !11
  %24 = tail call i32 @EVP_CipherInit_ex(ptr noundef %22, ptr noundef %23, ptr noundef null, ptr noundef %4, ptr noundef null, i32 noundef 1) #2
  %.not22 = icmp eq i32 %24, 0
  br i1 %.not22, label %28, label %25

25:                                               ; preds = %21
  store ptr %1, ptr %0, align 8, !tbaa !12
  %26 = getelementptr inbounds i8, ptr %0, i64 8
  store ptr %2, ptr %26, align 8, !tbaa !13
  %27 = getelementptr inbounds i8, ptr %0, i64 32
  store i32 %3, ptr %27, align 8, !tbaa !14
  br label %29

28:                                               ; preds = %21, %14, %18
  %.sink = phi i32 [ 47, %18 ], [ 47, %14 ], [ 53, %21 ]
  tail call void @ERR_new() #2
  tail call void @ERR_set_debug(ptr noundef nonnull @.str.3, i32 noundef %.sink, ptr noundef nonnull @__func__.ossl_quic_hdr_protector_init) #2
  tail call void (i32, i32, ptr, ...) @ERR_set_error(i32 noundef 20, i32 noundef 524294, ptr noundef null) #2
  tail call void @ossl_quic_hdr_protector_cleanup(ptr noundef nonnull %0)
  br label %29

29:                                               ; preds = %28, %25, %13, %8
  %.020 = phi i32 [ 0, %8 ], [ 0, %13 ], [ 0, %28 ], [ 1, %25 ]
  ret i32 %.020
}

declare void @ERR_new() local_unnamed_addr #1

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

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

declare ptr @EVP_CIPHER_CTX_new() local_unnamed_addr #1

declare ptr @EVP_CIPHER_fetch(ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #1

declare i32 @EVP_CIPHER_get_key_length(ptr noundef) local_unnamed_addr #1

declare i32 @EVP_CipherInit_ex(ptr noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef, i32 noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
declare dso_local void @ossl_quic_hdr_protector_cleanup(ptr noundef) local_unnamed_addr #0

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 = { 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, !7, i64 16}
!6 = !{!"quic_hdr_protector_st", !7, i64 0, !7, i64 8, !7, i64 16, !7, i64 24, !10, i64 32}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"int", !8, i64 0}
!11 = !{!6, !7, i64 24}
!12 = !{!6, !7, i64 0}
!13 = !{!6, !7, i64 8}
!14 = !{!6, !10, i64 32}


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