; LLVM IR from t-dillon/tdoku :: other/bb_sudoku/bb_sudoku_solver.ll (Z8RND_Initv)

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

@_ZL5RND_z = external hidden global i64, align 8
@_ZL5RND_w = external hidden global i64, align 8
@_ZL7RND_jsr = external hidden global i64, align 8
@_ZL9RND_jcong = external hidden global i64, align 8
@_ZL5RND_t = external hidden global [256 x i64], align 16

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @_Z8RND_Initv() #0 {
  %1 = alloca i32, align 4
  %2 = call i64 @time(ptr noundef null) #3
  %3 = trunc i64 %2 to i32
  call void @srand(i32 noundef %3) #3
  %4 = call i32 @rand() #3
  %5 = sext i32 %4 to i64
  store i64 %5, ptr @_ZL5RND_z, align 8, !tbaa !5
  %6 = call i32 @rand() #3
  %7 = sext i32 %6 to i64
  store i64 %7, ptr @_ZL5RND_w, align 8, !tbaa !5
  %8 = call i32 @rand() #3
  %9 = sext i32 %8 to i64
  store i64 %9, ptr @_ZL7RND_jsr, align 8, !tbaa !5
  %10 = call i32 @rand() #3
  %11 = sext i32 %10 to i64
  store i64 %11, ptr @_ZL9RND_jcong, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %1) #3
  store i32 0, ptr %1, align 4, !tbaa !9
  br label %12

12:                                               ; preds = %22, %0
  %13 = load i32, ptr %1, align 4, !tbaa !9
  %14 = icmp slt i32 %13, 256
  br i1 %14, label %16, label %15

15:                                               ; preds = %12
  call void @llvm.lifetime.end.p0(i64 4, ptr %1) #3
  br label %25

16:                                               ; preds = %12
  %17 = call i32 @rand() #3
  %18 = sext i32 %17 to i64
  %19 = load i32, ptr %1, align 4, !tbaa !9
  %20 = sext i32 %19 to i64
  %21 = getelementptr inbounds [256 x i64], ptr @_ZL5RND_t, i64 0, i64 %20
  store i64 %18, ptr %21, align 8, !tbaa !5
  br label %22

22:                                               ; preds = %16
  %23 = load i32, ptr %1, align 4, !tbaa !9
  %24 = add nsw i32 %23, 1
  store i32 %24, ptr %1, align 4, !tbaa !9
  br label %12, !llvm.loop !11

25:                                               ; preds = %15
  ret void
}

; Function Attrs: nounwind
declare void @srand(i32 noundef) #1

; Function Attrs: nounwind
declare i64 @time(ptr noundef) #1

; Function Attrs: nounwind
declare i32 @rand() #1

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

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

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 = { 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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = !{!"long", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"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"

@_ZL5RND_z = external hidden local_unnamed_addr global i64, align 8
@_ZL5RND_w = external hidden local_unnamed_addr global i64, align 8
@_ZL7RND_jsr = external hidden local_unnamed_addr global i64, align 8
@_ZL9RND_jcong = external hidden local_unnamed_addr global i64, align 8
@_ZL5RND_t = external hidden local_unnamed_addr global [256 x i64], align 16

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @_Z8RND_Initv() local_unnamed_addr #0 {
  %1 = tail call i64 @time(ptr noundef null) #2
  %2 = trunc i64 %1 to i32
  tail call void @srand(i32 noundef %2) #2
  %3 = tail call i32 @rand() #2
  %4 = sext i32 %3 to i64
  store i64 %4, ptr @_ZL5RND_z, align 8, !tbaa !5
  %5 = tail call i32 @rand() #2
  %6 = sext i32 %5 to i64
  store i64 %6, ptr @_ZL5RND_w, align 8, !tbaa !5
  %7 = tail call i32 @rand() #2
  %8 = sext i32 %7 to i64
  store i64 %8, ptr @_ZL7RND_jsr, align 8, !tbaa !5
  %9 = tail call i32 @rand() #2
  %10 = sext i32 %9 to i64
  store i64 %10, ptr @_ZL9RND_jcong, align 8, !tbaa !5
  br label %12

11:                                               ; preds = %12
  ret void

12:                                               ; preds = %0, %12
  %indvars.iv = phi i64 [ 0, %0 ], [ %indvars.iv.next, %12 ]
  %13 = tail call i32 @rand() #2
  %14 = sext i32 %13 to i64
  %15 = getelementptr inbounds [256 x i64], ptr @_ZL5RND_t, i64 0, i64 %indvars.iv
  store i64 %14, ptr %15, align 8, !tbaa !5
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next, 256
  br i1 %exitcond.not, label %11, label %12, !llvm.loop !9
}

; Function Attrs: nounwind
declare void @srand(i32 noundef) local_unnamed_addr #1

; Function Attrs: nounwind
declare i64 @time(ptr noundef) local_unnamed_addr #1

; Function Attrs: nounwind
declare i32 @rand() local_unnamed_addr #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 = { 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 }

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


; Effective O3 passes: GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,LoopRotatePass,SROAPass,SimplifyCFGPass,TailCallElimPass