; LLVM IR from AdarshGaur/Competitive-Programming :: Codechef/Starters 60 Division 2/Yet Another Palindrome Problem.ll (Z5solvev)

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

%"class.std::basic_istream" = type { ptr, i64, %"class.std::basic_ios" }
%"class.std::basic_ios" = type { %"class.std::ios_base", ptr, i8, i8, ptr, ptr, ptr, ptr }
%"class.std::ios_base" = type { ptr, i64, i64, i32, i32, i32, ptr, %"struct.std::ios_base::_Words", [8 x %"struct.std::ios_base::_Words"], i32, ptr, %"class.std::locale" }
%"struct.std::ios_base::_Words" = type { ptr, i64 }
%"class.std::locale" = type { ptr }
%"class.std::basic_ostream" = type { ptr, %"class.std::basic_ios" }

@_ZSt3cin = external global %"class.std::basic_istream", align 8
@_ZSt4cout = external global %"class.std::basic_ostream", align 8
@.str = external hidden unnamed_addr constant [2 x i8], align 1

; Function Attrs: mustprogress uwtable
define dso_local void @_Z5solvev() #0 {
  %1 = alloca i64, align 8
  %2 = alloca ptr, align 8
  %3 = alloca i64, align 8
  %4 = alloca i64, align 8
  %5 = alloca i64, align 8
  %6 = alloca i64, align 8
  %7 = alloca i64, align 8
  %8 = alloca i64, align 8
  %9 = alloca i64, align 8
  %10 = alloca i32, align 4
  call void @llvm.lifetime.start.p0(i64 8, ptr %1) #5
  %11 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERl(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 8 dereferenceable(8) %1)
  %12 = load i64, ptr %1, align 8, !tbaa !5
  %13 = call ptr @llvm.stacksave.p0()
  store ptr %13, ptr %2, align 8
  %14 = alloca i64, i64 %12, align 16
  store i64 %12, ptr %3, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #5
  store i64 0, ptr %4, align 8, !tbaa !5
  br label %15

15:                                               ; preds = %24, %0
  %16 = load i64, ptr %4, align 8, !tbaa !5
  %17 = load i64, ptr %1, align 8, !tbaa !5
  %18 = icmp slt i64 %16, %17
  br i1 %18, label %20, label %19

19:                                               ; preds = %15
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #5
  br label %27

20:                                               ; preds = %15
  %21 = load i64, ptr %4, align 8, !tbaa !5
  %22 = getelementptr inbounds i64, ptr %14, i64 %21
  %23 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERl(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 8 dereferenceable(8) %22)
  br label %24

24:                                               ; preds = %20
  %25 = load i64, ptr %4, align 8, !tbaa !5
  %26 = add nsw i64 %25, 1
  store i64 %26, ptr %4, align 8, !tbaa !5
  br label %15, !llvm.loop !9

27:                                               ; preds = %19
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #5
  %28 = load i64, ptr %1, align 8, !tbaa !5
  %29 = sdiv i64 %28, 2
  %30 = sub nsw i64 %29, 1
  store i64 %30, ptr %5, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #5
  %31 = load i64, ptr %1, align 8, !tbaa !5
  %32 = sdiv i64 %31, 2
  %33 = load i64, ptr %1, align 8, !tbaa !5
  %34 = srem i64 %33, 2
  %35 = add nsw i64 %32, %34
  store i64 %35, ptr %6, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #5
  store i64 0, ptr %7, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #5
  store i64 0, ptr %8, align 8, !tbaa !5
  br label %36

36:                                               ; preds = %87, %27
  %37 = load i64, ptr %5, align 8, !tbaa !5
  %38 = icmp sge i64 %37, 0
  br i1 %38, label %39, label %88

39:                                               ; preds = %36
  %40 = load i64, ptr %8, align 8, !tbaa !5
  %41 = load i64, ptr %5, align 8, !tbaa !5
  %42 = getelementptr inbounds i64, ptr %14, i64 %41
  %43 = load i64, ptr %42, align 8, !tbaa !5
  %44 = add nsw i64 %43, %40
  store i64 %44, ptr %42, align 8, !tbaa !5
  %45 = load i64, ptr %5, align 8, !tbaa !5
  %46 = getelementptr inbounds i64, ptr %14, i64 %45
  %47 = load i64, ptr %46, align 8, !tbaa !5
  %48 = load i64, ptr %6, align 8, !tbaa !5
  %49 = getelementptr inbounds i64, ptr %14, i64 %48
  %50 = load i64, ptr %49, align 8, !tbaa !5
  %51 = icmp eq i64 %47, %50
  br i1 %51, label %52, label %57

52:                                               ; preds = %39
  %53 = load i64, ptr %5, align 8, !tbaa !5
  %54 = add nsw i64 %53, -1
  store i64 %54, ptr %5, align 8, !tbaa !5
  %55 = load i64, ptr %6, align 8, !tbaa !5
  %56 = add nsw i64 %55, 1
  store i64 %56, ptr %6, align 8, !tbaa !5
  br label %87

57:                                               ; preds = %39
  %58 = load i64, ptr %5, align 8, !tbaa !5
  %59 = getelementptr inbounds i64, ptr %14, i64 %58
  %60 = load i64, ptr %59, align 8, !tbaa !5
  %61 = load i64, ptr %6, align 8, !tbaa !5
  %62 = getelementptr inbounds i64, ptr %14, i64 %61
  %63 = load i64, ptr %62, align 8, !tbaa !5
  %64 = icmp slt i64 %60, %63
  br i1 %64, label %65, label %83

65:                                               ; preds = %57
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #5
  %66 = load i64, ptr %6, align 8, !tbaa !5
  %67 = getelementptr inbounds i64, ptr %14, i64 %66
  %68 = load i64, ptr %67, align 8, !tbaa !5
  %69 = load i64, ptr %5, align 8, !tbaa !5
  %70 = getelementptr inbounds i64, ptr %14, i64 %69
  %71 = load i64, ptr %70, align 8, !tbaa !5
  %72 = sub nsw i64 %68, %71
  store i64 %72, ptr %9, align 8, !tbaa !5
  %73 = load i64, ptr %9, align 8, !tbaa !5
  %74 = load i64, ptr %7, align 8, !tbaa !5
  %75 = add nsw i64 %74, %73
  store i64 %75, ptr %7, align 8, !tbaa !5
  %76 = load i64, ptr %9, align 8, !tbaa !5
  %77 = load i64, ptr %8, align 8, !tbaa !5
  %78 = add nsw i64 %77, %76
  store i64 %78, ptr %8, align 8, !tbaa !5
  %79 = load i64, ptr %5, align 8, !tbaa !5
  %80 = add nsw i64 %79, -1
  store i64 %80, ptr %5, align 8, !tbaa !5
  %81 = load i64, ptr %6, align 8, !tbaa !5
  %82 = add nsw i64 %81, 1
  store i64 %82, ptr %6, align 8, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #5
  br label %86

83:                                               ; preds = %57
  %84 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEi(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, i32 noundef -1)
  %85 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc(ptr noundef nonnull align 8 dereferenceable(8) %84, ptr noundef @.str)
  store i32 1, ptr %10, align 4
  br label %92

86:                                               ; preds = %65
  br label %87

87:                                               ; preds = %86, %52
  br label %36, !llvm.loop !11

88:                                               ; preds = %36
  %89 = load i64, ptr %7, align 8, !tbaa !5
  %90 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEl(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, i64 noundef %89)
  %91 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc(ptr noundef nonnull align 8 dereferenceable(8) %90, ptr noundef @.str)
  store i32 0, ptr %10, align 4
  br label %92

92:                                               ; preds = %88, %83
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #5
  %93 = load ptr, ptr %2, align 8
  call void @llvm.stackrestore.p0(ptr %93)
  call void @llvm.lifetime.end.p0(i64 8, ptr %1) #5
  %94 = load i32, ptr %10, align 4
  switch i32 %94, label %96 [
    i32 0, label %95
    i32 1, label %95
  ]

95:                                               ; preds = %92, %92
  ret void

96:                                               ; preds = %92
  unreachable
}

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

; Function Attrs: mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERl(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef nonnull align 8 dereferenceable(8)) #0 align 2

; Function Attrs: nocallback nofree nosync nounwind willreturn
declare ptr @llvm.stacksave.p0() #2

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

; Function Attrs: inlinehint mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef) #3

declare noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEi(ptr noundef nonnull align 8 dereferenceable(8), i32 noundef) #4

; Function Attrs: mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEl(ptr noundef nonnull align 8 dereferenceable(8), i64 noundef) #0 align 2

; Function Attrs: nocallback nofree nosync nounwind willreturn
declare void @llvm.stackrestore.p0(ptr) #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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { nocallback nofree nosync nounwind willreturn }
attributes #3 = { inlinehint 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 #4 = { "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 }

!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 = !{!"long", !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}


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

%"class.std::basic_istream" = type { ptr, i64, %"class.std::basic_ios" }
%"class.std::basic_ios" = type { %"class.std::ios_base", ptr, i8, i8, ptr, ptr, ptr, ptr }
%"class.std::ios_base" = type { ptr, i64, i64, i32, i32, i32, ptr, %"struct.std::ios_base::_Words", [8 x %"struct.std::ios_base::_Words"], i32, ptr, %"class.std::locale" }
%"struct.std::ios_base::_Words" = type { ptr, i64 }
%"class.std::locale" = type { ptr }
%"class.std::basic_ostream" = type { ptr, %"class.std::basic_ios" }

@_ZSt3cin = external global %"class.std::basic_istream", align 8
@_ZSt4cout = external global %"class.std::basic_ostream", align 8
@.str = external hidden unnamed_addr constant [2 x i8], align 1

; Function Attrs: mustprogress uwtable
define dso_local void @_Z5solvev() local_unnamed_addr #0 {
  %1 = alloca i64, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %1) #5
  %2 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERl(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 8 dereferenceable(8) %1)
  %3 = load i64, ptr %1, align 8, !tbaa !5
  %4 = call ptr @llvm.stacksave.p0()
  %5 = alloca i64, i64 %3, align 16
  %6 = load i64, ptr %1, align 8, !tbaa !5
  %7 = icmp sgt i64 %6, 0
  br i1 %7, label %.lr.ph, label %._crit_edge40

._crit_edge:                                      ; preds = %.lr.ph
  %8 = icmp sgt i64 %15, 1
  br i1 %8, label %.lr.ph39.preheader, label %._crit_edge40

.lr.ph39.preheader:                               ; preds = %._crit_edge
  %9 = lshr i64 %15, 1
  %10 = and i64 %15, 1
  %11 = add nuw nsw i64 %9, %10
  br label %.lr.ph39

.lr.ph:                                           ; preds = %0, %.lr.ph
  %.032 = phi i64 [ %14, %.lr.ph ], [ 0, %0 ]
  %12 = getelementptr inbounds i64, ptr %5, i64 %.032
  %13 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERl(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 8 dereferenceable(8) %12)
  %14 = add nuw nsw i64 %.032, 1
  %15 = load i64, ptr %1, align 8, !tbaa !5
  %16 = icmp slt i64 %14, %15
  br i1 %16, label %.lr.ph, label %._crit_edge, !llvm.loop !9

.lr.ph39:                                         ; preds = %.lr.ph39.preheader, %31
  %.02637.in = phi i64 [ %.02637, %31 ], [ %9, %.lr.ph39.preheader ]
  %.02136 = phi i64 [ %.1, %31 ], [ 0, %.lr.ph39.preheader ]
  %.02235 = phi i64 [ %.123, %31 ], [ 0, %.lr.ph39.preheader ]
  %.02434 = phi i64 [ %.125, %31 ], [ %11, %.lr.ph39.preheader ]
  %.02637 = add nsw i64 %.02637.in, -1
  %17 = getelementptr inbounds i64, ptr %5, i64 %.02637
  %18 = load i64, ptr %17, align 8, !tbaa !5
  %19 = add nsw i64 %18, %.02136
  store i64 %19, ptr %17, align 8, !tbaa !5
  %20 = getelementptr inbounds i64, ptr %5, i64 %.02434
  %21 = load i64, ptr %20, align 8, !tbaa !5
  %22 = icmp eq i64 %19, %21
  br i1 %22, label %31, label %23

23:                                               ; preds = %.lr.ph39
  %24 = icmp slt i64 %19, %21
  br i1 %24, label %25, label %29

25:                                               ; preds = %23
  %26 = sub nsw i64 %21, %19
  %27 = add nsw i64 %26, %.02235
  %28 = add nsw i64 %26, %.02136
  br label %31

29:                                               ; preds = %23
  %30 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEi(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, i32 noundef -1)
  br label %34

31:                                               ; preds = %.lr.ph39, %25
  %.123 = phi i64 [ %27, %25 ], [ %.02235, %.lr.ph39 ]
  %.1 = phi i64 [ %28, %25 ], [ %.02136, %.lr.ph39 ]
  %.125 = add nuw nsw i64 %.02434, 1
  %32 = icmp ugt i64 %.02637.in, 1
  br i1 %32, label %.lr.ph39, label %._crit_edge40, !llvm.loop !11

._crit_edge40:                                    ; preds = %31, %0, %._crit_edge
  %.022.lcssa = phi i64 [ 0, %._crit_edge ], [ 0, %0 ], [ %.123, %31 ]
  %33 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEl(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, i64 noundef %.022.lcssa)
  br label %34

34:                                               ; preds = %._crit_edge40, %29
  %.sink = phi ptr [ %33, %._crit_edge40 ], [ %30, %29 ]
  %35 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc(ptr noundef nonnull align 8 dereferenceable(8) %.sink, ptr noundef nonnull @.str)
  call void @llvm.stackrestore.p0(ptr %4)
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %1) #5
  ret void
}

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

; Function Attrs: mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERl(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef nonnull align 8 dereferenceable(8)) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn
declare ptr @llvm.stacksave.p0() #2

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

; Function Attrs: inlinehint mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef) local_unnamed_addr #3

declare noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEi(ptr noundef nonnull align 8 dereferenceable(8), i32 noundef) local_unnamed_addr #4

; Function Attrs: mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEl(ptr noundef nonnull align 8 dereferenceable(8), i64 noundef) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn
declare void @llvm.stackrestore.p0(ptr) #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 nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { mustprogress nocallback nofree nosync nounwind willreturn }
attributes #3 = { inlinehint 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 #4 = { "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 }

!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 = !{!"long", !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}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,ReassociatePass,SROAPass,SimplifyCFGPass