; LLVM IR from lionsoul2014/friso :: src (friso_GBK)

; 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: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #0

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

; Function Attrs: nounwind uwtable
define dso_local i32 @gbk_numeric_string(ptr noundef %0) #1 {
  %2 = alloca i32, align 4
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #2
  %8 = load ptr, ptr %3, align 8, !tbaa !5
  store ptr %8, ptr %4, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #2
  store i32 0, ptr %5, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #2
  store i32 0, ptr %6, align 4, !tbaa !9
  br label %9

9:                                                ; preds = %45, %1
  %10 = load ptr, ptr %4, align 8, !tbaa !5
  %11 = load i8, ptr %10, align 1, !tbaa !11
  %12 = sext i8 %11 to i32
  %13 = icmp ne i32 %12, 0
  br i1 %13, label %14, label %46

14:                                               ; preds = %9
  %15 = load ptr, ptr %4, align 8, !tbaa !5
  %16 = getelementptr inbounds i8, ptr %15, i32 1
  store ptr %16, ptr %4, align 8, !tbaa !5
  %17 = load i8, ptr %15, align 1, !tbaa !11
  %18 = zext i8 %17 to i32
  store i32 %18, ptr %5, align 4, !tbaa !9
  %19 = load i32, ptr %5, align 4, !tbaa !9
  %20 = icmp sle i32 %19, 128
  br i1 %20, label %21, label %29

21:                                               ; preds = %14
  %22 = load i32, ptr %5, align 4, !tbaa !9
  %23 = icmp slt i32 %22, 48
  br i1 %23, label %27, label %24

24:                                               ; preds = %21
  %25 = load i32, ptr %6, align 4, !tbaa !9
  %26 = icmp sgt i32 %25, 57
  br i1 %26, label %27, label %28

27:                                               ; preds = %24, %21
  store i32 0, ptr %2, align 4
  store i32 1, ptr %7, align 4
  br label %47

28:                                               ; preds = %24
  br label %45

29:                                               ; preds = %14
  %30 = load i32, ptr %5, align 4, !tbaa !9
  %31 = icmp ne i32 %30, 163
  br i1 %31, label %32, label %33

32:                                               ; preds = %29
  store i32 0, ptr %2, align 4
  store i32 1, ptr %7, align 4
  br label %47

33:                                               ; preds = %29
  %34 = load ptr, ptr %4, align 8, !tbaa !5
  %35 = getelementptr inbounds i8, ptr %34, i32 1
  store ptr %35, ptr %4, align 8, !tbaa !5
  %36 = load i8, ptr %34, align 1, !tbaa !11
  %37 = zext i8 %36 to i32
  store i32 %37, ptr %6, align 4, !tbaa !9
  %38 = load i32, ptr %6, align 4, !tbaa !9
  %39 = icmp slt i32 %38, 176
  br i1 %39, label %43, label %40

40:                                               ; preds = %33
  %41 = load i32, ptr %6, align 4, !tbaa !9
  %42 = icmp sgt i32 %41, 185
  br i1 %42, label %43, label %44

43:                                               ; preds = %40, %33
  store i32 0, ptr %2, align 4
  store i32 1, ptr %7, align 4
  br label %47

44:                                               ; preds = %40
  br label %45

45:                                               ; preds = %44, %28
  br label %9, !llvm.loop !12

46:                                               ; preds = %9
  store i32 1, ptr %2, align 4
  store i32 1, ptr %7, align 4
  br label %47

47:                                               ; preds = %46, %43, %32, %27
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #2
  %48 = load i32, ptr %2, align 4
  ret i32 %48
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #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 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!7, !7, i64 0}
!12 = distinct !{!12, !13}
!13 = !{!"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"

; Function Attrs: nofree norecurse nosync nounwind memory(read, inaccessiblemem: none) uwtable
define dso_local range(i32 0, 2) i32 @gbk_numeric_string(ptr nocapture noundef readonly %0) local_unnamed_addr #0 {
  %2 = load i8, ptr %0, align 1, !tbaa !5
  %.not20 = icmp eq i8 %2, 0
  br i1 %.not20, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %1, %15
  %3 = phi i8 [ %16, %15 ], [ %2, %1 ]
  %.022 = phi i32 [ %.1, %15 ], [ 0, %1 ]
  %.01321 = phi ptr [ %.114, %15 ], [ %0, %1 ]
  %4 = getelementptr inbounds i8, ptr %.01321, i64 1
  %5 = icmp ult i8 %3, -127
  br i1 %5, label %6, label %9

6:                                                ; preds = %.lr.ph
  %7 = icmp ult i8 %3, 48
  %8 = icmp sgt i32 %.022, 57
  %or.cond = select i1 %7, i1 true, i1 %8
  br i1 %or.cond, label %._crit_edge, label %15

9:                                                ; preds = %.lr.ph
  %.not19 = icmp eq i8 %3, -93
  br i1 %.not19, label %10, label %._crit_edge

10:                                               ; preds = %9
  %11 = getelementptr inbounds i8, ptr %.01321, i64 2
  %12 = load i8, ptr %4, align 1, !tbaa !5
  %13 = zext i8 %12 to i32
  %14 = add i8 %12, 70
  %or.cond3 = icmp ult i8 %14, -10
  br i1 %or.cond3, label %._crit_edge, label %15

15:                                               ; preds = %10, %6
  %.114 = phi ptr [ %4, %6 ], [ %11, %10 ]
  %.1 = phi i32 [ %.022, %6 ], [ %13, %10 ]
  %16 = load i8, ptr %.114, align 1, !tbaa !5
  %.not = icmp eq i8 %16, 0
  br i1 %.not, label %._crit_edge, label %.lr.ph, !llvm.loop !8

._crit_edge:                                      ; preds = %6, %9, %10, %15, %1
  %.015 = phi i32 [ 1, %1 ], [ 1, %15 ], [ 0, %10 ], [ 0, %9 ], [ 0, %6 ]
  ret i32 %.015
}

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

!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/C++ TBAA"}
!8 = distinct !{!8, !9}
!9 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass