; LLVM IR from jdeokkim/ferox :: tests/src (ferox_tests)

; 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.greatest_run_info = type { i8, i8, i8, i8, i32, %struct.greatest_suite_info, i32, i32, i32, i32, i32, i32, ptr, ptr, ptr, ptr, ptr, ptr, i32, i32, ptr, ptr, ptr, ptr, [128 x i8], [2 x %struct.greatest_prng], i64, i64 }
%struct.greatest_suite_info = type { i32, i32, i32, i32, i64, i64, i64, i64 }
%struct.greatest_prng = type { i8, i8, [6 x i8], i64, i64, i64, i64, i64, i64, i64 }

@greatest_info = external dso_local global %struct.greatest_run_info, align 8

; 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: nounwind uwtable
define dso_local void @greatest_prng_step(i32 noundef %0) #1 {
  %2 = alloca i32, align 4
  %3 = alloca ptr, align 8
  store i32 %0, ptr %2, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #2
  %4 = load i32, ptr %2, align 4, !tbaa !5
  %5 = sext i32 %4 to i64
  %6 = getelementptr inbounds [2 x %struct.greatest_prng], ptr getelementptr inbounds (%struct.greatest_run_info, ptr @greatest_info, i32 0, i32 25), i64 0, i64 %5
  store ptr %6, ptr %3, align 8, !tbaa !9
  br label %7

7:                                                ; preds = %26, %1
  %8 = load ptr, ptr %3, align 8, !tbaa !9
  %9 = getelementptr inbounds %struct.greatest_prng, ptr %8, i32 0, i32 7
  %10 = load i64, ptr %9, align 8, !tbaa !11
  %11 = load ptr, ptr %3, align 8, !tbaa !9
  %12 = getelementptr inbounds %struct.greatest_prng, ptr %11, i32 0, i32 3
  %13 = load i64, ptr %12, align 8, !tbaa !14
  %14 = mul i64 %10, %13
  %15 = load ptr, ptr %3, align 8, !tbaa !9
  %16 = getelementptr inbounds %struct.greatest_prng, ptr %15, i32 0, i32 8
  %17 = load i64, ptr %16, align 8, !tbaa !15
  %18 = add i64 %14, %17
  %19 = load ptr, ptr %3, align 8, !tbaa !9
  %20 = getelementptr inbounds %struct.greatest_prng, ptr %19, i32 0, i32 9
  %21 = load i64, ptr %20, align 8, !tbaa !16
  %22 = sub i64 %21, 1
  %23 = and i64 %18, %22
  %24 = load ptr, ptr %3, align 8, !tbaa !9
  %25 = getelementptr inbounds %struct.greatest_prng, ptr %24, i32 0, i32 3
  store i64 %23, ptr %25, align 8, !tbaa !14
  br label %26

26:                                               ; preds = %7
  %27 = load ptr, ptr %3, align 8, !tbaa !9
  %28 = getelementptr inbounds %struct.greatest_prng, ptr %27, i32 0, i32 3
  %29 = load i64, ptr %28, align 8, !tbaa !14
  %30 = load ptr, ptr %3, align 8, !tbaa !9
  %31 = getelementptr inbounds %struct.greatest_prng, ptr %30, i32 0, i32 5
  %32 = load i64, ptr %31, align 8, !tbaa !17
  %33 = icmp uge i64 %29, %32
  br i1 %33, label %7, label %34, !llvm.loop !18

34:                                               ; preds = %26
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #2
  ret void
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #2 = { 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/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"any pointer", !7, i64 0}
!11 = !{!12, !13, i64 40}
!12 = !{!"greatest_prng", !7, i64 0, !7, i64 1, !7, i64 2, !13, i64 8, !13, i64 16, !13, i64 24, !13, i64 32, !13, i64 40, !13, i64 48, !13, i64 56}
!13 = !{!"long", !7, i64 0}
!14 = !{!12, !13, i64 8}
!15 = !{!12, !13, i64 48}
!16 = !{!12, !13, i64 56}
!17 = !{!12, !13, i64 24}
!18 = distinct !{!18, !19}
!19 = !{!"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.greatest_run_info = type { i8, i8, i8, i8, i32, %struct.greatest_suite_info, i32, i32, i32, i32, i32, i32, ptr, ptr, ptr, ptr, ptr, ptr, i32, i32, ptr, ptr, ptr, ptr, [128 x i8], [2 x %struct.greatest_prng], i64, i64 }
%struct.greatest_suite_info = type { i32, i32, i32, i32, i64, i64, i64, i64 }
%struct.greatest_prng = type { i8, i8, [6 x i8], i64, i64, i64, i64, i64, i64, i64 }

@greatest_info = external dso_local local_unnamed_addr global %struct.greatest_run_info, align 8

; Function Attrs: nofree norecurse nosync nounwind memory(readwrite, argmem: none, inaccessiblemem: none) uwtable
define dso_local void @greatest_prng_step(i32 noundef %0) local_unnamed_addr #0 {
  %2 = sext i32 %0 to i64
  %3 = getelementptr inbounds [2 x %struct.greatest_prng], ptr getelementptr inbounds (i8, ptr @greatest_info, i64 296), i64 0, i64 %2
  %4 = getelementptr inbounds i8, ptr %3, i64 40
  %5 = load i64, ptr %4, align 8, !tbaa !5
  %6 = getelementptr inbounds i8, ptr %3, i64 8
  %7 = getelementptr inbounds i8, ptr %3, i64 48
  %8 = load i64, ptr %7, align 8, !tbaa !10
  %9 = getelementptr inbounds i8, ptr %3, i64 56
  %10 = load i64, ptr %9, align 8, !tbaa !11
  %11 = add i64 %10, -1
  %12 = getelementptr inbounds i8, ptr %3, i64 24
  %13 = load i64, ptr %12, align 8, !tbaa !12
  %.promoted = load i64, ptr %6, align 8, !tbaa !13
  br label %14

14:                                               ; preds = %14, %1
  %15 = phi i64 [ %18, %14 ], [ %.promoted, %1 ]
  %16 = mul i64 %15, %5
  %17 = add i64 %16, %8
  %18 = and i64 %11, %17
  %.not = icmp ult i64 %18, %13
  br i1 %.not, label %19, label %14, !llvm.loop !14

19:                                               ; preds = %14
  store i64 %18, ptr %6, align 8, !tbaa !13
  ret void
}

attributes #0 = { nofree norecurse nosync nounwind memory(readwrite, argmem: none, inaccessiblemem: none) 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, !9, i64 40}
!6 = !{!"greatest_prng", !7, i64 0, !7, i64 1, !7, i64 2, !9, i64 8, !9, i64 16, !9, i64 24, !9, i64 32, !9, i64 40, !9, i64 48, !9, i64 56}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!"long", !7, i64 0}
!10 = !{!6, !9, i64 48}
!11 = !{!6, !9, i64 56}
!12 = !{!6, !9, i64 24}
!13 = !{!6, !9, i64 8}
!14 = distinct !{!14, !15}
!15 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,LCSSAPass,LICMPass,LoopUnrollPass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,SimplifyCFGPass