; LLVM IR from mitdbg/deneva :: system/txn_table.ll (ZN8TxnTable4dumpEv)

; 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.TxnTable = type { i64, ptr }
%struct.pool_node = type { ptr, ptr, i8, i64, i64 }
%struct.txn_node = type { ptr, i64, i64, i64, ptr, ptr }

@.str = external hidden unnamed_addr constant [14 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: mustprogress uwtable
define dso_local void @_ZN8TxnTable4dumpEv(ptr noundef nonnull align 8 dereferenceable(16) %0) #1 align 2 {
  %2 = alloca ptr, align 8
  %3 = alloca i64, align 8
  %4 = alloca ptr, align 8
  store ptr %0, ptr %2, align 8, !tbaa !5
  %5 = load ptr, ptr %2, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #4
  store i64 0, ptr %3, align 8, !tbaa !9
  br label %6

6:                                                ; preds = %47, %1
  %7 = load i64, ptr %3, align 8, !tbaa !9
  %8 = getelementptr inbounds %class.TxnTable, ptr %5, i32 0, i32 0
  %9 = load i64, ptr %8, align 8, !tbaa !11
  %10 = icmp ult i64 %7, %9
  br i1 %10, label %12, label %11

11:                                               ; preds = %6
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #4
  br label %50

12:                                               ; preds = %6
  %13 = getelementptr inbounds %class.TxnTable, ptr %5, i32 0, i32 1
  %14 = load ptr, ptr %13, align 8, !tbaa !13
  %15 = load i64, ptr %3, align 8, !tbaa !9
  %16 = getelementptr inbounds ptr, ptr %14, i64 %15
  %17 = load ptr, ptr %16, align 8, !tbaa !5
  %18 = getelementptr inbounds %struct.pool_node, ptr %17, i32 0, i32 3
  %19 = load i64, ptr %18, align 8, !tbaa !14
  %20 = icmp eq i64 %19, 0
  br i1 %20, label %21, label %22

21:                                               ; preds = %12
  br label %47

22:                                               ; preds = %12
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #4
  %23 = getelementptr inbounds %class.TxnTable, ptr %5, i32 0, i32 1
  %24 = load ptr, ptr %23, align 8, !tbaa !13
  %25 = load i64, ptr %3, align 8, !tbaa !9
  %26 = getelementptr inbounds ptr, ptr %24, i64 %25
  %27 = load ptr, ptr %26, align 8, !tbaa !5
  %28 = getelementptr inbounds %struct.pool_node, ptr %27, i32 0, i32 0
  %29 = load ptr, ptr %28, align 8, !tbaa !17
  store ptr %29, ptr %4, align 8, !tbaa !5
  br label %30

30:                                               ; preds = %33, %22
  %31 = load ptr, ptr %4, align 8, !tbaa !5
  %32 = icmp ne ptr %31, null
  br i1 %32, label %33, label %46

33:                                               ; preds = %30
  %34 = load ptr, ptr %4, align 8, !tbaa !5
  %35 = getelementptr inbounds %struct.txn_node, ptr %34, i32 0, i32 0
  %36 = load ptr, ptr %35, align 8, !tbaa !18
  %37 = call noundef i64 @_ZN10TxnManager10get_txn_idEv(ptr noundef nonnull align 8 dereferenceable(544) %36)
  %38 = load ptr, ptr %4, align 8, !tbaa !5
  %39 = getelementptr inbounds %struct.txn_node, ptr %38, i32 0, i32 0
  %40 = load ptr, ptr %39, align 8, !tbaa !18
  %41 = call noundef i64 @_ZN10TxnManager12get_batch_idEv(ptr noundef nonnull align 8 dereferenceable(544) %40)
  %42 = call i32 (ptr, ...) @printf(ptr noundef @.str, i64 noundef %37, i64 noundef %41)
  %43 = load ptr, ptr %4, align 8, !tbaa !5
  %44 = getelementptr inbounds %struct.txn_node, ptr %43, i32 0, i32 4
  %45 = load ptr, ptr %44, align 8, !tbaa !20
  store ptr %45, ptr %4, align 8, !tbaa !5
  br label %30, !llvm.loop !21

46:                                               ; preds = %30
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #4
  br label %47

47:                                               ; preds = %46, %21
  %48 = load i64, ptr %3, align 8, !tbaa !9
  %49 = add i64 %48, 1
  store i64 %49, ptr %3, align 8, !tbaa !9
  br label %6, !llvm.loop !23

50:                                               ; preds = %11
  ret void
}

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

declare noundef i64 @_ZN10TxnManager10get_txn_idEv(ptr noundef nonnull align 8 dereferenceable(544)) #2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i64 @_ZN10TxnManager12get_batch_idEv(ptr noundef nonnull align 8 dereferenceable(544)) #3 align 2

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { "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 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 #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++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"long", !7, i64 0}
!11 = !{!12, !10, i64 0}
!12 = !{!"_ZTS8TxnTable", !10, i64 0, !6, i64 8}
!13 = !{!12, !6, i64 8}
!14 = !{!15, !10, i64 24}
!15 = !{!"_ZTS9pool_node", !6, i64 0, !6, i64 8, !16, i64 16, !10, i64 24, !10, i64 32}
!16 = !{!"bool", !7, i64 0}
!17 = !{!15, !6, i64 0}
!18 = !{!19, !6, i64 0}
!19 = !{!"_ZTS8txn_node", !6, i64 0, !10, i64 8, !10, i64 16, !10, i64 24, !6, i64 32, !6, i64 40}
!20 = !{!19, !6, i64 32}
!21 = distinct !{!21, !22}
!22 = !{!"llvm.loop.mustprogress"}
!23 = distinct !{!23, !22}


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

@.str = external hidden unnamed_addr constant [14 x i8], align 1

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN8TxnTable4dumpEv(ptr nocapture noundef nonnull readonly align 8 dereferenceable(16) %0) local_unnamed_addr #0 align 2 {
  %2 = load i64, ptr %0, align 8, !tbaa !5
  %.not14 = icmp eq i64 %2, 0
  br i1 %.not14, label %._crit_edge, label %.lr.ph13

.lr.ph13:                                         ; preds = %1
  %3 = getelementptr inbounds i8, ptr %0, i64 8
  br label %4

._crit_edge:                                      ; preds = %.loopexit, %1
  ret void

4:                                                ; preds = %.lr.ph13, %.loopexit
  %5 = phi i64 [ %2, %.lr.ph13 ], [ %18, %.loopexit ]
  %.0812 = phi i64 [ 0, %.lr.ph13 ], [ %19, %.loopexit ]
  %6 = load ptr, ptr %3, align 8, !tbaa !11
  %7 = getelementptr inbounds ptr, ptr %6, i64 %.0812
  %8 = load ptr, ptr %7, align 8, !tbaa !12
  %9 = getelementptr inbounds i8, ptr %8, i64 24
  %10 = load i64, ptr %9, align 8, !tbaa !13
  %11 = icmp eq i64 %10, 0
  br i1 %11, label %.loopexit, label %.preheader

.preheader:                                       ; preds = %4
  %.09 = load ptr, ptr %8, align 8, !tbaa !12
  %.not10 = icmp eq ptr %.09, null
  br i1 %.not10, label %.loopexit, label %.lr.ph

.lr.ph:                                           ; preds = %.preheader, %.lr.ph
  %.011 = phi ptr [ %.0, %.lr.ph ], [ %.09, %.preheader ]
  %12 = load ptr, ptr %.011, align 8, !tbaa !16
  %13 = tail call noundef i64 @_ZN10TxnManager10get_txn_idEv(ptr noundef nonnull align 8 dereferenceable(544) %12)
  %14 = load ptr, ptr %.011, align 8, !tbaa !16
  %15 = tail call noundef i64 @_ZN10TxnManager12get_batch_idEv(ptr noundef nonnull align 8 dereferenceable(544) %14)
  %16 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, i64 noundef %13, i64 noundef %15)
  %17 = getelementptr inbounds i8, ptr %.011, i64 32
  %.0 = load ptr, ptr %17, align 8, !tbaa !12
  %.not = icmp eq ptr %.0, null
  br i1 %.not, label %.loopexit.loopexit, label %.lr.ph, !llvm.loop !18

.loopexit.loopexit:                               ; preds = %.lr.ph
  %.pre = load i64, ptr %0, align 8, !tbaa !5
  br label %.loopexit

.loopexit:                                        ; preds = %.loopexit.loopexit, %.preheader, %4
  %18 = phi i64 [ %.pre, %.loopexit.loopexit ], [ %5, %.preheader ], [ %5, %4 ]
  %19 = add nuw i64 %.0812, 1
  %20 = icmp ult i64 %19, %18
  br i1 %20, label %4, label %._crit_edge, !llvm.loop !20
}

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

declare noundef i64 @_ZN10TxnManager10get_txn_idEv(ptr noundef nonnull align 8 dereferenceable(544)) local_unnamed_addr #2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i64 @_ZN10TxnManager12get_batch_idEv(ptr noundef nonnull align 8 dereferenceable(544)) local_unnamed_addr #3 align 2

attributes #0 = { 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 #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 = { mustprogress 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" }

!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, !7, i64 0}
!6 = !{!"_ZTS8TxnTable", !7, i64 0, !10, i64 8}
!7 = !{!"long", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"any pointer", !8, i64 0}
!11 = !{!6, !10, i64 8}
!12 = !{!10, !10, i64 0}
!13 = !{!14, !7, i64 24}
!14 = !{!"_ZTS9pool_node", !10, i64 0, !10, i64 8, !15, i64 16, !7, i64 24, !7, i64 32}
!15 = !{!"bool", !8, i64 0}
!16 = !{!17, !10, i64 0}
!17 = !{!"_ZTS8txn_node", !10, i64 0, !7, i64 8, !7, i64 16, !7, i64 24, !10, i64 32, !10, i64 40}
!18 = distinct !{!18, !19}
!19 = !{!"llvm.loop.mustprogress"}
!20 = distinct !{!20, !19}


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