; LLVM IR from HarshCasper/NeoAlgo :: C/other (SudokuSolver)

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

@.str = external hidden unnamed_addr constant [17 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [2 x i8], align 1

; Function Attrs: nounwind uwtable
declare dso_local zeroext i1 @isSafeToPut(ptr noundef, i32 noundef, i32 noundef, i32 noundef, i32 noundef) #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: nounwind uwtable
define dso_local zeroext i1 @SudokuSolver(ptr noundef %0, i32 noundef %1, i32 noundef %2, i32 noundef %3) #0 {
  %5 = alloca i1, align 1
  %6 = alloca ptr, align 8
  %7 = alloca i32, align 4
  %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 i32, align 4
  %14 = alloca i8, align 1
  store ptr %0, ptr %6, align 8, !tbaa !5
  store i32 %1, ptr %7, align 4, !tbaa !9
  store i32 %2, ptr %8, align 4, !tbaa !9
  store i32 %3, ptr %9, align 4, !tbaa !9
  %15 = load i32, ptr %7, align 4, !tbaa !9
  %16 = load i32, ptr %9, align 4, !tbaa !9
  %17 = icmp eq i32 %15, %16
  br i1 %17, label %18, label %51

18:                                               ; preds = %4
  %19 = call i32 (ptr, ...) @printf(ptr noundef @.str)
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #3
  store i32 0, ptr %10, align 4, !tbaa !9
  br label %20

20:                                               ; preds = %46, %18
  %21 = load i32, ptr %10, align 4, !tbaa !9
  %22 = load i32, ptr %9, align 4, !tbaa !9
  %23 = icmp slt i32 %21, %22
  br i1 %23, label %25, label %24

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

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

26:                                               ; preds = %41, %25
  %27 = load i32, ptr %12, align 4, !tbaa !9
  %28 = load i32, ptr %9, align 4, !tbaa !9
  %29 = icmp slt i32 %27, %28
  br i1 %29, label %31, label %30

30:                                               ; preds = %26
  store i32 5, ptr %11, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #3
  br label %44

31:                                               ; preds = %26
  %32 = load ptr, ptr %6, align 8, !tbaa !5
  %33 = load i32, ptr %10, align 4, !tbaa !9
  %34 = sext i32 %33 to i64
  %35 = getelementptr inbounds [9 x i32], ptr %32, i64 %34
  %36 = load i32, ptr %12, align 4, !tbaa !9
  %37 = sext i32 %36 to i64
  %38 = getelementptr inbounds [9 x i32], ptr %35, i64 0, i64 %37
  %39 = load i32, ptr %38, align 4, !tbaa !9
  %40 = call i32 (ptr, ...) @printf(ptr noundef @.str.1, i32 noundef %39)
  br label %41

41:                                               ; preds = %31
  %42 = load i32, ptr %12, align 4, !tbaa !9
  %43 = add nsw i32 %42, 1
  store i32 %43, ptr %12, align 4, !tbaa !9
  br label %26, !llvm.loop !11

44:                                               ; preds = %30
  %45 = call i32 (ptr, ...) @printf(ptr noundef @.str.2)
  br label %46

46:                                               ; preds = %44
  %47 = load i32, ptr %10, align 4, !tbaa !9
  %48 = add nsw i32 %47, 1
  store i32 %48, ptr %10, align 4, !tbaa !9
  br label %20, !llvm.loop !13

49:                                               ; preds = %24
  %50 = call i32 (ptr, ...) @printf(ptr noundef @.str.2)
  store i1 true, ptr %5, align 1
  br label %128

51:                                               ; preds = %4
  %52 = load i32, ptr %8, align 4, !tbaa !9
  %53 = load i32, ptr %9, align 4, !tbaa !9
  %54 = icmp eq i32 %52, %53
  br i1 %54, label %55, label %61

55:                                               ; preds = %51
  %56 = load ptr, ptr %6, align 8, !tbaa !5
  %57 = load i32, ptr %7, align 4, !tbaa !9
  %58 = add nsw i32 %57, 1
  %59 = load i32, ptr %9, align 4, !tbaa !9
  %60 = call zeroext i1 @SudokuSolver(ptr noundef %56, i32 noundef %58, i32 noundef 0, i32 noundef %59)
  store i1 %60, ptr %5, align 1
  br label %128

61:                                               ; preds = %51
  %62 = load ptr, ptr %6, align 8, !tbaa !5
  %63 = load i32, ptr %7, align 4, !tbaa !9
  %64 = sext i32 %63 to i64
  %65 = getelementptr inbounds [9 x i32], ptr %62, i64 %64
  %66 = load i32, ptr %8, align 4, !tbaa !9
  %67 = sext i32 %66 to i64
  %68 = getelementptr inbounds [9 x i32], ptr %65, i64 0, i64 %67
  %69 = load i32, ptr %68, align 4, !tbaa !9
  %70 = icmp ne i32 %69, 0
  br i1 %70, label %71, label %78

71:                                               ; preds = %61
  %72 = load ptr, ptr %6, align 8, !tbaa !5
  %73 = load i32, ptr %7, align 4, !tbaa !9
  %74 = load i32, ptr %8, align 4, !tbaa !9
  %75 = add nsw i32 %74, 1
  %76 = load i32, ptr %9, align 4, !tbaa !9
  %77 = call zeroext i1 @SudokuSolver(ptr noundef %72, i32 noundef %73, i32 noundef %75, i32 noundef %76)
  store i1 %77, ptr %5, align 1
  br label %128

78:                                               ; preds = %61
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #3
  store i32 1, ptr %13, align 4, !tbaa !9
  br label %79

79:                                               ; preds = %122, %78
  %80 = load i32, ptr %13, align 4, !tbaa !9
  %81 = load i32, ptr %9, align 4, !tbaa !9
  %82 = icmp sle i32 %80, %81
  br i1 %82, label %84, label %83

83:                                               ; preds = %79
  store i32 8, ptr %11, align 4
  br label %125

84:                                               ; preds = %79
  %85 = load ptr, ptr %6, align 8, !tbaa !5
  %86 = load i32, ptr %7, align 4, !tbaa !9
  %87 = load i32, ptr %8, align 4, !tbaa !9
  %88 = load i32, ptr %9, align 4, !tbaa !9
  %89 = load i32, ptr %13, align 4, !tbaa !9
  %90 = call zeroext i1 @isSafeToPut(ptr noundef %85, i32 noundef %86, i32 noundef %87, i32 noundef %88, i32 noundef %89)
  br i1 %90, label %91, label %121

91:                                               ; preds = %84
  %92 = load i32, ptr %13, align 4, !tbaa !9
  %93 = load ptr, ptr %6, align 8, !tbaa !5
  %94 = load i32, ptr %7, align 4, !tbaa !9
  %95 = sext i32 %94 to i64
  %96 = getelementptr inbounds [9 x i32], ptr %93, i64 %95
  %97 = load i32, ptr %8, align 4, !tbaa !9
  %98 = sext i32 %97 to i64
  %99 = getelementptr inbounds [9 x i32], ptr %96, i64 0, i64 %98
  store i32 %92, ptr %99, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 1, ptr %14) #3
  %100 = load ptr, ptr %6, align 8, !tbaa !5
  %101 = load i32, ptr %7, align 4, !tbaa !9
  %102 = load i32, ptr %8, align 4, !tbaa !9
  %103 = add nsw i32 %102, 1
  %104 = load i32, ptr %9, align 4, !tbaa !9
  %105 = call zeroext i1 @SudokuSolver(ptr noundef %100, i32 noundef %101, i32 noundef %103, i32 noundef %104)
  %106 = zext i1 %105 to i8
  store i8 %106, ptr %14, align 1, !tbaa !14
  %107 = load i8, ptr %14, align 1, !tbaa !14, !range !16, !noundef !17
  %108 = trunc i8 %107 to i1
  br i1 %108, label %109, label %110

109:                                              ; preds = %91
  store i1 true, ptr %5, align 1
  store i32 1, ptr %11, align 4
  br label %118

110:                                              ; preds = %91
  %111 = load ptr, ptr %6, align 8, !tbaa !5
  %112 = load i32, ptr %7, align 4, !tbaa !9
  %113 = sext i32 %112 to i64
  %114 = getelementptr inbounds [9 x i32], ptr %111, i64 %113
  %115 = load i32, ptr %8, align 4, !tbaa !9
  %116 = sext i32 %115 to i64
  %117 = getelementptr inbounds [9 x i32], ptr %114, i64 0, i64 %116
  store i32 0, ptr %117, align 4, !tbaa !9
  store i32 0, ptr %11, align 4
  br label %118

118:                                              ; preds = %110, %109
  call void @llvm.lifetime.end.p0(i64 1, ptr %14) #3
  %119 = load i32, ptr %11, align 4
  switch i32 %119, label %125 [
    i32 0, label %120
  ]

120:                                              ; preds = %118
  br label %121

121:                                              ; preds = %120, %84
  br label %122

122:                                              ; preds = %121
  %123 = load i32, ptr %13, align 4, !tbaa !9
  %124 = add nsw i32 %123, 1
  store i32 %124, ptr %13, align 4, !tbaa !9
  br label %79, !llvm.loop !18

