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

; 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_sha2_st = type { [8 x i64], i64, i64, i64, i64, i64, %union.anon, i32, i32, i32, ptr, ptr, [64 x i8], ptr, ptr }
%union.anon = type { [99999999 x i8] }

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

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

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #2

declare i32 @prov_imb_sha2(i32 noundef, i8 noundef zeroext, ptr noundef, i64 noundef, ptr noundef) #3

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

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

13:                                               ; preds = %2
  %14 = load ptr, ptr %3, align 8, !tbaa !5
  %15 = getelementptr inbounds %struct.prov_sha2_st, ptr %14, i32 0, i32 9
  %16 = load i32, ptr %15, align 8, !tbaa !11
  %17 = icmp eq i32 %16, 675
  br i1 %17, label %18, label %22

18:                                               ; preds = %13, %2
  %19 = load ptr, ptr %3, align 8, !tbaa !5
  %20 = getelementptr inbounds %struct.prov_sha2_st, ptr %19, i32 0, i32 6
  %21 = getelementptr inbounds [99999999 x i8], ptr %20, i64 0, i64 0
  store ptr %21, ptr %6, align 8, !tbaa !5
  br label %22

22:                                               ; preds = %18, %13
  %23 = load ptr, ptr %3, align 8, !tbaa !5
  %24 = getelementptr inbounds %struct.prov_sha2_st, ptr %23, i32 0, i32 9
  %25 = load i32, ptr %24, align 8, !tbaa !11
  %26 = icmp eq i32 %25, 673
  br i1 %26, label %32, label %27

27:                                               ; preds = %22
  %28 = load ptr, ptr %3, align 8, !tbaa !5
  %29 = getelementptr inbounds %struct.prov_sha2_st, ptr %28, i32 0, i32 9
  %30 = load i32, ptr %29, align 8, !tbaa !11
  %31 = icmp eq i32 %30, 674
  br i1 %31, label %32, label %36

32:                                               ; preds = %27, %22
  %33 = load ptr, ptr %3, align 8, !tbaa !5
  %34 = getelementptr inbounds %struct.prov_sha2_st, ptr %33, i32 0, i32 6
  %35 = getelementptr inbounds [99999999 x i8], ptr %34, i64 0, i64 0
  store ptr %35, ptr %6, align 8, !tbaa !5
  br label %36

36:                                               ; preds = %32, %27
  %37 = load i32, ptr %5, align 4, !tbaa !9
  %38 = load ptr, ptr %3, align 8, !tbaa !5
  %39 = getelementptr inbounds %struct.prov_sha2_st, ptr %38, i32 0, i32 9
  %40 = load i32, ptr %39, align 8, !tbaa !11
  %41 = trunc i32 %40 to i8
  %42 = load ptr, ptr %6, align 8, !tbaa !5
  %43 = load ptr, ptr %3, align 8, !tbaa !5
  %44 = getelementptr inbounds %struct.prov_sha2_st, ptr %43, i32 0, i32 7
  %45 = load i32, ptr %44, align 8, !tbaa !15
  %46 = zext i32 %45 to i64
  %47 = load ptr, ptr %3, align 8, !tbaa !5
  %48 = getelementptr inbounds %struct.prov_sha2_st, ptr %47, i32 0, i32 12
  %49 = getelementptr inbounds [64 x i8], ptr %48, i64 0, i64 0
  %50 = call i32 @prov_imb_sha2(i32 noundef %37, i8 noundef zeroext %41, ptr noundef %42, i64 noundef %46, ptr noundef %49)
  %51 = load ptr, ptr %4, align 8, !tbaa !5
  %52 = load ptr, ptr %3, align 8, !tbaa !5
  %53 = getelementptr inbounds %struct.prov_sha2_st, ptr %52, i32 0, i32 12
  %54 = getelementptr inbounds [64 x i8], ptr %53, i64 0, i64 0
  %55 = load ptr, ptr %3, align 8, !tbaa !5
  %56 = getelementptr inbounds %struct.prov_sha2_st, ptr %55, i32 0, i32 4
  %57 = load i64, ptr %56, align 8, !tbaa !16
  call void @llvm.memcpy.p0.p0.i64(ptr align 1 %51, ptr align 8 %54, i64 %57, i1 false)
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #4
  ret i32 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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { "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 #4 = { 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 100000112}
!12 = !{!"prov_sha2_st", !7, i64 0, !13, i64 64, !13, i64 72, !14, i64 80, !14, i64 88, !14, i64 96, !7, i64 104, !10, i64 100000104, !10, i64 100000108, !10, i64 100000112, !6, i64 100000120, !6, i64 100000128, !7, i64 100000136, !6, i64 100000200, !6, i64 100000208}
!13 = !{!"long long", !7, i64 0}
!14 = !{!"long", !7, i64 0}
!15 = !{!12, !10, i64 100000104}
!16 = !{!12, !14, i64 88}


; 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
declare dso_local i32 @prov_sha2_ctx_get_nid(ptr noundef) local_unnamed_addr #0

; Function Attrs: mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #1

declare i32 @prov_imb_sha2(i32 noundef, i8 noundef zeroext, ptr noundef, i64 noundef, ptr noundef) local_unnamed_addr #2

; Function Attrs: nounwind uwtable
define dso_local noundef i32 @mb_prov_SHA2_final(ptr noundef %0, ptr nocapture noundef writeonly %1) local_unnamed_addr #0 {
  %3 = tail call i32 @prov_sha2_ctx_get_nid(ptr noundef %0)
  %4 = getelementptr inbounds i8, ptr %0, i64 100000112
  %5 = load i32, ptr %4, align 8, !tbaa !5
  switch i32 %5, label %8 [
    i32 672, label %6
    i32 675, label %6
  ]

6:                                                ; preds = %2, %2
  %7 = getelementptr inbounds i8, ptr %0, i64 104
  br label %8

8:                                                ; preds = %2, %6
  %.0 = phi ptr [ %7, %6 ], [ null, %2 ]
  %.off = add i32 %5, -673
  %switch = icmp ult i32 %.off, 2
  %9 = getelementptr inbounds i8, ptr %0, i64 104
  %spec.select = select i1 %switch, ptr %9, ptr %.0
  %10 = trunc i32 %5 to i8
  %11 = getelementptr inbounds i8, ptr %0, i64 100000104
  %12 = load i32, ptr %11, align 8, !tbaa !13
  %13 = zext i32 %12 to i64
  %14 = getelementptr inbounds i8, ptr %0, i64 100000136
  %15 = tail call i32 @prov_imb_sha2(i32 noundef %3, i8 noundef zeroext %10, ptr noundef %spec.select, i64 noundef %13, ptr noundef nonnull %14) #3
  %16 = getelementptr inbounds i8, ptr %0, i64 88
  %17 = load i64, ptr %16, align 8, !tbaa !14
  tail call void @llvm.memcpy.p0.p0.i64(ptr align 1 %1, ptr nonnull align 8 %14, i64 %17, i1 false)
  ret i32 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 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite) }
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, !11, i64 100000112}
!6 = !{!"prov_sha2_st", !7, i64 0, !9, i64 64, !9, i64 72, !10, i64 80, !10, i64 88, !10, i64 96, !7, i64 104, !11, i64 100000104, !11, i64 100000108, !11, i64 100000112, !12, i64 100000120, !12, i64 100000128, !7, i64 100000136, !12, i64 100000200, !12, i64 100000208}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!"long long", !7, i64 0}
!10 = !{!"long", !7, i64 0}
!11 = !{!"int", !7, i64 0}
!12 = !{!"any pointer", !7, i64 0}
!13 = !{!6, !11, i64 100000104}
!14 = !{!6, !10, i64 88}


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