; LLVM IR from openssl/openssl :: test/testutil (random)

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

@test_random_state = external hidden global [31 x i32], align 16

; Function Attrs: nounwind uwtable
declare dso_local i32 @test_random() #0

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

7:                                                ; preds = %24, %1
  %8 = load i32, ptr %3, align 4, !tbaa !5
  %9 = icmp slt i32 %8, 31
  br i1 %9, label %10, label %27

10:                                               ; preds = %7
  %11 = load i32, ptr %3, align 4, !tbaa !5
  %12 = sub nsw i32 %11, 1
  %13 = sext i32 %12 to i64
  %14 = getelementptr inbounds [31 x i32], ptr @test_random_state, i64 0, i64 %13
  %15 = load i32, ptr %14, align 4, !tbaa !5
  store i32 %15, ptr %4, align 4, !tbaa !5
  %16 = load i32, ptr %4, align 4, !tbaa !5
  %17 = sext i32 %16 to i64
  %18 = mul nsw i64 16807, %17
  %19 = srem i64 %18, 2147483647
  %20 = trunc i64 %19 to i32
  %21 = load i32, ptr %3, align 4, !tbaa !5
  %22 = sext i32 %21 to i64
  %23 = getelementptr inbounds [31 x i32], ptr @test_random_state, i64 0, i64 %22
  store i32 %20, ptr %23, align 4, !tbaa !5
  br label %24

24:                                               ; preds = %10
  %25 = load i32, ptr %3, align 4, !tbaa !5
  %26 = add nsw i32 %25, 1
  store i32 %26, ptr %3, align 4, !tbaa !5
  br label %7, !llvm.loop !9

27:                                               ; preds = %7
  store i32 34, ptr %3, align 4, !tbaa !5
  br label %28

28:                                               ; preds = %33, %27
  %29 = load i32, ptr %3, align 4, !tbaa !5
  %30 = icmp slt i32 %29, 344
  br i1 %30, label %31, label %36

31:                                               ; preds = %28
  %32 = call i32 @test_random()
  br label %33

33:                                               ; preds = %31
  %34 = load i32, ptr %3, align 4, !tbaa !5
  %35 = add nsw i32 %34, 1
  store i32 %35, ptr %3, align 4, !tbaa !5
  br label %28, !llvm.loop !11

36:                                               ; preds = %28
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #2
  ret void
}

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


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

@test_random_state = external hidden local_unnamed_addr global [31 x i32], align 16

; Function Attrs: nounwind uwtable
declare dso_local i32 @test_random() local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local void @test_random_seed(i32 noundef %0) local_unnamed_addr #0 {
.preheader.preheader:
  store i32 %0, ptr @test_random_state, align 16, !tbaa !5
  %1 = sext i32 %0 to i64
  %2 = mul nsw i64 %1, 16807
  %3 = srem i64 %2, 2147483647
  %4 = trunc nsw i64 %3 to i32
  store i32 %4, ptr getelementptr inbounds (i8, ptr @test_random_state, i64 4), align 4, !tbaa !5
  %5 = mul nsw i64 %3, 16807
  %6 = srem i64 %5, 2147483647
  %7 = trunc nsw i64 %6 to i32
  store i32 %7, ptr getelementptr inbounds (i8, ptr @test_random_state, i64 8), align 8, !tbaa !5
  %8 = mul nsw i64 %6, 16807
  %9 = srem i64 %8, 2147483647
  %10 = trunc nsw i64 %9 to i32
  store i32 %10, ptr getelementptr inbounds (i8, ptr @test_random_state, i64 12), align 4, !tbaa !5
  %11 = mul nsw i64 %9, 16807
  %12 = srem i64 %11, 2147483647
  %13 = trunc nsw i64 %12 to i32
  store i32 %13, ptr getelementptr inbounds (i8, ptr @test_random_state, i64 16), align 16, !tbaa !5
  %14 = mul nsw i64 %12, 16807
  %15 = srem i64 %14, 2147483647
  %16 = trunc nsw i64 %15 to i32
  store i32 %16, ptr getelementptr inbounds (i8, ptr @test_random_state, i64 20), align 4, !tbaa !5
  %17 = mul nsw i64 %15, 16807
  %18 = srem i64 %17, 2147483647
  %19 = trunc nsw i64 %18 to i32
  store i32 %19, ptr getelementptr inbounds (i8, ptr @test_random_state, i64 24), align 8, !tbaa !5
  %20 = mul nsw i64 %18, 16807
  %21 = srem i64 %20, 2147483647
  %22 = trunc nsw i64 %21 to i32
  store i32 %22, ptr getelementptr inbounds (i8, ptr @test_random_state, i64 28), align 4, !tbaa !5
  %23 = mul nsw i64 %21, 16807
  %24 = srem i64 %23, 2147483647
  %25 = trunc nsw i64 %24 to i32
  store i32 %25, ptr getelementptr inbounds (i8, ptr @test_random_state, i64 32), align 16, !tbaa !5
  %26 = mul nsw i64 %24, 16807
  %27 = srem i64 %26, 2147483647
  %28 = trunc nsw i64 %27 to i32
  store i32 %28, ptr getelementptr inbounds (i8, ptr @test_random_state, i64 36), align 4, !tbaa !5
  %29 = mul nsw i64 %27, 16807
  %30 = srem i64 %29, 2147483647
  %31 = trunc nsw i64 %30 to i32
  store i32 %31, ptr getelementptr inbounds (i8, ptr @test_random_state, i64 40), align 8, !tbaa !5
  %32 = mul nsw i64 %30, 16807
  %33 = srem i64 %32, 2147483647
  %34 = trunc nsw i64 %33 to i32
  store i32 %34, ptr getelementptr inbounds (i8, ptr @test_random_state, i64 44), align 4, !tbaa !5
  %35 = mul nsw i64 %33, 16807
  %36 = srem i64 %35, 2147483647
  %37 = trunc nsw i64 %36 to i32
  store i32 %37, ptr getelementptr inbounds (i8, ptr @test_random_state, i64 48), align 16, !tbaa !5
  %38 = mul nsw i64 %36, 16807
  %39 = srem i64 %38, 2147483647
  %40 = trunc nsw i64 %39 to i32
  store i32 %40, ptr getelementptr inbounds (i8, ptr @test_random_state, i64 52), align 4, !tbaa !5
  %41 = mul nsw i64 %39, 16807
  %42 = srem i64 %41, 2147483647
  %43 = trunc nsw i64 %42 to i32
  store i32 %43, ptr getelementptr inbounds (i8, ptr @test_random_state, i64 56), align 8, !tbaa !5
  %44 = mul nsw i64 %42, 16807
  %45 = srem i64 %44, 2147483647
  %46 = trunc nsw i64 %45 to i32
  store i32 %46, ptr getelementptr inbounds (i8, ptr @test_random_state, i64 60), align 4, !tbaa !5
  %47 = mul nsw i64 %45, 16807
  %48 = srem i64 %47, 2147483647
  %49 = trunc nsw i64 %48 to i32
  store i32 %49, ptr getelementptr inbounds (i8, ptr @test_random_state, i64 64), align 16, !tbaa !5
  %50 = mul nsw i64 %48, 16807
  %51 = srem i64 %50, 2147483647
  %52 = trunc nsw i64 %51 to i32
  store i32 %52, ptr getelementptr inbounds (i8, ptr @test_random_state, i64 68), align 4, !tbaa !5
  %53 = mul nsw i64 %51, 16807
  %54 = srem i64 %53, 2147483647
  %55 = trunc nsw i64 %54 to i32
  store i32 %55, ptr getelementptr inbounds (i8, ptr @test_random_state, i64 72), align 8, !tbaa !5
  %56 = mul nsw i64 %54, 16807
  %57 = srem i64 %56, 2147483647
  %58 = trunc nsw i64 %57 to i32
  store i32 %58, ptr getelementptr inbounds (i8, ptr @test_random_state, i64 76), align 4, !tbaa !5
  %59 = mul nsw i64 %57, 16807
  %60 = srem i64 %59, 2147483647
  %61 = trunc nsw i64 %60 to i32
  store i32 %61, ptr getelementptr inbounds (i8, ptr @test_random_state, i64 80), align 16, !tbaa !5
  %62 = mul nsw i64 %60, 16807
  %63 = srem i64 %62, 2147483647
  %64 = trunc nsw i64 %63 to i32
  store i32 %64, ptr getelementptr inbounds (i8, ptr @test_random_state, i64 84), align 4, !tbaa !5
  %65 = mul nsw i64 %63, 16807
  %66 = srem i64 %65, 2147483647
  %67 = trunc nsw i64 %66 to i32
  store i32 %67, ptr getelementptr inbounds (i8, ptr @test_random_state, i64 88), align 8, !tbaa !5
  %68 = mul nsw i64 %66, 16807
  %69 = srem i64 %68, 2147483647
  %70 = trunc nsw i64 %69 to i32
  store i32 %70, ptr getelementptr inbounds (i8, ptr @test_random_state, i64 92), align 4, !tbaa !5
  %71 = mul nsw i64 %69, 16807
  %72 = srem i64 %71, 2147483647
  %73 = trunc nsw i64 %72 to i32
  store i32 %73, ptr getelementptr inbounds (i8, ptr @test_random_state, i64 96), align 16, !tbaa !5
  %74 = mul nsw i64 %72, 16807
  %75 = srem i64 %74, 2147483647
  %76 = trunc nsw i64 %75 to i32
  store i32 %76, ptr getelementptr inbounds (i8, ptr @test_random_state, i64 100), align 4, !tbaa !5
  %77 = mul nsw i64 %75, 16807
  %78 = srem i64 %77, 2147483647
  %79 = trunc nsw i64 %78 to i32
  store i32 %79, ptr getelementptr inbounds (i8, ptr @test_random_state, i64 104), align 8, !tbaa !5
  %80 = mul nsw i64 %78, 16807
  %81 = srem i64 %80, 2147483647
  %82 = trunc nsw i64 %81 to i32
  store i32 %82, ptr getelementptr inbounds (i8, ptr @test_random_state, i64 108), align 4, !tbaa !5
  %83 = mul nsw i64 %81, 16807
  %84 = srem i64 %83, 2147483647
  %85 = trunc nsw i64 %84 to i32
  store i32 %85, ptr getelementptr inbounds (i8, ptr @test_random_state, i64 112), align 16, !tbaa !5
  %86 = mul nsw i64 %84, 16807
  %87 = srem i64 %86, 2147483647
  %88 = trunc nsw i64 %87 to i32
  store i32 %88, ptr getelementptr inbounds (i8, ptr @test_random_state, i64 116), align 4, !tbaa !5
  %89 = mul nsw i64 %87, 16807
  %90 = srem i64 %89, 2147483647
  %91 = trunc nsw i64 %90 to i32
  store i32 %91, ptr getelementptr inbounds (i8, ptr @test_random_state, i64 120), align 8, !tbaa !5
  br label %.preheader

.preheader:                                       ; preds = %.preheader.preheader, %.preheader
  %.19 = phi i32 [ %93, %.preheader ], [ 34, %.preheader.preheader ]
  %92 = tail call i32 @test_random()
  %93 = add nuw nsw i32 %.19, 1
  %exitcond11.not = icmp eq i32 %93, 344
  br i1 %exitcond11.not, label %94, label %.preheader, !llvm.loop !9

94:                                               ; preds = %.preheader
  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" }

!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 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: BDCEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,SROAPass,SimplifyCFGPass,TailCallElimPass