; LLVM IR from mickypaganini/SSI2016-jet-clustering :: spartyjet-4.0.2_mac/External/fastjet-3.0.0/src (BasicRandom)

; 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"

; Function Attrs: mustprogress nounwind uwtable
define dso_local noundef i32 @_ZN7fastjet26__default_random_generatorEPi(ptr noundef %0) #0 {
  %2 = alloca ptr, align 8
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  store ptr %0, ptr %2, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #2
  %5 = load ptr, ptr %2, align 8, !tbaa !5
  %6 = getelementptr inbounds i32, ptr %5, i64 0
  %7 = load i32, ptr %6, align 4, !tbaa !9
  %8 = sdiv i32 %7, 53668
  store i32 %8, ptr %3, align 4, !tbaa !9
  %9 = load ptr, ptr %2, align 8, !tbaa !5
  %10 = getelementptr inbounds i32, ptr %9, i64 0
  %11 = load i32, ptr %10, align 4, !tbaa !9
  %12 = load i32, ptr %3, align 4, !tbaa !9
  %13 = mul nsw i32 %12, 53668
  %14 = sub nsw i32 %11, %13
  %15 = mul nsw i32 %14, 40014
  %16 = load i32, ptr %3, align 4, !tbaa !9
  %17 = mul nsw i32 %16, 12211
  %18 = sub nsw i32 %15, %17
  %19 = load ptr, ptr %2, align 8, !tbaa !5
  %20 = getelementptr inbounds i32, ptr %19, i64 0
  store i32 %18, ptr %20, align 4, !tbaa !9
  %21 = load ptr, ptr %2, align 8, !tbaa !5
  %22 = getelementptr inbounds i32, ptr %21, i64 0
  %23 = load i32, ptr %22, align 4, !tbaa !9
  %24 = icmp slt i32 %23, 0
  br i1 %24, label %25, label %30

25:                                               ; preds = %1
  %26 = load ptr, ptr %2, align 8, !tbaa !5
  %27 = getelementptr inbounds i32, ptr %26, i64 0
  %28 = load i32, ptr %27, align 4, !tbaa !9
  %29 = add nsw i32 %28, 2147483563
  store i32 %29, ptr %27, align 4, !tbaa !9
  br label %30

30:                                               ; preds = %25, %1
  %31 = load ptr, ptr %2, align 8, !tbaa !5
  %32 = getelementptr inbounds i32, ptr %31, i64 1
  %33 = load i32, ptr %32, align 4, !tbaa !9
  %34 = sdiv i32 %33, 52774
  store i32 %34, ptr %3, align 4, !tbaa !9
  %35 = load ptr, ptr %2, align 8, !tbaa !5
  %36 = getelementptr inbounds i32, ptr %35, i64 1
  %37 = load i32, ptr %36, align 4, !tbaa !9
  %38 = load i32, ptr %3, align 4, !tbaa !9
  %39 = mul nsw i32 %38, 52774
  %40 = sub nsw i32 %37, %39
  %41 = mul nsw i32 %40, 40692
  %42 = load i32, ptr %3, align 4, !tbaa !9
  %43 = mul nsw i32 %42, 3791
  %44 = sub nsw i32 %41, %43
  %45 = load ptr, ptr %2, align 8, !tbaa !5
  %46 = getelementptr inbounds i32, ptr %45, i64 1
  store i32 %44, ptr %46, align 4, !tbaa !9
  %47 = load ptr, ptr %2, align 8, !tbaa !5
  %48 = getelementptr inbounds i32, ptr %47, i64 1
  %49 = load i32, ptr %48, align 4, !tbaa !9
  %50 = icmp slt i32 %49, 0
  br i1 %50, label %51, label %56

51:                                               ; preds = %30
  %52 = load ptr, ptr %2, align 8, !tbaa !5
  %53 = getelementptr inbounds i32, ptr %52, i64 1
  %54 = load i32, ptr %53, align 4, !tbaa !9
  %55 = add nsw i32 %54, 2147483399
  store i32 %55, ptr %53, align 4, !tbaa !9
  br label %56

56:                                               ; preds = %51, %30
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #2
  %57 = load ptr, ptr %2, align 8, !tbaa !5
  %58 = getelementptr inbounds i32, ptr %57, i64 0
  %59 = load i32, ptr %58, align 4, !tbaa !9
  %60 = load ptr, ptr %2, align 8, !tbaa !5
  %61 = getelementptr inbounds i32, ptr %60, i64 1
  %62 = load i32, ptr %61, align 4, !tbaa !9
  %63 = sub nsw i32 %59, %62
  store i32 %63, ptr %4, align 4, !tbaa !9
  %64 = load i32, ptr %4, align 4, !tbaa !9
  %65 = icmp slt i32 %64, 1
  br i1 %65, label %66, label %69

66:                                               ; preds = %56
  %67 = load i32, ptr %4, align 4, !tbaa !9
  %68 = add nsw i32 %67, 2147483562
  store i32 %68, ptr %4, align 4, !tbaa !9
  br label %69

69:                                               ; preds = %66, %56
  %70 = load i32, ptr %4, align 4, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #2
  ret i32 %70
}

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

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

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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = !{!"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}


; 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"

; Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: readwrite) uwtable
define dso_local noundef range(i32 -86, -2147483648) i32 @_ZN7fastjet26__default_random_generatorEPi(ptr nocapture noundef %0) local_unnamed_addr #0 {
  %2 = load i32, ptr %0, align 4, !tbaa !5
  %3 = sdiv i32 %2, 53668
  %.neg = mul nsw i32 %3, -53668
  %4 = add i32 %.neg, %2
  %5 = mul nsw i32 %4, 40014
  %.neg21 = mul nsw i32 %3, -12211
  %6 = add i32 %5, %.neg21
  %7 = icmp slt i32 %6, 0
  %8 = add nsw i32 %6, 2147483563
  %spec.select = select i1 %7, i32 %8, i32 %6
  store i32 %spec.select, ptr %0, align 4, !tbaa !5
  %9 = getelementptr inbounds i8, ptr %0, i64 4
  %10 = load i32, ptr %9, align 4, !tbaa !5
  %11 = sdiv i32 %10, 52774
  %.neg22 = mul nsw i32 %11, -52774
  %12 = add i32 %.neg22, %10
  %13 = mul nsw i32 %12, 40692
  %.neg23 = mul nsw i32 %11, -3791
  %14 = add i32 %13, %.neg23
  %15 = icmp slt i32 %14, 0
  %16 = add nsw i32 %14, 2147483399
  %storemerge24 = select i1 %15, i32 %16, i32 %14
  store i32 %storemerge24, ptr %9, align 4, !tbaa !5
  %17 = sub nsw i32 %spec.select, %storemerge24
  %18 = icmp slt i32 %17, 1
  %19 = add nsw i32 %17, 2147483562
  %.0 = select i1 %18, i32 %19, i32 %17
  ret i32 %.0
}

attributes #0 = { mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: readwrite) 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, !6, i64 0}
!6 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,SimplifyCFGPass