; LLVM IR from totte174/minesolve :: src (board)

; 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.Board = type { i32, i32, i32, i32, [1024 x i32], [1024 x i8], [1024 x i8], i8 }

@print_board_pretty.color_nums = external hidden global [10 x [10 x i8]], align 16
@.str.4 = external hidden unnamed_addr constant [7 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.9 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.10 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.11 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.12 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.13 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.14 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.15 = external hidden unnamed_addr constant [7 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

declare i32 @printf(ptr noundef, ...) #1

; Function Attrs: nounwind uwtable
define dso_local void @print_board_pretty(ptr noundef %0, i1 noundef zeroext %1) #2 {
  %3 = alloca ptr, align 8
  %4 = alloca i8, align 1
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  %10 = zext i1 %1 to i8
  store i8 %10, ptr %4, align 1, !tbaa !9
  %11 = load i8, ptr %4, align 1, !tbaa !9, !range !11, !noundef !12
  %12 = trunc i8 %11 to i1
  br i1 %12, label %13, label %16

13:                                               ; preds = %2
  %14 = call i32 (ptr, ...) @printf(ptr noundef @.str.4)
  %15 = call i32 (ptr, ...) @printf(ptr noundef @.str.5)
  br label %16

16:                                               ; preds = %13, %2
  %17 = call i32 (ptr, ...) @printf(ptr noundef @.str.6)
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #3
  store i32 0, ptr %5, align 4, !tbaa !13
  br label %18

18:                                               ; preds = %27, %16
  %19 = load i32, ptr %5, align 4, !tbaa !13
  %20 = load ptr, ptr %3, align 8, !tbaa !5
  %21 = getelementptr inbounds %struct.Board, ptr %20, i32 0, i32 0
  %22 = load i32, ptr %21, align 4, !tbaa !15
  %23 = icmp slt i32 %19, %22
  br i1 %23, label %25, label %24

24:                                               ; preds = %18
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #3
  br label %30

25:                                               ; preds = %18
  %26 = call i32 (ptr, ...) @printf(ptr noundef @.str.7)
  br label %27

27:                                               ; preds = %25
  %28 = load i32, ptr %5, align 4, !tbaa !13
  %29 = add nsw i32 %28, 1
  store i32 %29, ptr %5, align 4, !tbaa !13
  br label %18, !llvm.loop !17

30:                                               ; preds = %24
  %31 = call i32 (ptr, ...) @printf(ptr noundef @.str.8)
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #3
  store i32 0, ptr %6, align 4, !tbaa !13
  br label %32

32:                                               ; preds = %88, %30
  %33 = load i32, ptr %6, align 4, !tbaa !13
  %34 = load ptr, ptr %3, align 8, !tbaa !5
  %35 = getelementptr inbounds %struct.Board, ptr %34, i32 0, i32 1
  %36 = load i32, ptr %35, align 4, !tbaa !19
  %37 = icmp slt i32 %33, %36
  br i1 %37, label %39, label %38

38:                                               ; preds = %32
  store i32 5, ptr %7, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #3
  br label %91

39:                                               ; preds = %32
  %40 = call i32 (ptr, ...) @printf(ptr noundef @.str.9)
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #3
  store i32 0, ptr %8, align 4, !tbaa !13
  br label %41

41:                                               ; preds = %82, %39
  %42 = load i32, ptr %8, align 4, !tbaa !13
  %43 = load ptr, ptr %3, align 8, !tbaa !5
  %44 = getelementptr inbounds %struct.Board, ptr %43, i32 0, i32 0
  %45 = load i32, ptr %44, align 4, !tbaa !15
  %46 = icmp slt i32 %42, %45
  br i1 %46, label %48, label %47

47:                                               ; preds = %41
  store i32 8, ptr %7, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #3
  br label %85

48:                                               ; preds = %41
  %49 = load ptr, ptr %3, align 8, !tbaa !5
  %50 = getelementptr inbounds %struct.Board, ptr %49, i32 0, i32 5
  %51 = load i32, ptr %6, align 4, !tbaa !13
  %52 = load ptr, ptr %3, align 8, !tbaa !5
  %53 = getelementptr inbounds %struct.Board, ptr %52, i32 0, i32 0
  %54 = load i32, ptr %53, align 4, !tbaa !15
  %55 = mul nsw i32 %51, %54
  %56 = load i32, ptr %8, align 4, !tbaa !13
  %57 = add nsw i32 %55, %56
  %58 = sext i32 %57 to i64
  %59 = getelementptr inbounds [1024 x i8], ptr %50, i64 0, i64 %58
  %60 = load i8, ptr %59, align 1, !tbaa !9, !range !11, !noundef !12
  %61 = trunc i8 %60 to i1
  br i1 %61, label %62, label %79

62:                                               ; preds = %48
  %63 = load ptr, ptr %3, align 8, !tbaa !5
  %64 = getelementptr inbounds %struct.Board, ptr %63, i32 0, i32 4
  %65 = load i32, ptr %6, align 4, !tbaa !13
  %66 = load ptr, ptr %3, align 8, !tbaa !5
  %67 = getelementptr inbounds %struct.Board, ptr %66, i32 0, i32 0
  %68 = load i32, ptr %67, align 4, !tbaa !15
  %69 = mul nsw i32 %65, %68
  %70 = load i32, ptr %8, align 4, !tbaa !13
  %71 = add nsw i32 %69, %70
  %72 = sext i32 %71 to i64
  %73 = getelementptr inbounds [1024 x i32], ptr %64, i64 0, i64 %72
  %74 = load i32, ptr %73, align 4, !tbaa !13
  %75 = sext i32 %74 to i64
  %76 = getelementptr inbounds [10 x [10 x i8]], ptr @print_board_pretty.color_nums, i64 0, i64 %75
  %77 = getelementptr inbounds [10 x i8], ptr %76, i64 0, i64 0
  %78 = call i32 (ptr, ...) @printf(ptr noundef @.str.10, ptr noundef %77)
  br label %81

79:                                               ; preds = %48
  %80 = call i32 (ptr, ...) @printf(ptr noundef @.str.10, ptr noundef getelementptr inbounds ([10 x [10 x i8]], ptr @print_board_pretty.color_nums, i64 0, i64 9))
  br label %81

81:                                               ; preds = %79, %62
  br label %82

82:                                               ; preds = %81
  %83 = load i32, ptr %8, align 4, !tbaa !13
  %84 = add nsw i32 %83, 1
  store i32 %84, ptr %8, align 4, !tbaa !13
  br label %41, !llvm.loop !20

85:                                               ; preds = %47
  %86 = call i32 (ptr, ...) @printf(ptr noundef @.str.11)
  %87 = call i32 (ptr, ...) @printf(ptr noundef @.str.12)
  br label %88

88:                                               ; preds = %85
  %89 = load i32, ptr %6, align 4, !tbaa !13
  %90 = add nsw i32 %89, 1
  store i32 %90, ptr %6, align 4, !tbaa !13
  br label %32, !llvm.loop !21

91:                                               ; preds = %38
  %92 = call i32 (ptr, ...) @printf(ptr noundef @.str.13)
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #3
  store i32 0, ptr %9, align 4, !tbaa !13
  br label %93

93:                                               ; preds = %102, %91
  %94 = load i32, ptr %9, align 4, !tbaa !13
  %95 = load ptr, ptr %3, align 8, !tbaa !5
  %96 = getelementptr inbounds %struct.Board, ptr %95, i32 0, i32 0
  %97 = load i32, ptr %96, align 4, !tbaa !15
  %98 = icmp slt i32 %94, %97
  br i1 %98, label %100, label %99

99:                                               ; preds = %93
  store i32 11, ptr %7, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #3
  br label %105

100:                                              ; preds = %93
  %101 = call i32 (ptr, ...) @printf(ptr noundef @.str.7)
  br label %102

102:                                              ; preds = %100
  %103 = load i32, ptr %9, align 4, !tbaa !13
  %104 = add nsw i32 %103, 1
  store i32 %104, ptr %9, align 4, !tbaa !13
  br label %93, !llvm.loop !22

105:                                              ; preds = %99
  %106 = call i32 (ptr, ...) @printf(ptr noundef @.str.14)
  %107 = load i8, ptr %4, align 1, !tbaa !9, !range !11, !noundef !12
  %108 = trunc i8 %107 to i1
  br i1 %108, label %109, label %111

109:                                              ; preds = %105
  %110 = call i32 (ptr, ...) @printf(ptr noundef @.str.15)
  br label %111

111:                                              ; preds = %109, %105
  ret void
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { "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 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 #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 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"_Bool", !7, i64 0}
!11 = !{i8 0, i8 2}
!12 = !{}
!13 = !{!14, !14, i64 0}
!14 = !{!"int", !7, i64 0}
!15 = !{!16, !14, i64 0}
!16 = !{!"Board", !14, i64 0, !14, i64 4, !14, i64 8, !14, i64 12, !7, i64 16, !7, i64 4112, !7, i64 5136, !10, i64 6160}
!17 = distinct !{!17, !18}
!18 = !{!"llvm.loop.mustprogress"}
!19 = !{!16, !14, i64 4}
!20 = distinct !{!20, !18}
!21 = distinct !{!21, !18}
!22 = distinct !{!22, !18}


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

@print_board_pretty.color_nums = external hidden global [10 x [10 x i8]], align 16
@.str.4 = external hidden unnamed_addr constant [7 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.9 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.10 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.11 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.12 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.13 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.14 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.15 = external hidden unnamed_addr constant [7 x i8], align 1

; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #0

; Function Attrs: nofree nounwind uwtable
define dso_local void @print_board_pretty(ptr nocapture noundef readonly %0, i1 noundef zeroext %1) local_unnamed_addr #1 {
  br i1 %1, label %3, label %6

3:                                                ; preds = %2
  %4 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.4)
  %5 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.5)
  br label %6

6:                                                ; preds = %3, %2
  %7 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.6)
  %8 = load i32, ptr %0, align 4, !tbaa !5
  %9 = icmp sgt i32 %8, 0
  br i1 %9, label %.lr.ph, label %._crit_edge

._crit_edge:                                      ; preds = %.lr.ph, %6
  %10 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.8)
  %11 = getelementptr inbounds i8, ptr %0, i64 4
  %12 = load i32, ptr %11, align 4, !tbaa !11
  %13 = icmp sgt i32 %12, 0
  br i1 %13, label %.lr.ph32, label %._crit_edge33

