; LLVM IR from intel/intel-ipsec-mb :: test/fuzz-app (direct_api_fuzz_test)

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

@arch = external dso_local global i32, align 4
@flags = external dso_local global i64, align 8
@direct_apis = external dso_local global [101 x %struct.anon], align 16
@LLVMFuzzerTestOneInput.p_mgr = external hidden global ptr, align 8
@.str.102 = external hidden unnamed_addr constant [36 x i8], align 1

; 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
define dso_local i32 @LLVMFuzzerTestOneInput(ptr noundef %0, i64 noundef %1) #1 {
  %3 = alloca i32, align 4
  %4 = alloca ptr, align 8
  %5 = alloca i64, align 8
  %6 = alloca i64, align 8
  %7 = alloca ptr, align 8
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  store i64 %1, ptr %5, align 8, !tbaa !9
  %12 = load i64, ptr %5, align 8, !tbaa !9
  %13 = icmp ult i64 %12, 4
  br i1 %13, label %14, label %15

14:                                               ; preds = %2
  store i32 -1, ptr %3, align 4
  br label %77

15:                                               ; preds = %2
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #6
  %16 = load i64, ptr %5, align 8, !tbaa !9
  %17 = sub i64 %16, 4
  store i64 %17, ptr %6, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #6
  %18 = load i64, ptr %6, align 8, !tbaa !9
  %19 = call noalias ptr @malloc(i64 noundef %18) #7
  store ptr %19, ptr %7, align 8, !tbaa !5
  %20 = load ptr, ptr %7, align 8, !tbaa !5
  %21 = icmp eq ptr %20, null
  br i1 %21, label %22, label %23

22:                                               ; preds = %15
  store i32 -1, ptr %3, align 4
  store i32 1, ptr %8, align 4
  br label %76

23:                                               ; preds = %15
  %24 = load ptr, ptr %7, align 8, !tbaa !5
  %25 = load ptr, ptr %4, align 8, !tbaa !5
  %26 = getelementptr inbounds i8, ptr %25, i64 4
  %27 = load i64, ptr %6, align 8, !tbaa !9
  call void @llvm.memcpy.p0.p0.i64(ptr align 1 %24, ptr align 1 %26, i64 %27, i1 false)
  %28 = load ptr, ptr @LLVMFuzzerTestOneInput.p_mgr, align 8, !tbaa !5
  %29 = icmp eq ptr %28, null
  br i1 %29, label %30, label %58

30:                                               ; preds = %23
  %31 = load i64, ptr @flags, align 8, !tbaa !9
  %32 = call ptr @alloc_mb_mgr(i64 noundef %31)
  store ptr %32, ptr @LLVMFuzzerTestOneInput.p_mgr, align 8, !tbaa !5
  %33 = load ptr, ptr @LLVMFuzzerTestOneInput.p_mgr, align 8, !tbaa !5
  %34 = icmp eq ptr %33, null
  br i1 %34, label %35, label %38

35:                                               ; preds = %30
  %36 = call i32 (ptr, ...) @printf(ptr noundef @.str.102)
  %37 = load ptr, ptr %7, align 8, !tbaa !5
  call void @free(ptr noundef %37) #6
  store i32 -1, ptr %3, align 4
  store i32 1, ptr %8, align 4
  br label %76

38:                                               ; preds = %30
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #6
  store i32 5, ptr %9, align 4, !tbaa !11
  %39 = load i32, ptr @arch, align 4, !tbaa !11
  %40 = icmp eq i32 %39, 1
  br i1 %40, label %41, label %43

41:                                               ; preds = %38
  %42 = load ptr, ptr @LLVMFuzzerTestOneInput.p_mgr, align 8, !tbaa !5
  call void @init_mb_mgr_sse(ptr noundef %42)
  br label %57

43:                                               ; preds = %38
  %44 = load i32, ptr @arch, align 4, !tbaa !11
  %45 = icmp eq i32 %44, 2
  br i1 %45, label %46, label %48

46:                                               ; preds = %43
  %47 = load ptr, ptr @LLVMFuzzerTestOneInput.p_mgr, align 8, !tbaa !5
  call void @init_mb_mgr_avx2(ptr noundef %47)
  br label %56

48:                                               ; preds = %43
  %49 = load i32, ptr @arch, align 4, !tbaa !11
  %50 = icmp eq i32 %49, 3
  br i1 %50, label %51, label %53

