; LLVM IR from lzyrapx/Competitive-Programming :: 51Nod (1089（manacher）)

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

@l = external dso_local global i32, align 4
@len = external dso_local global i32, align 4
@s = external dso_local global [1000005 x i8], align 16
@S = external dso_local global [2000010 x i8], align 16
@.str.1 = external hidden unnamed_addr constant [3 x i8], align 1

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z8manacherv() #0

; 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

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() #2 {
  %1 = alloca i32, align 4
  %2 = alloca i32, align 4
  store i32 0, ptr %1, align 4
  %3 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.1, ptr noundef @s)
  %4 = call i64 @strlen(ptr noundef @s) #5
  %5 = trunc i64 %4 to i32
  store i32 %5, ptr @len, align 4, !tbaa !5
  store i32 -1, ptr @l, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #6
  store i32 0, ptr %2, align 4, !tbaa !5
  br label %6

6:                                                ; preds = %24, %0
  %7 = load i32, ptr %2, align 4, !tbaa !5
  %8 = load i32, ptr @len, align 4, !tbaa !5
  %9 = icmp slt i32 %7, %8
  br i1 %9, label %11, label %10

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

11:                                               ; preds = %6
  %12 = load i32, ptr @l, align 4, !tbaa !5
  %13 = add nsw i32 %12, 1
  store i32 %13, ptr @l, align 4, !tbaa !5
  %14 = sext i32 %13 to i64
  %15 = getelementptr inbounds [2000010 x i8], ptr @S, i64 0, i64 %14
  store i8 35, ptr %15, align 1, !tbaa !9
  %16 = load i32, ptr %2, align 4, !tbaa !5
  %17 = sext i32 %16 to i64
  %18 = getelementptr inbounds [1000005 x i8], ptr @s, i64 0, i64 %17
  %19 = load i8, ptr %18, align 1, !tbaa !9
  %20 = load i32, ptr @l, align 4, !tbaa !5
  %21 = add nsw i32 %20, 1
  store i32 %21, ptr @l, align 4, !tbaa !5
  %22 = sext i32 %21 to i64
  %23 = getelementptr inbounds [2000010 x i8], ptr @S, i64 0, i64 %22
  store i8 %19, ptr %23, align 1, !tbaa !9
  br label %24

24:                                               ; preds = %11
  %25 = load i32, ptr %2, align 4, !tbaa !5
  %26 = add nsw i32 %25, 1
  store i32 %26, ptr %2, align 4, !tbaa !5
  br label %6, !llvm.loop !10

27:                                               ; preds = %10
  %28 = load i32, ptr @l, align 4, !tbaa !5
  %29 = add nsw i32 %28, 1
  store i32 %29, ptr @l, align 4, !tbaa !5
  %30 = sext i32 %29 to i64
  %31 = getelementptr inbounds [2000010 x i8], ptr @S, i64 0, i64 %30
  store i8 35, ptr %31, align 1, !tbaa !9
  call void @_Z8manacherv()
  ret i32 0
}

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

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

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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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"}


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

@l = external dso_local local_unnamed_addr global i32, align 4
@len = external dso_local local_unnamed_addr global i32, align 4
@s = external dso_local global [1000005 x i8], align 16
@S = external dso_local local_unnamed_addr global [2000010 x i8], align 16
@.str.1 = external hidden unnamed_addr constant [3 x i8], align 1

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z8manacherv() 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.1, ptr noundef nonnull @s)
  %2 = tail call i64 @strlen(ptr noundef nonnull dereferenceable(1) @s) #4
  %3 = trunc i64 %2 to i32
  store i32 %3, ptr @len, align 4, !tbaa !5
  %4 = icmp sgt i32 %3, 0
  br i1 %4, label %.lr.ph.preheader, label %14

.lr.ph.preheader:                                 ; preds = %0
  %wide.trip.count = and i64 %2, 2147483647
  %min.iters.check = icmp ult i64 %wide.trip.count, 16
  br i1 %min.iters.check, label %.lr.ph.preheader12, label %vector.ph

.lr.ph.preheader12:                               ; preds = %middle.block, %.lr.ph.preheader
  %indvars.iv4.ph = phi i64 [ -1, %.lr.ph.preheader ], [ %ind.end, %middle.block ]
  %indvars.iv.ph = phi i64 [ 0, %.lr.ph.preheader ], [ %n.vec, %middle.block ]
  br label %.lr.ph

vector.ph:                                        ; preds = %.lr.ph.preheader
  %n.mod.vf = and i64 %2, 15
  %n.vec = sub nsw i64 %wide.trip.count, %n.mod.vf
  %5 = shl nsw i64 %n.vec, 1
  %ind.end = add nsw i64 %5, -1
  br label %vector.body

vector.body:                                      ; preds = %vector.body, %vector.ph
  %index = phi i64 [ 0, %vector.ph ], [ %index.next, %vector.body ]
  %6 = shl i64 %index, 1
  %7 = getelementptr inbounds [1000005 x i8], ptr @s, i64 0, i64 %index
  %8 = getelementptr inbounds i8, ptr %7, i64 8
  %wide.load = load <8 x i8>, ptr %7, align 16, !tbaa !9
  %wide.load10 = load <8 x i8>, ptr %8, align 8, !tbaa !9
  %9 = or disjoint i64 %6, 1
  %10 = or disjoint i64 %6, 17
  %gep = getelementptr [2000010 x i8], ptr getelementptr (i8, ptr @S, i64 -1), i64 0, i64 %9
  %gep15 = getelementptr [2000010 x i8], ptr getelementptr (i8, ptr @S, i64 -1), i64 0, i64 %10
  %interleaved.vec = shufflevector <8 x i8> <i8 35, i8 35, i8 35, i8 35, i8 35, i8 35, i8 35, i8 35>, <8 x i8> %wide.load, <16 x i32> <i32 0, i32 8, i32 1, i32 9, i32 2, i32 10, i32 3, i32 11, i32 4, i32 12, i32 5, i32 13, i32 6, i32 14, i32 7, i32 15>
  store <16 x i8> %interleaved.vec, ptr %gep, align 16, !tbaa !9
  %interleaved.vec11 = shufflevector <8 x i8> <i8 35, i8 35, i8 35, i8 35, i8 35, i8 35, i8 35, i8 35>, <8 x i8> %wide.load10, <16 x i32> <i32 0, i32 8, i32 1, i32 9, i32 2, i32 10, i32 3, i32 11, i32 4, i32 12, i32 5, i32 13, i32 6, i32 14, i32 7, i32 15>
  store <16 x i8> %interleaved.vec11, ptr %gep15, align 16, !tbaa !9
  %index.next = add nuw i64 %index, 16
  %11 = icmp eq i64 %index.next, %n.vec
  br i1 %11, label %middle.block, label %vector.body, !llvm.loop !10

middle.block:                                     ; preds = %vector.body
  %cmp.n = icmp eq i64 %n.mod.vf, 0
  br i1 %cmp.n, label %._crit_edge, label %.lr.ph.preheader12

._crit_edge:                                      ; preds = %.lr.ph, %middle.block
  %indvars.iv.next5.lcssa = phi i64 [ %ind.end, %middle.block ], [ %indvars.iv.next5, %.lr.ph ]
  %12 = trunc nuw nsw i64 %indvars.iv.next5.lcssa to i32
  %13 = add nsw i32 %12, 1
  br label %14

14:                                               ; preds = %._crit_edge, %0
  %15 = phi i32 [ %13, %._crit_edge ], [ 0, %0 ]
  store i32 %15, ptr @l, align 4, !tbaa !5
  %16 = sext i32 %15 to i64
  %17 = getelementptr inbounds [2000010 x i8], ptr @S, i64 0, i64 %16
  store i8 35, ptr %17, align 1, !tbaa !9
  tail call void @_Z8manacherv()
  ret i32 0

.lr.ph:                                           ; preds = %.lr.ph.preheader12, %.lr.ph
  %indvars.iv4 = phi i64 [ %indvars.iv.next5, %.lr.ph ], [ %indvars.iv4.ph, %.lr.ph.preheader12 ]
  %indvars.iv = phi i64 [ %indvars.iv.next, %.lr.ph ], [ %indvars.iv.ph, %.lr.ph.preheader12 ]
  %18 = add nsw i64 %indvars.iv4, 1
  %19 = getelementptr inbounds [2000010 x i8], ptr @S, i64 0, i64 %18
  store i8 35, ptr %19, align 1, !tbaa !9
  %20 = getelementptr inbounds [1000005 x i8], ptr @s, i64 0, i64 %indvars.iv
  %21 = load i8, ptr %20, align 1, !tbaa !9
  %indvars.iv.next5 = add nsw i64 %indvars.iv4, 2
  %22 = getelementptr inbounds [2000010 x i8], ptr @S, i64 0, i64 %indvars.iv.next5
  store i8 %21, ptr %22, align 1, !tbaa !9
  %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 !14
}

; 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

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, !12, !13}
!11 = !{!"llvm.loop.mustprogress"}
!12 = !{!"llvm.loop.isvectorized", i32 1}
!13 = !{!"llvm.loop.unroll.runtime.disable"}
!14 = distinct !{!14, !11, !13, !12}


; Effective O3 passes: DSEPass,EarlyCSEPass,GVNPass,GlobalOptPass,IndVarSimplifyPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,LCSSAPass,LICMPass,LoopLoadEliminationPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,LoopVectorizePass,SROAPass,SimplifyCFGPass,TailCallElimPass