; 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
@stderr = external global ptr, align 8
@.str.9 = external hidden unnamed_addr constant [43 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: nounwind
declare i32 @fprintf(ptr noundef, ptr noundef, ...) #1

; 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 i32 @greatest_prng_init_second_pass(i32 noundef %0, i64 noundef %1) #2 {
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = alloca i64, align 8
  %6 = alloca ptr, align 8
  %7 = alloca i32, align 4
  store i32 %0, ptr %4, align 4, !tbaa !5
  store i64 %1, ptr %5, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #3
  %8 = load i32, ptr %4, align 4, !tbaa !5
  %9 = sext i32 %8 to i64
  %10 = getelementptr inbounds [2 x %struct.greatest_prng], ptr getelementptr inbounds (%struct.greatest_run_info, ptr @greatest_info, i32 0, i32 25), i64 0, i64 %9
  store ptr %10, ptr %6, align 8, !tbaa !11
  %11 = load ptr, ptr %6, align 8, !tbaa !11
  %12 = getelementptr inbounds %struct.greatest_prng, ptr %11, i32 0, i32 4
  %13 = load i64, ptr %12, align 8, !tbaa !13
  %14 = icmp eq i64 %13, 0
  br i1 %14, label %15, label %16

15:                                               ; preds = %2
  store i32 0, ptr %3, align 4
  store i32 1, ptr %7, align 4
  br label %78

16:                                               ; preds = %2
  %17 = load ptr, ptr %6, align 8, !tbaa !11
  %18 = getelementptr inbounds %struct.greatest_prng, ptr %17, i32 0, i32 4
  %19 = load i64, ptr %18, align 8, !tbaa !13
  %20 = load ptr, ptr %6, align 8, !tbaa !11
  %21 = getelementptr inbounds %struct.greatest_prng, ptr %20, i32 0, i32 5
  store i64 %19, ptr %21, align 8, !tbaa !15
  %22 = load ptr, ptr %6, align 8, !tbaa !11
  %23 = getelementptr inbounds %struct.greatest_prng, ptr %22, i32 0, i32 9
  store i64 1, ptr %23, align 8, !tbaa !16
  br label %24

24:                                               ; preds = %33, %16
  %25 = load ptr, ptr %6, align 8, !tbaa !11
  %26 = getelementptr inbounds %struct.greatest_prng, ptr %25, i32 0, i32 9
  %27 = load i64, ptr %26, align 8, !tbaa !16
  %28 = load ptr, ptr %6, align 8, !tbaa !11
  %29 = getelementptr inbounds %struct.greatest_prng, ptr %28, i32 0, i32 4
  %30 = load i64, ptr %29, align 8, !tbaa !13
  %31 = icmp ult i64 %27, %30
  br i1 %31, label %32, label %38

32:                                               ; preds = %24
  br label %33

33:                                               ; preds = %32
  %34 = load ptr, ptr %6, align 8, !tbaa !11
  %35 = getelementptr inbounds %struct.greatest_prng, ptr %34, i32 0, i32 9
  %36 = load i64, ptr %35, align 8, !tbaa !16
  %37 = shl i64 %36, 1
  store i64 %37, ptr %35, align 8, !tbaa !16
  br label %24, !llvm.loop !17

38:                                               ; preds = %24
  %39 = load i64, ptr %5, align 8, !tbaa !9
  %40 = and i64 %39, 536870911
  %41 = load ptr, ptr %6, align 8, !tbaa !11
  %42 = getelementptr inbounds %struct.greatest_prng, ptr %41, i32 0, i32 3
  store i64 %40, ptr %42, align 8, !tbaa !19
  %43 = load ptr, ptr %6, align 8, !tbaa !11
  %44 = getelementptr inbounds %struct.greatest_prng, ptr %43, i32 0, i32 3
  %45 = load i64, ptr %44, align 8, !tbaa !19
  %46 = mul i64 4, %45
  %47 = load ptr, ptr %6, align 8, !tbaa !11
  %48 = getelementptr inbounds %struct.greatest_prng, ptr %47, i32 0, i32 7
  store i64 %46, ptr %48, align 8, !tbaa !20
  %49 = load ptr, ptr %6, align 8, !tbaa !11
  %50 = getelementptr inbounds %struct.greatest_prng, ptr %49, i32 0, i32 7
  %51 = load i64, ptr %50, align 8, !tbaa !20
  %52 = icmp ne i64 %51, 0
  br i1 %52, label %53, label %57

53:                                               ; preds = %38
  %54 = load ptr, ptr %6, align 8, !tbaa !11
  %55 = getelementptr inbounds %struct.greatest_prng, ptr %54, i32 0, i32 7
  %56 = load i64, ptr %55, align 8, !tbaa !20
  br label %58

57:                                               ; preds = %38
  br label %58

58:                                               ; preds = %57, %53
  %59 = phi i64 [ %56, %53 ], [ 4, %57 ]
  %60 = or i64 %59, 1
  %61 = load ptr, ptr %6, align 8, !tbaa !11
  %62 = getelementptr inbounds %struct.greatest_prng, ptr %61, i32 0, i32 7
  store i64 %60, ptr %62, align 8, !tbaa !20
  %63 = load ptr, ptr %6, align 8, !tbaa !11
  %64 = getelementptr inbounds %struct.greatest_prng, ptr %63, i32 0, i32 8
  store i64 2147483647, ptr %64, align 8, !tbaa !21
  %65 = load ptr, ptr %6, align 8, !tbaa !11
  %66 = getelementptr inbounds %struct.greatest_prng, ptr %65, i32 0, i32 1
  store i8 1, ptr %66, align 1, !tbaa !22
  %67 = load ptr, ptr @stderr, align 8, !tbaa !11
  %68 = load ptr, ptr %6, align 8, !tbaa !11
  %69 = getelementptr inbounds %struct.greatest_prng, ptr %68, i32 0, i32 7
  %70 = load i64, ptr %69, align 8, !tbaa !20
  %71 = load ptr, ptr %6, align 8, !tbaa !11
  %72 = getelementptr inbounds %struct.greatest_prng, ptr %71, i32 0, i32 8
  %73 = load i64, ptr %72, align 8, !tbaa !21
  %74 = load ptr, ptr %6, align 8, !tbaa !11
  %75 = getelementptr inbounds %struct.greatest_prng, ptr %74, i32 0, i32 3
  %76 = load i64, ptr %75, align 8, !tbaa !19
  %77 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %67, ptr noundef @.str.9, i64 noundef %70, i64 noundef %73, i64 noundef %76) #3
  store i32 1, ptr %3, align 4
  store i32 1, ptr %7, align 4
  br label %78

78:                                               ; preds = %58, %15
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #3
  %79 = load i32, ptr %3, align 4
  ret i32 %79
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 = { 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 #3 = { 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 = !{!"long", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"any pointer", !7, i64 0}
!13 = !{!14, !10, i64 16}
!14 = !{!"greatest_prng", !7, i64 0, !7, i64 1, !7, i64 2, !10, i64 8, !10, i64 16, !10, i64 24, !10, i64 32, !10, i64 40, !10, i64 48, !10, i64 56}
!15 = !{!14, !10, i64 24}
!16 = !{!14, !10, i64 56}
!17 = distinct !{!17, !18}
!18 = !{!"llvm.loop.mustprogress"}
!19 = !{!14, !10, i64 8}
!20 = !{!14, !10, i64 40}
!21 = !{!14, !10, i64 48}
!22 = !{!14, !7, i64 1}


; 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
@stderr = external local_unnamed_addr global ptr, align 8
@.str.9 = external hidden unnamed_addr constant [43 x i8], align 1

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

; Function Attrs: nofree nounwind uwtable
define dso_local range(i32 0, 2) i32 @greatest_prng_init_second_pass(i32 noundef %0, i64 noundef %1) local_unnamed_addr #1 {
  %3 = sext i32 %0 to i64
  %4 = getelementptr inbounds [2 x %struct.greatest_prng], ptr getelementptr inbounds (i8, ptr @greatest_info, i64 296), i64 0, i64 %3
  %5 = getelementptr inbounds i8, ptr %4, i64 16
  %6 = load i64, ptr %5, align 8, !tbaa !5
  %7 = icmp eq i64 %6, 0
  br i1 %7, label %24, label %8

8:                                                ; preds = %2
  %9 = getelementptr inbounds i8, ptr %4, i64 24
  store i64 %6, ptr %9, align 8, !tbaa !10
  br label %10

10:                                               ; preds = %10, %8
  %storemerge = phi i64 [ 1, %8 ], [ %12, %10 ]
  %11 = icmp ult i64 %storemerge, %6
  %12 = shl i64 %storemerge, 1
  br i1 %11, label %10, label %13, !llvm.loop !11

13:                                               ; preds = %10
  %14 = getelementptr inbounds i8, ptr %4, i64 56
  store i64 %storemerge, ptr %14, align 8, !tbaa !13
  %15 = and i64 %1, 536870911
  %16 = getelementptr inbounds i8, ptr %4, i64 8
  store i64 %15, ptr %16, align 8, !tbaa !14
  %17 = shl nuw nsw i64 %15, 2
  %18 = getelementptr inbounds i8, ptr %4, i64 40
  %.not = icmp eq i64 %15, 0
  %19 = or disjoint i64 %17, 1
  %spec.select = select i1 %.not, i64 5, i64 %19
  store i64 %spec.select, ptr %18, align 8, !tbaa !15
  %20 = getelementptr inbounds i8, ptr %4, i64 48
  store i64 2147483647, ptr %20, align 8, !tbaa !16
  %21 = getelementptr inbounds i8, ptr %4, i64 1
  store i8 1, ptr %21, align 1, !tbaa !17
  %22 = load ptr, ptr @stderr, align 8, !tbaa !18
  %23 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %22, ptr noundef nonnull @.str.9, i64 noundef %spec.select, i64 noundef 2147483647, i64 noundef %15) #2
  br label %24

24:                                               ; preds = %2, %13
  %.0 = phi i32 [ 1, %13 ], [ 0, %2 ]
  ret i32 %.0
}

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 = { nofree 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 = { cold 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, !9, i64 16}
!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 24}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = !{!6, !9, i64 56}
!14 = !{!6, !9, i64 8}
!15 = !{!6, !9, i64 40}
!16 = !{!6, !9, i64 48}
!17 = !{!6, !7, i64 1}
!18 = !{!19, !19, i64 0}
!19 = !{!"any pointer", !7, i64 0}


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