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

; 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_hdr_protector_decrypt_fields(ptr noundef %0, ptr noundef %1, i64 noundef %2, ptr noundef %3, ptr noundef %4) #1 {
  %6 = alloca i32, align 4
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca i64, align 8
  %10 = alloca ptr, align 8
  %11 = alloca ptr, align 8
  %12 = alloca [5 x i8], align 1
  %13 = alloca i8, align 1
  %14 = alloca i8, align 1
  %15 = alloca i32, align 4
  store ptr %0, ptr %7, align 8, !tbaa !5
  store ptr %1, ptr %8, align 8, !tbaa !5
  store i64 %2, ptr %9, align 8, !tbaa !9
  store ptr %3, ptr %10, align 8, !tbaa !5
  store ptr %4, ptr %11, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 5, ptr %12) #2
  call void @llvm.lifetime.start.p0(i64 1, ptr %13) #2
  call void @llvm.lifetime.start.p0(i64 1, ptr %14) #2
  %16 = load ptr, ptr %7, align 8, !tbaa !5
  %17 = load ptr, ptr %8, align 8, !tbaa !5
  %18 = load i64, ptr %9, align 8, !tbaa !9
  %19 = getelementptr inbounds [5 x i8], ptr %12, i64 0, i64 0
  %20 = call i32 @hdr_generate_mask(ptr noundef %16, ptr noundef %17, i64 noundef %18, ptr noundef %19)
  %21 = icmp ne i32 %20, 0
  br i1 %21, label %23, label %22

22:                                               ; preds = %5
  store i32 0, ptr %6, align 4
  store i32 1, ptr %15, align 4
  br label %72

23:                                               ; preds = %5
  %24 = getelementptr inbounds [5 x i8], ptr %12, i64 0, i64 0
  %25 = load i8, ptr %24, align 1, !tbaa !11
  %26 = zext i8 %25 to i32
  %27 = load ptr, ptr %10, align 8, !tbaa !5
  %28 = load i8, ptr %27, align 1, !tbaa !11
  %29 = zext i8 %28 to i32
  %30 = and i32 %29, 128
  %31 = icmp ne i32 %30, 0
  %32 = zext i1 %31 to i64
  %33 = select i1 %31, i32 15, i32 31
  %34 = and i32 %26, %33
  %35 = load ptr, ptr %10, align 8, !tbaa !5
  %36 = load i8, ptr %35, align 1, !tbaa !11
  %37 = zext i8 %36 to i32
  %38 = xor i32 %37, %34
  %39 = trunc i32 %38 to i8
  store i8 %39, ptr %35, align 1, !tbaa !11
  %40 = load ptr, ptr %10, align 8, !tbaa !5
  %41 = load i8, ptr %40, align 1, !tbaa !11
  %42 = zext i8 %41 to i32
  %43 = and i32 %42, 3
  %44 = add nsw i32 %43, 1
  %45 = trunc i32 %44 to i8
  store i8 %45, ptr %13, align 1, !tbaa !11
  store i8 0, ptr %14, align 1, !tbaa !11
  br label %46

46:                                               ; preds = %68, %23
  %47 = load i8, ptr %14, align 1, !tbaa !11
  %48 = zext i8 %47 to i32
  %49 = load i8, ptr %13, align 1, !tbaa !11
  %50 = zext i8 %49 to i32
  %51 = icmp slt i32 %48, %50
  br i1 %51, label %52, label %71

52:                                               ; preds = %46
  %53 = load i8, ptr %14, align 1, !tbaa !11
  %54 = zext i8 %53 to i32
  %55 = add nsw i32 %54, 1
  %56 = sext i32 %55 to i64
  %57 = getelementptr inbounds [5 x i8], ptr %12, i64 0, i64 %56
  %58 = load i8, ptr %57, align 1, !tbaa !11
  %59 = zext i8 %58 to i32
  %60 = load ptr, ptr %11, align 8, !tbaa !5
  %61 = load i8, ptr %14, align 1, !tbaa !11
  %62 = zext i8 %61 to i64
  %63 = getelementptr inbounds i8, ptr %60, i64 %62
  %64 = load i8, ptr %63, align 1, !tbaa !11
  %65 = zext i8 %64 to i32
  %66 = xor i32 %65, %59
  %67 = trunc i32 %66 to i8
  store i8 %67, ptr %63, align 1, !tbaa !11
  br label %68

68:                                               ; preds = %52
  %69 = load i8, ptr %14, align 1, !tbaa !11
  %70 = add i8 %69, 1
  store i8 %70, ptr %14, align 1, !tbaa !11
  br label %46, !llvm.loop !12

71:                                               ; preds = %46
  store i32 1, ptr %6, align 4
  store i32 1, ptr %15, align 4
  br label %72

72:                                               ; preds = %71, %22
  call void @llvm.lifetime.end.p0(i64 1, ptr %14) #2
  call void @llvm.lifetime.end.p0(i64 1, ptr %13) #2
  call void @llvm.lifetime.end.p0(i64 5, ptr %12) #2
  %73 = load i32, ptr %6, align 4
  ret i32 %73
}

; Function Attrs: nounwind uwtable
declare hidden i32 @hdr_generate_mask(ptr noundef, ptr noundef, i64 noundef, ptr noundef) #1

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 = !{!"long", !7, i64 0}
!11 = !{!7, !7, i64 0}
!12 = distinct !{!12, !13}
!13 = !{!"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: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #0

; Function Attrs: mustprogress 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 range(i32 0, 2) i32 @ossl_quic_hdr_protector_decrypt_fields(ptr noundef %0, ptr noundef %1, i64 noundef %2, ptr nocapture noundef %3, ptr nocapture noundef %4) local_unnamed_addr #1 {
  %6 = alloca [5 x i8], align 1
  call void @llvm.lifetime.start.p0(i64 5, ptr nonnull %6) #2
  %7 = call i32 @hdr_generate_mask(ptr noundef %0, ptr noundef %1, i64 noundef %2, ptr noundef nonnull %6)
  %.not = icmp eq i32 %7, 0
  br i1 %.not, label %.loopexit, label %8

8:                                                ; preds = %5
  %9 = load i8, ptr %6, align 1, !tbaa !5
  %10 = load i8, ptr %3, align 1, !tbaa !5
  %.not14 = icmp sgt i8 %10, -1
  %11 = select i1 %.not14, i8 31, i8 15
  %12 = and i8 %11, %9
  %13 = xor i8 %12, %10
  store i8 %13, ptr %3, align 1, !tbaa !5
  %14 = and i8 %13, 3
  %15 = add nuw nsw i8 %14, 1
  %16 = getelementptr inbounds i8, ptr %6, i64 1
  %17 = load i8, ptr %16, align 1, !tbaa !5
  %18 = load i8, ptr %4, align 1, !tbaa !5
  %19 = xor i8 %18, %17
  store i8 %19, ptr %4, align 1, !tbaa !5
  %exitcond = icmp eq i8 %14, 0
  br i1 %exitcond, label %.loopexit, label %20, !llvm.loop !8

20:                                               ; preds = %8
  %21 = getelementptr inbounds i8, ptr %6, i64 2
  %22 = load i8, ptr %21, align 1, !tbaa !5
  %23 = getelementptr inbounds i8, ptr %4, i64 1
  %24 = load i8, ptr %23, align 1, !tbaa !5
  %25 = xor i8 %24, %22
  store i8 %25, ptr %23, align 1, !tbaa !5
  %exitcond.1 = icmp eq i8 %15, 2
  br i1 %exitcond.1, label %.loopexit, label %26, !llvm.loop !8

26:                                               ; preds = %20
  %27 = getelementptr inbounds i8, ptr %6, i64 3
  %28 = load i8, ptr %27, align 1, !tbaa !5
  %29 = getelementptr inbounds i8, ptr %4, i64 2
  %30 = load i8, ptr %29, align 1, !tbaa !5
  %31 = xor i8 %30, %28
  store i8 %31, ptr %29, align 1, !tbaa !5
  %exitcond.2 = icmp eq i8 %15, 3
  br i1 %exitcond.2, label %.loopexit, label %32, !llvm.loop !8

32:                                               ; preds = %26
  %33 = getelementptr inbounds i8, ptr %6, i64 4
  %34 = load i8, ptr %33, align 1, !tbaa !5
  %35 = getelementptr inbounds i8, ptr %4, i64 3
  %36 = load i8, ptr %35, align 1, !tbaa !5
  %37 = xor i8 %36, %34
  store i8 %37, ptr %35, align 1, !tbaa !5
  br label %.loopexit

.loopexit:                                        ; preds = %8, %20, %26, %32, %5
  %.012 = phi i32 [ 0, %5 ], [ 1, %32 ], [ 1, %26 ], [ 1, %20 ], [ 1, %8 ]
  call void @llvm.lifetime.end.p0(i64 5, ptr nonnull %6) #2
  ret i32 %.012
}

; Function Attrs: nounwind uwtable
declare hidden i32 @hdr_generate_mask(ptr noundef, ptr noundef, i64 noundef, ptr noundef) local_unnamed_addr #1

attributes #0 = { mustprogress 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 = !{!"omnipotent char", !7, i64 0}
!7 = !{!"Simple C/C++ TBAA"}
!8 = distinct !{!8, !9}
!9 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SCCPPass,SROAPass,SimplifyCFGPass