; LLVM IR from Shah-Shishir/Codeforces-Solutions :: 989A. A Blend of Springtime (main)

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

@.str = external hidden unnamed_addr constant [3 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.2 = 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 [101 x i8], align 16
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = alloca i8, align 1
  store i32 0, ptr %1, align 4
  call void @llvm.lifetime.start.p0(i64 101, ptr %2) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #4
  call void @llvm.lifetime.start.p0(i64 1, ptr %5) #4
  br label %6

6:                                                ; preds = %167, %0
  %7 = getelementptr inbounds [101 x i8], ptr %2, i64 0, i64 0
  %8 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef %7)
  %9 = icmp ne i32 %8, -1
  br i1 %9, label %10, label %168

10:                                               ; preds = %6
  %11 = getelementptr inbounds [101 x i8], ptr %2, i64 0, i64 0
  %12 = call i64 @strlen(ptr noundef %11) #5
  %13 = trunc i64 %12 to i32
  store i32 %13, ptr %3, align 4, !tbaa !5
  store i8 0, ptr %5, align 1, !tbaa !9
  store i32 0, ptr %4, align 4, !tbaa !5
  br label %14

14:                                               ; preds = %159, %10
  %15 = load i32, ptr %4, align 4, !tbaa !5
  %16 = load i32, ptr %3, align 4, !tbaa !5
  %17 = icmp slt i32 %15, %16
  br i1 %17, label %18, label %162

18:                                               ; preds = %14
  %19 = load i32, ptr %4, align 4, !tbaa !5
  %20 = sext i32 %19 to i64
  %21 = getelementptr inbounds [101 x i8], ptr %2, i64 0, i64 %20
  %22 = load i8, ptr %21, align 1, !tbaa !11
  %23 = sext i8 %22 to i32
  %24 = icmp eq i32 %23, 65
  br i1 %24, label %25, label %41

25:                                               ; preds = %18
  %26 = load i32, ptr %4, align 4, !tbaa !5
  %27 = add nsw i32 %26, 1
  %28 = sext i32 %27 to i64
  %29 = getelementptr inbounds [101 x i8], ptr %2, i64 0, i64 %28
  %30 = load i8, ptr %29, align 1, !tbaa !11
  %31 = sext i8 %30 to i32
  %32 = icmp eq i32 %31, 66
  br i1 %32, label %33, label %41

33:                                               ; preds = %25
  %34 = load i32, ptr %4, align 4, !tbaa !5
  %35 = add nsw i32 %34, 2
  %36 = sext i32 %35 to i64
  %37 = getelementptr inbounds [101 x i8], ptr %2, i64 0, i64 %36
  %38 = load i8, ptr %37, align 1, !tbaa !11
  %39 = sext i8 %38 to i32
  %40 = icmp eq i32 %39, 67
  br i1 %40, label %156, label %41

41:                                               ; preds = %33, %25, %18
  %42 = load i32, ptr %4, align 4, !tbaa !5
  %43 = sext i32 %42 to i64
  %44 = getelementptr inbounds [101 x i8], ptr %2, i64 0, i64 %43
  %45 = load i8, ptr %44, align 1, !tbaa !11
  %46 = sext i8 %45 to i32
  %47 = icmp eq i32 %46, 65
  br i1 %47, label %48, label %64

48:                                               ; preds = %41
  %49 = load i32, ptr %4, align 4, !tbaa !5
  %50 = add nsw i32 %49, 1
  %51 = sext i32 %50 to i64
  %52 = getelementptr inbounds [101 x i8], ptr %2, i64 0, i64 %51
  %53 = load i8, ptr %52, align 1, !tbaa !11
  %54 = sext i8 %53 to i32
  %55 = icmp eq i32 %54, 67
  br i1 %55, label %56, label %64

56:                                               ; preds = %48
  %57 = load i32, ptr %4, align 4, !tbaa !5
  %58 = add nsw i32 %57, 2
  %59 = sext i32 %58 to i64
  %60 = getelementptr inbounds [101 x i8], ptr %2, i64 0, i64 %59
  %61 = load i8, ptr %60, align 1, !tbaa !11
  %62 = sext i8 %61 to i32
  %63 = icmp eq i32 %62, 66
  br i1 %63, label %156, label %64

64:                                               ; preds = %56, %48, %41
  %65 = load i32, ptr %4, align 4, !tbaa !5
  %66 = sext i32 %65 to i64
  %67 = getelementptr inbounds [101 x i8], ptr %2, i64 0, i64 %66
  %68 = load i8, ptr %67, align 1, !tbaa !11
  %69 = sext i8 %68 to i32
  %70 = icmp eq i32 %69, 66
  br i1 %70, label %71, label %87

71:                                               ; preds = %64
  %72 = load i32, ptr %4, align 4, !tbaa !5
  %73 = add nsw i32 %72, 1
  %74 = sext i32 %73 to i64
  %75 = getelementptr inbounds [101 x i8], ptr %2, i64 0, i64 %74
  %76 = load i8, ptr %75, align 1, !tbaa !11
  %77 = sext i8 %76 to i32
  %78 = icmp eq i32 %77, 65
  br i1 %78, label %79, label %87

79:                                               ; preds = %71
  %80 = load i32, ptr %4, align 4, !tbaa !5
  %81 = add nsw i32 %80, 2
  %82 = sext i32 %81 to i64
  %83 = getelementptr inbounds [101 x i8], ptr %2, i64 0, i64 %82
  %84 = load i8, ptr %83, align 1, !tbaa !11
  %85 = sext i8 %84 to i32
  %86 = icmp eq i32 %85, 67
  br i1 %86, label %156, label %87

87:                                               ; preds = %79, %71, %64
  %88 = load i32, ptr %4, align 4, !tbaa !5
  %89 = sext i32 %88 to i64
  %90 = getelementptr inbounds [101 x i8], ptr %2, i64 0, i64 %89
  %91 = load i8, ptr %90, align 1, !tbaa !11
  %92 = sext i8 %91 to i32
  %93 = icmp eq i32 %92, 66
  br i1 %93, label %94, label %110

94:                                               ; preds = %87
  %95 = load i32, ptr %4, align 4, !tbaa !5
  %96 = add nsw i32 %95, 1
  %97 = sext i32 %96 to i64
  %98 = getelementptr inbounds [101 x i8], ptr %2, i64 0, i64 %97
  %99 = load i8, ptr %98, align 1, !tbaa !11
  %100 = sext i8 %99 to i32
  %101 = icmp eq i32 %100, 67
  br i1 %101, label %102, label %110

102:                                              ; preds = %94
  %103 = load i32, ptr %4, align 4, !tbaa !5
  %104 = add nsw i32 %103, 2
  %105 = sext i32 %104 to i64
  %106 = getelementptr inbounds [101 x i8], ptr %2, i64 0, i64 %105
  %107 = load i8, ptr %106, align 1, !tbaa !11
  %108 = sext i8 %107 to i32
  %109 = icmp eq i32 %108, 65
  br i1 %109, label %156, label %110

110:                                              ; preds = %102, %94, %87
  %111 = load i32, ptr %4, align 4, !tbaa !5
  %112 = sext i32 %111 to i64
  %113 = getelementptr inbounds [101 x i8], ptr %2, i64 0, i64 %112
  %114 = load i8, ptr %113, align 1, !tbaa !11
  %115 = sext i8 %114 to i32
  %116 = icmp eq i32 %115, 67
  br i1 %116, label %117, label %133

117:                                              ; preds = %110
  %118 = load i32, ptr %4, align 4, !tbaa !5
  %119 = add nsw i32 %118, 1
  %120 = sext i32 %119 to i64
  %121 = getelementptr inbounds [101 x i8], ptr %2, i64 0, i64 %120
  %122 = load i8, ptr %121, align 1, !tbaa !11
  %123 = sext i8 %122 to i32
  %124 = icmp eq i32 %123, 66
  br i1 %124, label %125, label %133

125:                                              ; preds = %117
  %126 = load i32, ptr %4, align 4, !tbaa !5
  %127 = add nsw i32 %126, 2
  %128 = sext i32 %127 to i64
  %129 = getelementptr inbounds [101 x i8], ptr %2, i64 0, i64 %128
  %130 = load i8, ptr %129, align 1, !tbaa !11
  %131 = sext i8 %130 to i32
  %132 = icmp eq i32 %131, 65
  br i1 %132, label %156, label %133

133:                                              ; preds = %125, %117, %110
  %134 = load i32, ptr %4, align 4, !tbaa !5
  %135 = sext i32 %134 to i64
  %136 = getelementptr inbounds [101 x i8], ptr %2, i64 0, i64 %135
  %137 = load i8, ptr %136, align 1, !tbaa !11
  %138 = sext i8 %137 to i32
  %139 = icmp eq i32 %138, 67
  br i1 %139, label %140, label %158

140:                                              ; preds = %133
  %141 = load i32, ptr %4, align 4, !tbaa !5
  %142 = add nsw i32 %141, 1
  %143 = sext i32 %142 to i64
  %144 = getelementptr inbounds [101 x i8], ptr %2, i64 0, i64 %143
  %145 = load i8, ptr %144, align 1, !tbaa !11
  %146 = sext i8 %145 to i32
  %147 = icmp eq i32 %146, 65
  br i1 %147, label %148, label %158

148:                                              ; preds = %140
  %149 = load i32, ptr %4, align 4, !tbaa !5
  %150 = add nsw i32 %149, 2
  %151 = sext i32 %150 to i64
  %152 = getelementptr inbounds [101 x i8], ptr %2, i64 0, i64 %151
  %153 = load i8, ptr %152, align 1, !tbaa !11
  %154 = sext i8 %153 to i32
  %155 = icmp eq i32 %154, 66
  br i1 %155, label %156, label %158

156:                                              ; preds = %148, %125, %102, %79, %56, %33
  store i8 1, ptr %5, align 1, !tbaa !9
  %157 = call i32 (ptr, ...) @printf(ptr noundef @.str.1)
  br label %162

158:                                              ; preds = %148, %140, %133
  br label %159

159:                                              ; preds = %158
  %160 = load i32, ptr %4, align 4, !tbaa !5
  %161 = add nsw i32 %160, 1
  store i32 %161, ptr %4, align 4, !tbaa !5
  br label %14, !llvm.loop !12

162:                                              ; preds = %156, %14
  %163 = load i8, ptr %5, align 1, !tbaa !9, !range !14, !noundef !15
  %164 = trunc i8 %163 to i1
  br i1 %164, label %167, label %165

165:                                              ; preds = %162
  %166 = call i32 (ptr, ...) @printf(ptr noundef @.str.2)
  br label %167

167:                                              ; preds = %165, %162
  br label %6, !llvm.loop !16

168:                                              ; preds = %6
  call void @llvm.lifetime.end.p0(i64 1, ptr %5) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #4
  call void @llvm.lifetime.end.p0(i64 101, ptr %2) #4
  ret i32 0
}

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

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

; Function Attrs: nounwind willreturn memory(read)
declare i64 @strlen(ptr noundef) #3

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

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

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 = { "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 = { nounwind willreturn memory(read) "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 }
attributes #5 = { nounwind willreturn memory(read) }

!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 = !{!"bool", !7, i64 0}
!11 = !{!7, !7, i64 0}
!12 = distinct !{!12, !13}
!13 = !{!"llvm.loop.mustprogress"}
!14 = !{i8 0, i8 2}
!15 = !{}
!16 = distinct !{!16, !13}


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

@.str = external hidden unnamed_addr constant [3 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [4 x i8], align 1

; Function Attrs: mustprogress nofree norecurse nounwind uwtable
define dso_local noundef i32 @main() local_unnamed_addr #0 {
  %1 = alloca [101 x i8], align 16
  call void @llvm.lifetime.start.p0(i64 101, ptr nonnull %1) #4
  %2 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %1)
  %.not34 = icmp eq i32 %2, -1
  br i1 %.not34, label %._crit_edge, label %.lr.ph35

.lr.ph35:                                         ; preds = %0, %.critedge
  %3 = call i64 @strlen(ptr noundef nonnull dereferenceable(1) %1) #5
  %4 = trunc i64 %3 to i32
  %5 = icmp sgt i32 %4, 0
  br i1 %5, label %.lr.ph.preheader, label %.critedge

.lr.ph.preheader:                                 ; preds = %.lr.ph35
  %wide.trip.count = and i64 %3, 2147483647
  br label %.lr.ph

.lr.ph:                                           ; preds = %.lr.ph.preheader, %.thread32
  %indvars.iv = phi i64 [ 0, %.lr.ph.preheader ], [ %.pre, %.thread32 ]
  %6 = getelementptr inbounds [101 x i8], ptr %1, i64 0, i64 %indvars.iv
  %7 = load i8, ptr %6, align 1, !tbaa !5
  %.pre = add nuw nsw i64 %indvars.iv, 1
  switch i8 %7, label %.thread32 [
    i8 65, label %8
    i8 66, label %21
    i8 67, label %34
  ]

8:                                                ; preds = %.lr.ph
  %9 = getelementptr inbounds [101 x i8], ptr %1, i64 0, i64 %.pre
  %10 = load i8, ptr %9, align 1, !tbaa !5
  switch i8 %10, label %.thread32 [
    i8 66, label %11
    i8 67, label %16
  ]

11:                                               ; preds = %8
  %12 = add nuw nsw i64 %indvars.iv, 2
  %13 = getelementptr inbounds [101 x i8], ptr %1, i64 0, i64 %12
  %14 = load i8, ptr %13, align 1, !tbaa !5
  %15 = icmp eq i8 %14, 67
  br i1 %15, label %.critedge, label %.thread32

16:                                               ; preds = %8
  %17 = add nuw nsw i64 %indvars.iv, 2
  %18 = getelementptr inbounds [101 x i8], ptr %1, i64 0, i64 %17
  %19 = load i8, ptr %18, align 1, !tbaa !5
  %20 = icmp eq i8 %19, 66
  br i1 %20, label %.critedge, label %.thread32

21:                                               ; preds = %.lr.ph
  %22 = getelementptr inbounds [101 x i8], ptr %1, i64 0, i64 %.pre
  %23 = load i8, ptr %22, align 1, !tbaa !5
  switch i8 %23, label %.thread32 [
    i8 65, label %24
    i8 67, label %29
  ]

24:                                               ; preds = %21
  %25 = add nuw nsw i64 %indvars.iv, 2
  %26 = getelementptr inbounds [101 x i8], ptr %1, i64 0, i64 %25
  %27 = load i8, ptr %26, align 1, !tbaa !5
  %28 = icmp eq i8 %27, 67
  br i1 %28, label %.critedge, label %.thread32

29:                                               ; preds = %21
  %30 = add nuw nsw i64 %indvars.iv, 2
  %31 = getelementptr inbounds [101 x i8], ptr %1, i64 0, i64 %30
  %32 = load i8, ptr %31, align 1, !tbaa !5
  %33 = icmp eq i8 %32, 65
  br i1 %33, label %.critedge, label %.thread32

34:                                               ; preds = %.lr.ph
  %35 = getelementptr inbounds [101 x i8], ptr %1, i64 0, i64 %.pre
  %36 = load i8, ptr %35, align 1, !tbaa !5
  switch i8 %36, label %.thread32 [
    i8 66, label %37
    i8 65, label %42
  ]

37:                                               ; preds = %34
  %38 = add nuw nsw i64 %indvars.iv, 2
  %39 = getelementptr inbounds [101 x i8], ptr %1, i64 0, i64 %38
  %40 = load i8, ptr %39, align 1, !tbaa !5
  %41 = icmp eq i8 %40, 65
  br i1 %41, label %.critedge, label %.thread32

42:                                               ; preds = %34
  %43 = add nuw nsw i64 %indvars.iv, 2
  %44 = getelementptr inbounds [101 x i8], ptr %1, i64 0, i64 %43
  %45 = load i8, ptr %44, align 1, !tbaa !5
  %46 = icmp eq i8 %45, 66
  br i1 %46, label %.critedge, label %.thread32

.thread32:                                        ; preds = %34, %21, %8, %.lr.ph, %37, %24, %11, %29, %16, %42
  %exitcond.not = icmp eq i64 %.pre, %wide.trip.count
  br i1 %exitcond.not, label %.critedge, label %.lr.ph, !llvm.loop !8

.critedge:                                        ; preds = %.thread32, %11, %16, %24, %29, %37, %42, %.lr.ph35
  %.str.1.sink = phi ptr [ @.str.2, %.lr.ph35 ], [ @.str.1, %42 ], [ @.str.1, %37 ], [ @.str.1, %29 ], [ @.str.1, %24 ], [ @.str.1, %16 ], [ @.str.1, %11 ], [ @.str.2, %.thread32 ]
  %47 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) %.str.1.sink)
  %48 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %1)
  %.not = icmp eq i32 %48, -1
  br i1 %.not, label %._crit_edge, label %.lr.ph35, !llvm.loop !10

._crit_edge:                                      ; preds = %.critedge, %0
  call void @llvm.lifetime.end.p0(i64 101, ptr nonnull %1) #4
  ret i32 0
}

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

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

; Function Attrs: mustprogress nofree nounwind willreturn memory(argmem: read)
declare i64 @strlen(ptr nocapture noundef) local_unnamed_addr #3

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

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

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

!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 = !{!"omnipotent char", !7, i64 0}
!7 = !{!"Simple C++ TBAA"}
!8 = distinct !{!8, !9}
!9 = !{!"llvm.loop.mustprogress"}
!10 = distinct !{!10, !9}


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