; LLVM IR from mitdbg/deneva :: benchmarks/pps_wl.ll (ZN11PPSWorkload10init_tableEv)

; 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.pps_thr_args = type { ptr, i32, i32 }

@stdout = external global ptr, align 8
@g_init_parallelism = external global i32, align 4
@.str.17 = external hidden unnamed_addr constant [12 x i8], align 1
@.str.18 = external hidden unnamed_addr constant [15 x i8], align 1
@.str.19 = external hidden unnamed_addr constant [16 x i8], align 1
@.str.20 = external hidden unnamed_addr constant [11 x i8], align 1
@.str.21 = external hidden unnamed_addr constant [15 x i8], align 1
@.str.22 = external hidden unnamed_addr constant [33 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 i32 @printf(ptr noundef, ...) #1

declare i32 @fflush(ptr noundef) #1

; Function Attrs: mustprogress uwtable
define dso_local noundef i32 @_ZN11PPSWorkload10init_tableEv(ptr noundef nonnull align 8 dereferenceable(200) %0) unnamed_addr #2 align 2 {
  %2 = alloca ptr, align 8
  %3 = alloca ptr, align 8
  %4 = alloca i32, align 4
  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) #5
  %6 = load i32, ptr @g_init_parallelism, align 4, !tbaa !9
  %7 = zext i32 %6 to i64
  %8 = call { i64, i1 } @llvm.umul.with.overflow.i64(i64 %7, i64 16)
  %9 = extractvalue { i64, i1 } %8, 1
  %10 = extractvalue { i64, i1 } %8, 0
  %11 = select i1 %9, i64 -1, i64 %10
  %12 = call noalias noundef nonnull ptr @_Znam(i64 noundef %11) #6
  store ptr %12, ptr %3, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #5
  store i32 0, ptr %4, align 4, !tbaa !9
  br label %13

13:                                               ; preds = %30, %1
  %14 = load i32, ptr %4, align 4, !tbaa !9
  %15 = load i32, ptr @g_init_parallelism, align 4, !tbaa !9
  %16 = icmp ult i32 %14, %15
  br i1 %16, label %18, label %17

17:                                               ; preds = %13
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #5
  br label %33

18:                                               ; preds = %13
  %19 = load ptr, ptr %3, align 8, !tbaa !5
  %20 = load i32, ptr %4, align 4, !tbaa !9
  %21 = zext i32 %20 to i64
  %22 = getelementptr inbounds %struct.pps_thr_args, ptr %19, i64 %21
  %23 = getelementptr inbounds %struct.pps_thr_args, ptr %22, i32 0, i32 0
  store ptr %5, ptr %23, align 8, !tbaa !11
  %24 = load i32, ptr %4, align 4, !tbaa !9
  %25 = load ptr, ptr %3, align 8, !tbaa !5
  %26 = load i32, ptr %4, align 4, !tbaa !9
  %27 = zext i32 %26 to i64
  %28 = getelementptr inbounds %struct.pps_thr_args, ptr %25, i64 %27
  %29 = getelementptr inbounds %struct.pps_thr_args, ptr %28, i32 0, i32 1
  store i32 %24, ptr %29, align 8, !tbaa !13
  br label %30

30:                                               ; preds = %18
  %31 = load i32, ptr %4, align 4, !tbaa !9
  %32 = add i32 %31, 1
  store i32 %32, ptr %4, align 4, !tbaa !9
  br label %13, !llvm.loop !14

33:                                               ; preds = %17
  %34 = load ptr, ptr %3, align 8, !tbaa !5
  %35 = getelementptr inbounds %struct.pps_thr_args, ptr %34, i64 0
  %36 = call noundef ptr @_ZN11PPSWorkload15threadInitPartsEPv(ptr noundef %35)
  %37 = call i32 (ptr, ...) @printf(ptr noundef @.str.17)
  %38 = load ptr, ptr %3, align 8, !tbaa !5
  %39 = getelementptr inbounds %struct.pps_thr_args, ptr %38, i64 0
  %40 = call noundef ptr @_ZN11PPSWorkload18threadInitProductsEPv(ptr noundef %39)
  %41 = call i32 (ptr, ...) @printf(ptr noundef @.str.18)
  %42 = load ptr, ptr %3, align 8, !tbaa !5
  %43 = getelementptr inbounds %struct.pps_thr_args, ptr %42, i64 0
  %44 = call noundef ptr @_ZN11PPSWorkload19threadInitSuppliersEPv(ptr noundef %43)
  %45 = call i32 (ptr, ...) @printf(ptr noundef @.str.19)
  %46 = load ptr, ptr %3, align 8, !tbaa !5
  %47 = getelementptr inbounds %struct.pps_thr_args, ptr %46, i64 0
  %48 = call noundef ptr @_ZN11PPSWorkload14threadInitUsesEPv(ptr noundef %47)
  %49 = call i32 (ptr, ...) @printf(ptr noundef @.str.20)
  %50 = load ptr, ptr %3, align 8, !tbaa !5
  %51 = getelementptr inbounds %struct.pps_thr_args, ptr %50, i64 0
  %52 = call noundef ptr @_ZN11PPSWorkload18threadInitSuppliesEPv(ptr noundef %51)
  %53 = call i32 (ptr, ...) @printf(ptr noundef @.str.21)
  %54 = load ptr, ptr @stdout, align 8, !tbaa !5
  %55 = call i32 @fflush(ptr noundef %54)
  %56 = call i32 (ptr, ...) @printf(ptr noundef @.str.22)
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #5
  ret i32 0
}

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare { i64, i1 } @llvm.umul.with.overflow.i64(i64, i64) #3

; Function Attrs: nobuiltin allocsize(0)
declare noundef nonnull ptr @_Znam(i64 noundef) #4

; Function Attrs: mustprogress uwtable
declare dso_local noundef ptr @_ZN11PPSWorkload15threadInitPartsEPv(ptr noundef) #2 align 2

; Function Attrs: mustprogress uwtable
declare dso_local noundef ptr @_ZN11PPSWorkload18threadInitProductsEPv(ptr noundef) #2 align 2

; Function Attrs: mustprogress uwtable
declare dso_local noundef ptr @_ZN11PPSWorkload19threadInitSuppliersEPv(ptr noundef) #2 align 2

; Function Attrs: mustprogress uwtable
declare dso_local noundef ptr @_ZN11PPSWorkload14threadInitUsesEPv(ptr noundef) #2 align 2

; Function Attrs: mustprogress uwtable
declare dso_local noundef ptr @_ZN11PPSWorkload18threadInitSuppliesEPv(ptr noundef) #2 align 2

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 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #4 = { nobuiltin allocsize(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 #5 = { nounwind }
attributes #6 = { builtin allocsize(0) }

!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 = !{!"int", !7, i64 0}
!11 = !{!12, !6, i64 0}
!12 = !{!"_ZTS12pps_thr_args", !6, i64 0, !10, i64 8, !10, i64 12}
!13 = !{!12, !10, i64 8}
!14 = distinct !{!14, !15}
!15 = !{!"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"

%struct.pps_thr_args = type { ptr, i32, i32 }

@stdout = external local_unnamed_addr global ptr, align 8
@g_init_parallelism = external local_unnamed_addr global i32, align 4
@.str.17 = external hidden unnamed_addr constant [12 x i8], align 1
@.str.18 = external hidden unnamed_addr constant [15 x i8], align 1
@.str.19 = external hidden unnamed_addr constant [16 x i8], align 1
@.str.20 = external hidden unnamed_addr constant [11 x i8], align 1
@.str.21 = external hidden unnamed_addr constant [15 x i8], align 1
@.str.22 = external hidden unnamed_addr constant [33 x i8], align 1

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

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

; Function Attrs: mustprogress uwtable
define dso_local noundef i32 @_ZN11PPSWorkload10init_tableEv(ptr noundef nonnull align 8 dereferenceable(200) %0) unnamed_addr #1 align 2 {
  %2 = load i32, ptr @g_init_parallelism, align 4, !tbaa !5
  %3 = zext i32 %2 to i64
  %4 = shl nuw nsw i64 %3, 4
  %5 = tail call noalias noundef nonnull ptr @_Znam(i64 noundef %4) #3
  %.not = icmp eq i32 %2, 0
  br i1 %.not, label %._crit_edge, label %.lr.ph.preheader

.lr.ph.preheader:                                 ; preds = %1
  %xtraiter = and i64 %3, 3
  %6 = icmp ult i32 %2, 4
  br i1 %6, label %._crit_edge.loopexit.unr-lcssa, label %.lr.ph.preheader.new

.lr.ph.preheader.new:                             ; preds = %.lr.ph.preheader
  %unroll_iter = and i64 %3, 4294967292
  br label %.lr.ph

._crit_edge.loopexit.unr-lcssa:                   ; preds = %.lr.ph, %.lr.ph.preheader
  %indvars.iv.unr = phi i64 [ 0, %.lr.ph.preheader ], [ %indvars.iv.next.3, %.lr.ph ]
  %lcmp.mod.not = icmp eq i64 %xtraiter, 0
  br i1 %lcmp.mod.not, label %._crit_edge, label %.lr.ph.epil

.lr.ph.epil:                                      ; preds = %._crit_edge.loopexit.unr-lcssa, %.lr.ph.epil
  %indvars.iv.epil = phi i64 [ %indvars.iv.next.epil, %.lr.ph.epil ], [ %indvars.iv.unr, %._crit_edge.loopexit.unr-lcssa ]
  %epil.iter = phi i64 [ %epil.iter.next, %.lr.ph.epil ], [ 0, %._crit_edge.loopexit.unr-lcssa ]
  %7 = getelementptr inbounds %struct.pps_thr_args, ptr %5, i64 %indvars.iv.epil
  store ptr %0, ptr %7, align 8, !tbaa !9
  %8 = getelementptr inbounds i8, ptr %7, i64 8
  %9 = trunc nuw i64 %indvars.iv.epil to i32
  store i32 %9, ptr %8, align 8, !tbaa !12
  %indvars.iv.next.epil = add nuw nsw i64 %indvars.iv.epil, 1
  %epil.iter.next = add i64 %epil.iter, 1
  %epil.iter.cmp.not = icmp eq i64 %epil.iter.next, %xtraiter
  br i1 %epil.iter.cmp.not, label %._crit_edge, label %.lr.ph.epil, !llvm.loop !13

._crit_edge:                                      ; preds = %._crit_edge.loopexit.unr-lcssa, %.lr.ph.epil, %1
  %10 = tail call noundef ptr @_ZN11PPSWorkload15threadInitPartsEPv(ptr noundef nonnull %5)
  %11 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.17)
  %12 = tail call noundef ptr @_ZN11PPSWorkload18threadInitProductsEPv(ptr noundef nonnull %5)
  %13 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.18)
  %14 = tail call noundef ptr @_ZN11PPSWorkload19threadInitSuppliersEPv(ptr noundef nonnull %5)
  %15 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.19)
  %16 = tail call noundef ptr @_ZN11PPSWorkload14threadInitUsesEPv(ptr noundef nonnull %5)
  %17 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.20)
  %18 = tail call noundef ptr @_ZN11PPSWorkload18threadInitSuppliesEPv(ptr noundef nonnull %5)
  %19 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.21)
  %20 = load ptr, ptr @stdout, align 8, !tbaa !15
  %21 = tail call i32 @fflush(ptr noundef %20)
  %22 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.22)
  ret i32 0

.lr.ph:                                           ; preds = %.lr.ph, %.lr.ph.preheader.new
  %indvars.iv = phi i64 [ 0, %.lr.ph.preheader.new ], [ %indvars.iv.next.3, %.lr.ph ]
  %niter = phi i64 [ 0, %.lr.ph.preheader.new ], [ %niter.next.3, %.lr.ph ]
  %23 = getelementptr inbounds %struct.pps_thr_args, ptr %5, i64 %indvars.iv
  store ptr %0, ptr %23, align 8, !tbaa !9
  %24 = getelementptr inbounds i8, ptr %23, i64 8
  %25 = trunc nuw i64 %indvars.iv to i32
  store i32 %25, ptr %24, align 8, !tbaa !12
  %indvars.iv.next = or disjoint i64 %indvars.iv, 1
  %26 = getelementptr inbounds %struct.pps_thr_args, ptr %5, i64 %indvars.iv.next
  store ptr %0, ptr %26, align 8, !tbaa !9
  %27 = getelementptr inbounds i8, ptr %26, i64 8
  %28 = trunc nuw i64 %indvars.iv.next to i32
  store i32 %28, ptr %27, align 8, !tbaa !12
  %indvars.iv.next.1 = or disjoint i64 %indvars.iv, 2
  %29 = getelementptr inbounds %struct.pps_thr_args, ptr %5, i64 %indvars.iv.next.1
  store ptr %0, ptr %29, align 8, !tbaa !9
  %30 = getelementptr inbounds i8, ptr %29, i64 8
  %31 = trunc nuw i64 %indvars.iv.next.1 to i32
  store i32 %31, ptr %30, align 8, !tbaa !12
  %indvars.iv.next.2 = or disjoint i64 %indvars.iv, 3
  %32 = getelementptr inbounds %struct.pps_thr_args, ptr %5, i64 %indvars.iv.next.2
  store ptr %0, ptr %32, align 8, !tbaa !9
  %33 = getelementptr inbounds i8, ptr %32, i64 8
  %34 = trunc nuw i64 %indvars.iv.next.2 to i32
  store i32 %34, ptr %33, align 8, !tbaa !12
  %indvars.iv.next.3 = add nuw nsw i64 %indvars.iv, 4
  %niter.next.3 = add i64 %niter, 4
  %niter.ncmp.3 = icmp eq i64 %niter.next.3, %unroll_iter
  br i1 %niter.ncmp.3, label %._crit_edge.loopexit.unr-lcssa, label %.lr.ph, !llvm.loop !16
}

; Function Attrs: nobuiltin allocsize(0)
declare noundef nonnull ptr @_Znam(i64 noundef) local_unnamed_addr #2

; Function Attrs: mustprogress uwtable
declare dso_local noundef ptr @_ZN11PPSWorkload15threadInitPartsEPv(ptr noundef) local_unnamed_addr #1 align 2

; Function Attrs: mustprogress uwtable
declare dso_local noundef ptr @_ZN11PPSWorkload18threadInitProductsEPv(ptr noundef) local_unnamed_addr #1 align 2

; Function Attrs: mustprogress uwtable
declare dso_local noundef ptr @_ZN11PPSWorkload19threadInitSuppliersEPv(ptr noundef) local_unnamed_addr #1 align 2

; Function Attrs: mustprogress uwtable
declare dso_local noundef ptr @_ZN11PPSWorkload14threadInitUsesEPv(ptr noundef) local_unnamed_addr #1 align 2

; Function Attrs: mustprogress uwtable
declare dso_local noundef ptr @_ZN11PPSWorkload18threadInitSuppliesEPv(ptr noundef) local_unnamed_addr #1 align 2

attributes #0 = { 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 #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 = { nobuiltin allocsize(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 = { builtin allocsize(0) }

!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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !11, i64 0}
!10 = !{!"_ZTS12pps_thr_args", !11, i64 0, !6, i64 8, !6, i64 12}
!11 = !{!"any pointer", !7, i64 0}
!12 = !{!10, !6, i64 8}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.unroll.disable"}
!15 = !{!11, !11, i64 0}
!16 = distinct !{!16, !17}
!17 = !{!"llvm.loop.mustprogress"}


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