.lr.ph32:                                         ; preds = %._crit_edge
  %14 = getelementptr inbounds i8, ptr %0, i64 4112
  %15 = getelementptr inbounds i8, ptr %0, i64 16
  br label %23

.lr.ph:                                           ; preds = %6, %.lr.ph
  %.02325 = phi i32 [ %17, %.lr.ph ], [ 0, %6 ]
  %16 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.7)
  %17 = add nuw nsw i32 %.02325, 1
  %18 = load i32, ptr %0, align 4, !tbaa !5
  %19 = icmp slt i32 %17, %18
  br i1 %19, label %.lr.ph, label %._crit_edge, !llvm.loop !12

._crit_edge33:                                    ; preds = %._crit_edge29, %._crit_edge
  %20 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.13)
  %21 = load i32, ptr %0, align 4, !tbaa !5
  %22 = icmp sgt i32 %21, 0
  br i1 %22, label %.lr.ph36, label %._crit_edge37

23:                                               ; preds = %.lr.ph32, %._crit_edge29
  %.02230 = phi i32 [ 0, %.lr.ph32 ], [ %29, %._crit_edge29 ]
  %24 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.9)
  %25 = load i32, ptr %0, align 4, !tbaa !5
  %26 = icmp sgt i32 %25, 0
  br i1 %26, label %.lr.ph28, label %._crit_edge29

