; LLVM IR from mitdbg/deneva :: system/pool.ll (ZN7QryPool3putEmP9BaseQuery)

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

%class.mem_alloc = type { i8 }
%class.QryPool = type { ptr, ptr }

@mem_allocator = external global %class.mem_alloc, align 1
@.str = external hidden unnamed_addr constant [5 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [63 x i8], align 1
@__PRETTY_FUNCTION__._ZN7QryPool3putEmP9BaseQuery = external hidden unnamed_addr constant [41 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

declare void @_ZN9mem_alloc4freeEPvm(ptr noundef nonnull align 1 dereferenceable(1), ptr noundef, i64 noundef) #1

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN7QryPool3putEmP9BaseQuery(ptr noundef nonnull align 8 dereferenceable(16) %0, i64 noundef %1, ptr noundef %2) #2 align 2 {
  %4 = alloca ptr, align 8
  %5 = alloca i64, align 8
  %6 = alloca ptr, align 8
  %7 = alloca i32, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  store i64 %1, ptr %5, align 8, !tbaa !9
  store ptr %2, ptr %6, align 8, !tbaa !5
  %8 = load ptr, ptr %4, align 8
  %9 = load ptr, ptr %6, align 8, !tbaa !5
  %10 = icmp ne ptr %9, null
  br i1 %10, label %11, label %12

11:                                               ; preds = %3
  br label %14

12:                                               ; preds = %3
  call void @__assert_fail(ptr noundef @.str, ptr noundef @.str.1, i32 noundef 212, ptr noundef @__PRETTY_FUNCTION__._ZN7QryPool3putEmP9BaseQuery) #4
  unreachable

13:                                               ; No predecessors!
  br label %14

14:                                               ; preds = %13, %11
  %15 = load ptr, ptr %6, align 8, !tbaa !5
  call void @_ZN9YCSBQuery5resetEv(ptr noundef nonnull align 8 dereferenceable(136) %15)
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #5
  store i32 0, ptr %7, align 4, !tbaa !11
  br label %16

16:                                               ; preds = %29, %14
  %17 = getelementptr inbounds %class.QryPool, ptr %8, i32 0, i32 0
  %18 = load ptr, ptr %17, align 8, !tbaa !13
  %19 = load i64, ptr %5, align 8, !tbaa !9
  %20 = getelementptr inbounds ptr, ptr %18, i64 %19
  %21 = load ptr, ptr %20, align 8, !tbaa !5
  %22 = call noundef zeroext i1 @_ZN5boost8lockfree5queueIP9BaseQueryJEE4pushERKS3_(ptr noundef nonnull align 8 dereferenceable(136) %21, ptr noundef nonnull align 8 dereferenceable(8) %6)
  br i1 %22, label %27, label %23

23:                                               ; preds = %16
  %24 = load i32, ptr %7, align 4, !tbaa !11
  %25 = add nsw i32 %24, 1
  store i32 %25, ptr %7, align 4, !tbaa !11
  %26 = icmp slt i32 %24, 10
  br label %27

27:                                               ; preds = %23, %16
  %28 = phi i1 [ false, %16 ], [ %26, %23 ]
  br i1 %28, label %29, label %30

29:                                               ; preds = %27
  br label %16, !llvm.loop !15

30:                                               ; preds = %27
  %31 = load i32, ptr %7, align 4, !tbaa !11
  %32 = icmp sge i32 %31, 10
  br i1 %32, label %33, label %36

33:                                               ; preds = %30
  %34 = load ptr, ptr %6, align 8, !tbaa !5
  call void @_ZN9YCSBQuery7releaseEv(ptr noundef nonnull align 8 dereferenceable(136) %34)
  %35 = load ptr, ptr %6, align 8, !tbaa !5
  call void @_ZN9mem_alloc4freeEPvm(ptr noundef nonnull align 1 dereferenceable(1) @mem_allocator, ptr noundef %35, i64 noundef 112)
  br label %36

36:                                               ; preds = %33, %30
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #5
  ret void
}

; Function Attrs: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) #3

declare void @_ZN9YCSBQuery5resetEv(ptr noundef nonnull align 8 dereferenceable(136)) #1

; Function Attrs: mustprogress uwtable
declare dso_local noundef zeroext i1 @_ZN5boost8lockfree5queueIP9BaseQueryJEE4pushERKS3_(ptr noundef nonnull align 8 dereferenceable(136), ptr noundef nonnull align 8 dereferenceable(8)) #2 align 2

declare void @_ZN9YCSBQuery7releaseEv(ptr noundef nonnull align 8 dereferenceable(136)) #1

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { mustprogress 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 #3 = { noreturn 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 #4 = { noreturn nounwind }
attributes #5 = { 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++ 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 = !{!"_ZTS7QryPool", !6, i64 0, !6, i64 8}
!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"

%class.mem_alloc = type { i8 }

@mem_allocator = external global %class.mem_alloc, align 1
@.str = external hidden unnamed_addr constant [5 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [63 x i8], align 1
@__PRETTY_FUNCTION__._ZN7QryPool3putEmP9BaseQuery = external hidden unnamed_addr constant [41 x i8], align 1

declare void @_ZN9mem_alloc4freeEPvm(ptr noundef nonnull align 1 dereferenceable(1), ptr noundef, i64 noundef) local_unnamed_addr #0

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN7QryPool3putEmP9BaseQuery(ptr nocapture noundef nonnull readonly align 8 dereferenceable(16) %0, i64 noundef %1, ptr noundef %2) local_unnamed_addr #1 align 2 {
  %4 = alloca ptr, align 8
  store ptr %2, ptr %4, align 8, !tbaa !5
  %.not = icmp eq ptr %2, null
  br i1 %.not, label %5, label %6

5:                                                ; preds = %3
  tail call void @__assert_fail(ptr noundef nonnull @.str, ptr noundef nonnull @.str.1, i32 noundef 212, ptr noundef nonnull @__PRETTY_FUNCTION__._ZN7QryPool3putEmP9BaseQuery) #3
  unreachable

6:                                                ; preds = %3
  tail call void @_ZN9YCSBQuery5resetEv(ptr noundef nonnull align 8 dereferenceable(136) %2)
  %7 = load ptr, ptr %0, align 8, !tbaa !9
  %8 = getelementptr inbounds ptr, ptr %7, i64 %1
  %9 = load ptr, ptr %8, align 8, !tbaa !5
  %10 = call noundef zeroext i1 @_ZN5boost8lockfree5queueIP9BaseQueryJEE4pushERKS3_(ptr noundef nonnull align 8 dereferenceable(136) %9, ptr noundef nonnull align 8 dereferenceable(8) %4)
  br i1 %10, label %.critedge.thread, label %11

11:                                               ; preds = %6
  %12 = load ptr, ptr %0, align 8, !tbaa !9
  %13 = getelementptr inbounds ptr, ptr %12, i64 %1
  %14 = load ptr, ptr %13, align 8, !tbaa !5
  %15 = call noundef zeroext i1 @_ZN5boost8lockfree5queueIP9BaseQueryJEE4pushERKS3_(ptr noundef nonnull align 8 dereferenceable(136) %14, ptr noundef nonnull align 8 dereferenceable(8) %4)
  br i1 %15, label %.critedge.thread, label %16

16:                                               ; preds = %11
  %17 = load ptr, ptr %0, align 8, !tbaa !9
  %18 = getelementptr inbounds ptr, ptr %17, i64 %1
  %19 = load ptr, ptr %18, align 8, !tbaa !5
  %20 = call noundef zeroext i1 @_ZN5boost8lockfree5queueIP9BaseQueryJEE4pushERKS3_(ptr noundef nonnull align 8 dereferenceable(136) %19, ptr noundef nonnull align 8 dereferenceable(8) %4)
  br i1 %20, label %.critedge.thread, label %21

21:                                               ; preds = %16
  %22 = load ptr, ptr %0, align 8, !tbaa !9
  %23 = getelementptr inbounds ptr, ptr %22, i64 %1
  %24 = load ptr, ptr %23, align 8, !tbaa !5
  %25 = call noundef zeroext i1 @_ZN5boost8lockfree5queueIP9BaseQueryJEE4pushERKS3_(ptr noundef nonnull align 8 dereferenceable(136) %24, ptr noundef nonnull align 8 dereferenceable(8) %4)
  br i1 %25, label %.critedge.thread, label %26

26:                                               ; preds = %21
  %27 = load ptr, ptr %0, align 8, !tbaa !9
  %28 = getelementptr inbounds ptr, ptr %27, i64 %1
  %29 = load ptr, ptr %28, align 8, !tbaa !5
  %30 = call noundef zeroext i1 @_ZN5boost8lockfree5queueIP9BaseQueryJEE4pushERKS3_(ptr noundef nonnull align 8 dereferenceable(136) %29, ptr noundef nonnull align 8 dereferenceable(8) %4)
  br i1 %30, label %.critedge.thread, label %31

31:                                               ; preds = %26
  %32 = load ptr, ptr %0, align 8, !tbaa !9
  %33 = getelementptr inbounds ptr, ptr %32, i64 %1
  %34 = load ptr, ptr %33, align 8, !tbaa !5
  %35 = call noundef zeroext i1 @_ZN5boost8lockfree5queueIP9BaseQueryJEE4pushERKS3_(ptr noundef nonnull align 8 dereferenceable(136) %34, ptr noundef nonnull align 8 dereferenceable(8) %4)
  br i1 %35, label %.critedge.thread, label %36

36:                                               ; preds = %31
  %37 = load ptr, ptr %0, align 8, !tbaa !9
  %38 = getelementptr inbounds ptr, ptr %37, i64 %1
  %39 = load ptr, ptr %38, align 8, !tbaa !5
  %40 = call noundef zeroext i1 @_ZN5boost8lockfree5queueIP9BaseQueryJEE4pushERKS3_(ptr noundef nonnull align 8 dereferenceable(136) %39, ptr noundef nonnull align 8 dereferenceable(8) %4)
  br i1 %40, label %.critedge.thread, label %41

41:                                               ; preds = %36
  %42 = load ptr, ptr %0, align 8, !tbaa !9
  %43 = getelementptr inbounds ptr, ptr %42, i64 %1
  %44 = load ptr, ptr %43, align 8, !tbaa !5
  %45 = call noundef zeroext i1 @_ZN5boost8lockfree5queueIP9BaseQueryJEE4pushERKS3_(ptr noundef nonnull align 8 dereferenceable(136) %44, ptr noundef nonnull align 8 dereferenceable(8) %4)
  br i1 %45, label %.critedge.thread, label %46

46:                                               ; preds = %41
  %47 = load ptr, ptr %0, align 8, !tbaa !9
  %48 = getelementptr inbounds ptr, ptr %47, i64 %1
  %49 = load ptr, ptr %48, align 8, !tbaa !5
  %50 = call noundef zeroext i1 @_ZN5boost8lockfree5queueIP9BaseQueryJEE4pushERKS3_(ptr noundef nonnull align 8 dereferenceable(136) %49, ptr noundef nonnull align 8 dereferenceable(8) %4)
  br i1 %50, label %.critedge.thread, label %51

51:                                               ; preds = %46
  %52 = load ptr, ptr %0, align 8, !tbaa !9
  %53 = getelementptr inbounds ptr, ptr %52, i64 %1
  %54 = load ptr, ptr %53, align 8, !tbaa !5
  %55 = call noundef zeroext i1 @_ZN5boost8lockfree5queueIP9BaseQueryJEE4pushERKS3_(ptr noundef nonnull align 8 dereferenceable(136) %54, ptr noundef nonnull align 8 dereferenceable(8) %4)
  br i1 %55, label %.critedge.thread, label %.critedge

.critedge:                                        ; preds = %51
  %56 = load ptr, ptr %0, align 8, !tbaa !9
  %57 = getelementptr inbounds ptr, ptr %56, i64 %1
  %58 = load ptr, ptr %57, align 8, !tbaa !5
  %59 = call noundef zeroext i1 @_ZN5boost8lockfree5queueIP9BaseQueryJEE4pushERKS3_(ptr noundef nonnull align 8 dereferenceable(136) %58, ptr noundef nonnull align 8 dereferenceable(8) %4)
  %60 = load ptr, ptr %4, align 8, !tbaa !5
  call void @_ZN9YCSBQuery7releaseEv(ptr noundef nonnull align 8 dereferenceable(136) %60)
  %61 = load ptr, ptr %4, align 8, !tbaa !5
  call void @_ZN9mem_alloc4freeEPvm(ptr noundef nonnull align 1 dereferenceable(1) @mem_allocator, ptr noundef %61, i64 noundef 112)
  br label %.critedge.thread

.critedge.thread:                                 ; preds = %51, %46, %41, %36, %31, %26, %21, %16, %11, %6, %.critedge
  ret void
}

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

declare void @_ZN9YCSBQuery5resetEv(ptr noundef nonnull align 8 dereferenceable(136)) local_unnamed_addr #0

; Function Attrs: mustprogress uwtable
declare dso_local noundef zeroext i1 @_ZN5boost8lockfree5queueIP9BaseQueryJEE4pushERKS3_(ptr noundef nonnull align 8 dereferenceable(136), ptr noundef nonnull align 8 dereferenceable(8)) local_unnamed_addr #1 align 2

declare void @_ZN9YCSBQuery7releaseEv(ptr noundef nonnull align 8 dereferenceable(136)) local_unnamed_addr #0

attributes #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 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 = { noreturn 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 = { noreturn 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++ TBAA"}
!9 = !{!10, !6, i64 0}
!10 = !{!"_ZTS7QryPool", !6, i64 0, !6, i64 8}


; Effective O3 passes: ADCEPass,EarlyCSEPass,GVNPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass