; LLVM IR from leonfoks/coretran :: src/random (xoroshiro128plus)

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

@s = external dso_local global [2 x i64], align 16
@jump.JUMP = external hidden constant [2 x i64], align 16

; Function Attrs: nounwind uwtable
declare dso_local i64 @next() #0

; 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

; Function Attrs: nounwind uwtable
define dso_local void @jump() #0 {
  %1 = alloca i64, align 8
  %2 = alloca i64, align 8
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  call void @llvm.lifetime.start.p0(i64 8, ptr %1) #2
  store i64 0, ptr %1, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %2) #2
  store i64 0, ptr %2, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #2
  store i32 0, ptr %3, align 4, !tbaa !9
  br label %6

6:                                                ; preds = %39, %0
  %7 = load i32, ptr %3, align 4, !tbaa !9
  %8 = sext i32 %7 to i64
  %9 = icmp ult i64 %8, 2
  br i1 %9, label %11, label %10

10:                                               ; preds = %6
  store i32 2, ptr %4, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #2
  br label %42

11:                                               ; preds = %6
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #2
  store i32 0, ptr %5, align 4, !tbaa !9
  br label %12

12:                                               ; preds = %35, %11
  %13 = load i32, ptr %5, align 4, !tbaa !9
  %14 = icmp slt i32 %13, 64
  br i1 %14, label %16, label %15

15:                                               ; preds = %12
  store i32 5, ptr %4, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #2
  br label %38

16:                                               ; preds = %12
  %17 = load i32, ptr %3, align 4, !tbaa !9
  %18 = sext i32 %17 to i64
  %19 = getelementptr inbounds [2 x i64], ptr @jump.JUMP, i64 0, i64 %18
  %20 = load i64, ptr %19, align 8, !tbaa !5
  %21 = load i32, ptr %5, align 4, !tbaa !9
  %22 = zext i32 %21 to i64
  %23 = shl i64 1, %22
  %24 = and i64 %20, %23
  %25 = icmp ne i64 %24, 0
  br i1 %25, label %26, label %33

26:                                               ; preds = %16
  %27 = load i64, ptr @s, align 16, !tbaa !5
  %28 = load i64, ptr %1, align 8, !tbaa !5
  %29 = xor i64 %28, %27
  store i64 %29, ptr %1, align 8, !tbaa !5
  %30 = load i64, ptr getelementptr inbounds ([2 x i64], ptr @s, i64 0, i64 1), align 8, !tbaa !5
  %31 = load i64, ptr %2, align 8, !tbaa !5
  %32 = xor i64 %31, %30
  store i64 %32, ptr %2, align 8, !tbaa !5
  br label %33

33:                                               ; preds = %26, %16
  %34 = call i64 @next()
  br label %35

35:                                               ; preds = %33
  %36 = load i32, ptr %5, align 4, !tbaa !9
  %37 = add nsw i32 %36, 1
  store i32 %37, ptr %5, align 4, !tbaa !9
  br label %12, !llvm.loop !11

38:                                               ; preds = %15
  br label %39

39:                                               ; preds = %38
  %40 = load i32, ptr %3, align 4, !tbaa !9
  %41 = add nsw i32 %40, 1
  store i32 %41, ptr %3, align 4, !tbaa !9
  br label %6, !llvm.loop !13

42:                                               ; preds = %10
  %43 = load i64, ptr %1, align 8, !tbaa !5
  store i64 %43, ptr @s, align 16, !tbaa !5
  %44 = load i64, ptr %2, align 8, !tbaa !5
  store i64 %44, ptr getelementptr inbounds ([2 x i64], ptr @s, i64 0, i64 1), align 8, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 8, ptr %2) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %1) #2
  ret void
}

attributes #0 = { 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 = !{!"long", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = distinct !{!13, !12}


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

@s = external dso_local local_unnamed_addr global [2 x i64], align 16
@jump.JUMP = external hidden local_unnamed_addr constant [2 x i64], align 16

; Function Attrs: nounwind uwtable
declare dso_local i64 @next() local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local void @jump() local_unnamed_addr #0 {
.preheader:
  %0 = load i64, ptr @jump.JUMP, align 16, !tbaa !5
  br label %13

.preheader.1:                                     ; preds = %13
  %1 = load i64, ptr getelementptr inbounds (i8, ptr @jump.JUMP, i64 8), align 8, !tbaa !5
  br label %2

2:                                                ; preds = %2, %.preheader.1
  %indvars.iv.1 = phi i64 [ 0, %.preheader.1 ], [ %indvars.iv.next.1, %2 ]
  %3 = phi <2 x i64> [ %21, %.preheader.1 ], [ %10, %2 ]
  %4 = shl nuw i64 1, %indvars.iv.1
  %5 = and i64 %1, %4
  %.not.1 = icmp eq i64 %5, 0
  %6 = load <2 x i64>, ptr @s, align 16
  %7 = insertelement <2 x i1> poison, i1 %.not.1, i64 0
  %8 = shufflevector <2 x i1> %7, <2 x i1> poison, <2 x i32> zeroinitializer
  %9 = select <2 x i1> %8, <2 x i64> zeroinitializer, <2 x i64> %6
  %10 = xor <2 x i64> %9, %3
  %11 = tail call i64 @next()
  %indvars.iv.next.1 = add nuw nsw i64 %indvars.iv.1, 1
  %exitcond.1.not = icmp eq i64 %indvars.iv.next.1, 64
  br i1 %exitcond.1.not, label %12, label %2, !llvm.loop !9

12:                                               ; preds = %2
  store <2 x i64> %10, ptr @s, align 16, !tbaa !5
  ret void

13:                                               ; preds = %.preheader, %13
  %indvars.iv = phi i64 [ 0, %.preheader ], [ %indvars.iv.next, %13 ]
  %14 = phi <2 x i64> [ zeroinitializer, %.preheader ], [ %21, %13 ]
  %15 = shl nuw i64 1, %indvars.iv
  %16 = and i64 %0, %15
  %.not = icmp eq i64 %16, 0
  %17 = load <2 x i64>, ptr @s, align 16
  %18 = insertelement <2 x i1> poison, i1 %.not, i64 0
  %19 = shufflevector <2 x i1> %18, <2 x i1> poison, <2 x i32> zeroinitializer
  %20 = select <2 x i1> %19, <2 x i64> zeroinitializer, <2 x i64> %17
  %21 = xor <2 x i64> %20, %14
  %22 = tail call i64 @next()
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next, 64
  br i1 %exitcond.not, label %.preheader.1, label %13, !llvm.loop !9
}

attributes #0 = { 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" }

!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 = !{!"long", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}


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