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

; 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.prov_gcm_ctx_st = type { %struct.gcm_key_data, %struct.gcm_context_data, i32, i32, ptr, i32, ptr, ptr, i32, ptr, i32, i32, i32, i32, i32, i32, i32, ptr, ptr, i32, i64, i64, i64, i64, i64, i64, i8, [16 x i8], ptr, ptr, [48 x i8] }
%struct.gcm_key_data = type { [240 x i8], %union.anon }
%union.anon = type { %struct.anon.1 }
%struct.anon.1 = type { [1024 x i8] }
%struct.gcm_context_data = type { [16 x i8], i64, i64, [16 x i8], [16 x i8], [16 x i8], i64 }

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

; Function Attrs: nounwind uwtable
define dso_local i32 @vaesgcm_init_key(ptr noundef %0, ptr noundef %1) #1 {
  %3 = alloca i32, align 4
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca i32, align 4
  %9 = alloca ptr, align 8
  %10 = alloca i32, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #3
  %11 = load ptr, ptr %4, align 8, !tbaa !5
  store ptr %11, ptr %6, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #3
  store ptr null, ptr %7, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #3
  store i32 0, ptr %8, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #3
  store ptr null, ptr %9, align 8, !tbaa !5
  %12 = load ptr, ptr %4, align 8, !tbaa !5
  %13 = icmp eq ptr %12, null
  br i1 %13, label %17, label %14

14:                                               ; preds = %2
  %15 = load ptr, ptr %5, align 8, !tbaa !5
  %16 = icmp eq ptr %15, null
  br i1 %16, label %17, label %18

17:                                               ; preds = %14, %2
  store i32 0, ptr %3, align 4
  store i32 1, ptr %10, align 4
  br label %38

18:                                               ; preds = %14
  %19 = load ptr, ptr %6, align 8, !tbaa !5
  %20 = icmp eq ptr %19, null
  br i1 %20, label %21, label %22

21:                                               ; preds = %18
  store i32 0, ptr %3, align 4
  store i32 1, ptr %10, align 4
  br label %38

22:                                               ; preds = %18
  %23 = load ptr, ptr %4, align 8, !tbaa !5
  %24 = call i32 @prov_aes_gcm_ctx_get_nid(ptr noundef %23)
  store i32 %24, ptr %8, align 4, !tbaa !9
  %25 = load i32, ptr %8, align 4, !tbaa !9
  %26 = call i32 @prov_check_gcm_nid(i32 noundef %25)
  %27 = icmp ne i32 %26, 0
  br i1 %27, label %29, label %28

28:                                               ; preds = %22
  store i32 -1, ptr %3, align 4
  store i32 1, ptr %10, align 4
  br label %38

29:                                               ; preds = %22
  %30 = load ptr, ptr %5, align 8, !tbaa !5
  store ptr %30, ptr %9, align 8, !tbaa !5
  %31 = load ptr, ptr %6, align 8, !tbaa !5
  %32 = getelementptr inbounds %struct.prov_gcm_ctx_st, ptr %31, i32 0, i32 0
  store ptr %32, ptr %7, align 8, !tbaa !5
  %33 = load i32, ptr %8, align 4, !tbaa !9
  %34 = load ptr, ptr %9, align 8, !tbaa !5
  %35 = load ptr, ptr %7, align 8, !tbaa !5
  call void @prov_imb_aes_gcm_precomp(i32 noundef %33, ptr noundef %34, ptr noundef %35)
  %36 = load ptr, ptr %6, align 8, !tbaa !5
  %37 = getelementptr inbounds %struct.prov_gcm_ctx_st, ptr %36, i32 0, i32 3
  store i32 1, ptr %37, align 4, !tbaa !11
  store i32 1, ptr %3, align 4
  store i32 1, ptr %10, align 4
  br label %38

38:                                               ; preds = %29, %28, %21, %17
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #3
  %39 = load i32, ptr %3, align 4
  ret i32 %39
}

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

declare i32 @prov_aes_gcm_ctx_get_nid(ptr noundef) #2

; Function Attrs: nounwind uwtable
declare hidden i32 @prov_check_gcm_nid(i32 noundef) #1

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

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 = { "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, !10, i64 1356}
!12 = !{!"prov_gcm_ctx_st", !13, i64 0, !14, i64 1264, !10, i64 1352, !10, i64 1356, !6, i64 1360, !10, i64 1368, !6, i64 1376, !6, i64 1384, !10, i64 1392, !6, i64 1400, !10, i64 1408, !10, i64 1412, !10, i64 1416, !10, i64 1420, !10, i64 1424, !10, i64 1428, !10, i64 1432, !6, i64 1440, !6, i64 1448, !10, i64 1456, !15, i64 1464, !15, i64 1472, !15, i64 1480, !15, i64 1488, !15, i64 1496, !15, i64 1504, !10, i64 1512, !10, i64 1512, !10, i64 1512, !7, i64 1513, !6, i64 1536, !6, i64 1544}
!13 = !{!"gcm_key_data", !7, i64 0, !7, i64 240}
!14 = !{!"gcm_context_data", !7, i64 0, !15, i64 16, !15, i64 24, !7, i64 32, !7, i64 48, !7, i64 64, !15, i64 80}
!15 = !{!"long", !7, i64 0}


; 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: nounwind uwtable
define dso_local range(i32 -1, 2) i32 @vaesgcm_init_key(ptr noundef %0, ptr noundef %1) local_unnamed_addr #0 {
  %3 = icmp eq ptr %0, null
  %4 = icmp eq ptr %1, null
  %or.cond = or i1 %3, %4
  br i1 %or.cond, label %10, label %5

5:                                                ; preds = %2
  %6 = tail call i32 @prov_aes_gcm_ctx_get_nid(ptr noundef nonnull %0) #2
  %7 = tail call i32 @prov_check_gcm_nid(i32 noundef %6)
  %.not = icmp eq i32 %7, 0
  br i1 %.not, label %10, label %8

8:                                                ; preds = %5
  tail call void @prov_imb_aes_gcm_precomp(i32 noundef %6, ptr noundef nonnull %1, ptr noundef nonnull %0) #2
  %9 = getelementptr inbounds i8, ptr %0, i64 1356
  store i32 1, ptr %9, align 4, !tbaa !5
  br label %10

10:                                               ; preds = %5, %2, %8
  %.0 = phi i32 [ 1, %8 ], [ 0, %2 ], [ -1, %5 ]
  ret i32 %.0
}

declare i32 @prov_aes_gcm_ctx_get_nid(ptr noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
declare hidden i32 @prov_check_gcm_nid(i32 noundef) local_unnamed_addr #0

declare void @prov_imb_aes_gcm_precomp(i32 noundef, ptr noundef, ptr noundef) local_unnamed_addr #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 = { "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, !12, i64 1356}
!6 = !{!"prov_gcm_ctx_st", !7, i64 0, !10, i64 1264, !12, i64 1352, !12, i64 1356, !13, i64 1360, !12, i64 1368, !13, i64 1376, !13, i64 1384, !12, i64 1392, !13, i64 1400, !12, i64 1408, !12, i64 1412, !12, i64 1416, !12, i64 1420, !12, i64 1424, !12, i64 1428, !12, i64 1432, !13, i64 1440, !13, i64 1448, !12, i64 1456, !11, i64 1464, !11, i64 1472, !11, i64 1480, !11, i64 1488, !11, i64 1496, !11, i64 1504, !12, i64 1512, !12, i64 1512, !12, i64 1512, !8, i64 1513, !13, i64 1536, !13, i64 1544}
!7 = !{!"gcm_key_data", !8, i64 0, !8, i64 240}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"gcm_context_data", !8, i64 0, !11, i64 16, !11, i64 24, !8, i64 32, !8, i64 48, !8, i64 64, !11, i64 80}
!11 = !{!"long", !8, i64 0}
!12 = !{!"int", !8, i64 0}
!13 = !{!"any pointer", !8, i64 0}


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