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

%struct.Game = type { i32, [8 x [8 x i16]], i32, i32, i32 }

@.str.10 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.11 = external hidden unnamed_addr constant [6 x i8], align 1
@.str.12 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.13 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.14 = external hidden unnamed_addr constant [2 x i8], align 1

; 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
declare dso_local i32 @get_piece_type(i32 noundef) #1

; Function Attrs: nounwind
declare i32 @sprintf(ptr noundef, ptr noundef, ...) #2

; Function Attrs: nounwind uwtable
declare dso_local signext i8 @notate_piece(i32 noundef) #1

; Function Attrs: nounwind uwtable
declare dso_local void @notate_position(i32 noundef, i32 noundef, ptr noundef, i32 noundef) #1

; Function Attrs: nounwind uwtable
define dso_local void @notate_move(ptr noundef byval(%struct.Game) align 8 %0, i32 noundef %1, i32 noundef %2, i32 noundef %3, i32 noundef %4, i32 noundef %5, ptr noundef %6) #1 {
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  %12 = alloca i32, align 4
  %13 = alloca ptr, align 8
  %14 = alloca i32, align 4
  %15 = alloca i32, align 4
  %16 = alloca [3 x i8], align 1
  %17 = alloca [3 x i8], align 1
  store i32 %1, ptr %8, align 4, !tbaa !5
  store i32 %2, ptr %9, align 4, !tbaa !5
  store i32 %3, ptr %10, align 4, !tbaa !5
  store i32 %4, ptr %11, align 4, !tbaa !5
  store i32 %5, ptr %12, align 4, !tbaa !5
  store ptr %6, ptr %13, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #3
  store i32 0, ptr %14, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %15) #3
  %18 = getelementptr inbounds %struct.Game, ptr %0, i32 0, i32 1
  %19 = load i32, ptr %11, align 4, !tbaa !5
  %20 = sext i32 %19 to i64
  %21 = getelementptr inbounds [8 x [8 x i16]], ptr %18, i64 0, i64 %20
  %22 = load i32, ptr %10, align 4, !tbaa !5
  %23 = sext i32 %22 to i64
  %24 = getelementptr inbounds [8 x i16], ptr %21, i64 0, i64 %23
  %25 = load i16, ptr %24, align 2, !tbaa !11
  %26 = sext i16 %25 to i32
  %27 = call i32 @get_piece_type(i32 noundef %26)
  store i32 %27, ptr %15, align 4, !tbaa !5
  %28 = load i32, ptr %12, align 4, !tbaa !5
  %29 = icmp eq i32 %28, 3
  br i1 %29, label %30, label %50

30:                                               ; preds = %7
  %31 = load i32, ptr %10, align 4, !tbaa !5
  %32 = icmp eq i32 %31, 6
  br i1 %32, label %33, label %41

33:                                               ; preds = %30
  %34 = load ptr, ptr %13, align 8, !tbaa !9
  %35 = load i32, ptr %14, align 4, !tbaa !5
  %36 = sext i32 %35 to i64
  %37 = getelementptr inbounds i8, ptr %34, i64 %36
  %38 = call ptr @strcpy(ptr noundef %37, ptr noundef @.str.10) #3
  %39 = load i32, ptr %14, align 4, !tbaa !5
  %40 = add nsw i32 %39, 3
  store i32 %40, ptr %14, align 4, !tbaa !5
  br label %49

41:                                               ; preds = %30
  %42 = load ptr, ptr %13, align 8, !tbaa !9
  %43 = load i32, ptr %14, align 4, !tbaa !5
  %44 = sext i32 %43 to i64
  %45 = getelementptr inbounds i8, ptr %42, i64 %44
  %46 = call ptr @strcpy(ptr noundef %45, ptr noundef @.str.11) #3
  %47 = load i32, ptr %14, align 4, !tbaa !5
  %48 = add nsw i32 %47, 5
  store i32 %48, ptr %14, align 4, !tbaa !5
  br label %49

49:                                               ; preds = %41, %33
  br label %96

50:                                               ; preds = %7
  call void @llvm.lifetime.start.p0(i64 3, ptr %16) #3
  %51 = load i32, ptr %8, align 4, !tbaa !5
  %52 = load i32, ptr %9, align 4, !tbaa !5
  %53 = getelementptr inbounds [3 x i8], ptr %16, i64 0, i64 0
  call void @notate_position(i32 noundef %51, i32 noundef %52, ptr noundef %53, i32 noundef 3)
  %54 = load i32, ptr %15, align 4, !tbaa !5
  %55 = icmp ne i32 %54, 4
  br i1 %55, label %56, label %66

56:                                               ; preds = %50
  %57 = load ptr, ptr %13, align 8, !tbaa !9
  %58 = load i32, ptr %14, align 4, !tbaa !5
  %59 = add nsw i32 %58, 1
  store i32 %59, ptr %14, align 4, !tbaa !5
  %60 = sext i32 %58 to i64
  %61 = getelementptr inbounds i8, ptr %57, i64 %60
  %62 = load i32, ptr %15, align 4, !tbaa !5
  %63 = call signext i8 @notate_piece(i32 noundef %62)
  %64 = sext i8 %63 to i32
  %65 = call i32 (ptr, ptr, ...) @sprintf(ptr noundef %61, ptr noundef @.str.12, i32 noundef %64) #3
  br label %66

66:                                               ; preds = %56, %50
  %67 = load ptr, ptr %13, align 8, !tbaa !9
  %68 = load i32, ptr %14, align 4, !tbaa !5
  %69 = sext i32 %68 to i64
  %70 = getelementptr inbounds i8, ptr %67, i64 %69
  %71 = getelementptr inbounds [3 x i8], ptr %16, i64 0, i64 0
  %72 = call ptr @strcpy(ptr noundef %70, ptr noundef %71) #3
  %73 = load i32, ptr %14, align 4, !tbaa !5
  %74 = add nsw i32 %73, 2
  store i32 %74, ptr %14, align 4, !tbaa !5
  %75 = load i32, ptr %12, align 4, !tbaa !5
  %76 = icmp eq i32 %75, 2
  br i1 %76, label %77, label %84

77:                                               ; preds = %66
  %78 = load ptr, ptr %13, align 8, !tbaa !9
  %79 = load i32, ptr %14, align 4, !tbaa !5
  %80 = add nsw i32 %79, 1
  store i32 %80, ptr %14, align 4, !tbaa !5
  %81 = sext i32 %79 to i64
  %82 = getelementptr inbounds i8, ptr %78, i64 %81
  %83 = call ptr @strcpy(ptr noundef %82, ptr noundef @.str.13) #3
  br label %84

84:                                               ; preds = %77, %66
  call void @llvm.lifetime.start.p0(i64 3, ptr %17) #3
  %85 = load i32, ptr %10, align 4, !tbaa !5
  %86 = load i32, ptr %11, align 4, !tbaa !5
  %87 = getelementptr inbounds [3 x i8], ptr %17, i64 0, i64 0
  call void @notate_position(i32 noundef %85, i32 noundef %86, ptr noundef %87, i32 noundef 3)
  %88 = load ptr, ptr %13, align 8, !tbaa !9
  %89 = load i32, ptr %14, align 4, !tbaa !5
  %90 = sext i32 %89 to i64
  %91 = getelementptr inbounds i8, ptr %88, i64 %90
  %92 = getelementptr inbounds [3 x i8], ptr %17, i64 0, i64 0
  %93 = call ptr @strcpy(ptr noundef %91, ptr noundef %92) #3
  %94 = load i32, ptr %14, align 4, !tbaa !5
  %95 = add nsw i32 %94, 2
  store i32 %95, ptr %14, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 3, ptr %17) #3
  call void @llvm.lifetime.end.p0(i64 3, ptr %16) #3
  br label %96

96:                                               ; preds = %84, %49
  %97 = getelementptr inbounds %struct.Game, ptr %0, i32 0, i32 2
  %98 = load i32, ptr %97, align 4, !tbaa !13
  %99 = and i32 %98, 16
  %100 = icmp ne i32 %99, 0
  br i1 %100, label %106, label %101

101:                                              ; preds = %96
  %102 = getelementptr inbounds %struct.Game, ptr %0, i32 0, i32 2
  %103 = load i32, ptr %102, align 4, !tbaa !13
  %104 = and i32 %103, 32
  %105 = icmp ne i32 %104, 0
  br i1 %105, label %106, label %111

