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

; 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.test_params_t = type { ptr, ptr, i32, i32, ptr, i32, i32, i32, i32, i32, i32, ptr, [8 x ptr], [8 x ptr], [8 x ptr], [8 x ptr], i32, i32, i32, ptr, ptr, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, ptr, ptr, ptr, i32, i32 }

@stderr = external global ptr, align 8
@.str = external hidden unnamed_addr constant [28 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [28 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local void @tests_run_dsa(ptr noundef %0) #0 {
  %2 = alloca ptr, align 8
  %3 = alloca i32, align 4
  store ptr %0, ptr %2, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #4
  store i32 1, ptr %3, align 4, !tbaa !9
  %4 = load ptr, ptr %2, align 8, !tbaa !5
  %5 = getelementptr inbounds %struct.test_params_t, ptr %4, i32 0, i32 10
  %6 = load i32, ptr %5, align 4, !tbaa !11
  %7 = icmp ne i32 %6, 0
  br i1 %7, label %51, label %8

8:                                                ; preds = %1
  %9 = load ptr, ptr %2, align 8, !tbaa !5
  %10 = getelementptr inbounds %struct.test_params_t, ptr %9, i32 0, i32 3
  %11 = load i32, ptr %10, align 4, !tbaa !13
  %12 = icmp eq i32 %11, 2048
  br i1 %12, label %13, label %47

13:                                               ; preds = %8
  store i32 1, ptr %3, align 4, !tbaa !9
  br label %14

14:                                               ; preds = %43, %13
  %15 = load i32, ptr %3, align 4, !tbaa !9
  %16 = icmp slt i32 %15, 3
  br i1 %16, label %17, label %46

17:                                               ; preds = %14
  %18 = load i32, ptr %3, align 4, !tbaa !9
  %19 = icmp eq i32 %18, 1
  br i1 %19, label %20, label %30

20:                                               ; preds = %17
  %21 = load ptr, ptr %2, align 8, !tbaa !5
  %22 = call i32 @run_dsa(ptr noundef %21)
  br label %23

23:                                               ; preds = %20
  %24 = load ptr, ptr @stderr, align 8, !tbaa !5
  %25 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %24, ptr noundef @.str) #4
  %26 = load ptr, ptr @stderr, align 8, !tbaa !5
  %27 = call i32 @fflush(ptr noundef %26)
  br label %28

28:                                               ; preds = %23
  br label %29

29:                                               ; preds = %28
  br label %42

30:                                               ; preds = %17
  %31 = load ptr, ptr %2, align 8, !tbaa !5
  %32 = getelementptr inbounds %struct.test_params_t, ptr %31, i32 0, i32 34
  store i32 256, ptr %32, align 8, !tbaa !14
  %33 = load ptr, ptr %2, align 8, !tbaa !5
  %34 = call i32 @run_dsa(ptr noundef %33)
  br label %35

35:                                               ; preds = %30
  %36 = load ptr, ptr @stderr, align 8, !tbaa !5
  %37 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %36, ptr noundef @.str.1) #4
  %38 = load ptr, ptr @stderr, align 8, !tbaa !5
  %39 = call i32 @fflush(ptr noundef %38)
  br label %40

40:                                               ; preds = %35
  br label %41

41:                                               ; preds = %40
  br label %42

42:                                               ; preds = %41, %29
  br label %43

43:                                               ; preds = %42
  %44 = load i32, ptr %3, align 4, !tbaa !9
  %45 = add nsw i32 %44, 1
  store i32 %45, ptr %3, align 4, !tbaa !9
  br label %14, !llvm.loop !15

46:                                               ; preds = %14
  br label %50

47:                                               ; preds = %8
  %48 = load ptr, ptr %2, align 8, !tbaa !5
  %49 = call i32 @run_dsa(ptr noundef %48)
  br label %50

50:                                               ; preds = %47, %46
  br label %54

51:                                               ; preds = %1
  %52 = load ptr, ptr %2, align 8, !tbaa !5
  %53 = call i32 @start_async_job(ptr noundef %52, ptr noundef @run_dsa)
  br label %54

54:                                               ; preds = %51, %50
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #4
  ret void
}

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

; Function Attrs: nounwind uwtable
declare hidden i32 @run_dsa(ptr noundef) #0

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

declare i32 @fflush(ptr noundef) #3

declare i32 @start_async_job(ptr 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

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 = { 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 }

!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 52}
!12 = !{!"test_params_t", !6, i64 0, !6, i64 8, !10, i64 16, !10, i64 20, !6, i64 24, !10, i64 32, !10, i64 36, !10, i64 40, !10, i64 44, !10, i64 48, !10, i64 52, !6, i64 56, !7, i64 64, !7, i64 128, !7, i64 192, !7, i64 256, !10, i64 320, !10, i64 324, !10, i64 328, !6, i64 336, !6, i64 344, !10, i64 352, !10, i64 356, !10, i64 360, !10, i64 364, !10, i64 368, !10, i64 372, !10, i64 376, !10, i64 380, !10, i64 384, !10, i64 388, !6, i64 392, !6, i64 400, !6, i64 408, !10, i64 416, !10, i64 420}
!13 = !{!12, !10, i64 20}
!14 = !{!12, !10, i64 416}
!15 = distinct !{!15, !16}
!16 = !{!"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"

@stderr = external local_unnamed_addr global ptr, align 8
@.str = external hidden unnamed_addr constant [28 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [28 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local void @tests_run_dsa(ptr noundef %0) local_unnamed_addr #0 {
  %2 = getelementptr inbounds i8, ptr %0, i64 52
  %3 = load i32, ptr %2, align 4, !tbaa !5
  %.not = icmp eq i32 %3, 0
  br i1 %.not, label %4, label %21

4:                                                ; preds = %1
  %5 = getelementptr inbounds i8, ptr %0, i64 20
  %6 = load i32, ptr %5, align 4, !tbaa !11
  %7 = icmp eq i32 %6, 2048
  br i1 %7, label %.loopexit.loopexit, label %19

.loopexit.loopexit:                               ; preds = %4
  %8 = getelementptr inbounds i8, ptr %0, i64 416
  %9 = tail call i32 @run_dsa(ptr noundef nonnull %0)
  %10 = load ptr, ptr @stderr, align 8, !tbaa !12
  %11 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %10, ptr noundef nonnull @.str) #3
  %12 = load ptr, ptr @stderr, align 8, !tbaa !12
  %13 = tail call i32 @fflush(ptr noundef %12)
  store i32 256, ptr %8, align 8, !tbaa !13
  %14 = tail call i32 @run_dsa(ptr noundef nonnull %0)
  %15 = load ptr, ptr @stderr, align 8, !tbaa !12
  %16 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %15, ptr noundef nonnull @.str.1) #3
  %17 = load ptr, ptr @stderr, align 8, !tbaa !12
  %18 = tail call i32 @fflush(ptr noundef %17)
  br label %.loopexit

19:                                               ; preds = %4
  %20 = tail call i32 @run_dsa(ptr noundef nonnull %0)
  br label %.loopexit

21:                                               ; preds = %1
  %22 = tail call i32 @start_async_job(ptr noundef nonnull %0, ptr noundef nonnull @run_dsa) #4
  br label %.loopexit

.loopexit:                                        ; preds = %.loopexit.loopexit, %19, %21
  ret void
}

; Function Attrs: nounwind uwtable
declare hidden i32 @run_dsa(ptr noundef) #0

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

; Function Attrs: nofree nounwind
declare noundef i32 @fflush(ptr nocapture noundef) local_unnamed_addr #1

declare i32 @start_async_job(ptr noundef, ptr noundef) local_unnamed_addr #2

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 = { 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 #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 = { cold nounwind }
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, !10, i64 52}
!6 = !{!"test_params_t", !7, i64 0, !7, i64 8, !10, i64 16, !10, i64 20, !7, i64 24, !10, i64 32, !10, i64 36, !10, i64 40, !10, i64 44, !10, i64 48, !10, i64 52, !7, i64 56, !8, i64 64, !8, i64 128, !8, i64 192, !8, i64 256, !10, i64 320, !10, i64 324, !10, i64 328, !7, i64 336, !7, i64 344, !10, i64 352, !10, i64 356, !10, i64 360, !10, i64 364, !10, i64 368, !10, i64 372, !10, i64 376, !10, i64 380, !10, i64 384, !10, i64 388, !7, i64 392, !7, i64 400, !7, i64 408, !10, i64 416, !10, i64 420}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"int", !8, i64 0}
!11 = !{!6, !10, i64 20}
!12 = !{!7, !7, i64 0}
!13 = !{!6, !10, i64 416}


; Effective O3 passes: CorrelatedValuePropagationPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LICMPass,LoopRotatePass,LoopSimplifyPass,SCCPPass,SROAPass,SimplifyCFGPass,TailCallElimPass