; LLVM IR from int32bit/leetcode :: algorithms/ValidNumber (validNumber)

; 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 ptr @strip(ptr noundef %0, ptr noundef %1) #0 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  %9 = load ptr, ptr %4, align 8, !tbaa !5
  %10 = icmp eq ptr %9, null
  br i1 %10, label %11, label %12

11:                                               ; preds = %2
  store ptr null, ptr %3, align 8
  br label %84

12:                                               ; preds = %2
  %13 = load ptr, ptr %4, align 8, !tbaa !5
  %14 = call i64 @strlen(ptr noundef %13) #4
  %15 = icmp eq i64 %14, 0
  br i1 %15, label %16, label %19

16:                                               ; preds = %12
  %17 = load ptr, ptr %5, align 8, !tbaa !5
  %18 = getelementptr inbounds i8, ptr %17, i64 0
  store i8 0, ptr %18, align 1, !tbaa !9
  store ptr null, ptr %3, align 8
  br label %84

19:                                               ; preds = %12
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #5
  store i32 0, ptr %6, align 4, !tbaa !10
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #5
  %20 = load ptr, ptr %4, align 8, !tbaa !5
  %21 = call i64 @strlen(ptr noundef %20) #4
  %22 = sub i64 %21, 1
  %23 = trunc i64 %22 to i32
  store i32 %23, ptr %7, align 4, !tbaa !10
  br label %24

24:                                               ; preds = %39, %19
  %25 = call ptr @__ctype_b_loc() #6
  %26 = load ptr, ptr %25, align 8, !tbaa !5
  %27 = load ptr, ptr %4, align 8, !tbaa !5
  %28 = load i32, ptr %6, align 4, !tbaa !10
  %29 = sext i32 %28 to i64
  %30 = getelementptr inbounds i8, ptr %27, i64 %29
  %31 = load i8, ptr %30, align 1, !tbaa !9
  %32 = sext i8 %31 to i32
  %33 = sext i32 %32 to i64
  %34 = getelementptr inbounds i16, ptr %26, i64 %33
  %35 = load i16, ptr %34, align 2, !tbaa !12
  %36 = zext i16 %35 to i32
  %37 = and i32 %36, 1
  %38 = icmp ne i32 %37, 0
  br i1 %38, label %39, label %42

39:                                               ; preds = %24
  %40 = load i32, ptr %6, align 4, !tbaa !10
  %41 = add nsw i32 %40, 1
  store i32 %41, ptr %6, align 4, !tbaa !10
  br label %24, !llvm.loop !14

42:                                               ; preds = %24
  br label %43

43:                                               ; preds = %58, %42
  %44 = call ptr @__ctype_b_loc() #6
  %45 = load ptr, ptr %44, align 8, !tbaa !5
  %46 = load ptr, ptr %4, align 8, !tbaa !5
  %47 = load i32, ptr %7, align 4, !tbaa !10
  %48 = sext i32 %47 to i64
  %49 = getelementptr inbounds i8, ptr %46, i64 %48
  %50 = load i8, ptr %49, align 1, !tbaa !9
  %51 = sext i8 %50 to i32
  %52 = sext i32 %51 to i64
  %53 = getelementptr inbounds i16, ptr %45, i64 %52
  %54 = load i16, ptr %53, align 2, !tbaa !12
  %55 = zext i16 %54 to i32
  %56 = and i32 %55, 1
  %57 = icmp ne i32 %56, 0
  br i1 %57, label %58, label %61

58:                                               ; preds = %43
  %59 = load i32, ptr %7, align 4, !tbaa !10
  %60 = add nsw i32 %59, -1
  store i32 %60, ptr %7, align 4, !tbaa !10
  br label %43, !llvm.loop !16

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

62:                                               ; preds = %66, %61
  %63 = load i32, ptr %6, align 4, !tbaa !10
  %64 = load i32, ptr %7, align 4, !tbaa !10
  %65 = icmp sle i32 %63, %64
  br i1 %65, label %66, label %78

66:                                               ; preds = %62
  %67 = load ptr, ptr %4, align 8, !tbaa !5
  %68 = load i32, ptr %6, align 4, !tbaa !10
  %69 = add nsw i32 %68, 1
  store i32 %69, ptr %6, align 4, !tbaa !10
  %70 = sext i32 %68 to i64
  %71 = getelementptr inbounds i8, ptr %67, i64 %70
  %72 = load i8, ptr %71, align 1, !tbaa !9
  %73 = load ptr, ptr %5, align 8, !tbaa !5
  %74 = load i32, ptr %8, align 4, !tbaa !10
  %75 = add nsw i32 %74, 1
  store i32 %75, ptr %8, align 4, !tbaa !10
  %76 = sext i32 %74 to i64
  %77 = getelementptr inbounds i8, ptr %73, i64 %76
  store i8 %72, ptr %77, align 1, !tbaa !9
  br label %62, !llvm.loop !17

78:                                               ; preds = %62
  %79 = load ptr, ptr %5, align 8, !tbaa !5
  %80 = load i32, ptr %8, align 4, !tbaa !10
  %81 = sext i32 %80 to i64
  %82 = getelementptr inbounds i8, ptr %79, i64 %81
  store i8 0, ptr %82, align 1, !tbaa !9
  %83 = load ptr, ptr %5, align 8, !tbaa !5
  store ptr %83, ptr %3, align 8
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #5
  br label %84

84:                                               ; preds = %78, %16, %11
  %85 = load ptr, ptr %3, align 8
  ret ptr %85
}

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

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

; Function Attrs: nounwind willreturn memory(none)
declare ptr @__ctype_b_loc() #3

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

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

!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 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!7, !7, i64 0}
!10 = !{!11, !11, i64 0}
!11 = !{!"int", !7, i64 0}
!12 = !{!13, !13, i64 0}
!13 = !{!"short", !7, i64 0}
!14 = distinct !{!14, !15}
!15 = !{!"llvm.loop.mustprogress"}
!16 = distinct !{!16, !15}
!17 = distinct !{!17, !15}


; 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 nounwind memory(readwrite, inaccessiblemem: none) uwtable
define dso_local noundef ptr @strip(ptr noundef readonly %0, ptr noundef writeonly %1) local_unnamed_addr #0 {
  %3 = ptrtoint ptr %0 to i64
  %4 = ptrtoint ptr %1 to i64
  %5 = icmp eq ptr %0, null
  br i1 %5, label %43, label %6

6:                                                ; preds = %2
  %7 = tail call i64 @strlen(ptr noundef nonnull dereferenceable(1) %0) #4
  %8 = icmp eq i64 %7, 0
  br i1 %8, label %.sink.split, label %9

9:                                                ; preds = %6
  %10 = tail call ptr @__ctype_b_loc() #5
  %11 = load ptr, ptr %10, align 8, !tbaa !5
  br label %12

12:                                               ; preds = %12, %9
  %indvars.iv = phi i64 [ %indvars.iv.next, %12 ], [ 0, %9 ]
  %13 = getelementptr inbounds i8, ptr %0, i64 %indvars.iv
  %14 = load i8, ptr %13, align 1, !tbaa !9
  %15 = sext i8 %14 to i64
  %16 = getelementptr inbounds i16, ptr %11, i64 %15
  %17 = load i16, ptr %16, align 2, !tbaa !10
  %18 = and i16 %17, 1
  %.not = icmp eq i16 %18, 0
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  br i1 %.not, label %.preheader26, label %12, !llvm.loop !12

.preheader26:                                     ; preds = %12
  %19 = trunc i64 %7 to i32
  br label %20

20:                                               ; preds = %.preheader26, %20
  %.019.in = phi i32 [ %.019, %20 ], [ %19, %.preheader26 ]
  %.019 = add i32 %.019.in, -1
  %21 = sext i32 %.019 to i64
  %22 = getelementptr inbounds i8, ptr %0, i64 %21
  %23 = load i8, ptr %22, align 1, !tbaa !9
  %24 = sext i8 %23 to i64
  %25 = getelementptr inbounds i16, ptr %11, i64 %24
  %26 = load i16, ptr %25, align 2, !tbaa !10
  %27 = and i16 %26, 1
  %.not24 = icmp eq i16 %27, 0
  br i1 %.not24, label %.preheader, label %20, !llvm.loop !14

.preheader:                                       ; preds = %20
  %28 = trunc nuw nsw i64 %indvars.iv to i32
  %.not2527 = icmp slt i32 %.019, %28
  br i1 %.not2527, label %._crit_edge, label %.lr.ph.preheader

.lr.ph.preheader:                                 ; preds = %.preheader
  %smax = tail call i64 @llvm.smax.i64(i64 %indvars.iv, i64 %21)
  %reass.sub = sub nsw i64 %smax, %indvars.iv
  %29 = add i64 %reass.sub, 1
  %min.iters.check = icmp ult i64 %29, 32
  br i1 %min.iters.check, label %.lr.ph.preheader42, label %vector.memcheck

vector.memcheck:                                  ; preds = %.lr.ph.preheader
  %30 = add i64 %indvars.iv, %3
  %31 = sub i64 %4, %30
  %diff.check = icmp ult i64 %31, 32
  br i1 %diff.check, label %.lr.ph.preheader42, label %vector.ph

vector.ph:                                        ; preds = %vector.memcheck
  %n.vec = and i64 %29, -32
  %ind.end = add i64 %indvars.iv, %n.vec
  %32 = getelementptr i8, ptr %0, i64 %indvars.iv
  br label %vector.body

vector.body:                                      ; preds = %vector.body, %vector.ph
  %index = phi i64 [ 0, %vector.ph ], [ %index.next, %vector.body ]
  %33 = getelementptr i8, ptr %32, i64 %index
  %34 = getelementptr inbounds i8, ptr %33, i64 16
  %wide.load = load <16 x i8>, ptr %33, align 1, !tbaa !9
  %wide.load41 = load <16 x i8>, ptr %34, align 1, !tbaa !9
  %35 = getelementptr inbounds i8, ptr %1, i64 %index
  %36 = getelementptr inbounds i8, ptr %35, i64 16
  store <16 x i8> %wide.load, ptr %35, align 1, !tbaa !9
  store <16 x i8> %wide.load41, ptr %36, align 1, !tbaa !9
  %index.next = add nuw i64 %index, 32
  %37 = icmp eq i64 %index.next, %n.vec
  br i1 %37, label %middle.block, label %vector.body, !llvm.loop !15

middle.block:                                     ; preds = %vector.body
  %cmp.n = icmp eq i64 %29, %n.vec
  br i1 %cmp.n, label %._crit_edge.loopexit, label %.lr.ph.preheader42

.lr.ph.preheader42:                               ; preds = %middle.block, %vector.memcheck, %.lr.ph.preheader
  %indvars.iv33.ph = phi i64 [ %indvars.iv, %vector.memcheck ], [ %indvars.iv, %.lr.ph.preheader ], [ %ind.end, %middle.block ]
  %indvars.iv31.ph = phi i64 [ 0, %vector.memcheck ], [ 0, %.lr.ph.preheader ], [ %n.vec, %middle.block ]
  br label %.lr.ph

.lr.ph:                                           ; preds = %.lr.ph.preheader42, %.lr.ph
  %indvars.iv33 = phi i64 [ %indvars.iv.next34, %.lr.ph ], [ %indvars.iv33.ph, %.lr.ph.preheader42 ]
  %indvars.iv31 = phi i64 [ %indvars.iv.next32, %.lr.ph ], [ %indvars.iv31.ph, %.lr.ph.preheader42 ]
  %indvars.iv.next34 = add nuw nsw i64 %indvars.iv33, 1
  %38 = getelementptr inbounds i8, ptr %0, i64 %indvars.iv33
  %39 = load i8, ptr %38, align 1, !tbaa !9
  %indvars.iv.next32 = add nuw nsw i64 %indvars.iv31, 1
  %40 = getelementptr inbounds i8, ptr %1, i64 %indvars.iv31
  store i8 %39, ptr %40, align 1, !tbaa !9
  %.not25.not = icmp slt i64 %indvars.iv33, %21
  br i1 %.not25.not, label %.lr.ph, label %._crit_edge.loopexit, !llvm.loop !18

._crit_edge.loopexit:                             ; preds = %.lr.ph, %middle.block
  %indvars.iv.next32.lcssa = phi i64 [ %n.vec, %middle.block ], [ %indvars.iv.next32, %.lr.ph ]
  %41 = and i64 %indvars.iv.next32.lcssa, 4294967295
  br label %._crit_edge

._crit_edge:                                      ; preds = %._crit_edge.loopexit, %.preheader
  %.0.lcssa = phi i64 [ 0, %.preheader ], [ %41, %._crit_edge.loopexit ]
  %42 = getelementptr inbounds i8, ptr %1, i64 %.0.lcssa
  br label %.sink.split

.sink.split:                                      ; preds = %6, %._crit_edge
  %.sink = phi ptr [ %42, %._crit_edge ], [ %1, %6 ]
  %.021.ph = phi ptr [ %1, %._crit_edge ], [ null, %6 ]
  store i8 0, ptr %.sink, align 1, !tbaa !9
  br label %43

43:                                               ; preds = %.sink.split, %2
  %.021 = phi ptr [ null, %2 ], [ %.021.ph, %.sink.split ]
  ret ptr %.021
}

; Function Attrs: mustprogress nofree nounwind willreturn memory(argmem: read)
declare i64 @strlen(ptr nocapture noundef) local_unnamed_addr #1

; Function Attrs: mustprogress nofree nosync nounwind willreturn memory(none)
declare ptr @__ctype_b_loc() local_unnamed_addr #2

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

attributes #0 = { nofree nounwind memory(readwrite, inaccessiblemem: 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" }
attributes #1 = { 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 #2 = { mustprogress nofree nosync nounwind willreturn memory(none) "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 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #4 = { nounwind willreturn memory(read) }
attributes #5 = { nounwind willreturn memory(none) }

!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 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!7, !7, i64 0}
!10 = !{!11, !11, i64 0}
!11 = !{!"short", !7, i64 0}
!12 = distinct !{!12, !13}
!13 = !{!"llvm.loop.mustprogress"}
!14 = distinct !{!14, !13}
!15 = distinct !{!15, !13, !16, !17}
!16 = !{!"llvm.loop.isvectorized", i32 1}
!17 = !{!"llvm.loop.unroll.runtime.disable"}
!18 = distinct !{!18, !13, !16}


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