; LLVM IR from int32bit/leetcode :: algorithms/PalindromeNumber (solve)

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

; Function Attrs: nounwind uwtable
define dso_local zeroext i1 @isPalindrome(i32 noundef %0) #0 {
  %2 = alloca i1, align 1
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  store i32 %0, ptr %3, align 4, !tbaa !5
  %8 = load i32, ptr %3, align 4, !tbaa !5
  %9 = icmp slt i32 %8, 0
  br i1 %9, label %10, label %11

10:                                               ; preds = %1
  store i1 false, ptr %2, align 1
  br label %47

11:                                               ; preds = %1
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #2
  store i32 1, ptr %4, align 4, !tbaa !5
  br label %12

12:                                               ; preds = %18, %11
  %13 = load i32, ptr %3, align 4, !tbaa !5
  %14 = load i32, ptr %4, align 4, !tbaa !5
  %15 = sdiv i32 %13, %14
  %16 = icmp sge i32 %15, 10
  br i1 %16, label %17, label %21

17:                                               ; preds = %12
  br label %18

18:                                               ; preds = %17
  %19 = load i32, ptr %4, align 4, !tbaa !5
  %20 = mul nsw i32 %19, 10
  store i32 %20, ptr %4, align 4, !tbaa !5
  br label %12, !llvm.loop !9

21:                                               ; preds = %12
  br label %22

22:                                               ; preds = %44, %21
  %23 = load i32, ptr %3, align 4, !tbaa !5
  %24 = icmp ne i32 %23, 0
  br i1 %24, label %25, label %45

25:                                               ; preds = %22
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #2
  %26 = load i32, ptr %3, align 4, !tbaa !5
  %27 = load i32, ptr %4, align 4, !tbaa !5
  %28 = sdiv i32 %26, %27
  store i32 %28, ptr %5, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #2
  %29 = load i32, ptr %3, align 4, !tbaa !5
  %30 = srem i32 %29, 10
  store i32 %30, ptr %6, align 4, !tbaa !5
  %31 = load i32, ptr %6, align 4, !tbaa !5
  %32 = load i32, ptr %5, align 4, !tbaa !5
  %33 = icmp ne i32 %31, %32
  br i1 %33, label %34, label %35

34:                                               ; preds = %25
  store i1 false, ptr %2, align 1
  store i32 1, ptr %7, align 4
  br label %42

35:                                               ; preds = %25
  %36 = load i32, ptr %3, align 4, !tbaa !5
  %37 = load i32, ptr %4, align 4, !tbaa !5
  %38 = srem i32 %36, %37
  %39 = sdiv i32 %38, 10
  store i32 %39, ptr %3, align 4, !tbaa !5
  %40 = load i32, ptr %4, align 4, !tbaa !5
  %41 = sdiv i32 %40, 100
  store i32 %41, ptr %4, align 4, !tbaa !5
  store i32 0, ptr %7, align 4
  br label %42

42:                                               ; preds = %35, %34
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #2
  %43 = load i32, ptr %7, align 4
  switch i32 %43, label %46 [
    i32 0, label %44
  ]

44:                                               ; preds = %42
  br label %22, !llvm.loop !11

45:                                               ; preds = %22
  store i1 true, ptr %2, align 1
  store i32 1, ptr %7, align 4
  br label %46

46:                                               ; preds = %45, %42
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #2
  br label %47

47:                                               ; preds = %46, %10
  %48 = load i1, ptr %2, align 1
  ret i1 %48
}

; 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

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

; Function Attrs: nofree norecurse nosync nounwind memory(none) uwtable
define dso_local noundef zeroext i1 @isPalindrome(i32 noundef %0) local_unnamed_addr #0 {
  %2 = icmp slt i32 %0, 0
  br i1 %2, label %.thread, label %.preheader24

.preheader24:                                     ; preds = %1
  %3 = icmp ugt i32 %0, 9
  br i1 %3, label %.lr.ph, label %.preheader

.preheader:                                       ; preds = %.lr.ph, %.preheader24
  %.017.lcssa = phi i32 [ 1, %.preheader24 ], [ %4, %.lr.ph ]
  %.not26 = icmp eq i32 %0, 0
  br i1 %.not26, label %.thread, label %.lr.ph29

.lr.ph:                                           ; preds = %.preheader24, %.lr.ph
  %.01725 = phi i32 [ %4, %.lr.ph ], [ 1, %.preheader24 ]
  %4 = mul nuw nsw i32 %.01725, 10
  %5 = udiv i32 %0, %4
  %6 = icmp sgt i32 %5, 9
  br i1 %6, label %.lr.ph, label %.preheader, !llvm.loop !5

.lr.ph29:                                         ; preds = %.preheader, %10
  %.01528 = phi i32 [ %11, %10 ], [ %0, %.preheader ]
  %.11827 = phi i32 [ %12, %10 ], [ %.017.lcssa, %.preheader ]
  %7 = sdiv i32 %.01528, %.11827
  %8 = srem i32 %.01528, %.11827
  %9 = urem i32 %.01528, 10
  %.not21 = icmp eq i32 %9, %7
  br i1 %.not21, label %10, label %.thread

10:                                               ; preds = %.lr.ph29
  %11 = udiv i32 %8, 10
  %12 = sdiv i32 %.11827, 100
  %.not = icmp ult i32 %8, 10
  br i1 %.not, label %.thread, label %.lr.ph29

.thread:                                          ; preds = %10, %.lr.ph29, %.preheader, %1
  %.3 = phi i1 [ false, %1 ], [ true, %.preheader ], [ %.not21, %.lr.ph29 ], [ %.not21, %10 ]
  ret i1 %.3
}

attributes #0 = { nofree norecurse nosync nounwind memory(none) 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" }

!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}
!6 = !{!"llvm.loop.mustprogress"}


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