; LLVM IR from Leet-Us-Code/DSA-A-Z-Practice :: Sid's Levels/Level - 1/Recursion/knightTour.ll (Z11generateAlliiiPA10_ii)

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

@_ZSt4cout = external global %"class.std::basic_ostream", align 8

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z11printMatrixPA10_ii(ptr noundef, i32 noundef) #1

; Function Attrs: mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEPFRSoS_E(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef) #1 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 uwtable
define dso_local void @_Z11generateAlliiiPA10_ii(i32 noundef %0, i32 noundef %1, i32 noundef %2, ptr noundef %3, i32 noundef %4) #1 {
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca ptr, align 8
  %10 = alloca i32, align 4
  store i32 %0, ptr %6, align 4, !tbaa !5
  store i32 %1, ptr %7, align 4, !tbaa !5
  store i32 %2, ptr %8, align 4, !tbaa !5
  store ptr %3, ptr %9, align 8, !tbaa !9
  store i32 %4, ptr %10, align 4, !tbaa !5
  %11 = load i32, ptr %6, align 4, !tbaa !5
  %12 = load i32, ptr %7, align 4, !tbaa !5
  %13 = load i32, ptr %8, align 4, !tbaa !5
  %14 = load ptr, ptr %9, align 8, !tbaa !9
  %15 = call noundef zeroext i1 @_Z6isSafeiiiPA10_i(i32 noundef %11, i32 noundef %12, i32 noundef %13, ptr noundef %14)
  br i1 %15, label %17, label %16

16:                                               ; preds = %5
  br label %123

17:                                               ; preds = %5
  %18 = load i32, ptr %10, align 4, !tbaa !5
  %19 = load i32, ptr %8, align 4, !tbaa !5
  %20 = load i32, ptr %8, align 4, !tbaa !5
  %21 = mul nsw i32 %19, %20
  %22 = icmp eq i32 %18, %21
  br i1 %22, label %23, label %42

23:                                               ; preds = %17
  %24 = load i32, ptr %10, align 4, !tbaa !5
  %25 = load ptr, ptr %9, align 8, !tbaa !9
  %26 = load i32, ptr %6, align 4, !tbaa !5
  %27 = sext i32 %26 to i64
  %28 = getelementptr inbounds [10 x i32], ptr %25, i64 %27
  %29 = load i32, ptr %7, align 4, !tbaa !5
  %30 = sext i32 %29 to i64
  %31 = getelementptr inbounds [10 x i32], ptr %28, i64 0, i64 %30
  store i32 %24, ptr %31, align 4, !tbaa !5
  %32 = load ptr, ptr %9, align 8, !tbaa !9
  %33 = load i32, ptr %8, align 4, !tbaa !5
  call void @_Z11printMatrixPA10_ii(ptr noundef %32, i32 noundef %33)
  %34 = load ptr, ptr %9, align 8, !tbaa !9
  %35 = load i32, ptr %6, align 4, !tbaa !5
  %36 = sext i32 %35 to i64
  %37 = getelementptr inbounds [10 x i32], ptr %34, i64 %36
  %38 = load i32, ptr %7, align 4, !tbaa !5
  %39 = sext i32 %38 to i64
  %40 = getelementptr inbounds [10 x i32], ptr %37, i64 0, i64 %39
  store i32 0, ptr %40, align 4, !tbaa !5
  %41 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEPFRSoS_E(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, ptr noundef @_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_)
  br label %123

42:                                               ; preds = %17
  %43 = load i32, ptr %10, align 4, !tbaa !5
  %44 = load ptr, ptr %9, align 8, !tbaa !9
  %45 = load i32, ptr %6, align 4, !tbaa !5
  %46 = sext i32 %45 to i64
  %47 = getelementptr inbounds [10 x i32], ptr %44, i64 %46
  %48 = load i32, ptr %7, align 4, !tbaa !5
  %49 = sext i32 %48 to i64
  %50 = getelementptr inbounds [10 x i32], ptr %47, i64 0, i64 %49
  store i32 %43, ptr %50, align 4, !tbaa !5
  %51 = load i32, ptr %6, align 4, !tbaa !5
  %52 = sub nsw i32 %51, 2
  %53 = load i32, ptr %7, align 4, !tbaa !5
  %54 = add nsw i32 %53, 1
  %55 = load i32, ptr %8, align 4, !tbaa !5
  %56 = load ptr, ptr %9, align 8, !tbaa !9
  %57 = load i32, ptr %10, align 4, !tbaa !5
  %58 = add nsw i32 %57, 1
  call void @_Z11generateAlliiiPA10_ii(i32 noundef %52, i32 noundef %54, i32 noundef %55, ptr noundef %56, i32 noundef %58)
  %59 = load i32, ptr %6, align 4, !tbaa !5
  %60 = sub nsw i32 %59, 1
  %61 = load i32, ptr %7, align 4, !tbaa !5
  %62 = add nsw i32 %61, 2
  %63 = load i32, ptr %8, align 4, !tbaa !5
  %64 = load ptr, ptr %9, align 8, !tbaa !9
  %65 = load i32, ptr %10, align 4, !tbaa !5
  %66 = add nsw i32 %65, 1
  call void @_Z11generateAlliiiPA10_ii(i32 noundef %60, i32 noundef %62, i32 noundef %63, ptr noundef %64, i32 noundef %66)
  %67 = load i32, ptr %6, align 4, !tbaa !5
  %68 = add nsw i32 %67, 1
  %69 = load i32, ptr %7, align 4, !tbaa !5
  %70 = add nsw i32 %69, 2
  %71 = load i32, ptr %8, align 4, !tbaa !5
  %72 = load ptr, ptr %9, align 8, !tbaa !9
  %73 = load i32, ptr %10, align 4, !tbaa !5
  %74 = add nsw i32 %73, 1
  call void @_Z11generateAlliiiPA10_ii(i32 noundef %68, i32 noundef %70, i32 noundef %71, ptr noundef %72, i32 noundef %74)
  %75 = load i32, ptr %6, align 4, !tbaa !5
  %76 = add nsw i32 %75, 2
  %77 = load i32, ptr %7, align 4, !tbaa !5
  %78 = add nsw i32 %77, 1
  %79 = load i32, ptr %8, align 4, !tbaa !5
  %80 = load ptr, ptr %9, align 8, !tbaa !9
  %81 = load i32, ptr %10, align 4, !tbaa !5
  %82 = add nsw i32 %81, 1
  call void @_Z11generateAlliiiPA10_ii(i32 noundef %76, i32 noundef %78, i32 noundef %79, ptr noundef %80, i32 noundef %82)
  %83 = load i32, ptr %6, align 4, !tbaa !5
  %84 = add nsw i32 %83, 2
  %85 = load i32, ptr %7, align 4, !tbaa !5
  %86 = sub nsw i32 %85, 1
  %87 = load i32, ptr %8, align 4, !tbaa !5
  %88 = load ptr, ptr %9, align 8, !tbaa !9
  %89 = load i32, ptr %10, align 4, !tbaa !5
  %90 = add nsw i32 %89, 1
  call void @_Z11generateAlliiiPA10_ii(i32 noundef %84, i32 noundef %86, i32 noundef %87, ptr noundef %88, i32 noundef %90)
  %91 = load i32, ptr %6, align 4, !tbaa !5
  %92 = add nsw i32 %91, 1
  %93 = load i32, ptr %7, align 4, !tbaa !5
  %94 = sub nsw i32 %93, 2
  %95 = load i32, ptr %8, align 4, !tbaa !5
  %96 = load ptr, ptr %9, align 8, !tbaa !9
  %97 = load i32, ptr %10, align 4, !tbaa !5
  %98 = add nsw i32 %97, 1
  call void @_Z11generateAlliiiPA10_ii(i32 noundef %92, i32 noundef %94, i32 noundef %95, ptr noundef %96, i32 noundef %98)
  %99 = load i32, ptr %6, align 4, !tbaa !5
  %100 = sub nsw i32 %99, 1
  %101 = load i32, ptr %7, align 4, !tbaa !5
  %102 = sub nsw i32 %101, 2
  %103 = load i32, ptr %8, align 4, !tbaa !5
  %104 = load ptr, ptr %9, align 8, !tbaa !9
  %105 = load i32, ptr %10, align 4, !tbaa !5
  %106 = add nsw i32 %105, 1
  call void @_Z11generateAlliiiPA10_ii(i32 noundef %100, i32 noundef %102, i32 noundef %103, ptr noundef %104, i32 noundef %106)
  %107 = load i32, ptr %6, align 4, !tbaa !5
  %108 = sub nsw i32 %107, 2
  %109 = load i32, ptr %7, align 4, !tbaa !5
  %110 = sub nsw i32 %109, 1
  %111 = load i32, ptr %8, align 4, !tbaa !5
  %112 = load ptr, ptr %9, align 8, !tbaa !9
  %113 = load i32, ptr %10, align 4, !tbaa !5
  %114 = add nsw i32 %113, 1
  call void @_Z11generateAlliiiPA10_ii(i32 noundef %108, i32 noundef %110, i32 noundef %111, ptr noundef %112, i32 noundef %114)
  %115 = load ptr, ptr %9, align 8, !tbaa !9
  %116 = load i32, ptr %6, align 4, !tbaa !5
  %117 = sext i32 %116 to i64
  %118 = getelementptr inbounds [10 x i32], ptr %115, i64 %117
  %119 = load i32, ptr %7, align 4, !tbaa !5
  %120 = sext i32 %119 to i64
  %121 = getelementptr inbounds [10 x i32], ptr %118, i64 0, i64 %120
  store i32 0, ptr %121, align 4, !tbaa !5
  br label %122

122:                                              ; preds = %42
  br label %123

123:                                              ; preds = %122, %23, %16
  ret void
}

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

!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 = !{!10, !10, i64 0}
!10 = !{!"any pointer", !7, i64 0}


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

@_ZSt4cout = external global %"class.std::basic_ostream", align 8

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z11printMatrixPA10_ii(ptr noundef, i32 noundef) local_unnamed_addr #1

; 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 #1 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 uwtable
define dso_local void @_Z11generateAlliiiPA10_ii(i32 noundef %0, i32 noundef %1, i32 noundef %2, ptr noundef %3, i32 noundef %4) local_unnamed_addr #1 {
  %6 = tail call noundef zeroext i1 @_Z6isSafeiiiPA10_i(i32 noundef %0, i32 noundef %1, i32 noundef %2, ptr noundef %3)
  br i1 %6, label %7, label %common.ret62

7:                                                ; preds = %5
  %8 = mul nsw i32 %2, %2
  %9 = icmp eq i32 %8, %4
  %10 = sext i32 %0 to i64
  %11 = sext i32 %1 to i64
  %12 = getelementptr inbounds [10 x i32], ptr %3, i64 %10, i64 %11
  store i32 %4, ptr %12, align 4, !tbaa !5
  br i1 %9, label %13, label %15

13:                                               ; preds = %7
  tail call void @_Z11printMatrixPA10_ii(ptr noundef %3, i32 noundef %2)
  store i32 0, ptr %12, align 4, !tbaa !5
  %14 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEPFRSoS_E(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, ptr noundef nonnull @_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_)
  br label %common.ret62

common.ret62:                                     ; preds = %5, %13, %15
  ret void

15:                                               ; preds = %7
  %16 = add nsw i32 %0, -2
  %17 = add nsw i32 %1, 1
  %18 = add nsw i32 %4, 1
  tail call void @_Z11generateAlliiiPA10_ii(i32 noundef %16, i32 noundef %17, i32 noundef %2, ptr noundef %3, i32 noundef %18)
  %19 = add nsw i32 %0, -1
  %20 = add nsw i32 %1, 2
  tail call void @_Z11generateAlliiiPA10_ii(i32 noundef %19, i32 noundef %20, i32 noundef %2, ptr noundef %3, i32 noundef %18)
  %21 = add nsw i32 %0, 1
  tail call void @_Z11generateAlliiiPA10_ii(i32 noundef %21, i32 noundef %20, i32 noundef %2, ptr noundef %3, i32 noundef %18)
  %22 = add nsw i32 %0, 2
  tail call void @_Z11generateAlliiiPA10_ii(i32 noundef %22, i32 noundef %17, i32 noundef %2, ptr noundef %3, i32 noundef %18)
  %23 = add nsw i32 %1, -1
  tail call void @_Z11generateAlliiiPA10_ii(i32 noundef %22, i32 noundef %23, i32 noundef %2, ptr noundef %3, i32 noundef %18)
  %24 = add nsw i32 %1, -2
  tail call void @_Z11generateAlliiiPA10_ii(i32 noundef %21, i32 noundef %24, i32 noundef %2, ptr noundef %3, i32 noundef %18)
  tail call void @_Z11generateAlliiiPA10_ii(i32 noundef %19, i32 noundef %24, i32 noundef %2, ptr noundef %3, i32 noundef %18)
  tail call void @_Z11generateAlliiiPA10_ii(i32 noundef %16, i32 noundef %23, i32 noundef %2, ptr noundef %3, i32 noundef %18)
  store i32 0, ptr %12, align 4, !tbaa !5
  br label %common.ret62
}

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

!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"}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,InstCombinePass,SROAPass,SimplifyCFGPass,TailCallElimPass