; LLVM IR from sumitsojha88/Placement-Preparation :: Geeks For Geeks Solutions/Matrix/Spirally traversing a matrix.ll (Z3gfgv)

; 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_istream" = type { ptr, i64, %"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_ostream" = type { ptr, %"class.std::basic_ios" }

@_ZSt3cin = external global %"class.std::basic_istream", align 8
@.str = external hidden unnamed_addr constant [3 x i8], align 1
@_ZSt4cout = external global %"class.std::basic_ostream", align 8
@.str.1 = external hidden unnamed_addr constant [2 x i8], align 1

; Function Attrs: mustprogress uwtable
define dso_local void @_Z3gfgv() #0 {
  %1 = alloca i32, align 4
  %2 = alloca i32, align 4
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = alloca ptr, align 8
  %6 = alloca i64, align 8
  %7 = alloca i64, align 8
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  call void @llvm.lifetime.start.p0(i64 4, ptr %1) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #5
  %12 = 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)
  %13 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) %12, ptr noundef nonnull align 4 dereferenceable(4) %2)
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #5
  %14 = load i32, ptr %1, align 4, !tbaa !5
  %15 = zext i32 %14 to i64
  %16 = load i32, ptr %2, align 4, !tbaa !5
  %17 = zext i32 %16 to i64
  %18 = call ptr @llvm.stacksave.p0()
  store ptr %18, ptr %5, align 8
  %19 = mul nuw i64 %15, %17
  %20 = alloca i32, i64 %19, align 16
  store i64 %15, ptr %6, align 8
  store i64 %17, ptr %7, align 8
  store i32 0, ptr %3, align 4, !tbaa !5
  br label %21

21:                                               ; preds = %43, %0
  %22 = load i32, ptr %3, align 4, !tbaa !5
  %23 = load i32, ptr %1, align 4, !tbaa !5
  %24 = icmp slt i32 %22, %23
  br i1 %24, label %25, label %46

25:                                               ; preds = %21
  store i32 0, ptr %4, align 4, !tbaa !5
  br label %26

26:                                               ; preds = %39, %25
  %27 = load i32, ptr %4, align 4, !tbaa !5
  %28 = load i32, ptr %2, align 4, !tbaa !5
  %29 = icmp slt i32 %27, %28
  br i1 %29, label %30, label %42

30:                                               ; preds = %26
  %31 = load i32, ptr %3, align 4, !tbaa !5
  %32 = sext i32 %31 to i64
  %33 = mul nsw i64 %32, %17
  %34 = getelementptr inbounds i32, ptr %20, i64 %33
  %35 = load i32, ptr %4, align 4, !tbaa !5
  %36 = sext i32 %35 to i64
  %37 = getelementptr inbounds i32, ptr %34, i64 %36
  %38 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef %37)
  br label %39

39:                                               ; preds = %30
  %40 = load i32, ptr %4, align 4, !tbaa !5
  %41 = add nsw i32 %40, 1
  store i32 %41, ptr %4, align 4, !tbaa !5
  br label %26, !llvm.loop !9

42:                                               ; preds = %26
  br label %43

43:                                               ; preds = %42
  %44 = load i32, ptr %3, align 4, !tbaa !5
  %45 = add nsw i32 %44, 1
  store i32 %45, ptr %3, align 4, !tbaa !5
  br label %21, !llvm.loop !11

46:                                               ; preds = %21
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #5
  store i32 0, ptr %8, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #5
  %47 = load i32, ptr %2, align 4, !tbaa !5
  %48 = sub nsw i32 %47, 1
  store i32 %48, ptr %9, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #5
  %49 = load i32, ptr %1, align 4, !tbaa !5
  %50 = sub nsw i32 %49, 1
  store i32 %50, ptr %10, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #5
  store i32 0, ptr %11, align 4, !tbaa !5
  br label %51

51:                                               ; preds = %159, %46
  %52 = load i32, ptr %8, align 4, !tbaa !5
  %53 = load i32, ptr %10, align 4, !tbaa !5
  %54 = icmp sle i32 %52, %53
  br i1 %54, label %55, label %59

55:                                               ; preds = %51
  %56 = load i32, ptr %11, align 4, !tbaa !5
  %57 = load i32, ptr %9, align 4, !tbaa !5
  %58 = icmp sle i32 %56, %57
  br label %59

59:                                               ; preds = %55, %51
  %60 = phi i1 [ false, %51 ], [ %58, %55 ]
  br i1 %60, label %61, label %160

61:                                               ; preds = %59
  %62 = load i32, ptr %8, align 4, !tbaa !5
  store i32 %62, ptr %3, align 4, !tbaa !5
  br label %63

63:                                               ; preds = %78, %61
  %64 = load i32, ptr %3, align 4, !tbaa !5
  %65 = load i32, ptr %9, align 4, !tbaa !5
  %66 = icmp sle i32 %64, %65
  br i1 %66, label %67, label %81

67:                                               ; preds = %63
  %68 = load i32, ptr %8, align 4, !tbaa !5
  %69 = sext i32 %68 to i64
  %70 = mul nsw i64 %69, %17
  %71 = getelementptr inbounds i32, ptr %20, i64 %70
  %72 = load i32, ptr %3, align 4, !tbaa !5
  %73 = sext i32 %72 to i64
  %74 = getelementptr inbounds i32, ptr %71, i64 %73
  %75 = load i32, ptr %74, align 4, !tbaa !5
  %76 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEi(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, i32 noundef %75)
  %77 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc(ptr noundef nonnull align 8 dereferenceable(8) %76, ptr noundef @.str.1)
  br label %78

78:                                               ; preds = %67
  %79 = load i32, ptr %3, align 4, !tbaa !5
  %80 = add nsw i32 %79, 1
  store i32 %80, ptr %3, align 4, !tbaa !5
  br label %63, !llvm.loop !12

81:                                               ; preds = %63
  %82 = load i32, ptr %8, align 4, !tbaa !5
  %83 = add nsw i32 %82, 1
  store i32 %83, ptr %8, align 4, !tbaa !5
  %84 = load i32, ptr %8, align 4, !tbaa !5
  store i32 %84, ptr %3, align 4, !tbaa !5
  br label %85

85:                                               ; preds = %100, %81
  %86 = load i32, ptr %3, align 4, !tbaa !5
  %87 = load i32, ptr %10, align 4, !tbaa !5
  %88 = icmp sle i32 %86, %87
  br i1 %88, label %89, label %103

89:                                               ; preds = %85
  %90 = load i32, ptr %3, align 4, !tbaa !5
  %91 = sext i32 %90 to i64
  %92 = mul nsw i64 %91, %17
  %93 = getelementptr inbounds i32, ptr %20, i64 %92
  %94 = load i32, ptr %9, align 4, !tbaa !5
  %95 = sext i32 %94 to i64
  %96 = getelementptr inbounds i32, ptr %93, i64 %95
  %97 = load i32, ptr %96, align 4, !tbaa !5
  %98 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEi(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, i32 noundef %97)
  %99 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc(ptr noundef nonnull align 8 dereferenceable(8) %98, ptr noundef @.str.1)
  br label %100

100:                                              ; preds = %89
  %101 = load i32, ptr %3, align 4, !tbaa !5
  %102 = add nsw i32 %101, 1
  store i32 %102, ptr %3, align 4, !tbaa !5
  br label %85, !llvm.loop !13

103:                                              ; preds = %85
  %104 = load i32, ptr %9, align 4, !tbaa !5
  %105 = add nsw i32 %104, -1
  store i32 %105, ptr %9, align 4, !tbaa !5
  %106 = load i32, ptr %8, align 4, !tbaa !5
  %107 = load i32, ptr %10, align 4, !tbaa !5
  %108 = icmp sle i32 %106, %107
  br i1 %108, label %109, label %132

109:                                              ; preds = %103
  %110 = load i32, ptr %9, align 4, !tbaa !5
  store i32 %110, ptr %3, align 4, !tbaa !5
  br label %111

111:                                              ; preds = %126, %109
  %112 = load i32, ptr %3, align 4, !tbaa !5
  %113 = load i32, ptr %11, align 4, !tbaa !5
  %114 = icmp sge i32 %112, %113
  br i1 %114, label %115, label %129

115:                                              ; preds = %111
  %116 = load i32, ptr %10, align 4, !tbaa !5
  %117 = sext i32 %116 to i64
  %118 = mul nsw i64 %117, %17
  %119 = getelementptr inbounds i32, ptr %20, i64 %118
  %120 = load i32, ptr %3, align 4, !tbaa !5
  %121 = sext i32 %120 to i64
  %122 = getelementptr inbounds i32, ptr %119, i64 %121
  %123 = load i32, ptr %122, align 4, !tbaa !5
  %124 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEi(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, i32 noundef %123)
  %125 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc(ptr noundef nonnull align 8 dereferenceable(8) %124, ptr noundef @.str.1)
  br label %126

126:                                              ; preds = %115
  %127 = load i32, ptr %3, align 4, !tbaa !5
  %128 = add nsw i32 %127, -1
  store i32 %128, ptr %3, align 4, !tbaa !5
  br label %111, !llvm.loop !14

129:                                              ; preds = %111
  %130 = load i32, ptr %10, align 4, !tbaa !5
  %131 = add nsw i32 %130, -1
  store i32 %131, ptr %10, align 4, !tbaa !5
  br label %132

132:                                              ; preds = %129, %103
  %133 = load i32, ptr %11, align 4, !tbaa !5
  %134 = load i32, ptr %9, align 4, !tbaa !5
  %135 = icmp sle i32 %133, %134
  br i1 %135, label %136, label %159

136:                                              ; preds = %132
  %137 = load i32, ptr %10, align 4, !tbaa !5
  store i32 %137, ptr %3, align 4, !tbaa !5
  br label %138

138:                                              ; preds = %153, %136
  %139 = load i32, ptr %3, align 4, !tbaa !5
  %140 = load i32, ptr %8, align 4, !tbaa !5
  %141 = icmp sge i32 %139, %140
  br i1 %141, label %142, label %156

142:                                              ; preds = %138
  %143 = load i32, ptr %3, align 4, !tbaa !5
  %144 = sext i32 %143 to i64
  %145 = mul nsw i64 %144, %17
  %146 = getelementptr inbounds i32, ptr %20, i64 %145
  %147 = load i32, ptr %11, align 4, !tbaa !5
  %148 = sext i32 %147 to i64
  %149 = getelementptr inbounds i32, ptr %146, i64 %148
  %150 = load i32, ptr %149, align 4, !tbaa !5
  %151 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEi(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, i32 noundef %150)
  %152 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc(ptr noundef nonnull align 8 dereferenceable(8) %151, ptr noundef @.str.1)
  br label %153

153:                                              ; preds = %142
  %154 = load i32, ptr %3, align 4, !tbaa !5
  %155 = add nsw i32 %154, -1
  store i32 %155, ptr %3, align 4, !tbaa !5
  br label %138, !llvm.loop !15

156:                                              ; preds = %138
  %157 = load i32, ptr %11, align 4, !tbaa !5
  %158 = add nsw i32 %157, 1
  store i32 %158, ptr %11, align 4, !tbaa !5
  br label %159

159:                                              ; preds = %156, %132
  br label %51, !llvm.loop !16

160:                                              ; preds = %59
  %161 = 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_)
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #5
  %162 = load ptr, ptr %5, align 8
  call void @llvm.stackrestore.p0(ptr %162)
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %1) #5
  ret void
}

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

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

; Function Attrs: nocallback nofree nosync nounwind willreturn
declare ptr @llvm.stacksave.p0() #3

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

; 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) #4

declare noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEi(ptr noundef nonnull align 8 dereferenceable(8), i32 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)) #4

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

; Function Attrs: nocallback nofree nosync nounwind willreturn
declare void @llvm.stackrestore.p0(ptr) #3

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 = { "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 = { nocallback nofree nosync nounwind willreturn }
attributes #4 = { 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 #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}
!15 = distinct !{!15, !10}
!16 = distinct !{!16, !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_istream" = type { ptr, i64, %"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_ostream" = type { ptr, %"class.std::basic_ios" }

@_ZSt3cin = external global %"class.std::basic_istream", align 8
@.str = external hidden unnamed_addr constant [3 x i8], align 1
@_ZSt4cout = external global %"class.std::basic_ostream", align 8
@.str.1 = external hidden unnamed_addr constant [2 x i8], align 1

; Function Attrs: mustprogress uwtable
define dso_local void @_Z3gfgv() local_unnamed_addr #0 {
  %1 = alloca i32, align 4
  %2 = alloca i32, align 4
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %1) #6
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %2) #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 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) %3, ptr noundef nonnull align 4 dereferenceable(4) %2)
  %5 = load i32, ptr %1, align 4, !tbaa !5
  %6 = zext i32 %5 to i64
  %7 = load i32, ptr %2, align 4, !tbaa !5
  %8 = zext i32 %7 to i64
  %9 = call ptr @llvm.stacksave.p0()
  %10 = mul nuw i64 %8, %6
  %11 = alloca i32, i64 %10, align 16
  %12 = load i32, ptr %1, align 4, !tbaa !5
  %13 = icmp sgt i32 %12, 0
  %.pre117 = load i32, ptr %2, align 4, !tbaa !5
  %14 = icmp sgt i32 %.pre117, 0
  %or.cond = select i1 %13, i1 %14, i1 false
  br i1 %or.cond, label %.preheader57, label %._crit_edge84

.preheader57:                                     ; preds = %0, %._crit_edge
  %15 = phi i32 [ %26, %._crit_edge ], [ %12, %0 ]
  %16 = phi i32 [ %27, %._crit_edge ], [ %.pre117, %0 ]
  %indvars.iv88 = phi i64 [ %indvars.iv.next89, %._crit_edge ], [ 0, %0 ]
  %17 = icmp sgt i32 %16, 0
  br i1 %17, label %.lr.ph, label %._crit_edge

.lr.ph:                                           ; preds = %.preheader57
  %18 = mul nuw nsw i64 %indvars.iv88, %8
  %19 = getelementptr inbounds i32, ptr %11, i64 %18
  br label %20

20:                                               ; preds = %.lr.ph, %20
  %indvars.iv = phi i64 [ 0, %.lr.ph ], [ %indvars.iv.next, %20 ]
  %21 = getelementptr inbounds i32, ptr %19, i64 %indvars.iv
  %22 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %21)
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %23 = load i32, ptr %2, align 4, !tbaa !5
  %24 = sext i32 %23 to i64
  %25 = icmp slt i64 %indvars.iv.next, %24
  br i1 %25, label %20, label %._crit_edge.loopexit, !llvm.loop !9

._crit_edge.loopexit:                             ; preds = %20
  %.pre = load i32, ptr %1, align 4, !tbaa !5
  br label %._crit_edge

._crit_edge:                                      ; preds = %._crit_edge.loopexit, %.preheader57
  %26 = phi i32 [ %.pre, %._crit_edge.loopexit ], [ %15, %.preheader57 ]
  %27 = phi i32 [ %23, %._crit_edge.loopexit ], [ %16, %.preheader57 ]
  %indvars.iv.next89 = add nuw nsw i64 %indvars.iv88, 1
  %28 = sext i32 %26 to i64
  %29 = icmp slt i64 %indvars.iv.next89, %28
  br i1 %29, label %.preheader57, label %._crit_edge60, !llvm.loop !11

._crit_edge60:                                    ; preds = %._crit_edge
  %30 = icmp sgt i32 %26, 0
  %31 = icmp sgt i32 %27, 0
  %32 = and i1 %30, %31
  br i1 %32, label %.preheader56.preheader, label %._crit_edge84

.preheader56.preheader:                           ; preds = %._crit_edge60
  %33 = add nsw i32 %26, -1
  %34 = add nsw i32 %27, -2
  %35 = zext nneg i32 %27 to i64
  br label %.preheader56

.preheader56:                                     ; preds = %.preheader56.preheader, %._crit_edge119
  %indvars.iv112.in = phi i64 [ %35, %.preheader56.preheader ], [ %indvars.iv112, %._crit_edge119 ]
  %indvars.iv104 = phi i32 [ %34, %.preheader56.preheader ], [ %indvars.iv.next105, %._crit_edge119 ]
  %indvars.iv98 = phi i64 [ 1, %.preheader56.preheader ], [ %indvars.iv.next99, %._crit_edge119 ]
  %indvars.iv96 = phi i32 [ %27, %.preheader56.preheader ], [ %indvars.iv.next97, %._crit_edge119 ]
  %indvars.iv91 = phi i64 [ 0, %.preheader56.preheader ], [ %indvars.iv.next92, %._crit_edge119 ]
  %.083 = phi i32 [ 0, %.preheader56.preheader ], [ %.1, %._crit_edge119 ]
  %.04282 = phi i32 [ %33, %.preheader56.preheader ], [ %.143, %._crit_edge119 ]
  %indvars.iv112 = add nsw i64 %indvars.iv112.in, -1
  %36 = sext i32 %indvars.iv104 to i64
  %.not61.not = icmp slt i64 %indvars.iv91, %indvars.iv112.in
  br i1 %.not61.not, label %.lr.ph63, label %._crit_edge64

.lr.ph63:                                         ; preds = %.preheader56
  %37 = mul nuw nsw i64 %indvars.iv91, %8
  %38 = getelementptr inbounds i32, ptr %11, i64 %37
  %wide.trip.count = zext i32 %indvars.iv96 to i64
  br label %39

39:                                               ; preds = %.lr.ph63, %39
  %indvars.iv93 = phi i64 [ %indvars.iv91, %.lr.ph63 ], [ %indvars.iv.next94, %39 ]
  %40 = getelementptr inbounds i32, ptr %38, i64 %indvars.iv93
  %41 = load i32, ptr %40, align 4, !tbaa !5
  %42 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEi(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, i32 noundef %41)
  %43 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc(ptr noundef nonnull align 8 dereferenceable(8) %42, ptr noundef nonnull @.str.1)
  %indvars.iv.next94 = add nuw nsw i64 %indvars.iv93, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next94, %wide.trip.count
  br i1 %exitcond.not, label %._crit_edge64, label %39, !llvm.loop !13

._crit_edge64:                                    ; preds = %39, %.preheader56
  %indvars.iv.next92 = add nuw nsw i64 %indvars.iv91, 1
  %44 = sext i32 %.04282 to i64
  %.not5065.not = icmp slt i64 %indvars.iv91, %44
  br i1 %.not5065.not, label %.lr.ph68, label %._crit_edge69._crit_edge

.lr.ph68:                                         ; preds = %._crit_edge64
  %invariant.gep = getelementptr i32, ptr %11, i64 %indvars.iv112
  %45 = add nuw nsw i32 %.04282, 1
  br label %46

46:                                               ; preds = %.lr.ph68, %46
  %indvars.iv100 = phi i64 [ %indvars.iv98, %.lr.ph68 ], [ %indvars.iv.next101, %46 ]
  %47 = mul nuw nsw i64 %indvars.iv100, %8
  %gep = getelementptr i32, ptr %invariant.gep, i64 %47
  %48 = load i32, ptr %gep, align 4, !tbaa !5
  %49 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEi(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, i32 noundef %48)
  %50 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc(ptr noundef nonnull align 8 dereferenceable(8) %49, ptr noundef nonnull @.str.1)
  %indvars.iv.next101 = add nuw nsw i64 %indvars.iv100, 1
  %lftr.wideiv = trunc i64 %indvars.iv.next101 to i32
  %exitcond103.not = icmp eq i32 %45, %lftr.wideiv
  br i1 %exitcond103.not, label %._crit_edge69, label %46, !llvm.loop !14

._crit_edge69:                                    ; preds = %46
  br i1 %.not5065.not, label %.preheader55, label %._crit_edge69._crit_edge

._crit_edge69._crit_edge:                         ; preds = %._crit_edge64, %._crit_edge69
  %.pre120 = sext i32 %.083 to i64
  br label %60

.preheader55:                                     ; preds = %._crit_edge69
  %51 = sext i32 %.083 to i64
  %.not5270.not = icmp sgt i64 %indvars.iv112, %51
  br i1 %.not5270.not, label %.lr.ph72, label %._crit_edge73

.lr.ph72:                                         ; preds = %.preheader55
  %52 = mul nsw i64 %44, %8
  %53 = getelementptr inbounds i32, ptr %11, i64 %52
  br label %54

54:                                               ; preds = %.lr.ph72, %54
  %indvars.iv106 = phi i64 [ %36, %.lr.ph72 ], [ %indvars.iv.next107, %54 ]
  %55 = getelementptr inbounds i32, ptr %53, i64 %indvars.iv106
  %56 = load i32, ptr %55, align 4, !tbaa !5
  %57 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEi(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, i32 noundef %56)
  %58 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc(ptr noundef nonnull align 8 dereferenceable(8) %57, ptr noundef nonnull @.str.1)
  %indvars.iv.next107 = add nsw i64 %indvars.iv106, -1
  %.not52.not = icmp sgt i64 %indvars.iv106, %51
  br i1 %.not52.not, label %54, label %._crit_edge73, !llvm.loop !15

._crit_edge73:                                    ; preds = %54, %.preheader55
  %59 = add nsw i32 %.04282, -1
  br label %60

60:                                               ; preds = %._crit_edge69._crit_edge, %._crit_edge73
  %.pre-phi121 = phi i64 [ %.pre120, %._crit_edge69._crit_edge ], [ %51, %._crit_edge73 ]
  %.143 = phi i32 [ %.04282, %._crit_edge69._crit_edge ], [ %59, %._crit_edge73 ]
  %.not53.not = icmp slt i64 %.pre-phi121, %indvars.iv112
  %61 = sext i32 %.143 to i64
  br i1 %.not53.not, label %.preheader, label %._crit_edge119

.preheader:                                       ; preds = %60
  %.not54.not74 = icmp slt i64 %indvars.iv91, %61
  br i1 %.not54.not74, label %.lr.ph76, label %._crit_edge77

.lr.ph76:                                         ; preds = %.preheader
  %invariant.gep78 = getelementptr i32, ptr %11, i64 %.pre-phi121
  br label %62

62:                                               ; preds = %.lr.ph76, %62
  %indvars.iv109 = phi i64 [ %61, %.lr.ph76 ], [ %indvars.iv.next110, %62 ]
  %63 = mul nsw i64 %indvars.iv109, %8
  %gep79 = getelementptr i32, ptr %invariant.gep78, i64 %63
  %64 = load i32, ptr %gep79, align 4, !tbaa !5
  %65 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEi(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, i32 noundef %64)
  %66 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc(ptr noundef nonnull align 8 dereferenceable(8) %65, ptr noundef nonnull @.str.1)
  %indvars.iv.next110 = add nsw i64 %indvars.iv109, -1
  %.not54.not = icmp sgt i64 %indvars.iv.next110, %indvars.iv91
  br i1 %.not54.not, label %62, label %._crit_edge77, !llvm.loop !16

._crit_edge77:                                    ; preds = %62, %.preheader
  %67 = add nsw i32 %.083, 1
  %.pre118 = sext i32 %67 to i64
  br label %._crit_edge119

._crit_edge119:                                   ; preds = %60, %._crit_edge77
  %.pre-phi = phi i64 [ %.pre118, %._crit_edge77 ], [ %.pre-phi121, %60 ]
  %.1 = phi i32 [ %67, %._crit_edge77 ], [ %.083, %60 ]
  %68 = icmp slt i64 %indvars.iv91, %61
  %69 = icmp slt i64 %.pre-phi, %indvars.iv112
  %70 = select i1 %68, i1 %69, i1 false
  %indvars.iv.next97 = add nsw i32 %indvars.iv96, -1
  %indvars.iv.next99 = add nuw nsw i64 %indvars.iv98, 1
  %indvars.iv.next105 = add i32 %indvars.iv104, -1
  br i1 %70, label %.preheader56, label %._crit_edge84, !llvm.loop !17

._crit_edge84:                                    ; preds = %._crit_edge119, %0, %._crit_edge60
  %71 = 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_)
  call void @llvm.stackrestore.p0(ptr %9)
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %2) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %1) #6
  ret void
}

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

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 #2

; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn
declare ptr @llvm.stacksave.p0() #3

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

; 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 #5

declare noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEi(ptr noundef nonnull align 8 dereferenceable(8), i32 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)) #5

; 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 nocallback nofree nosync nounwind willreturn
declare void @llvm.stackrestore.p0(ptr) #3

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 = { "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 nocallback nofree nosync nounwind willreturn }
attributes #4 = { 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" }
attributes #5 = { 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 #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, !10, !12}
!12 = !{!"llvm.loop.unswitch.partial.disable"}
!13 = distinct !{!13, !10}
!14 = distinct !{!14, !10}
!15 = distinct !{!15, !10}
!16 = distinct !{!16, !10}
!17 = distinct !{!17, !10}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LICMPass,LoopRotatePass,LoopSimplifyCFGPass,LoopSimplifyPass,LoopUnrollPass,ReassociatePass,SCCPPass,SROAPass,SimpleLoopUnswitchPass,SimplifyCFGPass