; 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
declare hidden i32 @hdr_generate_mask(ptr noundef, ptr noundef, i64 noundef, ptr noundef) #1

; Function Attrs: nounwind uwtable
define dso_local i32 @ossl_quic_hdr_protector_encrypt_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 = load ptr, ptr %10, align 8, !tbaa !5
  %25 = load i8, ptr %24, align 1, !tbaa !11
  %26 = zext i8 %25 to i32
  %27 = and i32 %26, 3
  %28 = add nsw i32 %27, 1
  %29 = trunc i32 %28 to i8
  store i8 %29, ptr %13, align 1, !tbaa !11
  store i8 0, ptr %14, align 1, !tbaa !11
  br label %30

30:                                               ; preds = %52, %23
  %31 = load i8, ptr %14, align 1, !tbaa !11
  %32 = zext i8 %31 to i32
  %33 = load i8, ptr %13, align 1, !tbaa !11
  %34 = zext i8 %33 to i32
  %35 = icmp slt i32 %32, %34
  br i1 %35, label %36, label %55

36:                                               ; preds = %30
  %37 = load i8, ptr %14, align 1, !tbaa !11
  %38 = zext i8 %37 to i32
  %39 = add nsw i32 %38, 1
  %40 = sext i32 %39 to i64
  %41 = getelementptr inbounds [5 x i8], ptr %12, i64 0, i64 %40
  %42 = load i8, ptr %41, align 1, !tbaa !11
  %43 = zext i8 %42 to i32
  %44 = load ptr, ptr %11, align 8, !tbaa !5
  %45 = load i8, ptr %14, align 1, !tbaa !11
  %46 = zext i8 %45 to i64
  %47 = getelementptr inbounds i8, ptr %44, i64 %46
  %48 = load i8, ptr %47, align 1, !tbaa !11
  %49 = zext i8 %48 to i32
  %50 = xor i32 %49, %43
  %51 = trunc i32 %50 to i8
  store i8 %51, ptr %47, align 1, !tbaa !11
  br label %52

52:                                               ; preds = %36
  %53 = load i8, ptr %14, align 1, !tbaa !11
  %54 = add i8 %53, 1
  store i8 %54, ptr %14, align 1, !tbaa !11
  br label %30, !llvm.loop !12

55:                                               ; preds = %30
  %56 = getelementptr inbounds [5 x i8], ptr %12, i64 0, i64 0
  %57 = load i8, ptr %56, align 1, !tbaa !11
  %58 = zext i8 %57 to i32
  %59 = load ptr, ptr %10, align 8, !tbaa !5
  %60 = load i8, ptr %59, align 1, !tbaa !11
  %61 = zext i8 %60 to i32
  %62 = and i32 %61, 128
  %63 = icmp ne i32 %62, 0
  %64 = zext i1 %63 to i64
  %65 = select i1 %63, i32 15, i32 31
  %66 = and i32 %58, %65
  %67 = load ptr, ptr %10, align 8, !tbaa !5
  %68 = load i8, ptr %67, align 1, !tbaa !11
  %69 = zext i8 %68 to i32
  %70 = xor i32 %69, %66
  %71 = trunc i32 %70 to i8
  store i8 %71, ptr %67, align 1, !tbaa !11
  store i32 1, ptr %6, align 4
  store i32 1, ptr %15, align 4
  br label %72

72:                                               ; preds = %55, %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
}

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
declare hidden i32 @hdr_generate_mask(ptr noundef, ptr noundef, i64 noundef, ptr noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
define dso_local range(i32 0, 2) i32 @ossl_quic_hdr_protector_encrypt_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 %40, label %8

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

16:                                               ; preds = %8
  %17 = getelementptr inbounds i8, ptr %6, i64 2
  %18 = load i8, ptr %17, align 1, !tbaa !5
  %19 = getelementptr inbounds i8, ptr %4, i64 1
  %20 = load i8, ptr %19, align 1, !tbaa !5
  %21 = xor i8 %20, %18
  store i8 %21, ptr %19, align 1, !tbaa !5
  %exitcond.1 = icmp eq i8 %11, 2
  br i1 %exitcond.1, label %34, label %22, !llvm.loop !8

22:                                               ; preds = %16
  %23 = getelementptr inbounds i8, ptr %6, i64 3
  %24 = load i8, ptr %23, align 1, !tbaa !5
  %25 = getelementptr inbounds i8, ptr %4, i64 2
  %26 = load i8, ptr %25, align 1, !tbaa !5
  %27 = xor i8 %26, %24
  store i8 %27, ptr %25, align 1, !tbaa !5
  %exitcond.2 = icmp eq i8 %11, 3
  br i1 %exitcond.2, label %34, label %28, !llvm.loop !8

28:                                               ; preds = %22
  %29 = getelementptr inbounds i8, ptr %6, i64 4
  %30 = load i8, ptr %29, align 1, !tbaa !5
  %31 = getelementptr inbounds i8, ptr %4, i64 3
  %32 = load i8, ptr %31, align 1, !tbaa !5
  %33 = xor i8 %32, %30
  store i8 %33, ptr %31, align 1, !tbaa !5
  br label %34

34:                                               ; preds = %28, %22, %16, %8
  %35 = load i8, ptr %6, align 1, !tbaa !5
  %36 = load i8, ptr %3, align 1, !tbaa !5
  %.not15 = icmp sgt i8 %36, -1
  %37 = select i1 %.not15, i8 31, i8 15
  %38 = and i8 %37, %35
  %39 = xor i8 %38, %36
  store i8 %39, ptr %3, align 1, !tbaa !5
  br label %40

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

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,LoopRotatePass,LoopUnrollPass,PostOrderFunctionAttrsPass,SCCPPass,SROAPass,SimplifyCFGPass