; LLVM IR from chirag-singhal/Coding-Interview-101 :: Miscellaneous/Codechef/janlong (5)

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

%"class.std::basic_ostream" = type { ptr, %"class.std::basic_ios" }
%"class.std::basic_ios" = type { %"class.std::ios_base", ptr, i8, i8, ptr, ptr, ptr, ptr }
%"class.std::ios_base" = type { ptr, i64, i64, i32, i32, i32, ptr, %"struct.std::ios_base::_Words", [8 x %"struct.std::ios_base::_Words"], i32, ptr, %"class.std::locale" }
%"struct.std::ios_base::_Words" = type { ptr, i64 }
%"class.std::locale" = type { ptr }
%"class.std::basic_istream" = type { ptr, i64, %"class.std::basic_ios" }

@grid = external dso_local global [2000 x [2000 x i32]], align 16
@_ZSt4cout = external global %"class.std::basic_ostream", align 8
@_ZSt3cin = external global %"class.std::basic_istream", align 8
@.str.1 = external hidden unnamed_addr constant [7 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [4 x i8], align 1

; Function Attrs: mustprogress uwtable
declare dso_local noundef zeroext i1 @_Z11SolveSudokui(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: mustprogress uwtable
declare dso_local void @_Z9printGridi(i32 noundef) #0

; Function Attrs: inlinehint mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef) #2

; Function Attrs: mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEPFRSoS_E(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef) #0 align 2

; Function Attrs: inlinehint mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(8) ptr @_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_(ptr noundef nonnull align 8 dereferenceable(8)) #2

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() #3 {
  %1 = alloca i32, align 4
  %2 = alloca i32, align 4
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %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 i32 0, ptr %1, align 4
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #5
  %10 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 4 dereferenceable(4) %2)
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #5
  store i32 0, ptr %3, align 4, !tbaa !5
  br label %11

11:                                               ; preds = %83, %0
  %12 = load i32, ptr %3, align 4, !tbaa !5
  %13 = load i32, ptr %2, align 4, !tbaa !5
  %14 = icmp slt i32 %12, %13
  br i1 %14, label %16, label %15

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

16:                                               ; preds = %11
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #5
  %17 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 4 dereferenceable(4) %5)
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #5
  store i32 0, ptr %6, align 4, !tbaa !5
  br label %18

18:                                               ; preds = %40, %16
  %19 = load i32, ptr %6, align 4, !tbaa !5
  %20 = load i32, ptr %5, align 4, !tbaa !5
  %21 = icmp slt i32 %19, %20
  br i1 %21, label %23, label %22

22:                                               ; preds = %18
  store i32 5, ptr %4, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #5
  br label %43

23:                                               ; preds = %18
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #5
  store i32 0, ptr %7, align 4, !tbaa !5
  br label %24

24:                                               ; preds = %36, %23
  %25 = load i32, ptr %7, align 4, !tbaa !5
  %26 = load i32, ptr %5, align 4, !tbaa !5
  %27 = icmp slt i32 %25, %26
  br i1 %27, label %29, label %28

28:                                               ; preds = %24
  store i32 8, ptr %4, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #5
  br label %39

29:                                               ; preds = %24
  %30 = load i32, ptr %6, align 4, !tbaa !5
  %31 = sext i32 %30 to i64
  %32 = getelementptr inbounds [2000 x [2000 x i32]], ptr @grid, i64 0, i64 %31
  %33 = load i32, ptr %7, align 4, !tbaa !5
  %34 = sext i32 %33 to i64
  %35 = getelementptr inbounds [2000 x i32], ptr %32, i64 0, i64 %34
  store i32 0, ptr %35, align 4, !tbaa !5
  br label %36

36:                                               ; preds = %29
  %37 = load i32, ptr %7, align 4, !tbaa !5
  %38 = add nsw i32 %37, 1
  store i32 %38, ptr %7, align 4, !tbaa !5
  br label %24, !llvm.loop !9

39:                                               ; preds = %28
  br label %40

40:                                               ; preds = %39
  %41 = load i32, ptr %6, align 4, !tbaa !5
  %42 = add nsw i32 %41, 1
  store i32 %42, ptr %6, align 4, !tbaa !5
  br label %18, !llvm.loop !11

43:                                               ; preds = %22
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #5
  store i32 0, ptr %8, align 4, !tbaa !5
  br label %44

44:                                               ; preds = %54, %43
  %45 = load i32, ptr %8, align 4, !tbaa !5
  %46 = load i32, ptr %5, align 4, !tbaa !5
  %47 = icmp slt i32 %45, %46
  br i1 %47, label %49, label %48

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

49:                                               ; preds = %44
  %50 = load i32, ptr %8, align 4, !tbaa !5
  %51 = load i32, ptr %8, align 4, !tbaa !5
  %52 = sext i32 %51 to i64
  %53 = getelementptr inbounds [2000 x i32], ptr @grid, i64 0, i64 %52
  store i32 %50, ptr %53, align 4, !tbaa !5
  br label %54

54:                                               ; preds = %49
  %55 = load i32, ptr %8, align 4, !tbaa !5
  %56 = add nsw i32 %55, 1
  store i32 %56, ptr %8, align 4, !tbaa !5
  br label %44, !llvm.loop !12

57:                                               ; preds = %48
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #5
  store i32 0, ptr %9, align 4, !tbaa !5
  br label %58

58:                                               ; preds = %69, %57
  %59 = load i32, ptr %9, align 4, !tbaa !5
  %60 = load i32, ptr %5, align 4, !tbaa !5
  %61 = icmp slt i32 %59, %60
  br i1 %61, label %63, label %62

62:                                               ; preds = %58
  store i32 14, ptr %4, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #5
  br label %72

63:                                               ; preds = %58
  %64 = load i32, ptr %9, align 4, !tbaa !5
  %65 = load i32, ptr %9, align 4, !tbaa !5
  %66 = sext i32 %65 to i64
  %67 = getelementptr inbounds [2000 x [2000 x i32]], ptr @grid, i64 0, i64 %66
  %68 = getelementptr inbounds [2000 x i32], ptr %67, i64 0, i64 0
  store i32 %64, ptr %68, align 16, !tbaa !5
  br label %69

69:                                               ; preds = %63
  %70 = load i32, ptr %9, align 4, !tbaa !5
  %71 = add nsw i32 %70, 1
  store i32 %71, ptr %9, align 4, !tbaa !5
  br label %58, !llvm.loop !13

72:                                               ; preds = %62
  %73 = load i32, ptr %5, align 4, !tbaa !5
  %74 = call noundef zeroext i1 @_Z11SolveSudokui(i32 noundef %73)
  br i1 %74, label %75, label %79

75:                                               ; preds = %72
  %76 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, ptr noundef @.str.1)
  %77 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEPFRSoS_E(ptr noundef nonnull align 8 dereferenceable(8) %76, ptr noundef @_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_)
  %78 = load i32, ptr %5, align 4, !tbaa !5
  call void @_Z9printGridi(i32 noundef %78)
  br label %82

79:                                               ; preds = %72
  %80 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, ptr noundef @.str.2)
  %81 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEPFRSoS_E(ptr noundef nonnull align 8 dereferenceable(8) %80, ptr noundef @_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_)
  br label %82

82:                                               ; preds = %79, %75
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #5
  br label %83

83:                                               ; preds = %82
  %84 = load i32, ptr %3, align 4, !tbaa !5
  %85 = add nsw i32 %84, 1
  store i32 %85, ptr %3, align 4, !tbaa !5
  br label %11, !llvm.loop !14

86:                                               ; preds = %15
  store i32 0, ptr %1, align 4
  store i32 1, ptr %4, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #5
  %87 = load i32, ptr %1, align 4
  ret i32 %87
}

declare noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef nonnull align 4 dereferenceable(4)) #4

attributes #0 = { mustprogress 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 = { inlinehint mustprogress 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 = { mustprogress norecurse 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 #4 = { "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 #5 = { 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++ TBAA"}
!9 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}
!11 = distinct !{!11, !10}
!12 = distinct !{!12, !10}
!13 = distinct !{!13, !10}
!14 = distinct !{!14, !10}


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

%"class.std::basic_ostream" = type { ptr, %"class.std::basic_ios" }
%"class.std::basic_ios" = type { %"class.std::ios_base", ptr, i8, i8, ptr, ptr, ptr, ptr }
%"class.std::ios_base" = type { ptr, i64, i64, i32, i32, i32, ptr, %"struct.std::ios_base::_Words", [8 x %"struct.std::ios_base::_Words"], i32, ptr, %"class.std::locale" }
%"struct.std::ios_base::_Words" = type { ptr, i64 }
%"class.std::locale" = type { ptr }
%"class.std::basic_istream" = type { ptr, i64, %"class.std::basic_ios" }

@grid = external dso_local local_unnamed_addr global [2000 x [2000 x i32]], align 16
@_ZSt4cout = external global %"class.std::basic_ostream", align 8
@_ZSt3cin = external global %"class.std::basic_istream", align 8
@.str.1 = external hidden unnamed_addr constant [7 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [4 x i8], align 1

; Function Attrs: mustprogress uwtable
declare dso_local noundef zeroext i1 @_Z11SolveSudokui(i32 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: mustprogress uwtable
declare dso_local void @_Z9printGridi(i32 noundef) local_unnamed_addr #0

; Function Attrs: inlinehint mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef) local_unnamed_addr #2

; Function Attrs: mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEPFRSoS_E(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef) local_unnamed_addr #0 align 2

; Function Attrs: inlinehint mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(8) ptr @_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_(ptr noundef nonnull align 8 dereferenceable(8)) #2

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() local_unnamed_addr #3 {
  %1 = alloca i32, align 4
  %2 = alloca i32, align 4
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %1) #6
  %3 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 4 dereferenceable(4) %1)
  %4 = load i32, ptr %1, align 4, !tbaa !5
  %5 = icmp sgt i32 %4, 0
  br i1 %5, label %.lr.ph31, label %._crit_edge32

._crit_edge32:                                    ; preds = %45, %0
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %1) #6
  ret i32 0

.lr.ph31:                                         ; preds = %0, %45
  %.02029 = phi i32 [ %46, %45 ], [ 0, %0 ]
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %2) #6
  %6 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 4 dereferenceable(4) %2)
  %7 = load i32, ptr %2, align 4, !tbaa !5
  %8 = icmp sgt i32 %7, 0
  br i1 %8, label %.preheader.us.preheader, label %._crit_edge

.preheader.us.preheader:                          ; preds = %.lr.ph31
  %9 = zext nneg i32 %7 to i64
  %10 = shl nuw nsw i64 %9, 2
  %xtraiter = and i64 %9, 7
  %11 = icmp ult i32 %7, 8
  br i1 %11, label %.preheader23.unr-lcssa, label %.preheader.us.preheader.new

.preheader.us.preheader.new:                      ; preds = %.preheader.us.preheader
  %unroll_iter = and i64 %9, 2147483640
  br label %.preheader.us

.preheader.us:                                    ; preds = %.preheader.us, %.preheader.us.preheader.new
  %indvar = phi i64 [ 0, %.preheader.us.preheader.new ], [ %indvar.next.7, %.preheader.us ]
  %niter = phi i64 [ 0, %.preheader.us.preheader.new ], [ %niter.next.7, %.preheader.us ]
  %12 = mul nuw nsw i64 %indvar, 8000
  %scevgep = getelementptr i8, ptr @grid, i64 %12
  call void @llvm.memset.p0.i64(ptr align 16 %scevgep, i8 0, i64 %10, i1 false), !tbaa !5
  %13 = mul nuw i64 %indvar, 8000
  %gep = getelementptr i8, ptr getelementptr (i8, ptr @grid, i64 8000), i64 %13
  call void @llvm.memset.p0.i64(ptr align 16 %gep, i8 0, i64 %10, i1 false), !tbaa !5
  %14 = mul nuw i64 %indvar, 8000
  %gep50 = getelementptr i8, ptr getelementptr (i8, ptr @grid, i64 16000), i64 %14
  call void @llvm.memset.p0.i64(ptr align 16 %gep50, i8 0, i64 %10, i1 false), !tbaa !5
  %15 = mul nuw i64 %indvar, 8000
  %gep51 = getelementptr i8, ptr getelementptr (i8, ptr @grid, i64 24000), i64 %15
  call void @llvm.memset.p0.i64(ptr align 16 %gep51, i8 0, i64 %10, i1 false), !tbaa !5
  %16 = mul nuw i64 %indvar, 8000
  %gep52 = getelementptr i8, ptr getelementptr (i8, ptr @grid, i64 32000), i64 %16
  call void @llvm.memset.p0.i64(ptr align 16 %gep52, i8 0, i64 %10, i1 false), !tbaa !5
  %17 = mul nuw i64 %indvar, 8000
  %gep53 = getelementptr i8, ptr getelementptr (i8, ptr @grid, i64 40000), i64 %17
  call void @llvm.memset.p0.i64(ptr align 16 %gep53, i8 0, i64 %10, i1 false), !tbaa !5
  %18 = mul nuw i64 %indvar, 8000
  %gep54 = getelementptr i8, ptr getelementptr (i8, ptr @grid, i64 48000), i64 %18
  call void @llvm.memset.p0.i64(ptr align 16 %gep54, i8 0, i64 %10, i1 false), !tbaa !5
  %19 = mul nuw i64 %indvar, 8000
  %gep55 = getelementptr i8, ptr getelementptr (i8, ptr @grid, i64 56000), i64 %19
  call void @llvm.memset.p0.i64(ptr align 16 %gep55, i8 0, i64 %10, i1 false), !tbaa !5
  %indvar.next.7 = add nuw nsw i64 %indvar, 8
  %niter.next.7 = add i64 %niter, 8
  %niter.ncmp.7 = icmp eq i64 %niter.next.7, %unroll_iter
  br i1 %niter.ncmp.7, label %.preheader23.unr-lcssa, label %.preheader.us, !llvm.loop !9

.preheader23.unr-lcssa:                           ; preds = %.preheader.us, %.preheader.us.preheader
  %indvar.unr = phi i64 [ 0, %.preheader.us.preheader ], [ %indvar.next.7, %.preheader.us ]
  %lcmp.mod.not = icmp eq i64 %xtraiter, 0
  br i1 %lcmp.mod.not, label %.preheader23, label %.preheader.us.epil

.preheader.us.epil:                               ; preds = %.preheader23.unr-lcssa, %.preheader.us.epil
  %indvar.epil = phi i64 [ %indvar.next.epil, %.preheader.us.epil ], [ %indvar.unr, %.preheader23.unr-lcssa ]
  %epil.iter = phi i64 [ %epil.iter.next, %.preheader.us.epil ], [ 0, %.preheader23.unr-lcssa ]
  %20 = mul nuw nsw i64 %indvar.epil, 8000
  %scevgep.epil = getelementptr i8, ptr @grid, i64 %20
  call void @llvm.memset.p0.i64(ptr align 16 %scevgep.epil, i8 0, i64 %10, i1 false), !tbaa !5
  %indvar.next.epil = add nuw nsw i64 %indvar.epil, 1
  %epil.iter.next = add i64 %epil.iter, 1
  %epil.iter.cmp.not = icmp eq i64 %epil.iter.next, %xtraiter
  br i1 %epil.iter.cmp.not, label %.preheader23, label %.preheader.us.epil, !llvm.loop !11

.preheader23:                                     ; preds = %.preheader.us.epil, %.preheader23.unr-lcssa
  br i1 %8, label %.lr.ph.preheader, label %._crit_edge

.lr.ph.preheader:                                 ; preds = %.preheader23
  %wide.trip.count36 = zext nneg i32 %7 to i64
  %min.iters.check = icmp ult i32 %7, 8
  br i1 %min.iters.check, label %.lr.ph.preheader44, label %vector.ph

.lr.ph.preheader44:                               ; preds = %middle.block, %.lr.ph.preheader
  %indvars.iv.ph = phi i64 [ 0, %.lr.ph.preheader ], [ %n.vec, %middle.block ]
  br label %.lr.ph

vector.ph:                                        ; preds = %.lr.ph.preheader
  %n.vec = and i64 %9, 2147483640
  br label %vector.body

vector.body:                                      ; preds = %vector.body, %vector.ph
  %index = phi i64 [ 0, %vector.ph ], [ %index.next, %vector.body ]
  %vec.ind = phi <4 x i32> [ <i32 0, i32 1, i32 2, i32 3>, %vector.ph ], [ %vec.ind.next, %vector.body ]
  %step.add = add <4 x i32> %vec.ind, <i32 4, i32 4, i32 4, i32 4>
  %21 = getelementptr inbounds [2000 x i32], ptr @grid, i64 0, i64 %index
  %22 = getelementptr inbounds i8, ptr %21, i64 16
  store <4 x i32> %vec.ind, ptr %21, align 16, !tbaa !5
  store <4 x i32> %step.add, ptr %22, align 16, !tbaa !5
  %index.next = add nuw i64 %index, 8
  %vec.ind.next = add <4 x i32> %vec.ind, <i32 8, i32 8, i32 8, i32 8>
  %23 = icmp eq i64 %index.next, %n.vec
  br i1 %23, label %middle.block, label %vector.body, !llvm.loop !13

middle.block:                                     ; preds = %vector.body
  %cmp.n = icmp eq i64 %n.vec, %9
  br i1 %cmp.n, label %.preheader22, label %.lr.ph.preheader44

.preheader22:                                     ; preds = %.lr.ph, %middle.block
  br i1 %8, label %.lr.ph28.preheader, label %._crit_edge

.lr.ph28.preheader:                               ; preds = %.preheader22
  %xtraiter45 = and i64 %9, 3
  %24 = icmp ult i32 %7, 4
  br i1 %24, label %._crit_edge.loopexit.unr-lcssa, label %.lr.ph28.preheader.new

.lr.ph28.preheader.new:                           ; preds = %.lr.ph28.preheader
  %unroll_iter48 = and i64 %9, 2147483644
  br label %.lr.ph28

.lr.ph:                                           ; preds = %.lr.ph.preheader44, %.lr.ph
  %indvars.iv = phi i64 [ %indvars.iv.next, %.lr.ph ], [ %indvars.iv.ph, %.lr.ph.preheader44 ]
  %25 = getelementptr inbounds [2000 x i32], ptr @grid, i64 0, i64 %indvars.iv
  %26 = trunc nuw nsw i64 %indvars.iv to i32
  store i32 %26, ptr %25, align 4, !tbaa !5
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond37.not = icmp eq i64 %indvars.iv.next, %wide.trip.count36
  br i1 %exitcond37.not, label %.preheader22, label %.lr.ph, !llvm.loop !16

._crit_edge.loopexit.unr-lcssa:                   ; preds = %.lr.ph28, %.lr.ph28.preheader
  %indvars.iv38.unr = phi i64 [ 0, %.lr.ph28.preheader ], [ %indvars.iv.next39.3, %.lr.ph28 ]
  %lcmp.mod47.not = icmp eq i64 %xtraiter45, 0
  br i1 %lcmp.mod47.not, label %._crit_edge, label %.lr.ph28.epil

.lr.ph28.epil:                                    ; preds = %._crit_edge.loopexit.unr-lcssa, %.lr.ph28.epil
  %indvars.iv38.epil = phi i64 [ %indvars.iv.next39.epil, %.lr.ph28.epil ], [ %indvars.iv38.unr, %._crit_edge.loopexit.unr-lcssa ]
  %epil.iter46 = phi i64 [ %epil.iter46.next, %.lr.ph28.epil ], [ 0, %._crit_edge.loopexit.unr-lcssa ]
  %27 = getelementptr inbounds [2000 x [2000 x i32]], ptr @grid, i64 0, i64 %indvars.iv38.epil
  %28 = trunc nuw nsw i64 %indvars.iv38.epil to i32
  store i32 %28, ptr %27, align 16, !tbaa !5
  %indvars.iv.next39.epil = add nuw nsw i64 %indvars.iv38.epil, 1
  %epil.iter46.next = add i64 %epil.iter46, 1
  %epil.iter46.cmp.not = icmp eq i64 %epil.iter46.next, %xtraiter45
  br i1 %epil.iter46.cmp.not, label %._crit_edge, label %.lr.ph28.epil, !llvm.loop !17

._crit_edge:                                      ; preds = %._crit_edge.loopexit.unr-lcssa, %.lr.ph28.epil, %.lr.ph31, %.preheader23, %.preheader22
  %29 = call noundef zeroext i1 @_Z11SolveSudokui(i32 noundef %7)
  br i1 %29, label %38, label %42

.lr.ph28:                                         ; preds = %.lr.ph28, %.lr.ph28.preheader.new
  %indvars.iv38 = phi i64 [ 0, %.lr.ph28.preheader.new ], [ %indvars.iv.next39.3, %.lr.ph28 ]
  %niter49 = phi i64 [ 0, %.lr.ph28.preheader.new ], [ %niter49.next.3, %.lr.ph28 ]
  %30 = getelementptr inbounds [2000 x [2000 x i32]], ptr @grid, i64 0, i64 %indvars.iv38
  %31 = trunc nuw nsw i64 %indvars.iv38 to i32
  store i32 %31, ptr %30, align 16, !tbaa !5
  %indvars.iv.next39 = or disjoint i64 %indvars.iv38, 1
  %32 = getelementptr inbounds [2000 x [2000 x i32]], ptr @grid, i64 0, i64 %indvars.iv.next39
  %33 = trunc nuw nsw i64 %indvars.iv.next39 to i32
  store i32 %33, ptr %32, align 16, !tbaa !5
  %indvars.iv.next39.1 = or disjoint i64 %indvars.iv38, 2
  %34 = getelementptr inbounds [2000 x [2000 x i32]], ptr @grid, i64 0, i64 %indvars.iv.next39.1
  %35 = trunc nuw nsw i64 %indvars.iv.next39.1 to i32
  store i32 %35, ptr %34, align 16, !tbaa !5
  %indvars.iv.next39.2 = or disjoint i64 %indvars.iv38, 3
  %36 = getelementptr inbounds [2000 x [2000 x i32]], ptr @grid, i64 0, i64 %indvars.iv.next39.2
  %37 = trunc nuw nsw i64 %indvars.iv.next39.2 to i32
  store i32 %37, ptr %36, align 16, !tbaa !5
  %indvars.iv.next39.3 = add nuw nsw i64 %indvars.iv38, 4
  %niter49.next.3 = add i64 %niter49, 4
  %niter49.ncmp.3 = icmp eq i64 %niter49.next.3, %unroll_iter48
  br i1 %niter49.ncmp.3, label %._crit_edge.loopexit.unr-lcssa, label %.lr.ph28, !llvm.loop !18

38:                                               ; preds = %._crit_edge
  %39 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, ptr noundef nonnull @.str.1)
  %40 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEPFRSoS_E(ptr noundef nonnull align 8 dereferenceable(8) %39, ptr noundef nonnull @_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_)
  %41 = load i32, ptr %2, align 4, !tbaa !5
  call void @_Z9printGridi(i32 noundef %41)
  br label %45

42:                                               ; preds = %._crit_edge
  %43 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, ptr noundef nonnull @.str.2)
  %44 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEPFRSoS_E(ptr noundef nonnull align 8 dereferenceable(8) %43, ptr noundef nonnull @_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_)
  br label %45

45:                                               ; preds = %42, %38
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %2) #6
  %46 = add nuw nsw i32 %.02029, 1
  %47 = load i32, ptr %1, align 4, !tbaa !5
  %48 = icmp slt i32 %46, %47
  br i1 %48, label %.lr.ph31, label %._crit_edge32, !llvm.loop !19
}

declare noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef nonnull align 4 dereferenceable(4)) local_unnamed_addr #4

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

attributes #0 = { mustprogress 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 = { inlinehint mustprogress 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 = { mustprogress norecurse 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 #4 = { "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 #5 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #6 = { 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++ TBAA"}
!9 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.unroll.disable"}
!13 = distinct !{!13, !10, !14, !15}
!14 = !{!"llvm.loop.isvectorized", i32 1}
!15 = !{!"llvm.loop.unroll.runtime.disable"}
!16 = distinct !{!16, !10, !15, !14}
!17 = distinct !{!17, !12}
!18 = distinct !{!18, !10}
!19 = distinct !{!19, !10}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IndVarSimplifyPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LICMPass,LoopIdiomRecognizePass,LoopInstSimplifyPass,LoopLoadEliminationPass,LoopRotatePass,LoopSimplifyCFGPass,LoopSimplifyPass,LoopUnrollPass,LoopVectorizePass,SROAPass,SimplifyCFGPass