; LLVM IR from VAR-solutions/Algorithms :: Combinatorial Game Theory/Zobrist Hashing/zobrist.ll (Z9initTablev)

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

@ZobristTable = external dso_local global [8 x [8 x [12 x i64]]], align 16

; Function Attrs: mustprogress uwtable
declare dso_local noundef i64 @_Z9randomIntv() #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: mustprogress uwtable
define dso_local void @_Z9initTablev() #0 {
  %1 = alloca i32, align 4
  %2 = alloca i32, align 4
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  call void @llvm.lifetime.start.p0(i64 4, ptr %1) #2
  store i32 0, ptr %1, align 4, !tbaa !5
  br label %5

5:                                                ; preds = %38, %0
  %6 = load i32, ptr %1, align 4, !tbaa !5
  %7 = icmp slt i32 %6, 8
  br i1 %7, label %9, label %8

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

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

10:                                               ; preds = %34, %9
  %11 = load i32, ptr %3, align 4, !tbaa !5
  %12 = icmp slt i32 %11, 8
  br i1 %12, label %14, label %13

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

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

15:                                               ; preds = %30, %14
  %16 = load i32, ptr %4, align 4, !tbaa !5
  %17 = icmp slt i32 %16, 12
  br i1 %17, label %19, label %18

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

19:                                               ; preds = %15
  %20 = call noundef i64 @_Z9randomIntv()
  %21 = load i32, ptr %1, align 4, !tbaa !5
  %22 = sext i32 %21 to i64
  %23 = getelementptr inbounds [8 x [8 x [12 x i64]]], ptr @ZobristTable, i64 0, i64 %22
  %24 = load i32, ptr %3, align 4, !tbaa !5
  %25 = sext i32 %24 to i64
  %26 = getelementptr inbounds [8 x [12 x i64]], ptr %23, i64 0, i64 %25
  %27 = load i32, ptr %4, align 4, !tbaa !5
  %28 = sext i32 %27 to i64
  %29 = getelementptr inbounds [12 x i64], ptr %26, i64 0, i64 %28
  store i64 %20, ptr %29, align 8, !tbaa !9
  br label %30

30:                                               ; preds = %19
  %31 = load i32, ptr %4, align 4, !tbaa !5
  %32 = add nsw i32 %31, 1
  store i32 %32, ptr %4, align 4, !tbaa !5
  br label %15, !llvm.loop !11

33:                                               ; preds = %18
  br label %34

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

37:                                               ; preds = %13
  br label %38

38:                                               ; preds = %37
  %39 = load i32, ptr %1, align 4, !tbaa !5
  %40 = add nsw i32 %39, 1
  store i32 %40, ptr %1, align 4, !tbaa !5
  br label %5, !llvm.loop !14

41:                                               ; preds = %8
  ret void
}

attributes #0 = { mustprogress 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++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"long long", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = distinct !{!13, !12}
!14 = distinct !{!14, !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"

@ZobristTable = external dso_local local_unnamed_addr global [8 x [8 x [12 x i64]]], align 16

; Function Attrs: mustprogress uwtable
declare dso_local noundef i64 @_Z9randomIntv() local_unnamed_addr #0

; Function Attrs: mustprogress uwtable
define dso_local void @_Z9initTablev() local_unnamed_addr #0 {
  br label %.preheader11

.preheader11:                                     ; preds = %0, %26
  %indvars.iv17 = phi i64 [ 0, %0 ], [ %indvars.iv.next18, %26 ]
  br label %.preheader

1:                                                ; preds = %26
  ret void

.preheader:                                       ; preds = %.preheader11, %.preheader
  %indvars.iv = phi i64 [ 0, %.preheader11 ], [ %indvars.iv.next, %.preheader ]
  %2 = tail call noundef i64 @_Z9randomIntv()
  %3 = getelementptr inbounds [8 x [8 x [12 x i64]]], ptr @ZobristTable, i64 0, i64 %indvars.iv17, i64 %indvars.iv, i64 0
  store i64 %2, ptr %3, align 16, !tbaa !5
  %4 = tail call noundef i64 @_Z9randomIntv()
  %5 = getelementptr inbounds [8 x [8 x [12 x i64]]], ptr @ZobristTable, i64 0, i64 %indvars.iv17, i64 %indvars.iv, i64 1
  store i64 %4, ptr %5, align 8, !tbaa !5
  %6 = tail call noundef i64 @_Z9randomIntv()
  %7 = getelementptr inbounds [8 x [8 x [12 x i64]]], ptr @ZobristTable, i64 0, i64 %indvars.iv17, i64 %indvars.iv, i64 2
  store i64 %6, ptr %7, align 16, !tbaa !5
  %8 = tail call noundef i64 @_Z9randomIntv()
  %9 = getelementptr inbounds [8 x [8 x [12 x i64]]], ptr @ZobristTable, i64 0, i64 %indvars.iv17, i64 %indvars.iv, i64 3
  store i64 %8, ptr %9, align 8, !tbaa !5
  %10 = tail call noundef i64 @_Z9randomIntv()
  %11 = getelementptr inbounds [8 x [8 x [12 x i64]]], ptr @ZobristTable, i64 0, i64 %indvars.iv17, i64 %indvars.iv, i64 4
  store i64 %10, ptr %11, align 16, !tbaa !5
  %12 = tail call noundef i64 @_Z9randomIntv()
  %13 = getelementptr inbounds [8 x [8 x [12 x i64]]], ptr @ZobristTable, i64 0, i64 %indvars.iv17, i64 %indvars.iv, i64 5
  store i64 %12, ptr %13, align 8, !tbaa !5
  %14 = tail call noundef i64 @_Z9randomIntv()
  %15 = getelementptr inbounds [8 x [8 x [12 x i64]]], ptr @ZobristTable, i64 0, i64 %indvars.iv17, i64 %indvars.iv, i64 6
  store i64 %14, ptr %15, align 16, !tbaa !5
  %16 = tail call noundef i64 @_Z9randomIntv()
  %17 = getelementptr inbounds [8 x [8 x [12 x i64]]], ptr @ZobristTable, i64 0, i64 %indvars.iv17, i64 %indvars.iv, i64 7
  store i64 %16, ptr %17, align 8, !tbaa !5
  %18 = tail call noundef i64 @_Z9randomIntv()
  %19 = getelementptr inbounds [8 x [8 x [12 x i64]]], ptr @ZobristTable, i64 0, i64 %indvars.iv17, i64 %indvars.iv, i64 8
  store i64 %18, ptr %19, align 16, !tbaa !5
  %20 = tail call noundef i64 @_Z9randomIntv()
  %21 = getelementptr inbounds [8 x [8 x [12 x i64]]], ptr @ZobristTable, i64 0, i64 %indvars.iv17, i64 %indvars.iv, i64 9
  store i64 %20, ptr %21, align 8, !tbaa !5
  %22 = tail call noundef i64 @_Z9randomIntv()
  %23 = getelementptr inbounds [8 x [8 x [12 x i64]]], ptr @ZobristTable, i64 0, i64 %indvars.iv17, i64 %indvars.iv, i64 10
  store i64 %22, ptr %23, align 16, !tbaa !5
  %24 = tail call noundef i64 @_Z9randomIntv()
  %25 = getelementptr inbounds [8 x [8 x [12 x i64]]], ptr @ZobristTable, i64 0, i64 %indvars.iv17, i64 %indvars.iv, i64 11
  store i64 %24, ptr %25, align 8, !tbaa !5
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next, 8
  br i1 %exitcond.not, label %26, label %.preheader, !llvm.loop !9

26:                                               ; preds = %.preheader
  %indvars.iv.next18 = add nuw nsw i64 %indvars.iv17, 1
  %exitcond20.not = icmp eq i64 %indvars.iv.next18, 8
  br i1 %exitcond20.not, label %1, label %.preheader11, !llvm.loop !11
}

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


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