; LLVM IR from lzyrapx/Competitive-Programming :: HDUOJ (2087)

; 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 [4 x i8], align 1

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() #0 {
  %1 = alloca i32, align 4
  %2 = alloca [1001 x i8], align 16
  %3 = alloca [1001 x i8], align 16
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  store i32 0, ptr %1, align 4
  call void @llvm.lifetime.start.p0(i64 1001, ptr %2) #4
  call void @llvm.lifetime.start.p0(i64 1001, ptr %3) #4
  br label %11

11:                                               ; preds = %72, %0
  %12 = getelementptr inbounds [1001 x i8], ptr %2, i64 0, i64 0
  %13 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef %12)
  %14 = icmp ne i32 %13, 0
  br i1 %14, label %15, label %20

15:                                               ; preds = %11
  %16 = getelementptr inbounds [1001 x i8], ptr %2, i64 0, i64 0
  %17 = load i8, ptr %16, align 16, !tbaa !5
  %18 = sext i8 %17 to i32
  %19 = icmp ne i32 %18, 35
  br label %20

20:                                               ; preds = %15, %11
  %21 = phi i1 [ false, %11 ], [ %19, %15 ]
  br i1 %21, label %22, label %75

22:                                               ; preds = %20
  %23 = getelementptr inbounds [1001 x i8], ptr %3, i64 0, i64 0
  %24 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef %23)
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #4
  %25 = getelementptr inbounds [1001 x i8], ptr %2, i64 0, i64 0
  %26 = call i64 @strlen(ptr noundef %25) #5
  %27 = trunc i64 %26 to i32
  store i32 %27, ptr %4, align 4, !tbaa !8
  %28 = getelementptr inbounds [1001 x i8], ptr %3, i64 0, i64 0
  %29 = call i64 @strlen(ptr noundef %28) #5
  %30 = trunc i64 %29 to i32
  store i32 %30, ptr %5, align 4, !tbaa !8
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #4
  store i32 0, ptr %6, align 4, !tbaa !8
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #4
  store i32 0, ptr %7, align 4, !tbaa !8
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #4
  store i32 0, ptr %8, align 4, !tbaa !8
  br label %31

31:                                               ; preds = %68, %22
  %32 = load i32, ptr %8, align 4, !tbaa !8
  %33 = load i32, ptr %4, align 4, !tbaa !8
  %34 = icmp slt i32 %32, %33
  br i1 %34, label %36, label %35

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

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

37:                                               ; preds = %58, %36
  %38 = load i32, ptr %10, align 4, !tbaa !8
  %39 = load i32, ptr %5, align 4, !tbaa !8
  %40 = icmp slt i32 %38, %39
  br i1 %40, label %42, label %41

41:                                               ; preds = %37
  store i32 7, ptr %9, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #4
  br label %61

42:                                               ; preds = %37
  %43 = load i32, ptr %8, align 4, !tbaa !8
  %44 = load i32, ptr %10, align 4, !tbaa !8
  %45 = add nsw i32 %43, %44
  %46 = sext i32 %45 to i64
  %47 = getelementptr inbounds [1001 x i8], ptr %2, i64 0, i64 %46
  %48 = load i8, ptr %47, align 1, !tbaa !5
  %49 = sext i8 %48 to i32
  %50 = load i32, ptr %10, align 4, !tbaa !8
  %51 = sext i32 %50 to i64
  %52 = getelementptr inbounds [1001 x i8], ptr %3, i64 0, i64 %51
  %53 = load i8, ptr %52, align 1, !tbaa !5
  %54 = sext i8 %53 to i32
  %55 = icmp ne i32 %49, %54
  br i1 %55, label %56, label %57

56:                                               ; preds = %42
  store i32 1, ptr %6, align 4, !tbaa !8
  br label %57

57:                                               ; preds = %56, %42
  br label %58

58:                                               ; preds = %57
  %59 = load i32, ptr %10, align 4, !tbaa !8
  %60 = add nsw i32 %59, 1
  store i32 %60, ptr %10, align 4, !tbaa !8
  br label %37, !llvm.loop !10

61:                                               ; preds = %41
  %62 = load i32, ptr %6, align 4, !tbaa !8
  %63 = icmp eq i32 %62, 0
  br i1 %63, label %64, label %67

64:                                               ; preds = %61
  %65 = load i32, ptr %7, align 4, !tbaa !8
  %66 = add nsw i32 %65, 1
  store i32 %66, ptr %7, align 4, !tbaa !8
  br label %67

67:                                               ; preds = %64, %61
  store i32 0, ptr %6, align 4, !tbaa !8
  br label %68

68:                                               ; preds = %67
  %69 = load i32, ptr %8, align 4, !tbaa !8
  %70 = load i32, ptr %5, align 4, !tbaa !8
  %71 = add nsw i32 %69, %70
  store i32 %71, ptr %8, align 4, !tbaa !8
  br label %31, !llvm.loop !12

72:                                               ; preds = %35
  %73 = load i32, ptr %7, align 4, !tbaa !8
  %74 = call i32 (ptr, ...) @printf(ptr noundef @.str.1, i32 noundef %73)
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #4
  br label %11, !llvm.loop !13

75:                                               ; preds = %20
  store i32 0, ptr %1, align 4
  store i32 1, ptr %9, align 4
  call void @llvm.lifetime.end.p0(i64 1001, ptr %3) #4
  call void @llvm.lifetime.end.p0(i64 1001, ptr %2) #4
  %76 = load i32, ptr %1, align 4
  ret i32 %76
}

; 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

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

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

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

@.str = external hidden unnamed_addr constant [3 x i8], align 1
@.str.1 = 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 [1001 x i8], align 16
  %2 = alloca [1001 x i8], align 16
  call void @llvm.lifetime.start.p0(i64 1001, ptr nonnull %1) #5
  call void @llvm.lifetime.start.p0(i64 1001, ptr nonnull %2) #5
  %3 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %1)
  %4 = icmp ne i32 %3, 0
  %5 = load i8, ptr %1, align 16
  %6 = icmp ne i8 %5, 35
  %7 = select i1 %4, i1 %6, i1 false
  br i1 %7, label %.lr.ph, label %._crit_edge

.lr.ph:                                           ; preds = %0, %._crit_edge24
  %8 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %2)
  %9 = call i64 @strlen(ptr noundef nonnull dereferenceable(1) %1) #6
  %10 = trunc i64 %9 to i32
  %11 = call i64 @strlen(ptr noundef nonnull dereferenceable(1) %2) #6
  %12 = trunc i64 %11 to i32
  %13 = icmp sgt i32 %10, 0
  br i1 %13, label %.preheader.lr.ph, label %._crit_edge24

.preheader.lr.ph:                                 ; preds = %.lr.ph
  %14 = icmp sgt i32 %12, 0
  br i1 %14, label %.preheader.us.preheader, label %.preheader.preheader

.preheader.preheader:                             ; preds = %.preheader.lr.ph
  %smax = call i32 @llvm.smax.i32(i32 %12, i32 %10)
  %15 = add nsw i32 %smax, -1
  %16 = udiv i32 %15, %12
  %17 = add i32 %16, 1
  %min.iters.check39 = icmp ult i32 %17, 8
  br i1 %min.iters.check39, label %.preheader.preheader52, label %vector.ph40

.preheader.preheader52:                           ; preds = %middle.block37, %.preheader.preheader
  %.01423.ph = phi i32 [ 0, %.preheader.preheader ], [ %ind.end, %middle.block37 ]
  %.01522.ph = phi i32 [ 0, %.preheader.preheader ], [ %21, %middle.block37 ]
  br label %.preheader

vector.ph40:                                      ; preds = %.preheader.preheader
  %n.vec42 = and i32 %17, -8
  %ind.end = mul i32 %n.vec42, %12
  br label %vector.body44

vector.body44:                                    ; preds = %vector.body44, %vector.ph40
  %index45 = phi i32 [ 0, %vector.ph40 ], [ %index.next48, %vector.body44 ]
  %vec.phi46 = phi <4 x i32> [ zeroinitializer, %vector.ph40 ], [ %18, %vector.body44 ]
  %vec.phi47 = phi <4 x i32> [ zeroinitializer, %vector.ph40 ], [ %19, %vector.body44 ]
  %18 = add <4 x i32> %vec.phi46, <i32 1, i32 1, i32 1, i32 1>
  %19 = add <4 x i32> %vec.phi47, <i32 1, i32 1, i32 1, i32 1>
  %index.next48 = add nuw i32 %index45, 8
  %20 = icmp eq i32 %index.next48, %n.vec42
  br i1 %20, label %middle.block37, label %vector.body44, !llvm.loop !5

middle.block37:                                   ; preds = %vector.body44
  %bin.rdx49 = add <4 x i32> %19, %18
  %21 = call i32 @llvm.vector.reduce.add.v4i32(<4 x i32> %bin.rdx49)
  %cmp.n50 = icmp eq i32 %17, %n.vec42
  br i1 %cmp.n50, label %._crit_edge24, label %.preheader.preheader52

.preheader.us.preheader:                          ; preds = %.preheader.lr.ph
  %22 = and i64 %11, 2147483647
  %min.iters.check = icmp ult i64 %22, 8
  %n.mod.vf = and i64 %11, 7
  %n.vec = sub nsw i64 %22, %n.mod.vf
  %cmp.n = icmp eq i64 %n.mod.vf, 0
  br label %.preheader.us

.preheader.us:                                    ; preds = %.preheader.us.preheader, %._crit_edge.us
  %indvars.iv28 = phi i64 [ 0, %.preheader.us.preheader ], [ %indvars.iv.next29, %._crit_edge.us ]
  %.01522.us = phi i32 [ 0, %.preheader.us.preheader ], [ %spec.select.us, %._crit_edge.us ]
  br i1 %min.iters.check, label %scalar.ph.preheader, label %vector.body

vector.body:                                      ; preds = %.preheader.us, %vector.body
  %index = phi i64 [ %index.next, %vector.body ], [ 0, %.preheader.us ]
  %vec.phi = phi <4 x i1> [ %30, %vector.body ], [ zeroinitializer, %.preheader.us ]
  %vec.phi33 = phi <4 x i1> [ %31, %vector.body ], [ zeroinitializer, %.preheader.us ]
  %23 = add nuw nsw i64 %index, %indvars.iv28
  %24 = getelementptr inbounds [1001 x i8], ptr %1, i64 0, i64 %23
  %25 = getelementptr inbounds i8, ptr %24, i64 4
  %wide.load = load <4 x i8>, ptr %24, align 1, !tbaa !9
  %wide.load34 = load <4 x i8>, ptr %25, align 1, !tbaa !9
  %26 = getelementptr inbounds [1001 x i8], ptr %2, i64 0, i64 %index
  %27 = getelementptr inbounds i8, ptr %26, i64 4
  %wide.load35 = load <4 x i8>, ptr %26, align 8, !tbaa !9
  %wide.load36 = load <4 x i8>, ptr %27, align 4, !tbaa !9
  %28 = icmp ne <4 x i8> %wide.load, %wide.load35
  %29 = icmp ne <4 x i8> %wide.load34, %wide.load36
  %30 = or <4 x i1> %vec.phi, %28
  %31 = or <4 x i1> %vec.phi33, %29
  %index.next = add nuw i64 %index, 8
  %32 = icmp eq i64 %index.next, %n.vec
  br i1 %32, label %middle.block, label %vector.body, !llvm.loop !12

middle.block:                                     ; preds = %vector.body
  %bin.rdx = or <4 x i1> %31, %30
  %bin.rdx.fr = freeze <4 x i1> %bin.rdx
  %33 = bitcast <4 x i1> %bin.rdx.fr to i4
  %.not = icmp ne i4 %33, 0
  %rdx.select = zext i1 %.not to i32
  br i1 %cmp.n, label %._crit_edge.us, label %scalar.ph.preheader

scalar.ph.preheader:                              ; preds = %middle.block, %.preheader.us
  %indvars.iv.ph = phi i64 [ 0, %.preheader.us ], [ %n.vec, %middle.block ]
  %.11720.us.ph = phi i32 [ 0, %.preheader.us ], [ %rdx.select, %middle.block ]
  br label %scalar.ph

scalar.ph:                                        ; preds = %scalar.ph.preheader, %scalar.ph
  %indvars.iv = phi i64 [ %indvars.iv.next, %scalar.ph ], [ %indvars.iv.ph, %scalar.ph.preheader ]
  %.11720.us = phi i32 [ %spec.select19.us, %scalar.ph ], [ %.11720.us.ph, %scalar.ph.preheader ]
  %34 = add nuw nsw i64 %indvars.iv, %indvars.iv28
  %35 = getelementptr inbounds [1001 x i8], ptr %1, i64 0, i64 %34
  %36 = load i8, ptr %35, align 1, !tbaa !9
  %37 = getelementptr inbounds [1001 x i8], ptr %2, i64 0, i64 %indvars.iv
  %38 = load i8, ptr %37, align 1, !tbaa !9
  %.not.us = icmp eq i8 %36, %38
  %spec.select19.us = select i1 %.not.us, i32 %.11720.us, i32 1
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next, %22
  br i1 %exitcond.not, label %._crit_edge.us, label %scalar.ph, !llvm.loop !13

._crit_edge.us:                                   ; preds = %scalar.ph, %middle.block
  %spec.select19.us.lcssa = phi i32 [ %rdx.select, %middle.block ], [ %spec.select19.us, %scalar.ph ]
  %39 = icmp eq i32 %spec.select19.us.lcssa, 0
  %40 = zext i1 %39 to i32
  %spec.select.us = add nuw nsw i32 %.01522.us, %40
  %indvars.iv.next29 = add nuw nsw i64 %indvars.iv28, %22
  %41 = trunc nuw i64 %indvars.iv.next29 to i32
  %42 = icmp slt i32 %41, %10
  br i1 %42, label %.preheader.us, label %._crit_edge24, !llvm.loop !14

.preheader:                                       ; preds = %.preheader.preheader52, %.preheader
  %.01423 = phi i32 [ %43, %.preheader ], [ %.01423.ph, %.preheader.preheader52 ]
  %.01522 = phi i32 [ %spec.select, %.preheader ], [ %.01522.ph, %.preheader.preheader52 ]
  %spec.select = add nuw nsw i32 %.01522, 1
  %43 = add nsw i32 %.01423, %12
  %44 = icmp slt i32 %43, %10
  br i1 %44, label %.preheader, label %._crit_edge24, !llvm.loop !15

._crit_edge24:                                    ; preds = %.preheader, %._crit_edge.us, %middle.block37, %.lr.ph
  %.015.lcssa = phi i32 [ 0, %.lr.ph ], [ %21, %middle.block37 ], [ %spec.select.us, %._crit_edge.us ], [ %spec.select, %.preheader ]
  %45 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.1, i32 noundef %.015.lcssa)
  %46 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %1)
  %47 = icmp ne i32 %46, 0
  %48 = load i8, ptr %1, align 16
  %49 = icmp ne i8 %48, 35
  %50 = select i1 %47, i1 %49, i1 false
  br i1 %50, label %.lr.ph, label %._crit_edge, !llvm.loop !16

._crit_edge:                                      ; preds = %._crit_edge24, %0
  call void @llvm.lifetime.end.p0(i64 1001, ptr nonnull %2) #5
  call void @llvm.lifetime.end.p0(i64 1001, ptr nonnull %1) #5
  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: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1

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

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i32 @llvm.smax.i32(i32, i32) #4

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i32 @llvm.vector.reduce.add.v4i32(<4 x i32>) #4

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 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #5 = { nounwind }
attributes #6 = { 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 = distinct !{!5, !6, !7, !8}
!6 = !{!"llvm.loop.mustprogress"}
!7 = !{!"llvm.loop.isvectorized", i32 1}
!8 = !{!"llvm.loop.unroll.runtime.disable"}
!9 = !{!10, !10, i64 0}
!10 = !{!"omnipotent char", !11, i64 0}
!11 = !{!"Simple C++ TBAA"}
!12 = distinct !{!12, !6, !7, !8}
!13 = distinct !{!13, !6, !8, !7}
!14 = distinct !{!14, !6}
!15 = distinct !{!15, !6, !8, !7}
!16 = distinct !{!16, !6}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalDCEPass,GlobalOptPass,IndVarSimplifyPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LICMPass,LoopInstSimplifyPass,LoopLoadEliminationPass,LoopRotatePass,LoopSimplifyCFGPass,LoopSimplifyPass,LoopUnrollPass,LoopVectorizePass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,SimplifyCFGPass