51:                                               ; preds = %48
  %52 = load ptr, ptr @LLVMFuzzerTestOneInput.p_mgr, align 8, !tbaa !5
  call void @init_mb_mgr_avx512(ptr noundef %52)
  br label %55

53:                                               ; preds = %48
  %54 = load ptr, ptr @LLVMFuzzerTestOneInput.p_mgr, align 8, !tbaa !5
  call void @init_mb_mgr_auto(ptr noundef %54, ptr noundef %9)
  br label %55

55:                                               ; preds = %53, %51
  br label %56

56:                                               ; preds = %55, %46
  br label %57

57:                                               ; preds = %56, %41
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #6
  br label %58

58:                                               ; preds = %57, %23
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #6
  %59 = load ptr, ptr %4, align 8, !tbaa !5
  %60 = getelementptr inbounds i32, ptr %59, i64 0
  %61 = load i32, ptr %60, align 4, !tbaa !11
  %62 = sext i32 %61 to i64
  %63 = urem i64 %62, 101
  %64 = trunc i64 %63 to i32
  store i32 %64, ptr %10, align 4, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #6
  %65 = load i32, ptr %10, align 4, !tbaa !11
  %66 = sext i32 %65 to i64
  %67 = getelementptr inbounds [101 x %struct.anon], ptr @direct_apis, i64 0, i64 %66
  %68 = getelementptr inbounds %struct.anon, ptr %67, i32 0, i32 0
  %69 = load ptr, ptr %68, align 16, !tbaa !13
  %70 = load ptr, ptr @LLVMFuzzerTestOneInput.p_mgr, align 8, !tbaa !5
  %71 = load ptr, ptr %7, align 8, !tbaa !5
  %72 = load i64, ptr %6, align 8, !tbaa !9
  %73 = call i32 %69(ptr noundef %70, ptr noundef %71, i64 noundef %72)
  store i32 %73, ptr %11, align 4, !tbaa !11
  %74 = load ptr, ptr %7, align 8, !tbaa !5
  call void @free(ptr noundef %74) #6
  %75 = load i32, ptr %11, align 4, !tbaa !11
  store i32 %75, ptr %3, align 4
  store i32 1, ptr %8, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #6
  br label %76

76:                                               ; preds = %58, %35, %22
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #6
  br label %77

77:                                               ; preds = %76, %14
  %78 = load i32, ptr %3, align 4
  ret i32 %78
}

; Function Attrs: nounwind allocsize(0)
declare noalias ptr @malloc(i64 noundef) #2

; 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) #3

declare ptr @alloc_mb_mgr(i64 noundef) #4

declare i32 @printf(ptr noundef, ...) #4

; Function Attrs: nounwind
declare void @free(ptr noundef) #5

declare void @init_mb_mgr_sse(ptr noundef) #4

declare void @init_mb_mgr_avx2(ptr noundef) #4

declare void @init_mb_mgr_avx512(ptr noundef) #4

declare void @init_mb_mgr_auto(ptr noundef, ptr noundef) #4

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 allocsize(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 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #4 = { "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 #5 = { nounwind "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 #6 = { nounwind }
attributes #7 = { nounwind allocsize(0) }

!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 = !{!12, !12, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = !{!14, !6, i64 0}
!14 = !{!"", !6, i64 0, !6, i64 8}


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

@arch = external dso_local local_unnamed_addr global i32, align 4
@flags = external dso_local local_unnamed_addr global i64, align 8
@direct_apis = external dso_local local_unnamed_addr global [101 x %struct.anon], align 16
@LLVMFuzzerTestOneInput.p_mgr = external hidden local_unnamed_addr global ptr, align 8
@.str.102 = external hidden unnamed_addr constant [36 x i8], align 1

; 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
define dso_local i32 @LLVMFuzzerTestOneInput(ptr nocapture noundef readonly %0, i64 noundef %1) local_unnamed_addr #1 {
  %3 = alloca i32, align 4
  %4 = icmp ult i64 %1, 4
  br i1 %4, label %34, label %5

5:                                                ; preds = %2
  %6 = add i64 %1, -4
  %7 = tail call noalias ptr @malloc(i64 noundef %6) #7
  %8 = icmp eq ptr %7, null
  br i1 %8, label %34, label %9

9:                                                ; preds = %5
  %10 = getelementptr inbounds i8, ptr %0, i64 4
  tail call void @llvm.memcpy.p0.p0.i64(ptr nonnull align 1 %7, ptr nonnull align 1 %10, i64 %6, i1 false)
  %11 = load ptr, ptr @LLVMFuzzerTestOneInput.p_mgr, align 8, !tbaa !5
  %12 = icmp eq ptr %11, null
  br i1 %12, label %13, label %26

13:                                               ; preds = %9
  %14 = load i64, ptr @flags, align 8, !tbaa !9
  %15 = tail call ptr @alloc_mb_mgr(i64 noundef %14) #8
  store ptr %15, ptr @LLVMFuzzerTestOneInput.p_mgr, align 8, !tbaa !5
  %16 = icmp eq ptr %15, null
  br i1 %16, label %17, label %19

17:                                               ; preds = %13
  %18 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.102)
  tail call void @free(ptr noundef nonnull %7) #8
  br label %34

19:                                               ; preds = %13
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %3) #8
  store i32 5, ptr %3, align 4, !tbaa !11
  %20 = load i32, ptr @arch, align 4, !tbaa !11
  switch i32 %20, label %24 [
    i32 1, label %21
    i32 2, label %22
    i32 3, label %23
  ]

21:                                               ; preds = %19
  tail call void @init_mb_mgr_sse(ptr noundef nonnull %15) #8
  br label %25

22:                                               ; preds = %19
  tail call void @init_mb_mgr_avx2(ptr noundef nonnull %15) #8
  br label %25

23:                                               ; preds = %19
  tail call void @init_mb_mgr_avx512(ptr noundef nonnull %15) #8
  br label %25

24:                                               ; preds = %19
  call void @init_mb_mgr_auto(ptr noundef nonnull %15, ptr noundef nonnull %3) #8
  br label %25

25:                                               ; preds = %22, %24, %23, %21
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %3) #8
  %.pre = load ptr, ptr @LLVMFuzzerTestOneInput.p_mgr, align 8, !tbaa !5
  br label %26

26:                                               ; preds = %25, %9
  %27 = phi ptr [ %.pre, %25 ], [ %11, %9 ]
  %28 = load i32, ptr %0, align 4, !tbaa !11
  %29 = sext i32 %28 to i64
  %30 = urem i64 %29, 101
  %31 = getelementptr inbounds [101 x %struct.anon], ptr @direct_apis, i64 0, i64 %30
  %32 = load ptr, ptr %31, align 16, !tbaa !13
  %33 = call i32 %32(ptr noundef %27, ptr noundef nonnull %7, i64 noundef %6) #8
  call void @free(ptr noundef nonnull %7) #8
  br label %34

34:                                               ; preds = %17, %26, %5, %2
  %.1 = phi i32 [ -1, %2 ], [ -1, %17 ], [ %33, %26 ], [ -1, %5 ]
  ret i32 %.1
}

; Function Attrs: mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite)
declare noalias noundef ptr @malloc(i64 noundef) local_unnamed_addr #2

; 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) #3

declare ptr @alloc_mb_mgr(i64 noundef) local_unnamed_addr #4

; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #5

; Function Attrs: mustprogress nounwind willreturn allockind("free") memory(argmem: readwrite, inaccessiblemem: readwrite)
declare void @free(ptr allocptr nocapture noundef) local_unnamed_addr #6

declare void @init_mb_mgr_sse(ptr noundef) local_unnamed_addr #4

declare void @init_mb_mgr_avx2(ptr noundef) local_unnamed_addr #4

declare void @init_mb_mgr_avx512(ptr noundef) local_unnamed_addr #4

declare void @init_mb_mgr_auto(ptr noundef, ptr noundef) local_unnamed_addr #4

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 = { mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite) "alloc-family"="malloc" "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 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #4 = { "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 #5 = { nofree nounwind "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 #6 = { mustprogress nounwind willreturn allockind("free") memory(argmem: readwrite, inaccessiblemem: readwrite) "alloc-family"="malloc" "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 #7 = { nounwind allocsize(0) }
attributes #8 = { 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 = !{!12, !12, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = !{!14, !6, i64 0}
!14 = !{!"", !6, i64 0, !6, i64 8}


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