; LLVM IR from smv1999/CompetitiveProgrammingQuestionBank :: Backtracking (sudoku)

; 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: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #0

; Function Attrs: nounwind uwtable
define dso_local void @sudokuSolver(ptr noundef %0) #1 {
  %2 = alloca ptr, align 8
  %3 = alloca [9 x [9 x i32]], align 16
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  store ptr %0, ptr %2, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 324, ptr %3) #2
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #2
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #2
  store i32 0, ptr %4, align 4, !tbaa !9
  br label %6

6:                                                ; preds = %45, %1
  %7 = load i32, ptr %4, align 4, !tbaa !9
  %8 = icmp slt i32 %7, 9
  br i1 %8, label %9, label %48

9:                                                ; preds = %6
  store i32 0, ptr %5, align 4, !tbaa !9
  br label %10

10:                                               ; preds = %41, %9
  %11 = load i32, ptr %5, align 4, !tbaa !9
  %12 = icmp slt i32 %11, 9
  br i1 %12, label %13, label %44

13:                                               ; preds = %10
  %14 = load ptr, ptr %2, align 8, !tbaa !5
  %15 = load i32, ptr %4, align 4, !tbaa !9
  %16 = sext i32 %15 to i64
  %17 = getelementptr inbounds [9 x i32], ptr %14, i64 %16
  %18 = load i32, ptr %5, align 4, !tbaa !9
  %19 = sext i32 %18 to i64
  %20 = getelementptr inbounds [9 x i32], ptr %17, i64 0, i64 %19
  %21 = load i32, ptr %20, align 4, !tbaa !9
  %22 = icmp sgt i32 %21, 0
  br i1 %22, label %23, label %32

23:                                               ; preds = %13
  %24 = load ptr, ptr %2, align 8, !tbaa !5
  %25 = load i32, ptr %4, align 4, !tbaa !9
  %26 = sext i32 %25 to i64
  %27 = getelementptr inbounds [9 x i32], ptr %24, i64 %26
  %28 = load i32, ptr %5, align 4, !tbaa !9
  %29 = sext i32 %28 to i64
  %30 = getelementptr inbounds [9 x i32], ptr %27, i64 0, i64 %29
  %31 = load i32, ptr %30, align 4, !tbaa !9
  br label %33

32:                                               ; preds = %13
  br label %33

33:                                               ; preds = %32, %23
  %34 = phi i32 [ %31, %23 ], [ -1, %32 ]
  %35 = load i32, ptr %4, align 4, !tbaa !9
  %36 = sext i32 %35 to i64
  %37 = getelementptr inbounds [9 x [9 x i32]], ptr %3, i64 0, i64 %36
  %38 = load i32, ptr %5, align 4, !tbaa !9
  %39 = sext i32 %38 to i64
  %40 = getelementptr inbounds [9 x i32], ptr %37, i64 0, i64 %39
  store i32 %34, ptr %40, align 4, !tbaa !9
  br label %41

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

44:                                               ; preds = %10
  br label %45

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

48:                                               ; preds = %6
  %49 = load ptr, ptr %2, align 8, !tbaa !5
  %50 = getelementptr inbounds [9 x [9 x i32]], ptr %3, i64 0, i64 0
  call void @sudokuSolverUtility(ptr noundef %49, i32 noundef 0, i32 noundef 0, ptr noundef %50)
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #2
  call void @llvm.lifetime.end.p0(i64 324, ptr %3) #2
  ret void
}

; 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 void @sudokuSolverUtility(ptr noundef, i32 noundef, i32 noundef, ptr noundef) #1

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 }

!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: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #0

; Function Attrs: nounwind uwtable
define dso_local void @sudokuSolver(ptr noundef %0) local_unnamed_addr #1 {
.preheader:
  %1 = alloca [9 x [9 x i32]], align 16
  call void @llvm.lifetime.start.p0(i64 324, ptr nonnull %1) #2
  %2 = load <4 x i32>, ptr %0, align 4, !tbaa !5
  %3 = icmp sgt <4 x i32> %2, zeroinitializer
  %4 = select <4 x i1> %3, <4 x i32> %2, <4 x i32> <i32 -1, i32 -1, i32 -1, i32 -1>
  store <4 x i32> %4, ptr %1, align 16, !tbaa !5
  %5 = getelementptr inbounds i8, ptr %0, i64 16
  %6 = getelementptr inbounds i8, ptr %1, i64 16
  %7 = load <4 x i32>, ptr %5, align 4, !tbaa !5
  %8 = icmp sgt <4 x i32> %7, zeroinitializer
  %9 = select <4 x i1> %8, <4 x i32> %7, <4 x i32> <i32 -1, i32 -1, i32 -1, i32 -1>
  store <4 x i32> %9, ptr %6, align 16, !tbaa !5
  %10 = getelementptr inbounds i8, ptr %0, i64 32
  %11 = getelementptr inbounds i8, ptr %1, i64 32
  %12 = load <4 x i32>, ptr %10, align 4, !tbaa !5
  %13 = icmp sgt <4 x i32> %12, zeroinitializer
  %14 = select <4 x i1> %13, <4 x i32> %12, <4 x i32> <i32 -1, i32 -1, i32 -1, i32 -1>
  store <4 x i32> %14, ptr %11, align 16, !tbaa !5
  %15 = getelementptr inbounds i8, ptr %0, i64 48
  %16 = getelementptr inbounds i8, ptr %1, i64 48
  %17 = load <4 x i32>, ptr %15, align 4, !tbaa !5
  %18 = icmp sgt <4 x i32> %17, zeroinitializer
  %19 = select <4 x i1> %18, <4 x i32> %17, <4 x i32> <i32 -1, i32 -1, i32 -1, i32 -1>
  store <4 x i32> %19, ptr %16, align 16, !tbaa !5
  %20 = getelementptr inbounds i8, ptr %0, i64 64
  %21 = getelementptr inbounds i8, ptr %1, i64 64
  %22 = load <4 x i32>, ptr %20, align 4, !tbaa !5
  %23 = icmp sgt <4 x i32> %22, zeroinitializer
  %24 = select <4 x i1> %23, <4 x i32> %22, <4 x i32> <i32 -1, i32 -1, i32 -1, i32 -1>
  store <4 x i32> %24, ptr %21, align 16, !tbaa !5
  %25 = getelementptr inbounds i8, ptr %0, i64 80
  %26 = getelementptr inbounds i8, ptr %1, i64 80
  %27 = load <4 x i32>, ptr %25, align 4, !tbaa !5
  %28 = icmp sgt <4 x i32> %27, zeroinitializer
  %29 = select <4 x i1> %28, <4 x i32> %27, <4 x i32> <i32 -1, i32 -1, i32 -1, i32 -1>
  store <4 x i32> %29, ptr %26, align 16, !tbaa !5
  %30 = getelementptr inbounds i8, ptr %0, i64 96
  %31 = getelementptr inbounds i8, ptr %1, i64 96
  %32 = load <4 x i32>, ptr %30, align 4, !tbaa !5
  %33 = icmp sgt <4 x i32> %32, zeroinitializer
  %34 = select <4 x i1> %33, <4 x i32> %32, <4 x i32> <i32 -1, i32 -1, i32 -1, i32 -1>
  store <4 x i32> %34, ptr %31, align 16, !tbaa !5
  %35 = getelementptr inbounds i8, ptr %0, i64 112
  %36 = getelementptr inbounds i8, ptr %1, i64 112
  %37 = load <4 x i32>, ptr %35, align 4, !tbaa !5
  %38 = icmp sgt <4 x i32> %37, zeroinitializer
  %39 = select <4 x i1> %38, <4 x i32> %37, <4 x i32> <i32 -1, i32 -1, i32 -1, i32 -1>
  store <4 x i32> %39, ptr %36, align 16, !tbaa !5
  %40 = getelementptr inbounds i8, ptr %0, i64 128
  %41 = getelementptr inbounds i8, ptr %1, i64 128
  %42 = load <4 x i32>, ptr %40, align 4, !tbaa !5
  %43 = icmp sgt <4 x i32> %42, zeroinitializer
  %44 = select <4 x i1> %43, <4 x i32> %42, <4 x i32> <i32 -1, i32 -1, i32 -1, i32 -1>
  store <4 x i32> %44, ptr %41, align 16, !tbaa !5
  %45 = getelementptr inbounds i8, ptr %0, i64 144
  %46 = getelementptr inbounds i8, ptr %1, i64 144
  %47 = load <4 x i32>, ptr %45, align 4, !tbaa !5
  %48 = icmp sgt <4 x i32> %47, zeroinitializer
  %49 = select <4 x i1> %48, <4 x i32> %47, <4 x i32> <i32 -1, i32 -1, i32 -1, i32 -1>
  store <4 x i32> %49, ptr %46, align 16, !tbaa !5
  %50 = getelementptr inbounds i8, ptr %0, i64 160
  %51 = getelementptr inbounds i8, ptr %1, i64 160
  %52 = load <4 x i32>, ptr %50, align 4, !tbaa !5
  %53 = icmp sgt <4 x i32> %52, zeroinitializer
  %54 = select <4 x i1> %53, <4 x i32> %52, <4 x i32> <i32 -1, i32 -1, i32 -1, i32 -1>
  store <4 x i32> %54, ptr %51, align 16, !tbaa !5
  %55 = getelementptr inbounds i8, ptr %0, i64 176
  %56 = getelementptr inbounds i8, ptr %1, i64 176
  %57 = load <4 x i32>, ptr %55, align 4, !tbaa !5
  %58 = icmp sgt <4 x i32> %57, zeroinitializer
  %59 = select <4 x i1> %58, <4 x i32> %57, <4 x i32> <i32 -1, i32 -1, i32 -1, i32 -1>
  store <4 x i32> %59, ptr %56, align 16, !tbaa !5
  %60 = getelementptr inbounds i8, ptr %0, i64 192
  %61 = getelementptr inbounds i8, ptr %1, i64 192
  %62 = load <4 x i32>, ptr %60, align 4, !tbaa !5
  %63 = icmp sgt <4 x i32> %62, zeroinitializer
  %64 = select <4 x i1> %63, <4 x i32> %62, <4 x i32> <i32 -1, i32 -1, i32 -1, i32 -1>
  store <4 x i32> %64, ptr %61, align 16, !tbaa !5
  %65 = getelementptr inbounds i8, ptr %0, i64 208
  %66 = getelementptr inbounds i8, ptr %1, i64 208
  %67 = load <4 x i32>, ptr %65, align 4, !tbaa !5
  %68 = icmp sgt <4 x i32> %67, zeroinitializer
  %69 = select <4 x i1> %68, <4 x i32> %67, <4 x i32> <i32 -1, i32 -1, i32 -1, i32 -1>
  store <4 x i32> %69, ptr %66, align 16, !tbaa !5
  %70 = getelementptr inbounds i8, ptr %0, i64 224
  %71 = getelementptr inbounds i8, ptr %1, i64 224
  %72 = load <4 x i32>, ptr %70, align 4, !tbaa !5
  %73 = icmp sgt <4 x i32> %72, zeroinitializer
  %74 = select <4 x i1> %73, <4 x i32> %72, <4 x i32> <i32 -1, i32 -1, i32 -1, i32 -1>
  store <4 x i32> %74, ptr %71, align 16, !tbaa !5
  %75 = getelementptr inbounds i8, ptr %0, i64 240
  %76 = getelementptr inbounds i8, ptr %1, i64 240
  %77 = load <4 x i32>, ptr %75, align 4, !tbaa !5
  %78 = icmp sgt <4 x i32> %77, zeroinitializer
  %79 = select <4 x i1> %78, <4 x i32> %77, <4 x i32> <i32 -1, i32 -1, i32 -1, i32 -1>
  store <4 x i32> %79, ptr %76, align 16, !tbaa !5
  %80 = getelementptr inbounds i8, ptr %0, i64 256
  %81 = getelementptr inbounds i8, ptr %1, i64 256
  %82 = load <4 x i32>, ptr %80, align 4, !tbaa !5
  %83 = icmp sgt <4 x i32> %82, zeroinitializer
  %84 = select <4 x i1> %83, <4 x i32> %82, <4 x i32> <i32 -1, i32 -1, i32 -1, i32 -1>
  store <4 x i32> %84, ptr %81, align 16, !tbaa !5
  %85 = getelementptr inbounds i8, ptr %0, i64 272
  %86 = getelementptr inbounds i8, ptr %1, i64 272
  %87 = load <4 x i32>, ptr %85, align 4, !tbaa !5
  %88 = icmp sgt <4 x i32> %87, zeroinitializer
  %89 = select <4 x i1> %88, <4 x i32> %87, <4 x i32> <i32 -1, i32 -1, i32 -1, i32 -1>
  store <4 x i32> %89, ptr %86, align 16, !tbaa !5
  %90 = getelementptr inbounds i8, ptr %0, i64 288
  %91 = getelementptr inbounds i8, ptr %1, i64 288
  %92 = load <4 x i32>, ptr %90, align 4, !tbaa !5
  %93 = icmp sgt <4 x i32> %92, zeroinitializer
  %94 = select <4 x i1> %93, <4 x i32> %92, <4 x i32> <i32 -1, i32 -1, i32 -1, i32 -1>
  store <4 x i32> %94, ptr %91, align 16, !tbaa !5
  %95 = getelementptr inbounds i8, ptr %0, i64 304
  %96 = getelementptr inbounds i8, ptr %1, i64 304
  %97 = load <4 x i32>, ptr %95, align 4, !tbaa !5
  %98 = icmp sgt <4 x i32> %97, zeroinitializer
  %99 = select <4 x i1> %98, <4 x i32> %97, <4 x i32> <i32 -1, i32 -1, i32 -1, i32 -1>
  store <4 x i32> %99, ptr %96, align 16, !tbaa !5
  %100 = getelementptr inbounds i8, ptr %0, i64 320
  %101 = load i32, ptr %100, align 4, !tbaa !5
  %102 = icmp sgt i32 %101, 0
  %spec.select.8.8 = select i1 %102, i32 %101, i32 -1
  %103 = getelementptr inbounds i8, ptr %1, i64 320
  store i32 %spec.select.8.8, ptr %103, align 16, !tbaa !5
  call void @sudokuSolverUtility(ptr noundef nonnull %0, i32 noundef 0, i32 noundef 0, ptr noundef nonnull %1)
  call void @llvm.lifetime.end.p0(i64 324, ptr nonnull %1) #2
  ret void
}

; 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 void @sudokuSolverUtility(ptr noundef, i32 noundef, i32 noundef, ptr noundef) local_unnamed_addr #1

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


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IndVarSimplifyPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,LICMPass,LoopRotatePass,LoopSimplifyPass,SLPVectorizerPass,SROAPass,SimplifyCFGPass