106:                                              ; preds = %101, %96
  %107 = load ptr, ptr %13, align 8, !tbaa !9
  %108 = load i32, ptr %14, align 4, !tbaa !5
  %109 = sext i32 %108 to i64
  %110 = getelementptr inbounds i8, ptr %107, i64 %109
  store i8 35, ptr %110, align 1, !tbaa !15
  br label %128

111:                                              ; preds = %101
  %112 = getelementptr inbounds %struct.Game, ptr %0, i32 0, i32 2
  %113 = load i32, ptr %112, align 4, !tbaa !13
  %114 = and i32 %113, 4
  %115 = icmp ne i32 %114, 0
  br i1 %115, label %121, label %116

116:                                              ; preds = %111
  %117 = getelementptr inbounds %struct.Game, ptr %0, i32 0, i32 2
  %118 = load i32, ptr %117, align 4, !tbaa !13
  %119 = and i32 %118, 8
  %120 = icmp ne i32 %119, 0
  br i1 %120, label %121, label %127

121:                                              ; preds = %116, %111
  %122 = load ptr, ptr %13, align 8, !tbaa !9
  %123 = load i32, ptr %14, align 4, !tbaa !5
  %124 = sext i32 %123 to i64
  %125 = getelementptr inbounds i8, ptr %122, i64 %124
  %126 = call ptr @strcpy(ptr noundef %125, ptr noundef @.str.14) #3
  br label %127

127:                                              ; preds = %121, %116
  br label %128

128:                                              ; preds = %127, %106
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #3
  ret void
}

; Function Attrs: nounwind
declare ptr @strcpy(ptr noundef, ptr noundef) #2

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 "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 #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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"any pointer", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"short", !7, i64 0}
!13 = !{!14, !6, i64 132}
!14 = !{!"", !6, i64 0, !7, i64 4, !6, i64 132, !6, i64 136, !6, i64 140}
!15 = !{!7, !7, i64 0}


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

%struct.Game = type { i32, [8 x [8 x i16]], i32, i32, i32 }

@.str.10 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.11 = external hidden unnamed_addr constant [6 x i8], align 1
@.str.12 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.13 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.14 = external hidden unnamed_addr constant [2 x i8], align 1

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

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

; Function Attrs: nounwind uwtable
declare dso_local i32 @get_piece_type(i32 noundef) local_unnamed_addr #1

; Function Attrs: nofree nounwind
declare noundef i32 @sprintf(ptr noalias nocapture noundef writeonly, ptr nocapture noundef readonly, ...) local_unnamed_addr #2

; Function Attrs: nounwind uwtable
declare dso_local signext i8 @notate_piece(i32 noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
declare dso_local void @notate_position(i32 noundef, i32 noundef, ptr noundef, i32 noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
define dso_local void @notate_move(ptr nocapture noundef readonly byval(%struct.Game) align 8 %0, i32 noundef %1, i32 noundef %2, i32 noundef %3, i32 noundef %4, i32 noundef %5, ptr noundef %6) local_unnamed_addr #1 {
  %8 = alloca [3 x i8], align 1
  %9 = alloca [3 x i8], align 1
  %10 = getelementptr inbounds i8, ptr %0, i64 4
  %11 = sext i32 %4 to i64
  %12 = sext i32 %3 to i64
  %13 = getelementptr inbounds [8 x [8 x i16]], ptr %10, i64 0, i64 %11, i64 %12
  %14 = load i16, ptr %13, align 2, !tbaa !5
  %15 = sext i16 %14 to i32
  %16 = tail call i32 @get_piece_type(i32 noundef %15)
  %17 = icmp eq i32 %5, 3
  br i1 %17, label %18, label %24

18:                                               ; preds = %7
  %19 = icmp eq i32 %3, 6
  br i1 %19, label %20, label %22

20:                                               ; preds = %18
  %21 = tail call ptr @strcpy(ptr noundef nonnull dereferenceable(1) %6, ptr noundef nonnull dereferenceable(1) @.str.10) #4
  br label %46

22:                                               ; preds = %18
  %23 = tail call ptr @strcpy(ptr noundef nonnull dereferenceable(1) %6, ptr noundef nonnull dereferenceable(1) @.str.11) #4
  br label %46

24:                                               ; preds = %7
  call void @llvm.lifetime.start.p0(i64 3, ptr nonnull %8) #4
  call void @notate_position(i32 noundef %1, i32 noundef %2, ptr noundef nonnull %8, i32 noundef 3)
  %.not = icmp eq i32 %16, 4
  br i1 %.not, label %29, label %25

25:                                               ; preds = %24
  %26 = call signext i8 @notate_piece(i32 noundef %16)
  %27 = sext i8 %26 to i32
  %28 = call i32 (ptr, ptr, ...) @sprintf(ptr noundef nonnull dereferenceable(1) %6, ptr noundef nonnull dereferenceable(1) @.str.12, i32 noundef %27) #4
  br label %29

29:                                               ; preds = %25, %24
  %.0 = phi i32 [ 1, %25 ], [ 0, %24 ]
  %30 = zext nneg i32 %.0 to i64
  %31 = getelementptr inbounds i8, ptr %6, i64 %30
  %32 = call ptr @strcpy(ptr noundef nonnull dereferenceable(1) %31, ptr noundef nonnull dereferenceable(1) %8) #4
  %33 = or disjoint i32 %.0, 2
  %34 = icmp eq i32 %5, 2
  br i1 %34, label %35, label %40

35:                                               ; preds = %29
  %36 = add nuw nsw i32 %.0, 3
  %37 = zext nneg i32 %33 to i64
  %38 = getelementptr inbounds i8, ptr %6, i64 %37
  %39 = call ptr @strcpy(ptr noundef nonnull dereferenceable(1) %38, ptr noundef nonnull dereferenceable(1) @.str.13) #4
  br label %40

40:                                               ; preds = %35, %29
  %.1 = phi i32 [ %36, %35 ], [ %33, %29 ]
  call void @llvm.lifetime.start.p0(i64 3, ptr nonnull %9) #4
  call void @notate_position(i32 noundef %3, i32 noundef %4, ptr noundef nonnull %9, i32 noundef 3)
  %41 = zext nneg i32 %.1 to i64
  %42 = getelementptr inbounds i8, ptr %6, i64 %41
  %43 = call ptr @strcpy(ptr noundef nonnull dereferenceable(1) %42, ptr noundef nonnull dereferenceable(1) %9) #4
  %44 = add nuw nsw i32 %.1, 2
  call void @llvm.lifetime.end.p0(i64 3, ptr nonnull %9) #4
  call void @llvm.lifetime.end.p0(i64 3, ptr nonnull %8) #4
  %45 = zext nneg i32 %44 to i64
  br label %46

46:                                               ; preds = %20, %22, %40
  %.2 = phi i64 [ 3, %20 ], [ 5, %22 ], [ %45, %40 ]
  %47 = getelementptr inbounds i8, ptr %0, i64 132
  %48 = load i32, ptr %47, align 4, !tbaa !9
  %49 = and i32 %48, 48
  %or.cond = icmp eq i32 %49, 0
  br i1 %or.cond, label %52, label %50

50:                                               ; preds = %46
  %51 = getelementptr inbounds i8, ptr %6, i64 %.2
  store i8 35, ptr %51, align 1, !tbaa !12
  br label %57

52:                                               ; preds = %46
  %53 = and i32 %48, 12
  %or.cond36 = icmp eq i32 %53, 0
  br i1 %or.cond36, label %57, label %54

54:                                               ; preds = %52
  %55 = getelementptr inbounds i8, ptr %6, i64 %.2
  %56 = call ptr @strcpy(ptr noundef nonnull dereferenceable(1) %55, ptr noundef nonnull dereferenceable(1) @.str.14) #4
  br label %57

57:                                               ; preds = %52, %54, %50
  ret void
}

; Function Attrs: mustprogress nofree nounwind willreturn memory(argmem: readwrite)
declare ptr @strcpy(ptr noalias noundef returned writeonly, ptr noalias nocapture noundef readonly) local_unnamed_addr #3

attributes #0 = { mustprogress 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 = { nofree 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 #3 = { mustprogress nofree nounwind willreturn memory(argmem: readwrite) "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 #4 = { 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 = !{!"short", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !11, i64 132}
!10 = !{!"", !11, i64 0, !7, i64 4, !11, i64 132, !11, i64 136, !11, i64 140}
!11 = !{!"int", !7, i64 0}
!12 = !{!7, !7, i64 0}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass