; LLVM IR from intel/QAT_Engine :: test (tests)

; 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.epoll_event = type <{ i32, %union.epoll_data }>
%union.epoll_data = type { ptr }
%struct.ENG_POLL_EVENT = type { i32, ptr }

@efd = external hidden global i32, align 4
@.str = external hidden unnamed_addr constant [10 x i8], align 1
@no_of_inst = external hidden global i32, align 4
@event = external dso_local global [64 x %struct.epoll_event], align 16
@qat_keep_polling = external hidden global i32, align 4
@.str.8 = external hidden unnamed_addr constant [63 x i8], align 1
@testapp_polling_threads = external dso_local global ptr, align 8
@testapp_heartbeat_threads = external dso_local global ptr, align 8

; 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 willreturn memory(read)
declare i32 @strncmp(ptr noundef, ptr noundef, i64 noundef) #1

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

; Function Attrs: nounwind
declare i32 @epoll_ctl(i32 noundef, i32 noundef, i32 noundef, ptr noundef) #2

declare i32 @ENGINE_free(ptr noundef) #3

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

19:                                               ; preds = %6
  %20 = load i32, ptr %9, align 4, !tbaa !9
  %21 = icmp ne i32 %20, 0
  br i1 %21, label %70, label %22

22:                                               ; preds = %19
  %23 = load i32, ptr %10, align 4, !tbaa !9
  %24 = icmp ne i32 %23, 0
  br i1 %24, label %25, label %70

25:                                               ; preds = %22
  store i32 0, ptr @qat_keep_polling, align 4, !tbaa !9
  %26 = load ptr, ptr @testapp_polling_threads, align 8, !tbaa !5
  %27 = getelementptr inbounds i64, ptr %26, i64 0
  %28 = load i64, ptr %27, align 8, !tbaa !11
  %29 = call i32 @pthread_join(i64 noundef %28, ptr noundef null)
  %30 = load ptr, ptr @testapp_polling_threads, align 8, !tbaa !5
  %31 = icmp ne ptr %30, null
  br i1 %31, label %32, label %34

32:                                               ; preds = %25
  %33 = load ptr, ptr @testapp_polling_threads, align 8, !tbaa !5
  call void @CRYPTO_free(ptr noundef %33, ptr noundef @.str.8, i32 noundef 659)
  br label %34

34:                                               ; preds = %32, %25
  %35 = load i32, ptr %11, align 4, !tbaa !9
  %36 = icmp ne i32 %35, 0
  br i1 %36, label %37, label %69

37:                                               ; preds = %34
  store i32 0, ptr %13, align 4, !tbaa !9
  br label %38

38:                                               ; preds = %65, %37
  %39 = load i32, ptr %13, align 4, !tbaa !9
  %40 = load i32, ptr @no_of_inst, align 4, !tbaa !9
  %41 = icmp slt i32 %39, %40
  br i1 %41, label %42, label %68

42:                                               ; preds = %38
  %43 = load i32, ptr %13, align 4, !tbaa !9
  %44 = sext i32 %43 to i64
  %45 = getelementptr inbounds [64 x %struct.epoll_event], ptr @event, i64 0, i64 %44
  %46 = getelementptr inbounds %struct.epoll_event, ptr %45, i32 0, i32 1
  %47 = load ptr, ptr %46, align 4, !tbaa !13
  store ptr %47, ptr %15, align 8, !tbaa !5
  %48 = load ptr, ptr %15, align 8, !tbaa !5
  %49 = getelementptr inbounds %struct.ENG_POLL_EVENT, ptr %48, i32 0, i32 0
  %50 = load i32, ptr %49, align 8, !tbaa !14
  store i32 %50, ptr %14, align 4, !tbaa !9
  %51 = load i32, ptr @efd, align 4, !tbaa !9
  %52 = load i32, ptr %14, align 4, !tbaa !9
  %53 = load i32, ptr %13, align 4, !tbaa !9
  %54 = sext i32 %53 to i64
  %55 = getelementptr inbounds [64 x %struct.epoll_event], ptr @event, i64 0, i64 %54
  %56 = call i32 @epoll_ctl(i32 noundef %51, i32 noundef 2, i32 noundef %52, ptr noundef %55) #5
  %57 = icmp eq i32 -1, %56
  br i1 %57, label %58, label %59

58:                                               ; preds = %42
  br label %59

59:                                               ; preds = %58, %42
  %60 = load ptr, ptr %15, align 8, !tbaa !5
  %61 = icmp ne ptr %60, null
  br i1 %61, label %62, label %64

62:                                               ; preds = %59
  %63 = load ptr, ptr %15, align 8, !tbaa !5
  call void @free(ptr noundef %63) #5
  br label %64

