; LLVM IR from tangjz/acm-icpc :: codeforces (559B)

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

@slen = external dso_local global i32, align 4
@tlen = external dso_local global i32, align 4
@hs = external dso_local global [200010 x [2 x i32]], align 16
@ht = external dso_local global [200010 x [2 x i32]], align 16
@s = external dso_local global [200010 x i8], align 16
@t = external dso_local global [200010 x i8], 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
@.str.2 = external hidden unnamed_addr constant [3 x i8], align 1

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

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

; Function Attrs: mustprogress uwtable
declare dso_local noundef zeroext i1 @_Z5equiviii(i32 noundef, i32 noundef, i32 noundef) #1

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() #2 {
  %1 = alloca i32, align 4
  %2 = alloca i32, align 4
  %3 = alloca i32, align 4
  store i32 0, ptr %1, align 4
  %4 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef @s, ptr noundef @t)
  %5 = call i64 @strlen(ptr noundef @s) #5
  %6 = trunc i64 %5 to i32
  store i32 %6, ptr @slen, align 4, !tbaa !5
  %7 = call i64 @strlen(ptr noundef @t) #5
  %8 = trunc i64 %7 to i32
  store i32 %8, ptr @tlen, align 4, !tbaa !5
  %9 = load i8, ptr @s, align 16, !tbaa !9
  %10 = sext i8 %9 to i32
  %11 = sub nsw i32 %10, 97
  store i32 %11, ptr getelementptr inbounds ([2 x i32], ptr @hs, i64 0, i64 1), align 4, !tbaa !5
  store i32 %11, ptr @hs, align 16, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #6
  store i32 1, ptr %2, align 4, !tbaa !5
  br label %12

12:                                               ; preds = %60, %0
  %13 = load i32, ptr %2, align 4, !tbaa !5
  %14 = load i32, ptr @slen, align 4, !tbaa !5
  %15 = icmp slt i32 %13, %14
  br i1 %15, label %17, label %16

16:                                               ; preds = %12
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #6
  br label %63

17:                                               ; preds = %12
  %18 = load i32, ptr %2, align 4, !tbaa !5
  %19 = sub nsw i32 %18, 1
  %20 = sext i32 %19 to i64
  %21 = getelementptr inbounds [200010 x [2 x i32]], ptr @hs, i64 0, i64 %20
  %22 = getelementptr inbounds [2 x i32], ptr %21, i64 0, i64 0
  %23 = load i32, ptr %22, align 8, !tbaa !5
  %24 = sext i32 %23 to i64
  %25 = mul nsw i64 %24, 29
  %26 = load i32, ptr %2, align 4, !tbaa !5
  %27 = sext i32 %26 to i64
  %28 = getelementptr inbounds [200010 x i8], ptr @s, i64 0, i64 %27
  %29 = load i8, ptr %28, align 1, !tbaa !9
  %30 = sext i8 %29 to i64
  %31 = add nsw i64 %25, %30
  %32 = sub nsw i64 %31, 97
  %33 = srem i64 %32, 1000000007
  %34 = trunc i64 %33 to i32
  %35 = load i32, ptr %2, align 4, !tbaa !5
  %36 = sext i32 %35 to i64
  %37 = getelementptr inbounds [200010 x [2 x i32]], ptr @hs, i64 0, i64 %36
  %38 = getelementptr inbounds [2 x i32], ptr %37, i64 0, i64 0
  store i32 %34, ptr %38, align 8, !tbaa !5
  %39 = load i32, ptr %2, align 4, !tbaa !5
  %40 = sub nsw i32 %39, 1
  %41 = sext i32 %40 to i64
  %42 = getelementptr inbounds [200010 x [2 x i32]], ptr @hs, i64 0, i64 %41
  %43 = getelementptr inbounds [2 x i32], ptr %42, i64 0, i64 1
  %44 = load i32, ptr %43, align 4, !tbaa !5
  %45 = sext i32 %44 to i64
  %46 = mul nsw i64 %45, 31
  %47 = load i32, ptr %2, align 4, !tbaa !5
  %48 = sext i32 %47 to i64
  %49 = getelementptr inbounds [200010 x i8], ptr @s, i64 0, i64 %48
  %50 = load i8, ptr %49, align 1, !tbaa !9
  %51 = sext i8 %50 to i64
  %52 = add nsw i64 %46, %51
  %53 = sub nsw i64 %52, 97
  %54 = srem i64 %53, 1000000009
  %55 = trunc i64 %54 to i32
  %56 = load i32, ptr %2, align 4, !tbaa !5
  %57 = sext i32 %56 to i64
  %58 = getelementptr inbounds [200010 x [2 x i32]], ptr @hs, i64 0, i64 %57
  %59 = getelementptr inbounds [2 x i32], ptr %58, i64 0, i64 1
  store i32 %55, ptr %59, align 4, !tbaa !5
  br label %60

60:                                               ; preds = %17
  %61 = load i32, ptr %2, align 4, !tbaa !5
  %62 = add nsw i32 %61, 1
  store i32 %62, ptr %2, align 4, !tbaa !5
  br label %12, !llvm.loop !10

63:                                               ; preds = %16
  %64 = load i8, ptr @t, align 16, !tbaa !9
  %65 = sext i8 %64 to i32
  %66 = sub nsw i32 %65, 97
  store i32 %66, ptr getelementptr inbounds ([2 x i32], ptr @ht, i64 0, i64 1), align 4, !tbaa !5
  store i32 %66, ptr @ht, align 16, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #6
  store i32 1, ptr %3, align 4, !tbaa !5
  br label %67

67:                                               ; preds = %115, %63
  %68 = load i32, ptr %3, align 4, !tbaa !5
  %69 = load i32, ptr @tlen, align 4, !tbaa !5
  %70 = icmp slt i32 %68, %69
  br i1 %70, label %72, label %71

71:                                               ; preds = %67
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #6
  br label %118

72:                                               ; preds = %67
  %73 = load i32, ptr %3, align 4, !tbaa !5
  %74 = sub nsw i32 %73, 1
  %75 = sext i32 %74 to i64
  %76 = getelementptr inbounds [200010 x [2 x i32]], ptr @ht, i64 0, i64 %75
  %77 = getelementptr inbounds [2 x i32], ptr %76, i64 0, i64 0
  %78 = load i32, ptr %77, align 8, !tbaa !5
  %79 = sext i32 %78 to i64
  %80 = mul nsw i64 %79, 29
  %81 = load i32, ptr %3, align 4, !tbaa !5
  %82 = sext i32 %81 to i64
  %83 = getelementptr inbounds [200010 x i8], ptr @t, i64 0, i64 %82
  %84 = load i8, ptr %83, align 1, !tbaa !9
  %85 = sext i8 %84 to i64
  %86 = add nsw i64 %80, %85
  %87 = sub nsw i64 %86, 97
  %88 = srem i64 %87, 1000000007
  %89 = trunc i64 %88 to i32
  %90 = load i32, ptr %3, align 4, !tbaa !5
  %91 = sext i32 %90 to i64
  %92 = getelementptr inbounds [200010 x [2 x i32]], ptr @ht, i64 0, i64 %91
  %93 = getelementptr inbounds [2 x i32], ptr %92, i64 0, i64 0
  store i32 %89, ptr %93, align 8, !tbaa !5
  %94 = load i32, ptr %3, align 4, !tbaa !5
  %95 = sub nsw i32 %94, 1
  %96 = sext i32 %95 to i64
  %97 = getelementptr inbounds [200010 x [2 x i32]], ptr @ht, i64 0, i64 %96
  %98 = getelementptr inbounds [2 x i32], ptr %97, i64 0, i64 1
  %99 = load i32, ptr %98, align 4, !tbaa !5
  %100 = sext i32 %99 to i64
  %101 = mul nsw i64 %100, 31
  %102 = load i32, ptr %3, align 4, !tbaa !5
  %103 = sext i32 %102 to i64
  %104 = getelementptr inbounds [200010 x i8], ptr @t, i64 0, i64 %103
  %105 = load i8, ptr %104, align 1, !tbaa !9
  %106 = sext i8 %105 to i64
  %107 = add nsw i64 %101, %106
  %108 = sub nsw i64 %107, 97
  %109 = srem i64 %108, 1000000009
  %110 = trunc i64 %109 to i32
  %111 = load i32, ptr %3, align 4, !tbaa !5
  %112 = sext i32 %111 to i64
  %113 = getelementptr inbounds [200010 x [2 x i32]], ptr @ht, i64 0, i64 %112
  %114 = getelementptr inbounds [2 x i32], ptr %113, i64 0, i64 1
  store i32 %110, ptr %114, align 4, !tbaa !5
  br label %115

115:                                              ; preds = %72
  %116 = load i32, ptr %3, align 4, !tbaa !5
  %117 = add nsw i32 %116, 1
  store i32 %117, ptr %3, align 4, !tbaa !5
  br label %67, !llvm.loop !12

118:                                              ; preds = %71
  %119 = load i32, ptr @tlen, align 4, !tbaa !5
  %120 = call noundef zeroext i1 @_Z5equiviii(i32 noundef 0, i32 noundef 0, i32 noundef %119)
  %121 = zext i1 %120 to i64
  %122 = select i1 %120, ptr @.str.1, ptr @.str.2
  %123 = call i32 @puts(ptr noundef %122)
  ret i32 0
}

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

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

declare i32 @puts(ptr noundef) #3

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { 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 #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 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 #5 = { nounwind willreturn memory(read) }
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 = !{!7, !7, i64 0}
!10 = distinct !{!10, !11}
!11 = !{!"llvm.loop.mustprogress"}
!12 = distinct !{!12, !11}


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

@slen = external dso_local local_unnamed_addr global i32, align 4
@tlen = external dso_local local_unnamed_addr global i32, align 4
@hs = external dso_local local_unnamed_addr global [200010 x [2 x i32]], align 16
@ht = external dso_local local_unnamed_addr global [200010 x [2 x i32]], align 16
@s = external dso_local global [200010 x i8], align 16
@t = external dso_local global [200010 x i8], 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
@.str.2 = external hidden unnamed_addr constant [3 x i8], align 1

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

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() local_unnamed_addr #1 {
  %1 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull @s, ptr noundef nonnull @t)
  %2 = tail call i64 @strlen(ptr noundef nonnull dereferenceable(1) @s) #4
  %3 = trunc i64 %2 to i32
  store i32 %3, ptr @slen, align 4, !tbaa !5
  %4 = tail call i64 @strlen(ptr noundef nonnull dereferenceable(1) @t) #4
  %5 = trunc i64 %4 to i32
  store i32 %5, ptr @tlen, align 4, !tbaa !5
  %6 = load i8, ptr @s, align 16, !tbaa !9
  %7 = sext i8 %6 to i32
  %8 = add nsw i32 %7, -97
  store i32 %8, ptr getelementptr inbounds (i8, ptr @hs, i64 4), align 4, !tbaa !5
  store i32 %8, ptr @hs, align 16, !tbaa !5
  %9 = icmp sgt i32 %3, 1
  br i1 %9, label %.lr.ph.preheader, label %._crit_edge

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

._crit_edge:                                      ; preds = %.lr.ph, %0
  %10 = load i8, ptr @t, align 16, !tbaa !9
  %11 = sext i8 %10 to i32
  %12 = add nsw i32 %11, -97
  store i32 %12, ptr getelementptr inbounds (i8, ptr @ht, i64 4), align 4, !tbaa !5
  store i32 %12, ptr @ht, align 16, !tbaa !5
  %13 = icmp sgt i32 %5, 1
  br i1 %13, label %.lr.ph21.preheader, label %._crit_edge22

.lr.ph21.preheader:                               ; preds = %._crit_edge
  %wide.trip.count27 = and i64 %4, 2147483647
  br label %.lr.ph21

.lr.ph:                                           ; preds = %.lr.ph.preheader, %.lr.ph
  %14 = phi i32 [ %8, %.lr.ph.preheader ], [ %30, %.lr.ph ]
  %15 = phi i32 [ %8, %.lr.ph.preheader ], [ %24, %.lr.ph ]
  %indvars.iv = phi i64 [ 1, %.lr.ph.preheader ], [ %indvars.iv.next, %.lr.ph ]
  %16 = sext i32 %15 to i64
  %17 = mul nsw i64 %16, 29
  %18 = getelementptr inbounds [200010 x i8], ptr @s, i64 0, i64 %indvars.iv
  %19 = load i8, ptr %18, align 1, !tbaa !9
  %20 = sext i8 %19 to i64
  %21 = add nsw i64 %20, -97
  %22 = add nsw i64 %21, %17
  %23 = srem i64 %22, 1000000007
  %24 = trunc nsw i64 %23 to i32
  %25 = getelementptr inbounds [200010 x [2 x i32]], ptr @hs, i64 0, i64 %indvars.iv
  store i32 %24, ptr %25, align 8, !tbaa !5
  %26 = sext i32 %14 to i64
  %27 = mul nsw i64 %26, 31
  %28 = add nsw i64 %21, %27
  %29 = srem i64 %28, 1000000009
  %30 = trunc nsw i64 %29 to i32
  %31 = getelementptr inbounds i8, ptr %25, i64 4
  store i32 %30, ptr %31, align 4, !tbaa !5
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next, %wide.trip.count
  br i1 %exitcond.not, label %._crit_edge, label %.lr.ph, !llvm.loop !10

._crit_edge22:                                    ; preds = %.lr.ph21, %._crit_edge
  %32 = tail call noundef zeroext i1 @_Z5equiviii(i32 noundef 0, i32 noundef 0, i32 noundef %5)
  %33 = select i1 %32, ptr @.str.1, ptr @.str.2
  %34 = tail call i32 @puts(ptr noundef nonnull dereferenceable(1) %33)
  ret i32 0

.lr.ph21:                                         ; preds = %.lr.ph21.preheader, %.lr.ph21
  %35 = phi i32 [ %12, %.lr.ph21.preheader ], [ %51, %.lr.ph21 ]
  %36 = phi i32 [ %12, %.lr.ph21.preheader ], [ %45, %.lr.ph21 ]
  %indvars.iv24 = phi i64 [ 1, %.lr.ph21.preheader ], [ %indvars.iv.next25, %.lr.ph21 ]
  %37 = sext i32 %36 to i64
  %38 = mul nsw i64 %37, 29
  %39 = getelementptr inbounds [200010 x i8], ptr @t, i64 0, i64 %indvars.iv24
  %40 = load i8, ptr %39, align 1, !tbaa !9
  %41 = sext i8 %40 to i64
  %42 = add nsw i64 %41, -97
  %43 = add nsw i64 %42, %38
  %44 = srem i64 %43, 1000000007
  %45 = trunc nsw i64 %44 to i32
  %46 = getelementptr inbounds [200010 x [2 x i32]], ptr @ht, i64 0, i64 %indvars.iv24
  store i32 %45, ptr %46, align 8, !tbaa !5
  %47 = sext i32 %35 to i64
  %48 = mul nsw i64 %47, 31
  %49 = add nsw i64 %42, %48
  %50 = srem i64 %49, 1000000009
  %51 = trunc nsw i64 %50 to i32
  %52 = getelementptr inbounds i8, ptr %46, i64 4
  store i32 %51, ptr %52, align 4, !tbaa !5
  %indvars.iv.next25 = add nuw nsw i64 %indvars.iv24, 1
  %exitcond28.not = icmp eq i64 %indvars.iv.next25, %wide.trip.count27
  br i1 %exitcond28.not, label %._crit_edge22, label %.lr.ph21, !llvm.loop !12
}

; 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 @puts(ptr nocapture noundef readonly) local_unnamed_addr #2

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 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 #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 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 = !{!7, !7, i64 0}
!10 = distinct !{!10, !11}
!11 = !{!"llvm.loop.mustprogress"}
!12 = distinct !{!12, !11}


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