; LLVM IR from lolosssss/leetcode :: c (37_sudoku_solver)

; 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: nounwind uwtable
declare dso_local void @readSudoku(ptr noundef, ptr noundef, ptr noundef, ptr noundef, ptr 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
declare dso_local zeroext i1 @setCell(ptr noundef, ptr noundef, ptr noundef, ptr noundef, i32 noundef, i32 noundef) #0

; Function Attrs: nounwind uwtable
define dso_local void @solveSudoku(ptr noundef %0, i32 noundef %1, i32 noundef %2) #0 {
  %4 = alloca ptr, align 8
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca [9 x [9 x i32]], align 16
  %8 = alloca [9 x [9 x i32]], align 16
  %9 = alloca [9 x [9 x i32]], align 16
  %10 = alloca i32, align 4
  %11 = alloca [9 x [9 x i32]], align 16
  store ptr %0, ptr %4, align 8, !tbaa !5
  store i32 %1, ptr %5, align 4, !tbaa !9
  store i32 %2, ptr %6, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 324, ptr %7) #3
  call void @llvm.lifetime.start.p0(i64 324, ptr %8) #3
  call void @llvm.lifetime.start.p0(i64 324, ptr %9) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #3
  store i32 0, ptr %10, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 324, ptr %11) #3
  %12 = getelementptr inbounds [9 x [9 x i32]], ptr %8, i64 0, i64 0
  call void @llvm.memset.p0.i64(ptr align 16 %12, i8 0, i64 324, i1 false)
  %13 = getelementptr inbounds [9 x [9 x i32]], ptr %7, i64 0, i64 0
  call void @llvm.memset.p0.i64(ptr align 16 %13, i8 0, i64 324, i1 false)
  %14 = getelementptr inbounds [9 x [9 x i32]], ptr %9, i64 0, i64 0
  call void @llvm.memset.p0.i64(ptr align 16 %14, i8 0, i64 324, i1 false)
  %15 = getelementptr inbounds [9 x [9 x i32]], ptr %11, i64 0, i64 0
  call void @llvm.memset.p0.i64(ptr align 16 %15, i8 0, i64 324, i1 false)
  %16 = load ptr, ptr %4, align 8, !tbaa !5
  %17 = getelementptr inbounds [9 x [9 x i32]], ptr %11, i64 0, i64 0
  %18 = getelementptr inbounds [9 x [9 x i32]], ptr %8, i64 0, i64 0
  %19 = getelementptr inbounds [9 x [9 x i32]], ptr %7, i64 0, i64 0
  %20 = getelementptr inbounds [9 x [9 x i32]], ptr %9, i64 0, i64 0
  call void @readSudoku(ptr noundef %16, ptr noundef %17, ptr noundef %18, ptr noundef %19, ptr noundef %20)
  br label %21

21:                                               ; preds = %84, %3
  br label %22

22:                                               ; preds = %21
  br label %23

23:                                               ; preds = %39, %22
  %24 = load i32, ptr %10, align 4, !tbaa !9
  %25 = icmp slt i32 %24, 81
  br i1 %25, label %26, label %37

26:                                               ; preds = %23
  %27 = load i32, ptr %10, align 4, !tbaa !9
  %28 = sdiv i32 %27, 9
  %29 = sext i32 %28 to i64
  %30 = getelementptr inbounds [9 x [9 x i32]], ptr %11, i64 0, i64 %29
  %31 = load i32, ptr %10, align 4, !tbaa !9
  %32 = srem i32 %31, 9
  %33 = sext i32 %32 to i64
  %34 = getelementptr inbounds [9 x i32], ptr %30, i64 0, i64 %33
  %35 = load i32, ptr %34, align 4, !tbaa !9
  %36 = icmp ne i32 %35, 0
  br label %37

37:                                               ; preds = %26, %23
  %38 = phi i1 [ false, %23 ], [ %36, %26 ]
  br i1 %38, label %39, label %42

39:                                               ; preds = %37
  %40 = load i32, ptr %10, align 4, !tbaa !9
  %41 = add nsw i32 %40, 1
  store i32 %41, ptr %10, align 4, !tbaa !9
  br label %23, !llvm.loop !11

42:                                               ; preds = %37
  %43 = load i32, ptr %10, align 4, !tbaa !9
  %44 = icmp sge i32 %43, 81
  br i1 %44, label %45, label %46

45:                                               ; preds = %42
  br label %85

46:                                               ; preds = %42
  %47 = load ptr, ptr %4, align 8, !tbaa !5
  %48 = getelementptr inbounds [9 x [9 x i32]], ptr %8, i64 0, i64 0
  %49 = getelementptr inbounds [9 x [9 x i32]], ptr %7, i64 0, i64 0
  %50 = getelementptr inbounds [9 x [9 x i32]], ptr %9, i64 0, i64 0
  %51 = load i32, ptr %10, align 4, !tbaa !9
  %52 = sdiv i32 %51, 9
  %53 = load i32, ptr %10, align 4, !tbaa !9
  %54 = srem i32 %53, 9
  %55 = call zeroext i1 @setCell(ptr noundef %47, ptr noundef %48, ptr noundef %49, ptr noundef %50, i32 noundef %52, i32 noundef %54)
  br i1 %55, label %56, label %59

56:                                               ; preds = %46
  %57 = load i32, ptr %10, align 4, !tbaa !9
  %58 = add nsw i32 %57, 1
  store i32 %58, ptr %10, align 4, !tbaa !9
  br label %84

59:                                               ; preds = %46
  br label %60

60:                                               ; preds = %77, %59
  %61 = load i32, ptr %10, align 4, !tbaa !9
  %62 = add nsw i32 %61, -1
  store i32 %62, ptr %10, align 4, !tbaa !9
  br label %63

63:                                               ; preds = %60
  %64 = load i32, ptr %10, align 4, !tbaa !9
  %65 = icmp sge i32 %64, 0
  br i1 %65, label %66, label %77

66:                                               ; preds = %63
  %67 = load i32, ptr %10, align 4, !tbaa !9
  %68 = sdiv i32 %67, 9
  %69 = sext i32 %68 to i64
  %70 = getelementptr inbounds [9 x [9 x i32]], ptr %11, i64 0, i64 %69
  %71 = load i32, ptr %10, align 4, !tbaa !9
  %72 = srem i32 %71, 9
  %73 = sext i32 %72 to i64
  %74 = getelementptr inbounds [9 x i32], ptr %70, i64 0, i64 %73
  %75 = load i32, ptr %74, align 4, !tbaa !9
  %76 = icmp ne i32 %75, 0
  br label %77

77:                                               ; preds = %66, %63
  %78 = phi i1 [ false, %63 ], [ %76, %66 ]
  br i1 %78, label %60, label %79, !llvm.loop !13

79:                                               ; preds = %77
  %80 = load i32, ptr %10, align 4, !tbaa !9
  %81 = icmp slt i32 %80, 0
  br i1 %81, label %82, label %83

82:                                               ; preds = %79
  br label %85

83:                                               ; preds = %79
  br label %84

84:                                               ; preds = %83, %56
  br label %21

85:                                               ; preds = %82, %45
  call void @llvm.lifetime.end.p0(i64 324, ptr %11) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #3
  call void @llvm.lifetime.end.p0(i64 324, ptr %9) #3
  call void @llvm.lifetime.end.p0(i64 324, ptr %8) #3
  call void @llvm.lifetime.end.p0(i64 324, ptr %7) #3
  ret void
}

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #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 = { nocallback nofree nounwind willreturn memory(argmem: write) }
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}


; 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: nounwind uwtable
declare dso_local void @readSudoku(ptr noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #0

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

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

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

; Function Attrs: nounwind uwtable
define dso_local void @solveSudoku(ptr noundef %0, i32 noundef %1, i32 noundef %2) local_unnamed_addr #0 {
  %4 = alloca [9 x [9 x i32]], align 16
  %5 = alloca [9 x [9 x i32]], align 16
  %6 = alloca [9 x [9 x i32]], align 16
  %7 = alloca [9 x [9 x i32]], align 16
  call void @llvm.lifetime.start.p0(i64 324, ptr nonnull %4) #3
  call void @llvm.lifetime.start.p0(i64 324, ptr nonnull %5) #3
  call void @llvm.lifetime.start.p0(i64 324, ptr nonnull %6) #3
  call void @llvm.lifetime.start.p0(i64 324, ptr nonnull %7) #3
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 16 dereferenceable(324) %5, i8 0, i64 324, i1 false)
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 16 dereferenceable(324) %4, i8 0, i64 324, i1 false)
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 16 dereferenceable(324) %6, i8 0, i64 324, i1 false)
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 16 dereferenceable(324) %7, i8 0, i64 324, i1 false)
  call void @readSudoku(ptr noundef %0, ptr noundef nonnull %7, ptr noundef nonnull %5, ptr noundef nonnull %4, ptr noundef nonnull %6)
  br label %.lr.ph

.lr.ph:                                           ; preds = %.lr.ph.backedge, %3
  %.121 = phi i32 [ 0, %3 ], [ %.121.be, %.lr.ph.backedge ]
  %8 = sdiv i32 %.121, 9
  %9 = sext i32 %8 to i64
  %10 = srem i32 %.121, 9
  %11 = sext i32 %10 to i64
  %12 = getelementptr inbounds [9 x [9 x i32]], ptr %7, i64 0, i64 %9, i64 %11
  %13 = load i32, ptr %12, align 4, !tbaa !5
  %.not = icmp eq i32 %13, 0
  br i1 %.not, label %.critedge, label %14

14:                                               ; preds = %.lr.ph
  %15 = add i32 %.121, 1
  %exitcond.not = icmp eq i32 %.121, 80
  br i1 %exitcond.not, label %.critedge.thread, label %.lr.ph.backedge

.lr.ph.backedge:                                  ; preds = %14, %.critedge2
  %.121.be = phi i32 [ %15, %14 ], [ %.3, %.critedge2 ]
  br label %.lr.ph, !llvm.loop !9

.critedge:                                        ; preds = %.lr.ph
  %16 = call zeroext i1 @setCell(ptr noundef %0, ptr noundef nonnull %5, ptr noundef nonnull %4, ptr noundef nonnull %6, i32 noundef %8, i32 noundef %10)
  br i1 %16, label %17, label %.preheader

17:                                               ; preds = %.critedge
  %18 = add nsw i32 %.121, 1
  br label %.critedge2

.preheader:                                       ; preds = %.critedge, %20
  %.2 = phi i32 [ %21, %20 ], [ %.121, %.critedge ]
  %19 = icmp sgt i32 %.2, 0
  br i1 %19, label %20, label %.critedge.thread

20:                                               ; preds = %.preheader
  %21 = add nsw i32 %.2, -1
  %22 = udiv i32 %21, 9
  %23 = zext nneg i32 %22 to i64
  %24 = urem i32 %21, 9
  %25 = zext nneg i32 %24 to i64
  %26 = getelementptr inbounds [9 x [9 x i32]], ptr %7, i64 0, i64 %23, i64 %25
  %27 = load i32, ptr %26, align 4, !tbaa !5
  %.not18 = icmp eq i32 %27, 0
  br i1 %.not18, label %.critedge2, label %.preheader, !llvm.loop !11

.critedge2:                                       ; preds = %20, %17
  %.3 = phi i32 [ %18, %17 ], [ %21, %20 ]
  %28 = icmp slt i32 %.3, 81
  br i1 %28, label %.lr.ph.backedge, label %.critedge.thread

.critedge.thread:                                 ; preds = %.critedge2, %14, %.preheader
  call void @llvm.lifetime.end.p0(i64 324, ptr nonnull %7) #3
  call void @llvm.lifetime.end.p0(i64 324, ptr nonnull %6) #3
  call void @llvm.lifetime.end.p0(i64 324, ptr nonnull %5) #3
  call void @llvm.lifetime.end.p0(i64 324, ptr nonnull %4) #3
  ret void
}

; Function Attrs: mustprogress nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #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 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: write) }
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 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}
!11 = distinct !{!11, !10}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,SROAPass,SimplifyCFGPass