._crit_edge29:                                    ; preds = %44, %23
  %27 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.11)
  %28 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.12)
  %29 = add nuw nsw i32 %.02230, 1
  %30 = load i32, ptr %11, align 4, !tbaa !11
  %31 = icmp slt i32 %29, %30
  br i1 %31, label %23, label %._crit_edge33, !llvm.loop !14

.lr.ph28:                                         ; preds = %23, %44
  %32 = phi i32 [ %47, %44 ], [ %25, %23 ]
  %.02126 = phi i32 [ %46, %44 ], [ 0, %23 ]
  %33 = mul nsw i32 %32, %.02230
  %34 = add nsw i32 %33, %.02126
  %35 = sext i32 %34 to i64
  %36 = getelementptr inbounds [1024 x i8], ptr %14, i64 0, i64 %35
  %37 = load i8, ptr %36, align 1, !tbaa !15, !range !16, !noundef !17
  %38 = trunc nuw i8 %37 to i1
  br i1 %38, label %39, label %44

39:                                               ; preds = %.lr.ph28
  %40 = getelementptr inbounds [1024 x i32], ptr %15, i64 0, i64 %35
  %41 = load i32, ptr %40, align 4, !tbaa !18
  %42 = sext i32 %41 to i64
  %43 = getelementptr inbounds [10 x [10 x i8]], ptr @print_board_pretty.color_nums, i64 0, i64 %42
  br label %44

44:                                               ; preds = %.lr.ph28, %39
  %.sink = phi ptr [ %43, %39 ], [ getelementptr inbounds (i8, ptr @print_board_pretty.color_nums, i64 90), %.lr.ph28 ]
  %45 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.10, ptr noundef nonnull %.sink)
  %46 = add nuw nsw i32 %.02126, 1
  %47 = load i32, ptr %0, align 4, !tbaa !5
  %48 = icmp slt i32 %46, %47
  br i1 %48, label %.lr.ph28, label %._crit_edge29, !llvm.loop !19

._crit_edge37:                                    ; preds = %.lr.ph36, %._crit_edge33
  %49 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.14)
  br i1 %1, label %54, label %56

.lr.ph36:                                         ; preds = %._crit_edge33, %.lr.ph36
  %.034 = phi i32 [ %51, %.lr.ph36 ], [ 0, %._crit_edge33 ]
  %50 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.7)
  %51 = add nuw nsw i32 %.034, 1
  %52 = load i32, ptr %0, align 4, !tbaa !5
  %53 = icmp slt i32 %51, %52
  br i1 %53, label %.lr.ph36, label %._crit_edge37, !llvm.loop !20

54:                                               ; preds = %._crit_edge37
  %55 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.15)
  br label %56

56:                                               ; preds = %54, %._crit_edge37
  ret void
}

attributes #0 = { 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 #1 = { nofree 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, !7, i64 0}
!6 = !{!"Board", !7, i64 0, !7, i64 4, !7, i64 8, !7, i64 12, !8, i64 16, !8, i64 4112, !8, i64 5136, !10, i64 6160}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"_Bool", !8, i64 0}
!11 = !{!6, !7, i64 4}
!12 = distinct !{!12, !13}
!13 = !{!"llvm.loop.mustprogress"}
!14 = distinct !{!14, !13}
!15 = !{!10, !10, i64 0}
!16 = !{i8 0, i8 2}
!17 = !{}
!18 = !{!7, !7, i64 0}
!19 = distinct !{!19, !13}
!20 = distinct !{!20, !13}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass