; LLVM IR from stivalaa/EstimNetDirected :: src/Random123-1.09/examples (pi_cppapi)

; 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.r123::ReinterpretCtr" = type { i8 }
%struct.r123array4x64 = type { [4 x i64] }
%struct.r123array8x32 = type { [8 x i32] }

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

; Function Attrs: mustprogress uwtable
declare dso_local noundef i32 @_Z8pi_checkmm(i64 noundef, i64 noundef) #0

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #1

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

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main(i32 noundef %0, ptr noundef %1) #3 {
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = alloca ptr, align 8
  %6 = alloca i64, align 8
  %7 = alloca i64, align 8
  %8 = alloca i64, align 8
  %9 = alloca %"struct.r123::ReinterpretCtr", align 1
  %10 = alloca %struct.r123array4x64, align 8
  %11 = alloca %struct.r123array8x32, align 4
  %12 = alloca %struct.r123array8x32, align 4
  %13 = alloca %struct.r123array8x32, align 8
  %14 = alloca %struct.r123array4x64, align 8
  %15 = alloca i64, align 8
  %16 = alloca i64, align 8
  %17 = alloca i64, align 8
  store i32 0, ptr %3, align 4
  store i32 %0, ptr %4, align 4, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #7
  store i64 0, ptr %6, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #7
  store i64 0, ptr %7, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #7
  store i64 4611686018427387904, ptr %8, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 1, ptr %9) #7
  call void @llvm.lifetime.start.p0(i64 32, ptr %10) #7
  call void @llvm.memset.p0.i64(ptr align 8 %10, i8 0, i64 32, i1 false)
  call void @llvm.lifetime.start.p0(i64 32, ptr %11) #7
  call void @llvm.memset.p0.i64(ptr align 4 %11, i8 0, i64 32, i1 false)
  %18 = call i32 (ptr, ...) @printf(ptr noundef @.str.6, i64 noundef 10000000)
  br label %19

19:                                               ; preds = %56, %2
  %20 = load i64, ptr %7, align 8, !tbaa !11
  %21 = icmp ult i64 %20, 10000000
  br i1 %21, label %22, label %57

22:                                               ; preds = %19
  %23 = call noundef nonnull align 4 dereferenceable(32) ptr @_ZN13r123array8x324incrEy(ptr noundef nonnull align 4 dereferenceable(32) %11, i64 noundef 1)
  call void @llvm.lifetime.start.p0(i64 32, ptr %12) #7
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %13, ptr align 4 %11, i64 32, i1 false), !tbaa.struct !13
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %14, ptr align 8 %10, i64 32, i1 false), !tbaa.struct !13
  call void @_ZN4r12314ReinterpretCtrI13r123array8x32NS_14Threefry4x64_RILj20EEEEclES1_13r123array4x64(ptr dead_on_unwind writable sret(%struct.r123array8x32) align 4 %12, ptr noundef nonnull align 1 dereferenceable(1) %9, ptr noundef byval(%struct.r123array8x32) align 8 %13, ptr noundef byval(%struct.r123array4x64) align 8 %14)
  call void @llvm.lifetime.start.p0(i64 8, ptr %15) #7
  store i64 0, ptr %15, align 8, !tbaa !11
  br label %24

24:                                               ; preds = %53, %22
  %25 = load i64, ptr %15, align 8, !tbaa !11
  %26 = call noundef i64 @_ZNK13r123array8x324sizeEv(ptr noundef nonnull align 4 dereferenceable(32) %12)
  %27 = icmp ult i64 %25, %26
  br i1 %27, label %29, label %28

28:                                               ; preds = %24
  call void @llvm.lifetime.end.p0(i64 8, ptr %15) #7
  br label %56

29:                                               ; preds = %24
  call void @llvm.lifetime.start.p0(i64 8, ptr %16) #7
  %30 = load i64, ptr %15, align 8, !tbaa !11
  %31 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZN13r123array8x32ixEm(ptr noundef nonnull align 4 dereferenceable(32) %12, i64 noundef %30)
  %32 = load i32, ptr %31, align 4, !tbaa !5
  %33 = sext i32 %32 to i64
  store i64 %33, ptr %16, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %17) #7
  %34 = load i64, ptr %15, align 8, !tbaa !11
  %35 = add i64 %34, 1
  %36 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZN13r123array8x32ixEm(ptr noundef nonnull align 4 dereferenceable(32) %12, i64 noundef %35)
  %37 = load i32, ptr %36, align 4, !tbaa !5
  %38 = sext i32 %37 to i64
  store i64 %38, ptr %17, align 8, !tbaa !11
  %39 = load i64, ptr %16, align 8, !tbaa !11
  %40 = load i64, ptr %16, align 8, !tbaa !11
  %41 = mul nsw i64 %39, %40
  %42 = load i64, ptr %17, align 8, !tbaa !11
  %43 = load i64, ptr %17, align 8, !tbaa !11
  %44 = mul nsw i64 %42, %43
  %45 = add nsw i64 %41, %44
  %46 = icmp slt i64 %45, 4611686018427387904
  br i1 %46, label %47, label %50

47:                                               ; preds = %29
  %48 = load i64, ptr %6, align 8, !tbaa !11
  %49 = add i64 %48, 1
  store i64 %49, ptr %6, align 8, !tbaa !11
  br label %50

50:                                               ; preds = %47, %29
  %51 = load i64, ptr %7, align 8, !tbaa !11
  %52 = add i64 %51, 1
  store i64 %52, ptr %7, align 8, !tbaa !11
  call void @llvm.lifetime.end.p0(i64 8, ptr %17) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %16) #7
  br label %53

53:                                               ; preds = %50
  %54 = load i64, ptr %15, align 8, !tbaa !11
  %55 = add i64 %54, 2
  store i64 %55, ptr %15, align 8, !tbaa !11
  br label %24, !llvm.loop !15

56:                                               ; preds = %28
  call void @llvm.lifetime.end.p0(i64 32, ptr %12) #7
  br label %19, !llvm.loop !17

57:                                               ; preds = %19
  %58 = load i64, ptr %6, align 8, !tbaa !11
  %59 = load i64, ptr %7, align 8, !tbaa !11
  %60 = call noundef i32 @_Z8pi_checkmm(i64 noundef %58, i64 noundef %59)
  call void @llvm.lifetime.end.p0(i64 32, ptr %11) #7
  call void @llvm.lifetime.end.p0(i64 32, ptr %10) #7
  call void @llvm.lifetime.end.p0(i64 1, ptr %9) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #7
  ret i32 %60
}

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #4

; Function Attrs: mustprogress uwtable
declare dso_local noundef nonnull align 4 dereferenceable(32) ptr @_ZN13r123array8x324incrEy(ptr noundef nonnull align 4 dereferenceable(32), i64 noundef) #0 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN4r12314ReinterpretCtrI13r123array8x32NS_14Threefry4x64_RILj20EEEEclES1_13r123array4x64(ptr dead_on_unwind noalias writable sret(%struct.r123array8x32) align 4, ptr noundef nonnull align 1 dereferenceable(1), ptr noundef byval(%struct.r123array8x32) align 8, ptr noundef byval(%struct.r123array4x64) align 8) #0 align 2

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #5

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i64 @_ZNK13r123array8x324sizeEv(ptr noundef nonnull align 4 dereferenceable(32)) #6 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 4 dereferenceable(4) ptr @_ZN13r123array8x32ixEm(ptr noundef nonnull align 4 dereferenceable(32), i64 noundef) #6 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 = { 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 = { mustprogress norecurse 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 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #5 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #6 = { 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 #7 = { 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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"any pointer", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"long", !7, i64 0}
!13 = !{i64 0, i64 32, !14}
!14 = !{!7, !7, i64 0}
!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"

%"struct.r123::ReinterpretCtr" = type { i8 }
%struct.r123array8x32 = type { [8 x i32] }
%struct.r123array4x64 = type { [4 x i64] }

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

; Function Attrs: mustprogress uwtable
declare dso_local noundef i32 @_Z8pi_checkmm(i64 noundef, i64 noundef) local_unnamed_addr #0

; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #1

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

; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main(i32 noundef %0, ptr nocapture noundef readnone %1) local_unnamed_addr #3 {
  %3 = alloca %"struct.r123::ReinterpretCtr", align 1
  %4 = alloca %struct.r123array8x32, align 8
  %5 = alloca %struct.r123array8x32, align 4
  %6 = alloca %struct.r123array4x64, align 8
  call void @llvm.lifetime.start.p0(i64 1, ptr nonnull %3) #6
  call void @llvm.lifetime.start.p0(i64 32, ptr nonnull %4) #6
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(32) %4, i8 0, i64 32, i1 false)
  %7 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.6, i64 noundef 10000000)
  br label %8

8:                                                ; preds = %2, %._crit_edge
  %.021 = phi i64 [ 0, %2 ], [ %.1.lcssa, %._crit_edge ]
  %.01320 = phi i64 [ 0, %2 ], [ %.114.lcssa, %._crit_edge ]
  %9 = call noundef nonnull align 4 dereferenceable(32) ptr @_ZN13r123array8x324incrEy(ptr noundef nonnull align 4 dereferenceable(32) %4, i64 noundef 1)
  call void @llvm.lifetime.start.p0(i64 32, ptr nonnull %5) #6
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(32) %6, i8 0, i64 32, i1 false)
  call void @_ZN4r12314ReinterpretCtrI13r123array8x32NS_14Threefry4x64_RILj20EEEEclES1_13r123array4x64(ptr dead_on_unwind nonnull writable sret(%struct.r123array8x32) align 4 %5, ptr noundef nonnull align 1 dereferenceable(1) %3, ptr noundef nonnull byval(%struct.r123array8x32) align 8 %4, ptr noundef nonnull byval(%struct.r123array4x64) align 8 %6)
  %10 = call noundef i64 @_ZNK13r123array8x324sizeEv(ptr noundef nonnull align 4 dereferenceable(32) %5)
  %.not = icmp eq i64 %10, 0
  br i1 %.not, label %._crit_edge, label %.lr.ph

._crit_edge:                                      ; preds = %.lr.ph, %8
  %.114.lcssa = phi i64 [ %.01320, %8 ], [ %24, %.lr.ph ]
  %.1.lcssa = phi i64 [ %.021, %8 ], [ %spec.select, %.lr.ph ]
  call void @llvm.lifetime.end.p0(i64 32, ptr nonnull %5) #6
  %11 = icmp ult i64 %.114.lcssa, 10000000
  br i1 %11, label %8, label %28, !llvm.loop !5

.lr.ph:                                           ; preds = %8, %.lr.ph
  %.118 = phi i64 [ %spec.select, %.lr.ph ], [ %.021, %8 ]
  %.11417 = phi i64 [ %24, %.lr.ph ], [ %.01320, %8 ]
  %.01516 = phi i64 [ %25, %.lr.ph ], [ 0, %8 ]
  %12 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZN13r123array8x32ixEm(ptr noundef nonnull align 4 dereferenceable(32) %5, i64 noundef %.01516)
  %13 = load i32, ptr %12, align 4, !tbaa !7
  %14 = sext i32 %13 to i64
  %15 = or disjoint i64 %.01516, 1
  %16 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZN13r123array8x32ixEm(ptr noundef nonnull align 4 dereferenceable(32) %5, i64 noundef %15)
  %17 = load i32, ptr %16, align 4, !tbaa !7
  %18 = sext i32 %17 to i64
  %19 = mul nsw i64 %14, %14
  %20 = mul nsw i64 %18, %18
  %21 = add nuw nsw i64 %20, %19
  %22 = icmp ult i64 %21, 4611686018427387904
  %23 = zext i1 %22 to i64
  %spec.select = add i64 %.118, %23
  %24 = add i64 %.11417, 1
  %25 = add i64 %.01516, 2
  %26 = call noundef i64 @_ZNK13r123array8x324sizeEv(ptr noundef nonnull align 4 dereferenceable(32) %5)
  %27 = icmp ult i64 %25, %26
  br i1 %27, label %.lr.ph, label %._crit_edge, !llvm.loop !11

28:                                               ; preds = %._crit_edge
  %29 = call noundef i32 @_Z8pi_checkmm(i64 noundef %.1.lcssa, i64 noundef %.114.lcssa)
  call void @llvm.lifetime.end.p0(i64 32, ptr nonnull %4) #6
  call void @llvm.lifetime.end.p0(i64 1, ptr nonnull %3) #6
  ret i32 %29
}

; Function Attrs: mustprogress nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #4

; Function Attrs: mustprogress uwtable
declare dso_local noundef nonnull align 4 dereferenceable(32) ptr @_ZN13r123array8x324incrEy(ptr noundef nonnull align 4 dereferenceable(32), i64 noundef) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN4r12314ReinterpretCtrI13r123array8x32NS_14Threefry4x64_RILj20EEEEclES1_13r123array4x64(ptr dead_on_unwind noalias writable sret(%struct.r123array8x32) align 4, ptr noundef nonnull align 1 dereferenceable(1), ptr noundef byval(%struct.r123array8x32) align 8, ptr noundef byval(%struct.r123array4x64) align 8) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i64 @_ZNK13r123array8x324sizeEv(ptr noundef nonnull align 4 dereferenceable(32)) local_unnamed_addr #5 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 4 dereferenceable(4) ptr @_ZN13r123array8x32ixEm(ptr noundef nonnull align 4 dereferenceable(32), i64 noundef) local_unnamed_addr #5 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 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { 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 #3 = { mustprogress norecurse 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 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #5 = { 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 #6 = { 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 = distinct !{!5, !6}
!6 = !{!"llvm.loop.mustprogress"}
!7 = !{!8, !8, i64 0}
!8 = !{!"int", !9, i64 0}
!9 = !{!"omnipotent char", !10, i64 0}
!10 = !{!"Simple C++ TBAA"}
!11 = distinct !{!11, !6}


; Effective O3 passes: CorrelatedValuePropagationPass,DSEPass,GVNPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,MemCpyOptPass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass