; LLVM IR from mitdbg/deneva :: benchmarks/tpcc_query.ll (ZN9TPCCQuery5printEv)

; 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.TPCCQuery = type { %class.BaseQuery, i32, i64, i64, i64, i64, i64, i64, [16 x i8], double, i8, %class.Array.0, i8, i8, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64 }
%class.BaseQuery = type { ptr, i64, %class.Array, %class.Array, %class.Array, %class.Array }
%class.Array = type { ptr, i64, i64 }
%class.Array.0 = type { ptr, i64, i64 }
%struct.Item_no = type { i64, i64, i64 }

@.str = external hidden unnamed_addr constant [86 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [8 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [6 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [2 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 @_ZN9TPCCQuery5printEv(ptr noundef nonnull align 8 dereferenceable(320) %0) unnamed_addr #1 align 2 {
  %2 = alloca ptr, align 8
  %3 = alloca i64, align 8
  store ptr %0, ptr %2, align 8, !tbaa !5
  %4 = load ptr, ptr %2, align 8
  %5 = getelementptr inbounds %class.TPCCQuery, ptr %4, i32 0, i32 1
  %6 = load i32, ptr %5, align 8, !tbaa !9
  %7 = getelementptr inbounds %class.TPCCQuery, ptr %4, i32 0, i32 2
  %8 = load i64, ptr %7, align 8, !tbaa !18
  %9 = getelementptr inbounds %class.TPCCQuery, ptr %4, i32 0, i32 3
  %10 = load i64, ptr %9, align 8, !tbaa !19
  %11 = getelementptr inbounds %class.TPCCQuery, ptr %4, i32 0, i32 4
  %12 = load i64, ptr %11, align 8, !tbaa !20
  %13 = getelementptr inbounds %class.TPCCQuery, ptr %4, i32 0, i32 5
  %14 = load i64, ptr %13, align 8, !tbaa !21
  %15 = getelementptr inbounds %class.TPCCQuery, ptr %4, i32 0, i32 6
  %16 = load i64, ptr %15, align 8, !tbaa !22
  %17 = getelementptr inbounds %class.TPCCQuery, ptr %4, i32 0, i32 7
  %18 = load i64, ptr %17, align 8, !tbaa !23
  %19 = call i32 (ptr, ...) @printf(ptr noundef @.str, i32 noundef %6, i64 noundef %8, i64 noundef %10, i64 noundef %12, i64 noundef %14, i64 noundef %16, i64 noundef %18)
  %20 = getelementptr inbounds %class.TPCCQuery, ptr %4, i32 0, i32 1
  %21 = load i32, ptr %20, align 8, !tbaa !9
  %22 = icmp eq i32 %21, 2
  br i1 %22, label %23, label %43

23:                                               ; preds = %1
  %24 = call i32 (ptr, ...) @printf(ptr noundef @.str.1)
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #4
  store i64 0, ptr %3, align 8, !tbaa !24
  br label %25

25:                                               ; preds = %38, %23
  %26 = load i64, ptr %3, align 8, !tbaa !24
  %27 = getelementptr inbounds %class.TPCCQuery, ptr %4, i32 0, i32 11
  %28 = call noundef i64 @_ZN5ArrayIP7Item_noE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %27)
  %29 = icmp ult i64 %26, %28
  br i1 %29, label %31, label %30

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

31:                                               ; preds = %25
  %32 = getelementptr inbounds %class.TPCCQuery, ptr %4, i32 0, i32 11
  %33 = load i64, ptr %3, align 8, !tbaa !24
  %34 = call noundef ptr @_ZN5ArrayIP7Item_noEixEm(ptr noundef nonnull align 8 dereferenceable(24) %32, i64 noundef %33)
  %35 = getelementptr inbounds %struct.Item_no, ptr %34, i32 0, i32 0
  %36 = load i64, ptr %35, align 8, !tbaa !25
  %37 = call i32 (ptr, ...) @printf(ptr noundef @.str.2, i64 noundef %36)
  br label %38

38:                                               ; preds = %31
  %39 = load i64, ptr %3, align 8, !tbaa !24
  %40 = add i64 %39, 1
  store i64 %40, ptr %3, align 8, !tbaa !24
  br label %25, !llvm.loop !27

41:                                               ; preds = %30
  %42 = call i32 (ptr, ...) @printf(ptr noundef @.str.3)
  br label %43

43:                                               ; preds = %41, %1
  ret void
}

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

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef ptr @_ZN5ArrayIP7Item_noEixEm(ptr noundef nonnull align 8 dereferenceable(24), i64 noundef) #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, !14, i64 112}
!10 = !{!"_ZTS9TPCCQuery", !11, i64 0, !14, i64 112, !12, i64 120, !12, i64 128, !12, i64 136, !12, i64 144, !12, i64 152, !12, i64 160, !7, i64 168, !15, i64 184, !16, i64 192, !17, i64 200, !16, i64 224, !16, i64 225, !12, i64 232, !12, i64 240, !12, i64 248, !12, i64 256, !12, i64 264, !12, i64 272, !12, i64 280, !12, i64 288, !12, i64 296, !12, i64 304, !12, i64 312}
!11 = !{!"_ZTS9BaseQuery", !12, i64 8, !13, i64 16, !13, i64 40, !13, i64 64, !13, i64 88}
!12 = !{!"long", !7, i64 0}
!13 = !{!"_ZTS5ArrayImE", !6, i64 0, !12, i64 8, !12, i64 16}
!14 = !{!"_ZTS11TPCCTxnType", !7, i64 0}
!15 = !{!"double", !7, i64 0}
!16 = !{!"bool", !7, i64 0}
!17 = !{!"_ZTS5ArrayIP7Item_noE", !6, i64 0, !12, i64 8, !12, i64 16}
!18 = !{!10, !12, i64 120}
!19 = !{!10, !12, i64 128}
!20 = !{!10, !12, i64 136}
!21 = !{!10, !12, i64 144}
!22 = !{!10, !12, i64 152}
!23 = !{!10, !12, i64 160}
!24 = !{!12, !12, i64 0}
!25 = !{!26, !12, i64 0}
!26 = !{!"_ZTS7Item_no", !12, i64 0, !12, i64 8, !12, i64 16}
!27 = distinct !{!27, !28}
!28 = !{!"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"

@.str = external hidden unnamed_addr constant [86 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [8 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [6 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [2 x i8], align 1

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @_ZN9TPCCQuery5printEv(ptr noundef nonnull align 8 dereferenceable(320) %0) unnamed_addr #0 align 2 {
  %2 = getelementptr inbounds i8, ptr %0, i64 112
  %3 = load i32, ptr %2, align 8, !tbaa !5
  %4 = getelementptr inbounds i8, ptr %0, i64 120
  %5 = load i64, ptr %4, align 8, !tbaa !17
  %6 = getelementptr inbounds i8, ptr %0, i64 128
  %7 = load i64, ptr %6, align 8, !tbaa !18
  %8 = getelementptr inbounds i8, ptr %0, i64 136
  %9 = load i64, ptr %8, align 8, !tbaa !19
  %10 = getelementptr inbounds i8, ptr %0, i64 144
  %11 = load i64, ptr %10, align 8, !tbaa !20
  %12 = getelementptr inbounds i8, ptr %0, i64 152
  %13 = load i64, ptr %12, align 8, !tbaa !21
  %14 = getelementptr inbounds i8, ptr %0, i64 160
  %15 = load i64, ptr %14, align 8, !tbaa !22
  %16 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, i32 noundef %3, i64 noundef %5, i64 noundef %7, i64 noundef %9, i64 noundef %11, i64 noundef %13, i64 noundef %15)
  %17 = load i32, ptr %2, align 8, !tbaa !5
  %18 = icmp eq i32 %17, 2
  br i1 %18, label %19, label %30

19:                                               ; preds = %1
  %20 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.1)
  %21 = getelementptr inbounds i8, ptr %0, i64 200
  %22 = tail call noundef i64 @_ZN5ArrayIP7Item_noE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %21)
  %.not = icmp eq i64 %22, 0
  br i1 %.not, label %._crit_edge, label %.lr.ph

._crit_edge:                                      ; preds = %.lr.ph, %19
  %23 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.3)
  br label %30

.lr.ph:                                           ; preds = %19, %.lr.ph
  %.03 = phi i64 [ %27, %.lr.ph ], [ 0, %19 ]
  %24 = tail call noundef ptr @_ZN5ArrayIP7Item_noEixEm(ptr noundef nonnull align 8 dereferenceable(24) %21, i64 noundef %.03)
  %25 = load i64, ptr %24, align 8, !tbaa !23
  %26 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2, i64 noundef %25)
  %27 = add nuw i64 %.03, 1
  %28 = tail call noundef i64 @_ZN5ArrayIP7Item_noE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %21)
  %29 = icmp ult i64 %27, %28
  br i1 %29, label %.lr.ph, label %._crit_edge, !llvm.loop !25

30:                                               ; preds = %._crit_edge, %1
  ret void
}

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i64 @_ZN5ArrayIP7Item_noE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24)) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef ptr @_ZN5ArrayIP7Item_noEixEm(ptr noundef nonnull align 8 dereferenceable(24), i64 noundef) local_unnamed_addr #0 align 2

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

!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, !13, i64 112}
!6 = !{!"_ZTS9TPCCQuery", !7, i64 0, !13, i64 112, !8, i64 120, !8, i64 128, !8, i64 136, !8, i64 144, !8, i64 152, !8, i64 160, !9, i64 168, !14, i64 184, !15, i64 192, !16, i64 200, !15, i64 224, !15, i64 225, !8, i64 232, !8, i64 240, !8, i64 248, !8, i64 256, !8, i64 264, !8, i64 272, !8, i64 280, !8, i64 288, !8, i64 296, !8, i64 304, !8, i64 312}
!7 = !{!"_ZTS9BaseQuery", !8, i64 8, !11, i64 16, !11, i64 40, !11, i64 64, !11, i64 88}
!8 = !{!"long", !9, i64 0}
!9 = !{!"omnipotent char", !10, i64 0}
!10 = !{!"Simple C++ TBAA"}
!11 = !{!"_ZTS5ArrayImE", !12, i64 0, !8, i64 8, !8, i64 16}
!12 = !{!"any pointer", !9, i64 0}
!13 = !{!"_ZTS11TPCCTxnType", !9, i64 0}
!14 = !{!"double", !9, i64 0}
!15 = !{!"bool", !9, i64 0}
!16 = !{!"_ZTS5ArrayIP7Item_noE", !12, i64 0, !8, i64 8, !8, i64 16}
!17 = !{!6, !8, i64 120}
!18 = !{!6, !8, i64 128}
!19 = !{!6, !8, i64 136}
!20 = !{!6, !8, i64 144}
!21 = !{!6, !8, i64 152}
!22 = !{!6, !8, i64 160}
!23 = !{!24, !8, i64 0}
!24 = !{!"_ZTS7Item_no", !8, i64 0, !8, i64 8, !8, i64 16}
!25 = distinct !{!25, !26}
!26 = !{!"llvm.loop.mustprogress"}


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