; LLVM IR from intel/intel-ipsec-mb :: test/imb-provider (prov_evp)

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

@info = external hidden global [3 x %struct._chained_info], align 16

; 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

declare void @EVP_CIPHER_meth_free(ptr noundef) #1

; Function Attrs: nounwind uwtable
define dso_local void @prov_free_ciphers() #2 {
  %1 = alloca i32, align 4
  call void @llvm.lifetime.start.p0(i64 4, ptr %1) #3
  store i32 0, ptr %1, align 4, !tbaa !5
  br label %2

2:                                                ; preds = %30, %0
  %3 = load i32, ptr %1, align 4, !tbaa !5
  %4 = icmp ult i32 %3, 3
  br i1 %4, label %5, label %33

5:                                                ; preds = %2
  %6 = load i32, ptr %1, align 4, !tbaa !5
  %7 = sext i32 %6 to i64
  %8 = getelementptr inbounds [3 x %struct._chained_info], ptr @info, i64 0, i64 %7
  %9 = getelementptr inbounds %struct._chained_info, ptr %8, i32 0, i32 1
  %10 = load ptr, ptr %9, align 8, !tbaa !9
  %11 = icmp ne ptr %10, null
  br i1 %11, label %12, label %29

12:                                               ; preds = %5
  %13 = load i32, ptr %1, align 4, !tbaa !5
  %14 = sext i32 %13 to i64
  %15 = getelementptr inbounds [3 x %struct._chained_info], ptr @info, i64 0, i64 %14
  %16 = getelementptr inbounds %struct._chained_info, ptr %15, i32 0, i32 0
  %17 = load i32, ptr %16, align 8, !tbaa !12
  switch i32 %17, label %24 [
    i32 895, label %18
    i32 898, label %18
    i32 901, label %18
  ]

18:                                               ; preds = %12, %12, %12
  %19 = load i32, ptr %1, align 4, !tbaa !5
  %20 = sext i32 %19 to i64
  %21 = getelementptr inbounds [3 x %struct._chained_info], ptr @info, i64 0, i64 %20
  %22 = getelementptr inbounds %struct._chained_info, ptr %21, i32 0, i32 1
  %23 = load ptr, ptr %22, align 8, !tbaa !9
  call void @EVP_CIPHER_meth_free(ptr noundef %23)
  br label %24

24:                                               ; preds = %18, %12
  %25 = load i32, ptr %1, align 4, !tbaa !5
  %26 = sext i32 %25 to i64
  %27 = getelementptr inbounds [3 x %struct._chained_info], ptr @info, i64 0, i64 %26
  %28 = getelementptr inbounds %struct._chained_info, ptr %27, i32 0, i32 1
  store ptr null, ptr %28, align 8, !tbaa !9
  br label %29

29:                                               ; preds = %24, %5
  br label %30

30:                                               ; preds = %29
  %31 = load i32, ptr %1, align 4, !tbaa !5
  %32 = add nsw i32 %31, 1
  store i32 %32, ptr %1, align 4, !tbaa !5
  br label %2, !llvm.loop !13

33:                                               ; preds = %2
  call void @llvm.lifetime.end.p0(i64 4, ptr %1) #3
  ret void
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 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 #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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !11, i64 8}
!10 = !{!"_chained_info", !6, i64 0, !11, i64 8, !6, i64 16}
!11 = !{!"any pointer", !7, i64 0}
!12 = !{!10, !6, i64 0}
!13 = distinct !{!13, !14}
!14 = !{!"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"

%struct._chained_info = type { i32, ptr, i32 }

@info = external hidden local_unnamed_addr global [3 x %struct._chained_info], align 16

declare void @EVP_CIPHER_meth_free(ptr noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local void @prov_free_ciphers() local_unnamed_addr #1 {
  %1 = load ptr, ptr getelementptr inbounds (i8, ptr @info, i64 8), align 8, !tbaa !5
  %.not = icmp eq ptr %1, null
  br i1 %.not, label %6, label %2

2:                                                ; preds = %0
  %3 = load i32, ptr @info, align 16, !tbaa !11
  switch i32 %3, label %5 [
    i32 895, label %4
    i32 898, label %4
    i32 901, label %4
  ]

4:                                                ; preds = %2, %2, %2
  tail call void @EVP_CIPHER_meth_free(ptr noundef nonnull %1) #2
  br label %5

5:                                                ; preds = %4, %2
  store ptr null, ptr getelementptr inbounds (i8, ptr @info, i64 8), align 8, !tbaa !5
  br label %6

6:                                                ; preds = %0, %5
  %7 = load ptr, ptr getelementptr inbounds (i8, ptr @info, i64 32), align 16, !tbaa !5
  %.not.1 = icmp eq ptr %7, null
  br i1 %.not.1, label %12, label %8

8:                                                ; preds = %6
  %9 = load i32, ptr getelementptr inbounds (i8, ptr @info, i64 24), align 8, !tbaa !11
  switch i32 %9, label %11 [
    i32 895, label %10
    i32 898, label %10
    i32 901, label %10
  ]

10:                                               ; preds = %8, %8, %8
  tail call void @EVP_CIPHER_meth_free(ptr noundef nonnull %7) #2
  br label %11

11:                                               ; preds = %10, %8
  store ptr null, ptr getelementptr inbounds (i8, ptr @info, i64 32), align 16, !tbaa !5
  br label %12

12:                                               ; preds = %11, %6
  %13 = load ptr, ptr getelementptr inbounds (i8, ptr @info, i64 56), align 8, !tbaa !5
  %.not.2 = icmp eq ptr %13, null
  br i1 %.not.2, label %18, label %14

14:                                               ; preds = %12
  %15 = load i32, ptr getelementptr inbounds (i8, ptr @info, i64 48), align 16, !tbaa !11
  switch i32 %15, label %17 [
    i32 895, label %16
    i32 898, label %16
    i32 901, label %16
  ]

16:                                               ; preds = %14, %14, %14
  tail call void @EVP_CIPHER_meth_free(ptr noundef nonnull %13) #2
  br label %17

17:                                               ; preds = %16, %14
  store ptr null, ptr getelementptr inbounds (i8, ptr @info, i64 56), align 8, !tbaa !5
  br label %18

18:                                               ; preds = %17, %12
  ret void
}

attributes #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 = { 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, !10, i64 8}
!6 = !{!"_chained_info", !7, i64 0, !10, i64 8, !7, i64 16}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"any pointer", !8, i64 0}
!11 = !{!6, !7, i64 0}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,LoopRotatePass,SROAPass,SimplifyCFGPass,TailCallElimPass