125:                                              ; preds = %118, %83
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #3
  %126 = load i32, ptr %11, align 4
  switch i32 %126, label %130 [
    i32 8, label %127
    i32 1, label %128
  ]

127:                                              ; preds = %125
  store i1 false, ptr %5, align 1
  br label %128

128:                                              ; preds = %127, %125, %71, %55, %49
  %129 = load i1, ptr %5, align 1
  ret i1 %129

130:                                              ; preds = %125
  unreachable
}

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

attributes #0 = { 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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { "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 = !{!"int", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = distinct !{!13, !12}
!14 = !{!15, !15, i64 0}
!15 = !{!"_Bool", !7, i64 0}
!16 = !{i8 0, i8 2}
!17 = !{}
!18 = distinct !{!18, !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"

@.str = external hidden unnamed_addr constant [17 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [2 x i8], align 1

; Function Attrs: nounwind uwtable
declare dso_local zeroext i1 @isSafeToPut(ptr noundef, i32 noundef, i32 noundef, i32 noundef, i32 noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local noundef zeroext i1 @SudokuSolver(ptr noundef %0, i32 noundef %1, i32 noundef %2, i32 noundef %3) local_unnamed_addr #0 {
  %5 = icmp eq i32 %1, %3
  br i1 %5, label %tailrecurse.outer._crit_edge, label %.lr.ph.preheader

.lr.ph.preheader:                                 ; preds = %4
  %6 = sext i32 %1 to i64
  br label %.lr.ph.split

.lr.ph.split:                                     ; preds = %tailrecurse.outer, %.lr.ph.preheader
  %indvars.iv95 = phi i64 [ %6, %.lr.ph.preheader ], [ %indvars.iv.next96, %tailrecurse.outer ]
  %.tr56.ph74 = phi i32 [ %2, %.lr.ph.preheader ], [ 0, %tailrecurse.outer ]
  %7 = icmp eq i32 %.tr56.ph74, %3
  br i1 %7, label %tailrecurse.outer, label %.lr.ph71.preheader

.lr.ph71.preheader:                               ; preds = %.lr.ph.split
  %8 = sext i32 %.tr56.ph74 to i64
  br label %.lr.ph71

tailrecurse.outer._crit_edge:                     ; preds = %tailrecurse.outer, %4
  %9 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str)
  %10 = icmp sgt i32 %3, 0
  br i1 %10, label %.preheader.us.preheader, label %._crit_edge83

.preheader.us.preheader:                          ; preds = %tailrecurse.outer._crit_edge
  %wide.trip.count104 = zext nneg i32 %3 to i64
  br label %.preheader.us

.preheader.us:                                    ; preds = %.preheader.us.preheader, %._crit_edge.us
  %indvars.iv101 = phi i64 [ 0, %.preheader.us.preheader ], [ %indvars.iv.next102, %._crit_edge.us ]
  br label %11

11:                                               ; preds = %.preheader.us, %11
  %indvars.iv97 = phi i64 [ 0, %.preheader.us ], [ %indvars.iv.next98, %11 ]
  %12 = getelementptr inbounds [9 x i32], ptr %0, i64 %indvars.iv101, i64 %indvars.iv97
  %13 = load i32, ptr %12, align 4, !tbaa !5
  %14 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.1, i32 noundef %13)
  %indvars.iv.next98 = add nuw nsw i64 %indvars.iv97, 1
  %exitcond100.not = icmp eq i64 %indvars.iv.next98, %wide.trip.count104
  br i1 %exitcond100.not, label %._crit_edge.us, label %11, !llvm.loop !9

._crit_edge.us:                                   ; preds = %11
  %15 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2)
  %indvars.iv.next102 = add nuw nsw i64 %indvars.iv101, 1
  %exitcond105.not = icmp eq i64 %indvars.iv.next102, %wide.trip.count104
  br i1 %exitcond105.not, label %._crit_edge83, label %.preheader.us, !llvm.loop !11

._crit_edge83:                                    ; preds = %._crit_edge.us, %tailrecurse.outer._crit_edge
  %16 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2)
  br label %.critedge

tailrecurse.outer:                                ; preds = %tailrecurse, %.lr.ph.split
  %indvars.iv.next96 = add nsw i64 %indvars.iv95, 1
  %17 = trunc nsw i64 %indvars.iv.next96 to i32
  %18 = icmp eq i32 %17, %3
  br i1 %18, label %tailrecurse.outer._crit_edge, label %.lr.ph.split

.lr.ph71:                                         ; preds = %.lr.ph71.preheader, %tailrecurse
  %indvars.iv = phi i64 [ %8, %.lr.ph71.preheader ], [ %indvars.iv.next, %tailrecurse ]
  %19 = getelementptr inbounds [9 x i32], ptr %0, i64 %indvars.iv95, i64 %indvars.iv
  %20 = load i32, ptr %19, align 4, !tbaa !5
  %.not = icmp eq i32 %20, 0
  br i1 %.not, label %.preheader58, label %tailrecurse

.preheader58:                                     ; preds = %.lr.ph71
  %21 = trunc nsw i64 %indvars.iv95 to i32
  %22 = trunc nsw i64 %indvars.iv to i32
  %.not5475 = icmp sgt i32 %3, 0
  br i1 %.not5475, label %.lr.ph77, label %.critedge

.lr.ph77:                                         ; preds = %.preheader58
  %23 = add nsw i32 %22, 1
  br label %26

tailrecurse:                                      ; preds = %.lr.ph71
  %indvars.iv.next = add nsw i64 %indvars.iv, 1
  %24 = trunc nsw i64 %indvars.iv.next to i32
  %25 = icmp eq i32 %24, %3
  br i1 %25, label %tailrecurse.outer, label %.lr.ph71

26:                                               ; preds = %.lr.ph77, %31
  %.04576 = phi i32 [ 1, %.lr.ph77 ], [ %32, %31 ]
  %27 = tail call zeroext i1 @isSafeToPut(ptr noundef %0, i32 noundef %21, i32 noundef %22, i32 noundef %3, i32 noundef %.04576)
  br i1 %27, label %28, label %31

28:                                               ; preds = %26
  store i32 %.04576, ptr %19, align 4, !tbaa !5
  %29 = tail call zeroext i1 @SudokuSolver(ptr noundef %0, i32 noundef %21, i32 noundef %23, i32 noundef %3)
  br i1 %29, label %.critedge, label %30

30:                                               ; preds = %28
  store i32 0, ptr %19, align 4, !tbaa !5
  br label %31

31:                                               ; preds = %30, %26
  %32 = add nuw i32 %.04576, 1
  %exitcond.not = icmp eq i32 %.04576, %3
  br i1 %exitcond.not, label %.critedge, label %26, !llvm.loop !12

.critedge:                                        ; preds = %28, %31, %.preheader58, %._crit_edge83
  %.4 = phi i1 [ true, %._crit_edge83 ], [ false, %.preheader58 ], [ true, %28 ], [ false, %31 ]
  ret i1 %.4
}

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

attributes #0 = { 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 = { 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" }

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


; Effective O3 passes: ConstraintEliminationPass,CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LICMPass,LoopInstSimplifyPass,LoopRotatePass,LoopSimplifyCFGPass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SCCPPass,SROAPass,SimplifyCFGPass,TailCallElimPass