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

; 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 }

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

9:                                                ; preds = %1
  %10 = load ptr, ptr %2, align 8, !tbaa !5
  %11 = getelementptr inbounds %struct.test_params_t, ptr %10, i32 0, i32 22
  %12 = load i32, ptr %11, align 4, !tbaa !13
  %13 = icmp ne i32 %12, -1
  br i1 %13, label %14, label %34

14:                                               ; preds = %9, %1
  %15 = load ptr, ptr %2, align 8, !tbaa !5
  %16 = getelementptr inbounds %struct.test_params_t, ptr %15, i32 0, i32 22
  %17 = load i32, ptr %16, align 4, !tbaa !13
  %18 = icmp eq i32 %17, -1
  br i1 %18, label %19, label %22

19:                                               ; preds = %14
  %20 = load ptr, ptr %2, align 8, !tbaa !5
  %21 = getelementptr inbounds %struct.test_params_t, ptr %20, i32 0, i32 22
  store i32 0, ptr %21, align 4, !tbaa !13
  br label %22

22:                                               ; preds = %19, %14
  %23 = load ptr, ptr %2, align 8, !tbaa !5
  %24 = getelementptr inbounds %struct.test_params_t, ptr %23, i32 0, i32 10
  %25 = load i32, ptr %24, align 4, !tbaa !14
  %26 = icmp ne i32 %25, 0
  br i1 %26, label %30, label %27

27:                                               ; preds = %22
  %28 = load ptr, ptr %2, align 8, !tbaa !5
  %29 = call i32 @runHkdfOps(ptr noundef %28)
  br label %33

30:                                               ; preds = %22
  %31 = load ptr, ptr %2, align 8, !tbaa !5
  %32 = call i32 @start_async_job(ptr noundef %31, ptr noundef @runHkdfOps)
  br label %33

33:                                               ; preds = %30, %27
  store i32 1, ptr %4, align 4
  br label %68

34:                                               ; preds = %9
  %35 = load ptr, ptr %2, align 8, !tbaa !5
  %36 = getelementptr inbounds %struct.test_params_t, ptr %35, i32 0, i32 10
  %37 = load i32, ptr %36, align 4, !tbaa !14
  %38 = icmp ne i32 %37, 0
  br i1 %38, label %53, label %39

39:                                               ; preds = %34
  store i32 0, ptr %3, align 4, !tbaa !9
  br label %40

40:                                               ; preds = %49, %39
  %41 = load i32, ptr %3, align 4, !tbaa !9
  %42 = icmp sle i32 %41, 2
  br i1 %42, label %43, label %52

43:                                               ; preds = %40
  %44 = load i32, ptr %3, align 4, !tbaa !9
  %45 = load ptr, ptr %2, align 8, !tbaa !5
  %46 = getelementptr inbounds %struct.test_params_t, ptr %45, i32 0, i32 22
  store i32 %44, ptr %46, align 4, !tbaa !13
  %47 = load ptr, ptr %2, align 8, !tbaa !5
  %48 = call i32 @runHkdfOps(ptr noundef %47)
  br label %49

49:                                               ; preds = %43
  %50 = load i32, ptr %3, align 4, !tbaa !9
  %51 = add nsw i32 %50, 1
  store i32 %51, ptr %3, align 4, !tbaa !9
  br label %40, !llvm.loop !15

52:                                               ; preds = %40
  br label %67

53:                                               ; preds = %34
  store i32 0, ptr %3, align 4, !tbaa !9
  br label %54

54:                                               ; preds = %63, %53
  %55 = load i32, ptr %3, align 4, !tbaa !9
  %56 = icmp sle i32 %55, 2
  br i1 %56, label %57, label %66

57:                                               ; preds = %54
  %58 = load i32, ptr %3, align 4, !tbaa !9
  %59 = load ptr, ptr %2, align 8, !tbaa !5
  %60 = getelementptr inbounds %struct.test_params_t, ptr %59, i32 0, i32 22
  store i32 %58, ptr %60, align 4, !tbaa !13
  %61 = load ptr, ptr %2, align 8, !tbaa !5
  %62 = call i32 @start_async_job(ptr noundef %61, ptr noundef @runHkdfOps)
  br label %63

63:                                               ; preds = %57
  %64 = load i32, ptr %3, align 4, !tbaa !9
  %65 = add nsw i32 %64, 1
  store i32 %65, ptr %3, align 4, !tbaa !9
  br label %54, !llvm.loop !17

66:                                               ; preds = %54
  br label %67

67:                                               ; preds = %66, %52
  store i32 0, ptr %4, align 4
  br label %68

68:                                               ; preds = %67, %33
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #3
  %69 = load i32, ptr %4, align 4
  switch i32 %69, label %71 [
    i32 0, label %70
    i32 1, label %70
  ]

70:                                               ; preds = %68, %68
  ret void

71:                                               ; preds = %68
  unreachable
}

; 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 @runHkdfOps(ptr noundef) #0

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

; 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 = { "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 40}
!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 356}
!14 = !{!12, !10, i64 52}
!15 = distinct !{!15, !16}
!16 = !{!"llvm.loop.mustprogress"}
!17 = distinct !{!17, !16}


; 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 void @tests_run_hkdf(ptr noundef %0) local_unnamed_addr #0 {
  %2 = getelementptr inbounds i8, ptr %0, i64 40
  %3 = load i32, ptr %2, align 8, !tbaa !5
  %.not = icmp eq i32 %3, 0
  %4 = getelementptr inbounds i8, ptr %0, i64 356
  %5 = load i32, ptr %4, align 4, !tbaa !11
  %.not17 = icmp eq i32 %5, -1
  br i1 %.not, label %6, label %7

6:                                                ; preds = %1
  br i1 %.not17, label %16, label %.thread

7:                                                ; preds = %1
  br i1 %.not17, label %8, label %.thread

8:                                                ; preds = %7
  %9 = getelementptr inbounds i8, ptr %0, i64 356
  store i32 0, ptr %9, align 4, !tbaa !11
  br label %.thread

.thread:                                          ; preds = %6, %8, %7
  %10 = getelementptr inbounds i8, ptr %0, i64 52
  %11 = load i32, ptr %10, align 4, !tbaa !12
  %.not19 = icmp eq i32 %11, 0
  br i1 %.not19, label %12, label %14

12:                                               ; preds = %.thread
  %13 = tail call i32 @runHkdfOps(ptr noundef nonnull %0)
  br label %.loopexit

14:                                               ; preds = %.thread
  %15 = tail call i32 @start_async_job(ptr noundef nonnull %0, ptr noundef nonnull @runHkdfOps) #2
  br label %.loopexit

16:                                               ; preds = %6
  %17 = getelementptr inbounds i8, ptr %0, i64 52
  %18 = load i32, ptr %17, align 4, !tbaa !12
  %.not18 = icmp eq i32 %18, 0
  store i32 0, ptr %4, align 4, !tbaa !11
  br i1 %.not18, label %.preheader.preheader, label %.preheader20.preheader

.preheader20.preheader:                           ; preds = %16
  %19 = tail call i32 @start_async_job(ptr noundef nonnull %0, ptr noundef nonnull @runHkdfOps) #2
  store i32 1, ptr %4, align 4, !tbaa !11
  %20 = tail call i32 @start_async_job(ptr noundef nonnull %0, ptr noundef nonnull @runHkdfOps) #2
  store i32 2, ptr %4, align 4, !tbaa !11
  %21 = tail call i32 @start_async_job(ptr noundef nonnull %0, ptr noundef nonnull @runHkdfOps) #2
  br label %.loopexit

.preheader.preheader:                             ; preds = %16
  %22 = tail call i32 @runHkdfOps(ptr noundef nonnull %0)
  store i32 1, ptr %4, align 4, !tbaa !11
  %23 = tail call i32 @runHkdfOps(ptr noundef nonnull %0)
  store i32 2, ptr %4, align 4, !tbaa !11
  %24 = tail call i32 @runHkdfOps(ptr noundef nonnull %0)
  br label %.loopexit

.loopexit:                                        ; preds = %.preheader20.preheader, %.preheader.preheader, %12, %14
  ret void
}

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

declare i32 @start_async_job(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, !10, i64 40}
!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 356}
!12 = !{!6, !10, i64 52}


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