64:                                               ; preds = %62, %59
  br label %65

65:                                               ; preds = %64
  %66 = load i32, ptr %13, align 4, !tbaa !9
  %67 = add nsw i32 %66, 1
  store i32 %67, ptr %13, align 4, !tbaa !9
  br label %38, !llvm.loop !16

68:                                               ; preds = %38
  br label %69

69:                                               ; preds = %68, %34
  br label %70

70:                                               ; preds = %69, %22, %19
  %71 = load i32, ptr %12, align 4, !tbaa !9
  %72 = icmp ne i32 %71, 0
  br i1 %72, label %73, label %86

73:                                               ; preds = %70
  %74 = load i32, ptr %10, align 4, !tbaa !9
  %75 = icmp ne i32 %74, 0
  br i1 %75, label %76, label %86

76:                                               ; preds = %73
  store i32 0, ptr @qat_keep_polling, align 4, !tbaa !9
  %77 = load ptr, ptr @testapp_heartbeat_threads, align 8, !tbaa !5
  %78 = getelementptr inbounds i64, ptr %77, i64 0
  %79 = load i64, ptr %78, align 8, !tbaa !11
  %80 = call i32 @pthread_join(i64 noundef %79, ptr noundef null)
  %81 = load ptr, ptr @testapp_heartbeat_threads, align 8, !tbaa !5
  %82 = icmp ne ptr %81, null
  br i1 %82, label %83, label %85

83:                                               ; preds = %76
  %84 = load ptr, ptr @testapp_heartbeat_threads, align 8, !tbaa !5
  call void @CRYPTO_free(ptr noundef %84, ptr noundef @.str.8, i32 noundef 679)
  br label %85

85:                                               ; preds = %83, %76
  br label %86

86:                                               ; preds = %85, %73, %70
  br label %87

87:                                               ; preds = %86, %6
  %88 = load ptr, ptr %7, align 8, !tbaa !5
  %89 = icmp ne ptr %88, null
  br i1 %89, label %90, label %95

90:                                               ; preds = %87
  %91 = load ptr, ptr %7, align 8, !tbaa !5
  %92 = call i32 @ENGINE_finish(ptr noundef %91)
  %93 = load ptr, ptr %7, align 8, !tbaa !5
  %94 = call i32 @ENGINE_free(ptr noundef %93)
  br label %95

95:                                               ; preds = %90, %87
  call void @llvm.lifetime.end.p0(i64 8, ptr %15) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #5
  ret void
}

declare i32 @pthread_join(i64 noundef, ptr noundef) #3

declare void @CRYPTO_free(ptr noundef, ptr noundef, i32 noundef) #3

declare i32 @ENGINE_finish(ptr noundef) #3

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

!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, !12, i64 0}
!12 = !{!"long", !7, i64 0}
!13 = !{!7, !7, i64 0}
!14 = !{!15, !10, i64 0}
!15 = !{!"", !10, i64 0, !6, i64 8}
!16 = distinct !{!16, !17}
!17 = !{!"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.epoll_event = type <{ i32, %union.epoll_data }>
%union.epoll_data = type { ptr }

@efd = external hidden local_unnamed_addr global i32, align 4
@.str = external hidden unnamed_addr constant [10 x i8], align 1
@no_of_inst = external hidden local_unnamed_addr global i32, align 4
@event = external dso_local global [64 x %struct.epoll_event], align 16
@qat_keep_polling = external hidden local_unnamed_addr global i32, align 4
@.str.8 = external hidden unnamed_addr constant [63 x i8], align 1
@testapp_polling_threads = external dso_local local_unnamed_addr global ptr, align 8
@testapp_heartbeat_threads = external dso_local local_unnamed_addr global ptr, align 8

; Function Attrs: mustprogress nofree nounwind willreturn memory(argmem: read)
declare i32 @strncmp(ptr nocapture noundef, ptr nocapture noundef, i64 noundef) local_unnamed_addr #0

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

; Function Attrs: nounwind
declare i32 @epoll_ctl(i32 noundef, i32 noundef, i32 noundef, ptr noundef) local_unnamed_addr #2

declare i32 @ENGINE_free(ptr noundef) local_unnamed_addr #3

; Function Attrs: nounwind uwtable
define dso_local void @tests_cleanup_engine(ptr noundef %0, ptr nocapture noundef readonly %1, i32 noundef %2, i32 noundef %3, i32 noundef %4, i32 noundef %5) local_unnamed_addr #4 {
  %7 = tail call i32 @strncmp(ptr noundef nonnull dereferenceable(1) %1, ptr noundef nonnull dereferenceable(1) @.str, i64 noundef 9) #5
  %8 = icmp eq i32 %7, 0
  br i1 %8, label %9, label %37

9:                                                ; preds = %6
  %10 = icmp eq i32 %2, 0
  %11 = icmp ne i32 %3, 0
  %or.cond = and i1 %10, %11
  br i1 %or.cond, label %12, label %.loopexit

12:                                               ; preds = %9
  store i32 0, ptr @qat_keep_polling, align 4, !tbaa !5
  %13 = load ptr, ptr @testapp_polling_threads, align 8, !tbaa !9
  %14 = load i64, ptr %13, align 8, !tbaa !11
  %15 = tail call i32 @pthread_join(i64 noundef %14, ptr noundef null) #6
  %16 = load ptr, ptr @testapp_polling_threads, align 8, !tbaa !9
  %.not = icmp eq ptr %16, null
  br i1 %.not, label %18, label %17

17:                                               ; preds = %12
  tail call void @CRYPTO_free(ptr noundef nonnull %16, ptr noundef nonnull @.str.8, i32 noundef 659) #6
  br label %18

18:                                               ; preds = %17, %12
  %.not22 = icmp ne i32 %4, 0
  %19 = load i32, ptr @no_of_inst, align 4
  %20 = icmp sgt i32 %19, 0
  %or.cond27 = select i1 %.not22, i1 %20, i1 false
  br i1 %or.cond27, label %.lr.ph, label %.loopexit

.lr.ph:                                           ; preds = %18, %.lr.ph
  %indvars.iv = phi i64 [ %indvars.iv.next, %.lr.ph ], [ 0, %18 ]
  %21 = getelementptr inbounds [64 x %struct.epoll_event], ptr @event, i64 0, i64 %indvars.iv
  %22 = getelementptr inbounds i8, ptr %21, i64 4
  %23 = load ptr, ptr %22, align 4, !tbaa !13
  %24 = load i32, ptr %23, align 8, !tbaa !14
  %25 = load i32, ptr @efd, align 4, !tbaa !5
  %26 = tail call i32 @epoll_ctl(i32 noundef %25, i32 noundef 2, i32 noundef %24, ptr noundef nonnull %21) #6
  tail call void @free(ptr noundef %23) #6
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %27 = load i32, ptr @no_of_inst, align 4, !tbaa !5
  %28 = sext i32 %27 to i64
  %29 = icmp slt i64 %indvars.iv.next, %28
  br i1 %29, label %.lr.ph, label %.loopexit, !llvm.loop !16

.loopexit:                                        ; preds = %.lr.ph, %18, %9
  %30 = icmp ne i32 %5, 0
  %or.cond3 = and i1 %11, %30
  br i1 %or.cond3, label %31, label %37

31:                                               ; preds = %.loopexit
  store i32 0, ptr @qat_keep_polling, align 4, !tbaa !5
  %32 = load ptr, ptr @testapp_heartbeat_threads, align 8, !tbaa !9
  %33 = load i64, ptr %32, align 8, !tbaa !11
  %34 = tail call i32 @pthread_join(i64 noundef %33, ptr noundef null) #6
  %35 = load ptr, ptr @testapp_heartbeat_threads, align 8, !tbaa !9
  %.not23 = icmp eq ptr %35, null
  br i1 %.not23, label %37, label %36

36:                                               ; preds = %31
  tail call void @CRYPTO_free(ptr noundef nonnull %35, ptr noundef nonnull @.str.8, i32 noundef 679) #6
  br label %37

37:                                               ; preds = %.loopexit, %36, %31, %6
  %.not24 = icmp eq ptr %0, null
  br i1 %.not24, label %41, label %38

38:                                               ; preds = %37
  %39 = tail call i32 @ENGINE_finish(ptr noundef nonnull %0) #6
  %40 = tail call i32 @ENGINE_free(ptr noundef nonnull %0) #6
  br label %41

41:                                               ; preds = %38, %37
  ret void
}

declare i32 @pthread_join(i64 noundef, ptr noundef) local_unnamed_addr #3

declare void @CRYPTO_free(ptr noundef, ptr noundef, i32 noundef) local_unnamed_addr #3

declare i32 @ENGINE_finish(ptr noundef) local_unnamed_addr #3

attributes #0 = { mustprogress nofree nounwind willreturn memory(argmem: read) "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 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 #2 = { 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 #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 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 #5 = { nounwind willreturn memory(read) }
attributes #6 = { 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, !10, i64 0}
!10 = !{!"any pointer", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"long", !7, i64 0}
!13 = !{!7, !7, i64 0}
!14 = !{!15, !6, i64 0}
!15 = !{!"", !6, i64 0, !10, i64 8}
!16 = distinct !{!16, !17}
!17 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass