; 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

; Function Attrs: nounwind uwtable
declare dso_local ptr @prov_create_gcm_cipher_meth(i32 noundef, i32 noundef) #1

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

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

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 eq ptr %10, null
  br i1 %11, label %12, label %36

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 %34 [
    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 0
  %23 = load i32, ptr %22, align 8, !tbaa !12
  %24 = load i32, ptr %1, align 4, !tbaa !5
  %25 = sext i32 %24 to i64
  %26 = getelementptr inbounds [3 x %struct._chained_info], ptr @info, i64 0, i64 %25
  %27 = getelementptr inbounds %struct._chained_info, ptr %26, i32 0, i32 2
  %28 = load i32, ptr %27, align 8, !tbaa !13
  %29 = call ptr @prov_create_gcm_cipher_meth(i32 noundef %23, i32 noundef %28)
  %30 = load i32, ptr %1, align 4, !tbaa !5
  %31 = sext i32 %30 to i64
  %32 = getelementptr inbounds [3 x %struct._chained_info], ptr @info, i64 0, i64 %31
  %33 = getelementptr inbounds %struct._chained_info, ptr %32, i32 0, i32 1
  store ptr %29, ptr %33, align 8, !tbaa !9
  br label %35

34:                                               ; preds = %12
  br label %35

35:                                               ; preds = %34, %18
  br label %36

36:                                               ; preds = %35, %5
  br label %37

37:                                               ; preds = %36
  %38 = load i32, ptr %1, align 4, !tbaa !5
  %39 = add nsw i32 %38, 1
  store i32 %39, ptr %1, align 4, !tbaa !5
  br label %2, !llvm.loop !14

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

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 = !{!"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 = !{!10, !6, i64 16}
!14 = distinct !{!14, !15}
!15 = !{!"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

; Function Attrs: nounwind uwtable
declare dso_local ptr @prov_create_gcm_cipher_meth(i32 noundef, i32 noundef) local_unnamed_addr #0

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

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

5:                                                ; preds = %3, %3, %3
  %6 = load i32, ptr getelementptr inbounds (i8, ptr @info, i64 16), align 16, !tbaa !12
  %7 = tail call ptr @prov_create_gcm_cipher_meth(i32 noundef %4, i32 noundef %6)
  store ptr %7, ptr getelementptr inbounds (i8, ptr @info, i64 8), align 8, !tbaa !5
  br label %8

8:                                                ; preds = %0, %3, %5
  %9 = load ptr, ptr getelementptr inbounds (i8, ptr @info, i64 32), align 16, !tbaa !5
  %10 = icmp eq ptr %9, null
  br i1 %10, label %11, label %16

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

13:                                               ; preds = %11, %11, %11
  %14 = load i32, ptr getelementptr inbounds (i8, ptr @info, i64 40), align 8, !tbaa !12
  %15 = tail call ptr @prov_create_gcm_cipher_meth(i32 noundef %12, i32 noundef %14)
  store ptr %15, ptr getelementptr inbounds (i8, ptr @info, i64 32), align 16, !tbaa !5
  br label %16

16:                                               ; preds = %13, %11, %8
  %17 = load ptr, ptr getelementptr inbounds (i8, ptr @info, i64 56), align 8, !tbaa !5
  %18 = icmp eq ptr %17, null
  br i1 %18, label %19, label %24

19:                                               ; preds = %16
  %20 = load i32, ptr getelementptr inbounds (i8, ptr @info, i64 48), align 16, !tbaa !11
  switch i32 %20, label %24 [
    i32 895, label %21
    i32 898, label %21
    i32 901, label %21
  ]

21:                                               ; preds = %19, %19, %19
  %22 = load i32, ptr getelementptr inbounds (i8, ptr @info, i64 64), align 16, !tbaa !12
  %23 = tail call ptr @prov_create_gcm_cipher_meth(i32 noundef %20, i32 noundef %22)
  store ptr %23, ptr getelementptr inbounds (i8, ptr @info, i64 56), align 8, !tbaa !5
  br label %24

24:                                               ; preds = %21, %19, %16
  ret void
}

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

!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}
!12 = !{!6, !7, i64 16}


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