; LLVM IR from AlgoGenesis/C :: Backtracking Algorithms/Chess-In-Terminal/src (main)

; 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: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #0

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

; Function Attrs: nounwind uwtable
define dso_local void @init_board(ptr noundef %0) #1 {
  %2 = alloca ptr, align 8
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  store ptr %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 %7

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

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

11:                                               ; preds = %7
  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 = %24, %11
  %13 = load i32, ptr %5, align 4, !tbaa !9
  %14 = icmp slt i32 %13, 8
  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 %27

16:                                               ; preds = %12
  %17 = load ptr, ptr %2, align 8, !tbaa !5
  %18 = load i32, ptr %3, align 4, !tbaa !9
  %19 = sext i32 %18 to i64
  %20 = getelementptr inbounds [8 x i16], ptr %17, i64 %19
  %21 = load i32, ptr %5, align 4, !tbaa !9
  %22 = sext i32 %21 to i64
  %23 = getelementptr inbounds [8 x i16], ptr %20, i64 0, i64 %22
  store i16 0, ptr %23, align 2, !tbaa !11
  br label %24

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

27:                                               ; preds = %15
  br label %28

28:                                               ; preds = %27
  %29 = load i32, ptr %3, align 4, !tbaa !9
  %30 = add nsw i32 %29, 1
  store i32 %30, ptr %3, align 4, !tbaa !9
  br label %7, !llvm.loop !15

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

32:                                               ; preds = %47, %31
  %33 = load i32, ptr %6, align 4, !tbaa !9
  %34 = icmp slt i32 %33, 8
  br i1 %34, label %36, label %35

35:                                               ; preds = %32
  store i32 8, ptr %4, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #2
  br label %50

36:                                               ; preds = %32
  %37 = load ptr, ptr %2, align 8, !tbaa !5
  %38 = getelementptr inbounds [8 x i16], ptr %37, i64 1
  %39 = load i32, ptr %6, align 4, !tbaa !9
  %40 = sext i32 %39 to i64
  %41 = getelementptr inbounds [8 x i16], ptr %38, i64 0, i64 %40
  store i16 6, ptr %41, align 2, !tbaa !11
  %42 = load ptr, ptr %2, align 8, !tbaa !5
  %43 = getelementptr inbounds [8 x i16], ptr %42, i64 6
  %44 = load i32, ptr %6, align 4, !tbaa !9
  %45 = sext i32 %44 to i64
  %46 = getelementptr inbounds [8 x i16], ptr %43, i64 0, i64 %45
  store i16 5, ptr %46, align 2, !tbaa !11
  br label %47

47:                                               ; preds = %36
  %48 = load i32, ptr %6, align 4, !tbaa !9
  %49 = add nsw i32 %48, 1
  store i32 %49, ptr %6, align 4, !tbaa !9
  br label %32, !llvm.loop !16

50:                                               ; preds = %35
  %51 = load ptr, ptr %2, align 8, !tbaa !5
  %52 = getelementptr inbounds [8 x i16], ptr %51, i64 0
  %53 = getelementptr inbounds [8 x i16], ptr %52, i64 0, i64 7
  store i16 34, ptr %53, align 2, !tbaa !11
  %54 = load ptr, ptr %2, align 8, !tbaa !5
  %55 = getelementptr inbounds [8 x i16], ptr %54, i64 0
  %56 = getelementptr inbounds [8 x i16], ptr %55, i64 0, i64 0
  store i16 34, ptr %56, align 2, !tbaa !11
  %57 = load ptr, ptr %2, align 8, !tbaa !5
  %58 = getelementptr inbounds [8 x i16], ptr %57, i64 0
  %59 = getelementptr inbounds [8 x i16], ptr %58, i64 0, i64 6
  store i16 10, ptr %59, align 2, !tbaa !11
  %60 = load ptr, ptr %2, align 8, !tbaa !5
  %61 = getelementptr inbounds [8 x i16], ptr %60, i64 0
  %62 = getelementptr inbounds [8 x i16], ptr %61, i64 0, i64 1
  store i16 10, ptr %62, align 2, !tbaa !11
  %63 = load ptr, ptr %2, align 8, !tbaa !5
  %64 = getelementptr inbounds [8 x i16], ptr %63, i64 0
  %65 = getelementptr inbounds [8 x i16], ptr %64, i64 0, i64 5
  store i16 18, ptr %65, align 2, !tbaa !11
  %66 = load ptr, ptr %2, align 8, !tbaa !5
  %67 = getelementptr inbounds [8 x i16], ptr %66, i64 0
  %68 = getelementptr inbounds [8 x i16], ptr %67, i64 0, i64 2
  store i16 18, ptr %68, align 2, !tbaa !11
  %69 = load ptr, ptr %2, align 8, !tbaa !5
  %70 = getelementptr inbounds [8 x i16], ptr %69, i64 0
  %71 = getelementptr inbounds [8 x i16], ptr %70, i64 0, i64 3
  store i16 66, ptr %71, align 2, !tbaa !11
  %72 = load ptr, ptr %2, align 8, !tbaa !5
  %73 = getelementptr inbounds [8 x i16], ptr %72, i64 0
  %74 = getelementptr inbounds [8 x i16], ptr %73, i64 0, i64 4
  store i16 130, ptr %74, align 2, !tbaa !11
  %75 = load ptr, ptr %2, align 8, !tbaa !5
  %76 = getelementptr inbounds [8 x i16], ptr %75, i64 7
  %77 = getelementptr inbounds [8 x i16], ptr %76, i64 0, i64 7
  store i16 33, ptr %77, align 2, !tbaa !11
  %78 = load ptr, ptr %2, align 8, !tbaa !5
  %79 = getelementptr inbounds [8 x i16], ptr %78, i64 7
  %80 = getelementptr inbounds [8 x i16], ptr %79, i64 0, i64 0
  store i16 33, ptr %80, align 2, !tbaa !11
  %81 = load ptr, ptr %2, align 8, !tbaa !5
  %82 = getelementptr inbounds [8 x i16], ptr %81, i64 7
  %83 = getelementptr inbounds [8 x i16], ptr %82, i64 0, i64 6
  store i16 9, ptr %83, align 2, !tbaa !11
  %84 = load ptr, ptr %2, align 8, !tbaa !5
  %85 = getelementptr inbounds [8 x i16], ptr %84, i64 7
  %86 = getelementptr inbounds [8 x i16], ptr %85, i64 0, i64 1
  store i16 9, ptr %86, align 2, !tbaa !11
  %87 = load ptr, ptr %2, align 8, !tbaa !5
  %88 = getelementptr inbounds [8 x i16], ptr %87, i64 7
  %89 = getelementptr inbounds [8 x i16], ptr %88, i64 0, i64 5
  store i16 17, ptr %89, align 2, !tbaa !11
  %90 = load ptr, ptr %2, align 8, !tbaa !5
  %91 = getelementptr inbounds [8 x i16], ptr %90, i64 7
  %92 = getelementptr inbounds [8 x i16], ptr %91, i64 0, i64 2
  store i16 17, ptr %92, align 2, !tbaa !11
  %93 = load ptr, ptr %2, align 8, !tbaa !5
  %94 = getelementptr inbounds [8 x i16], ptr %93, i64 7
  %95 = getelementptr inbounds [8 x i16], ptr %94, i64 0, i64 3
  store i16 65, ptr %95, align 2, !tbaa !11
  %96 = load ptr, ptr %2, align 8, !tbaa !5
  %97 = getelementptr inbounds [8 x i16], ptr %96, i64 7
  %98 = getelementptr inbounds [8 x i16], ptr %97, i64 0, i64 4
  store i16 129, ptr %98, align 2, !tbaa !11
  ret void
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #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/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"short", !7, i64 0}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}
!15 = distinct !{!15, !14}
!16 = distinct !{!16, !14}


; 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: write) uwtable
define dso_local void @init_board(ptr nocapture noundef writeonly %0) local_unnamed_addr #0 {
.preheader:
  %1 = getelementptr inbounds i8, ptr %0, i64 32
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 2 dereferenceable(128) %1, i8 0, i64 64, i1 false), !tbaa !5
  %2 = getelementptr inbounds i8, ptr %0, i64 16
  %3 = getelementptr inbounds i8, ptr %0, i64 96
  store <8 x i16> <i16 6, i16 6, i16 6, i16 6, i16 6, i16 6, i16 6, i16 6>, ptr %2, align 2, !tbaa !5
  store <8 x i16> <i16 5, i16 5, i16 5, i16 5, i16 5, i16 5, i16 5, i16 5>, ptr %3, align 2, !tbaa !5
  store <8 x i16> <i16 34, i16 10, i16 18, i16 66, i16 130, i16 18, i16 10, i16 34>, ptr %0, align 2, !tbaa !5
  %4 = getelementptr inbounds i8, ptr %0, i64 112
  store <8 x i16> <i16 33, i16 9, i16 17, i16 65, i16 129, i16 17, i16 9, i16 33>, ptr %4, align 2, !tbaa !5
  ret void
}

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #1

attributes #0 = { mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: write) 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 nounwind willreturn memory(argmem: write) }

!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 = !{!"short", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}


; Effective O3 passes: DSEPass,EarlyCSEPass,GVNPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,LICMPass,LoopIdiomRecognizePass,LoopRotatePass,LoopSimplifyPass,PostOrderFunctionAttrsPass,SLPVectorizerPass,SROAPass,SimplifyCFGPass,TailCallElimPass