; LLVM IR from VastoLorde95/Competitive-Programming :: Codeforces/291 Division 2/Problem E/E.ll (Z4multPA101_xS0_i)

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

@MOD = external dso_local global i64, align 8
@b = external dso_local global [101 x [101 x i64]], align 16
@res = external dso_local global [101 x [101 x i64]], align 16

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @_Z4multPA101_xS0_i(ptr noundef %0, ptr noundef %1, i32 noundef %2) #0 {
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  %7 = alloca [101 x [101 x i64]], align 16
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  %12 = alloca i32, align 4
  %13 = alloca i32, align 4
  %14 = alloca i32, align 4
  %15 = alloca i32, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  store i32 %2, ptr %6, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 81608, ptr %7) #2
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #2
  store i32 0, ptr %8, align 4, !tbaa !9
  br label %16

16:                                               ; preds = %92, %3
  %17 = load i32, ptr %8, align 4, !tbaa !9
  %18 = icmp slt i32 %17, 101
  br i1 %18, label %20, label %19

19:                                               ; preds = %16
  store i32 2, ptr %9, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #2
  br label %95

20:                                               ; preds = %16
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #2
  store i32 0, ptr %10, align 4, !tbaa !9
  br label %21

21:                                               ; preds = %88, %20
  %22 = load i32, ptr %10, align 4, !tbaa !9
  %23 = icmp slt i32 %22, 101
  br i1 %23, label %25, label %24

24:                                               ; preds = %21
  store i32 5, ptr %9, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #2
  br label %91

25:                                               ; preds = %21
  %26 = load i32, ptr %8, align 4, !tbaa !9
  %27 = sext i32 %26 to i64
  %28 = getelementptr inbounds [101 x [101 x i64]], ptr %7, i64 0, i64 %27
  %29 = load i32, ptr %10, align 4, !tbaa !9
  %30 = sext i32 %29 to i64
  %31 = getelementptr inbounds [101 x i64], ptr %28, i64 0, i64 %30
  store i64 0, ptr %31, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #2
  store i32 0, ptr %11, align 4, !tbaa !9
  br label %32

32:                                               ; preds = %84, %25
  %33 = load i32, ptr %11, align 4, !tbaa !9
  %34 = icmp slt i32 %33, 101
  br i1 %34, label %36, label %35

35:                                               ; preds = %32
  store i32 8, ptr %9, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #2
  br label %87

36:                                               ; preds = %32
  %37 = load ptr, ptr %4, align 8, !tbaa !5
  %38 = load i32, ptr %8, align 4, !tbaa !9
  %39 = sext i32 %38 to i64
  %40 = getelementptr inbounds [101 x i64], ptr %37, i64 %39
  %41 = load i32, ptr %11, align 4, !tbaa !9
  %42 = sext i32 %41 to i64
  %43 = getelementptr inbounds [101 x i64], ptr %40, i64 0, i64 %42
  %44 = load i64, ptr %43, align 8, !tbaa !11
  %45 = load ptr, ptr %5, align 8, !tbaa !5
  %46 = load i32, ptr %11, align 4, !tbaa !9
  %47 = sext i32 %46 to i64
  %48 = getelementptr inbounds [101 x i64], ptr %45, i64 %47
  %49 = load i32, ptr %10, align 4, !tbaa !9
  %50 = sext i32 %49 to i64
  %51 = getelementptr inbounds [101 x i64], ptr %48, i64 0, i64 %50
  %52 = load i64, ptr %51, align 8, !tbaa !11
  %53 = mul nsw i64 %44, %52
  %54 = load i64, ptr @MOD, align 8, !tbaa !11
  %55 = srem i64 %53, %54
  %56 = load i32, ptr %8, align 4, !tbaa !9
  %57 = sext i32 %56 to i64
  %58 = getelementptr inbounds [101 x [101 x i64]], ptr %7, i64 0, i64 %57
  %59 = load i32, ptr %10, align 4, !tbaa !9
  %60 = sext i32 %59 to i64
  %61 = getelementptr inbounds [101 x i64], ptr %58, i64 0, i64 %60
  %62 = load i64, ptr %61, align 8, !tbaa !11
  %63 = add nsw i64 %62, %55
  store i64 %63, ptr %61, align 8, !tbaa !11
  %64 = load i32, ptr %8, align 4, !tbaa !9
  %65 = sext i32 %64 to i64
  %66 = getelementptr inbounds [101 x [101 x i64]], ptr %7, i64 0, i64 %65
  %67 = load i32, ptr %10, align 4, !tbaa !9
  %68 = sext i32 %67 to i64
  %69 = getelementptr inbounds [101 x i64], ptr %66, i64 0, i64 %68
  %70 = load i64, ptr %69, align 8, !tbaa !11
  %71 = load i64, ptr @MOD, align 8, !tbaa !11
  %72 = icmp sge i64 %70, %71
  br i1 %72, label %73, label %83

73:                                               ; preds = %36
  %74 = load i64, ptr @MOD, align 8, !tbaa !11
  %75 = load i32, ptr %8, align 4, !tbaa !9
  %76 = sext i32 %75 to i64
  %77 = getelementptr inbounds [101 x [101 x i64]], ptr %7, i64 0, i64 %76
  %78 = load i32, ptr %10, align 4, !tbaa !9
  %79 = sext i32 %78 to i64
  %80 = getelementptr inbounds [101 x i64], ptr %77, i64 0, i64 %79
  %81 = load i64, ptr %80, align 8, !tbaa !11
  %82 = sub nsw i64 %81, %74
  store i64 %82, ptr %80, align 8, !tbaa !11
  br label %83

83:                                               ; preds = %73, %36
  br label %84

84:                                               ; preds = %83
  %85 = load i32, ptr %11, align 4, !tbaa !9
  %86 = add nsw i32 %85, 1
  store i32 %86, ptr %11, align 4, !tbaa !9
  br label %32, !llvm.loop !13

87:                                               ; preds = %35
  br label %88

88:                                               ; preds = %87
  %89 = load i32, ptr %10, align 4, !tbaa !9
  %90 = add nsw i32 %89, 1
  store i32 %90, ptr %10, align 4, !tbaa !9
  br label %21, !llvm.loop !15

91:                                               ; preds = %24
  br label %92

92:                                               ; preds = %91
  %93 = load i32, ptr %8, align 4, !tbaa !9
  %94 = add nsw i32 %93, 1
  store i32 %94, ptr %8, align 4, !tbaa !9
  br label %16, !llvm.loop !16

95:                                               ; preds = %19
  %96 = load i32, ptr %6, align 4, !tbaa !9
  %97 = icmp eq i32 %96, 0
  br i1 %97, label %98, label %130

98:                                               ; preds = %95
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #2
  store i32 0, ptr %12, align 4, !tbaa !9
  br label %99

99:                                               ; preds = %126, %98
  %100 = load i32, ptr %12, align 4, !tbaa !9
  %101 = icmp slt i32 %100, 101
  br i1 %101, label %103, label %102

102:                                              ; preds = %99
  store i32 11, ptr %9, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #2
  br label %129

103:                                              ; preds = %99
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #2
  store i32 0, ptr %13, align 4, !tbaa !9
  br label %104

104:                                              ; preds = %122, %103
  %105 = load i32, ptr %13, align 4, !tbaa !9
  %106 = icmp slt i32 %105, 101
  br i1 %106, label %108, label %107

107:                                              ; preds = %104
  store i32 14, ptr %9, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #2
  br label %125

108:                                              ; preds = %104
  %109 = load i32, ptr %12, align 4, !tbaa !9
  %110 = sext i32 %109 to i64
  %111 = getelementptr inbounds [101 x [101 x i64]], ptr %7, i64 0, i64 %110
  %112 = load i32, ptr %13, align 4, !tbaa !9
  %113 = sext i32 %112 to i64
  %114 = getelementptr inbounds [101 x i64], ptr %111, i64 0, i64 %113
  %115 = load i64, ptr %114, align 8, !tbaa !11
  %116 = load i32, ptr %12, align 4, !tbaa !9
  %117 = sext i32 %116 to i64
  %118 = getelementptr inbounds [101 x [101 x i64]], ptr @res, i64 0, i64 %117
  %119 = load i32, ptr %13, align 4, !tbaa !9
  %120 = sext i32 %119 to i64
  %121 = getelementptr inbounds [101 x i64], ptr %118, i64 0, i64 %120
  store i64 %115, ptr %121, align 8, !tbaa !11
  br label %122

122:                                              ; preds = %108
  %123 = load i32, ptr %13, align 4, !tbaa !9
  %124 = add nsw i32 %123, 1
  store i32 %124, ptr %13, align 4, !tbaa !9
  br label %104, !llvm.loop !17

125:                                              ; preds = %107
  br label %126

126:                                              ; preds = %125
  %127 = load i32, ptr %12, align 4, !tbaa !9
  %128 = add nsw i32 %127, 1
  store i32 %128, ptr %12, align 4, !tbaa !9
  br label %99, !llvm.loop !18

129:                                              ; preds = %102
  br label %162

130:                                              ; preds = %95
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #2
  store i32 0, ptr %14, align 4, !tbaa !9
  br label %131

131:                                              ; preds = %158, %130
  %132 = load i32, ptr %14, align 4, !tbaa !9
  %133 = icmp slt i32 %132, 101
  br i1 %133, label %135, label %134

134:                                              ; preds = %131
  store i32 17, ptr %9, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #2
  br label %161

135:                                              ; preds = %131
  call void @llvm.lifetime.start.p0(i64 4, ptr %15) #2
  store i32 0, ptr %15, align 4, !tbaa !9
  br label %136

136:                                              ; preds = %154, %135
  %137 = load i32, ptr %15, align 4, !tbaa !9
  %138 = icmp slt i32 %137, 101
  br i1 %138, label %140, label %139

139:                                              ; preds = %136
  store i32 20, ptr %9, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #2
  br label %157

140:                                              ; preds = %136
  %141 = load i32, ptr %14, align 4, !tbaa !9
  %142 = sext i32 %141 to i64
  %143 = getelementptr inbounds [101 x [101 x i64]], ptr %7, i64 0, i64 %142
  %144 = load i32, ptr %15, align 4, !tbaa !9
  %145 = sext i32 %144 to i64
  %146 = getelementptr inbounds [101 x i64], ptr %143, i64 0, i64 %145
  %147 = load i64, ptr %146, align 8, !tbaa !11
  %148 = load i32, ptr %14, align 4, !tbaa !9
  %149 = sext i32 %148 to i64
  %150 = getelementptr inbounds [101 x [101 x i64]], ptr @b, i64 0, i64 %149
  %151 = load i32, ptr %15, align 4, !tbaa !9
  %152 = sext i32 %151 to i64
  %153 = getelementptr inbounds [101 x i64], ptr %150, i64 0, i64 %152
  store i64 %147, ptr %153, align 8, !tbaa !11
  br label %154

154:                                              ; preds = %140
  %155 = load i32, ptr %15, align 4, !tbaa !9
  %156 = add nsw i32 %155, 1
  store i32 %156, ptr %15, align 4, !tbaa !9
  br label %136, !llvm.loop !19

157:                                              ; preds = %139
  br label %158

158:                                              ; preds = %157
  %159 = load i32, ptr %14, align 4, !tbaa !9
  %160 = add nsw i32 %159, 1
  store i32 %160, ptr %14, align 4, !tbaa !9
  br label %131, !llvm.loop !20

161:                                              ; preds = %134
  br label %162

162:                                              ; preds = %161, %129
  store i32 1, ptr %9, align 4
  call void @llvm.lifetime.end.p0(i64 81608, ptr %7) #2
  ret void
}

; 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

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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"long long", !7, i64 0}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}
!15 = distinct !{!15, !14}
!16 = distinct !{!16, !14}
!17 = distinct !{!17, !14}
!18 = distinct !{!18, !14}
!19 = distinct !{!19, !14}
!20 = distinct !{!20, !14}


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

@MOD = external dso_local local_unnamed_addr global i64, align 8
@b = external dso_local local_unnamed_addr global [101 x [101 x i64]], align 16
@res = external dso_local local_unnamed_addr global [101 x [101 x i64]], align 16

; Function Attrs: mustprogress nofree norecurse nosync nounwind memory(readwrite, argmem: read, inaccessiblemem: none) uwtable
define dso_local void @_Z4multPA101_xS0_i(ptr nocapture noundef readonly %0, ptr nocapture noundef readonly %1, i32 noundef %2) local_unnamed_addr #0 {
  %4 = alloca [101 x [101 x i64]], align 16
  call void @llvm.lifetime.start.p0(i64 81608, ptr nonnull %4) #3
  %5 = load i64, ptr @MOD, align 8, !tbaa !5
  br label %.preheader48

.preheader48:                                     ; preds = %3, %8
  %indvars.iv64 = phi i64 [ 0, %3 ], [ %indvars.iv.next65, %8 ]
  br label %9

6:                                                ; preds = %8
  %7 = icmp eq i32 %2, 0
  br i1 %7, label %.preheader.preheader, label %.preheader45.preheader

.preheader45.preheader:                           ; preds = %6
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 16 dereferenceable(81608) @b, ptr noundef nonnull align 16 dereferenceable(81608) %4, i64 81608, i1 false), !tbaa !5
  br label %.loopexit

.preheader.preheader:                             ; preds = %6
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 16 dereferenceable(81608) @res, ptr noundef nonnull align 16 dereferenceable(81608) %4, i64 81608, i1 false), !tbaa !5
  br label %.loopexit

8:                                                ; preds = %11
  %indvars.iv.next65 = add nuw nsw i64 %indvars.iv64, 1
  %exitcond67.not = icmp eq i64 %indvars.iv.next65, 101
  br i1 %exitcond67.not, label %6, label %.preheader48, !llvm.loop !9

9:                                                ; preds = %.preheader48, %11
  %indvars.iv60 = phi i64 [ 0, %.preheader48 ], [ %indvars.iv.next61, %11 ]
  %10 = getelementptr inbounds [101 x [101 x i64]], ptr %4, i64 0, i64 %indvars.iv64, i64 %indvars.iv60
  br label %12

11:                                               ; preds = %12
  store i64 %spec.select, ptr %10, align 8, !tbaa !5
  %indvars.iv.next61 = add nuw nsw i64 %indvars.iv60, 1
  %exitcond63.not = icmp eq i64 %indvars.iv.next61, 101
  br i1 %exitcond63.not, label %8, label %9, !llvm.loop !11

12:                                               ; preds = %9, %12
  %indvars.iv = phi i64 [ 0, %9 ], [ %indvars.iv.next, %12 ]
  %spec.select4950 = phi i64 [ 0, %9 ], [ %spec.select, %12 ]
  %13 = getelementptr inbounds [101 x i64], ptr %0, i64 %indvars.iv64, i64 %indvars.iv
  %14 = load i64, ptr %13, align 8, !tbaa !5
  %15 = getelementptr inbounds [101 x i64], ptr %1, i64 %indvars.iv, i64 %indvars.iv60
  %16 = load i64, ptr %15, align 8, !tbaa !5
  %17 = mul nsw i64 %16, %14
  %18 = srem i64 %17, %5
  %19 = add nsw i64 %spec.select4950, %18
  %.not = icmp slt i64 %19, %5
  %20 = select i1 %.not, i64 0, i64 %5
  %spec.select = sub nsw i64 %19, %20
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next, 101
  br i1 %exitcond.not, label %11, label %12, !llvm.loop !12

.loopexit:                                        ; preds = %.preheader45.preheader, %.preheader.preheader
  call void @llvm.lifetime.end.p0(i64 81608, ptr nonnull %4) #3
  ret void
}

; 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: nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #2

attributes #0 = { mustprogress nofree norecurse nosync nounwind memory(readwrite, argmem: read, inaccessiblemem: none) 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 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
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 = !{!"long long", !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}


; Effective O3 passes: DSEPass,EarlyCSEPass,GVNPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,LCSSAPass,LICMPass,LoopIdiomRecognizePass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,SimplifyCFGPass