; LLVM IR from tangjz/acm-icpc :: uvalive (6132)

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

@b = external dso_local global i32, align 4
@s = external dso_local global i32, align 4
@f = external dso_local global [101 x [201 x [201 x i32]]], align 16
@.str = external hidden unnamed_addr constant [5 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [4 x i8], align 1

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

6:                                                ; preds = %117, %0
  %7 = load i32, ptr %2, align 4, !tbaa !5
  %8 = icmp sle i32 %7, 100
  br i1 %8, label %10, label %9

9:                                                ; preds = %6
  store i32 2, ptr %3, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #4
  br label %120

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

11:                                               ; preds = %113, %10
  %12 = load i32, ptr %4, align 4, !tbaa !5
  %13 = icmp sle i32 %12, 200
  br i1 %13, label %15, label %14

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

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

16:                                               ; preds = %109, %15
  %17 = load i32, ptr %5, align 4, !tbaa !5
  %18 = icmp sle i32 %17, 200
  br i1 %18, label %20, label %19

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

20:                                               ; preds = %16
  %21 = load i32, ptr %4, align 4, !tbaa !5
  %22 = icmp ne i32 %21, 0
  br i1 %22, label %23, label %52

23:                                               ; preds = %20
  %24 = load i32, ptr %5, align 4, !tbaa !5
  %25 = icmp ne i32 %24, 0
  br i1 %25, label %26, label %52

26:                                               ; preds = %23
  %27 = load i32, ptr %5, align 4, !tbaa !5
  %28 = load i32, ptr %4, align 4, !tbaa !5
  %29 = icmp sle i32 %27, %28
  br i1 %29, label %30, label %52

30:                                               ; preds = %26
  %31 = load i32, ptr %2, align 4, !tbaa !5
  %32 = sext i32 %31 to i64
  %33 = getelementptr inbounds [101 x [201 x [201 x i32]]], ptr @f, i64 0, i64 %32
  %34 = load i32, ptr %4, align 4, !tbaa !5
  %35 = sext i32 %34 to i64
  %36 = getelementptr inbounds [201 x [201 x i32]], ptr %33, i64 0, i64 %35
  %37 = load i32, ptr %5, align 4, !tbaa !5
  %38 = sext i32 %37 to i64
  %39 = getelementptr inbounds [201 x i32], ptr %36, i64 0, i64 %38
  %40 = load i32, ptr %2, align 4, !tbaa !5
  %41 = sext i32 %40 to i64
  %42 = getelementptr inbounds [101 x [201 x [201 x i32]]], ptr @f, i64 0, i64 %41
  %43 = load i32, ptr %4, align 4, !tbaa !5
  %44 = sub nsw i32 %43, 1
  %45 = sext i32 %44 to i64
  %46 = getelementptr inbounds [201 x [201 x i32]], ptr %42, i64 0, i64 %45
  %47 = load i32, ptr %5, align 4, !tbaa !5
  %48 = sub nsw i32 %47, 1
  %49 = sext i32 %48 to i64
  %50 = getelementptr inbounds [201 x i32], ptr %46, i64 0, i64 %49
  %51 = load i32, ptr %50, align 4, !tbaa !5
  call void @_Z3AddRii(ptr noundef nonnull align 4 dereferenceable(4) %39, i32 noundef %51)
  br label %52

52:                                               ; preds = %30, %26, %23, %20
  %53 = load i32, ptr %5, align 4, !tbaa !5
  %54 = mul nsw i32 %53, 2
  %55 = load i32, ptr %4, align 4, !tbaa !5
  %56 = icmp sle i32 %54, %55
  br i1 %56, label %57, label %79

57:                                               ; preds = %52
  %58 = load i32, ptr %2, align 4, !tbaa !5
  %59 = sext i32 %58 to i64
  %60 = getelementptr inbounds [101 x [201 x [201 x i32]]], ptr @f, i64 0, i64 %59
  %61 = load i32, ptr %4, align 4, !tbaa !5
  %62 = sext i32 %61 to i64
  %63 = getelementptr inbounds [201 x [201 x i32]], ptr %60, i64 0, i64 %62
  %64 = load i32, ptr %5, align 4, !tbaa !5
  %65 = sext i32 %64 to i64
  %66 = getelementptr inbounds [201 x i32], ptr %63, i64 0, i64 %65
  %67 = load i32, ptr %2, align 4, !tbaa !5
  %68 = sub nsw i32 %67, 1
  %69 = sext i32 %68 to i64
  %70 = getelementptr inbounds [101 x [201 x [201 x i32]]], ptr @f, i64 0, i64 %69
  %71 = load i32, ptr %4, align 4, !tbaa !5
  %72 = sext i32 %71 to i64
  %73 = getelementptr inbounds [201 x [201 x i32]], ptr %70, i64 0, i64 %72
  %74 = load i32, ptr %5, align 4, !tbaa !5
  %75 = mul nsw i32 %74, 2
  %76 = sext i32 %75 to i64
  %77 = getelementptr inbounds [201 x i32], ptr %73, i64 0, i64 %76
  %78 = load i32, ptr %77, align 4, !tbaa !5
  call void @_Z3AddRii(ptr noundef nonnull align 4 dereferenceable(4) %66, i32 noundef %78)
  br label %79

79:                                               ; preds = %57, %52
  %80 = load i32, ptr %5, align 4, !tbaa !5
  %81 = mul nsw i32 %80, 2
  %82 = add nsw i32 %81, 1
  %83 = load i32, ptr %4, align 4, !tbaa !5
  %84 = icmp sle i32 %82, %83
  br i1 %84, label %85, label %108

85:                                               ; preds = %79
  %86 = load i32, ptr %2, align 4, !tbaa !5
  %87 = sext i32 %86 to i64
  %88 = getelementptr inbounds [101 x [201 x [201 x i32]]], ptr @f, i64 0, i64 %87
  %89 = load i32, ptr %4, align 4, !tbaa !5
  %90 = sext i32 %89 to i64
  %91 = getelementptr inbounds [201 x [201 x i32]], ptr %88, i64 0, i64 %90
  %92 = load i32, ptr %5, align 4, !tbaa !5
  %93 = sext i32 %92 to i64
  %94 = getelementptr inbounds [201 x i32], ptr %91, i64 0, i64 %93
  %95 = load i32, ptr %2, align 4, !tbaa !5
  %96 = sub nsw i32 %95, 1
  %97 = sext i32 %96 to i64
  %98 = getelementptr inbounds [101 x [201 x [201 x i32]]], ptr @f, i64 0, i64 %97
  %99 = load i32, ptr %4, align 4, !tbaa !5
  %100 = sext i32 %99 to i64
  %101 = getelementptr inbounds [201 x [201 x i32]], ptr %98, i64 0, i64 %100
  %102 = load i32, ptr %5, align 4, !tbaa !5
  %103 = mul nsw i32 %102, 2
  %104 = add nsw i32 %103, 1
  %105 = sext i32 %104 to i64
  %106 = getelementptr inbounds [201 x i32], ptr %101, i64 0, i64 %105
  %107 = load i32, ptr %106, align 4, !tbaa !5
  call void @_Z3AddRii(ptr noundef nonnull align 4 dereferenceable(4) %94, i32 noundef %107)
  br label %108

108:                                              ; preds = %85, %79
  br label %109

109:                                              ; preds = %108
  %110 = load i32, ptr %5, align 4, !tbaa !5
  %111 = add nsw i32 %110, 1
  store i32 %111, ptr %5, align 4, !tbaa !5
  br label %16, !llvm.loop !9

112:                                              ; preds = %19
  br label %113

113:                                              ; preds = %112
  %114 = load i32, ptr %4, align 4, !tbaa !5
  %115 = add nsw i32 %114, 1
  store i32 %115, ptr %4, align 4, !tbaa !5
  br label %11, !llvm.loop !11

116:                                              ; preds = %14
  br label %117

117:                                              ; preds = %116
  %118 = load i32, ptr %2, align 4, !tbaa !5
  %119 = add nsw i32 %118, 1
  store i32 %119, ptr %2, align 4, !tbaa !5
  br label %6, !llvm.loop !12

120:                                              ; preds = %9
  br label %121

121:                                              ; preds = %124, %120
  %122 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef @s, ptr noundef @b)
  %123 = icmp eq i32 %122, 2
  br i1 %123, label %124, label %134

124:                                              ; preds = %121
  %125 = load i32, ptr @b, align 4, !tbaa !5
  %126 = sext i32 %125 to i64
  %127 = getelementptr inbounds [101 x [201 x [201 x i32]]], ptr @f, i64 0, i64 %126
  %128 = load i32, ptr @s, align 4, !tbaa !5
  %129 = sext i32 %128 to i64
  %130 = getelementptr inbounds [201 x [201 x i32]], ptr %127, i64 0, i64 %129
  %131 = getelementptr inbounds [201 x i32], ptr %130, i64 0, i64 0
  %132 = load i32, ptr %131, align 4, !tbaa !5
  %133 = call i32 (ptr, ...) @printf(ptr noundef @.str.1, i32 noundef %132)
  br label %121, !llvm.loop !13

134:                                              ; preds = %121
  ret i32 0
}

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

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local void @_Z3AddRii(ptr noundef nonnull align 4 dereferenceable(4), i32 noundef) #2

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

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

declare i32 @printf(ptr noundef, ...) #3

attributes #0 = { 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 #1 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { inlinehint 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 #3 = { "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 = { 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}


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

@b = external dso_local global i32, align 4
@s = external dso_local global i32, align 4
@f = external dso_local global [101 x [201 x [201 x i32]]], align 16
@.str = external hidden unnamed_addr constant [5 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [4 x i8], align 1

; Function Attrs: mustprogress norecurse nounwind uwtable
define dso_local noundef i32 @main() local_unnamed_addr #0 {
  store i32 1, ptr @f, align 16, !tbaa !5
  br label %.preheader44

.preheader44:                                     ; preds = %0, %5
  %indvars.iv53 = phi i64 [ 1, %0 ], [ %indvars.iv.next54, %5 ]
  %1 = add nsw i64 %indvars.iv53, -1
  br label %.preheader43

.preheader:                                       ; preds = %5
  %2 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull @s, ptr noundef nonnull @b)
  %3 = icmp eq i32 %2, 2
  br i1 %3, label %.lr.ph, label %._crit_edge

.preheader43:                                     ; preds = %.preheader44, %6
  %indvars.iv49 = phi i64 [ 0, %.preheader44 ], [ %indvars.iv.next50, %6 ]
  %4 = add nsw i64 %indvars.iv49, -1
  br label %7

5:                                                ; preds = %6
  %indvars.iv.next54 = add nuw nsw i64 %indvars.iv53, 1
  %exitcond56.not = icmp eq i64 %indvars.iv.next54, 101
  br i1 %exitcond56.not, label %.preheader, label %.preheader44, !llvm.loop !9

6:                                                ; preds = %26
  %indvars.iv.next50 = add nuw nsw i64 %indvars.iv49, 1
  %exitcond52.not = icmp eq i64 %indvars.iv.next50, 201
  br i1 %exitcond52.not, label %5, label %.preheader43, !llvm.loop !11

7:                                                ; preds = %.preheader43, %26
  %indvars.iv = phi i64 [ 0, %.preheader43 ], [ %indvars.iv.next, %26 ]
  %8 = add nsw i64 %indvars.iv, -1
  %9 = and i64 %8, 4294967295
  %.not = icmp ult i64 %9, %indvars.iv49
  br i1 %.not, label %10, label %14

10:                                               ; preds = %7
  %11 = getelementptr inbounds [101 x [201 x [201 x i32]]], ptr @f, i64 0, i64 %indvars.iv53, i64 %indvars.iv49, i64 %indvars.iv
  %12 = getelementptr inbounds [101 x [201 x [201 x i32]]], ptr @f, i64 0, i64 %indvars.iv53, i64 %4, i64 %8
  %13 = load i32, ptr %12, align 4, !tbaa !5
  tail call void @_Z3AddRii(ptr noundef nonnull align 4 dereferenceable(4) %11, i32 noundef %13)
  br label %14

14:                                               ; preds = %10, %7
  %15 = shl nuw nsw i64 %indvars.iv, 1
  %.not37 = icmp ugt i64 %15, %indvars.iv49
  br i1 %.not37, label %20, label %16

16:                                               ; preds = %14
  %17 = getelementptr inbounds [101 x [201 x [201 x i32]]], ptr @f, i64 0, i64 %indvars.iv53, i64 %indvars.iv49, i64 %indvars.iv
  %18 = getelementptr inbounds [101 x [201 x [201 x i32]]], ptr @f, i64 0, i64 %1, i64 %indvars.iv49, i64 %15
  %19 = load i32, ptr %18, align 4, !tbaa !5
  tail call void @_Z3AddRii(ptr noundef nonnull align 4 dereferenceable(4) %17, i32 noundef %19)
  br label %20

20:                                               ; preds = %16, %14
  %.not38.not = icmp ult i64 %15, %indvars.iv49
  br i1 %.not38.not, label %21, label %26

21:                                               ; preds = %20
  %22 = or disjoint i64 %15, 1
  %23 = getelementptr inbounds [101 x [201 x [201 x i32]]], ptr @f, i64 0, i64 %indvars.iv53, i64 %indvars.iv49, i64 %indvars.iv
  %24 = getelementptr inbounds [101 x [201 x [201 x i32]]], ptr @f, i64 0, i64 %1, i64 %indvars.iv49, i64 %22
  %25 = load i32, ptr %24, align 4, !tbaa !5
  tail call void @_Z3AddRii(ptr noundef nonnull align 4 dereferenceable(4) %23, i32 noundef %25)
  br label %26

26:                                               ; preds = %20, %21
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next, 201
  br i1 %exitcond.not, label %6, label %7, !llvm.loop !12

.lr.ph:                                           ; preds = %.preheader, %.lr.ph
  %27 = load i32, ptr @b, align 4, !tbaa !5
  %28 = sext i32 %27 to i64
  %29 = load i32, ptr @s, align 4, !tbaa !5
  %30 = sext i32 %29 to i64
  %31 = getelementptr inbounds [101 x [201 x [201 x i32]]], ptr @f, i64 0, i64 %28, i64 %30
  %32 = load i32, ptr %31, align 4, !tbaa !5
  %33 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.1, i32 noundef %32)
  %34 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull @s, ptr noundef nonnull @b)
  %35 = icmp eq i32 %34, 2
  br i1 %35, label %.lr.ph, label %._crit_edge, !llvm.loop !13

._crit_edge:                                      ; preds = %.lr.ph, %.preheader
  ret i32 0
}

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local void @_Z3AddRii(ptr noundef nonnull align 4 dereferenceable(4), i32 noundef) local_unnamed_addr #1

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

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

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

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


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass