; 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_decimal_string(ptr noundef %0) #1 {
  %2 = alloca i32, align 4
  %3 = alloca ptr, align 8
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #3
  store i32 0, ptr %4, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #3
  store i32 0, ptr %5, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #3
  %10 = load ptr, ptr %3, align 8, !tbaa !5
  %11 = call i64 @strlen(ptr noundef %10) #4
  %12 = trunc i64 %11 to i32
  store i32 %12, ptr %6, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #3
  store i32 0, ptr %8, align 4, !tbaa !9
  %13 = load ptr, ptr %3, align 8, !tbaa !5
  %14 = getelementptr inbounds i8, ptr %13, i64 0
  %15 = load i8, ptr %14, align 1, !tbaa !11
  %16 = sext i8 %15 to i32
  %17 = icmp eq i32 %16, 46
  br i1 %17, label %27, label %18

18:                                               ; preds = %1
  %19 = load ptr, ptr %3, align 8, !tbaa !5
  %20 = load i32, ptr %6, align 4, !tbaa !9
  %21 = sub nsw i32 %20, 1
  %22 = sext i32 %21 to i64
  %23 = getelementptr inbounds i8, ptr %19, i64 %22
  %24 = load i8, ptr %23, align 1, !tbaa !11
  %25 = sext i8 %24 to i32
  %26 = icmp eq i32 %25, 46
  br i1 %26, label %27, label %28

27:                                               ; preds = %18, %1
  store i32 0, ptr %2, align 4
  store i32 1, ptr %9, align 4
  br label %81

28:                                               ; preds = %18
  store i32 0, ptr %7, align 4, !tbaa !9
  br label %29

29:                                               ; preds = %76, %43, %28
  %30 = load i32, ptr %7, align 4, !tbaa !9
  %31 = load i32, ptr %6, align 4, !tbaa !9
  %32 = icmp slt i32 %30, %31
  br i1 %32, label %33, label %77

33:                                               ; preds = %29
  %34 = load ptr, ptr %3, align 8, !tbaa !5
  %35 = load i32, ptr %7, align 4, !tbaa !9
  %36 = add nsw i32 %35, 1
  store i32 %36, ptr %7, align 4, !tbaa !9
  %37 = sext i32 %35 to i64
  %38 = getelementptr inbounds i8, ptr %34, i64 %37
  %39 = load i8, ptr %38, align 1, !tbaa !11
  %40 = zext i8 %39 to i32
  store i32 %40, ptr %4, align 4, !tbaa !9
  %41 = load i32, ptr %4, align 4, !tbaa !9
  %42 = icmp eq i32 %41, 46
  br i1 %42, label %43, label %46

43:                                               ; preds = %33
  %44 = load i32, ptr %8, align 4, !tbaa !9
  %45 = add nsw i32 %44, 1
  store i32 %45, ptr %8, align 4, !tbaa !9
  br label %29, !llvm.loop !12

46:                                               ; preds = %33
  %47 = load i32, ptr %4, align 4, !tbaa !9
  %48 = icmp sle i32 %47, 128
  br i1 %48, label %49, label %57

49:                                               ; preds = %46
  %50 = load i32, ptr %4, align 4, !tbaa !9
  %51 = icmp slt i32 %50, 48
  br i1 %51, label %55, label %52

52:                                               ; preds = %49
  %53 = load i32, ptr %4, align 4, !tbaa !9
  %54 = icmp sgt i32 %53, 57
  br i1 %54, label %55, label %56

55:                                               ; preds = %52, %49
  store i32 0, ptr %2, align 4
  store i32 1, ptr %9, align 4
  br label %81

56:                                               ; preds = %52
  br label %76

57:                                               ; preds = %46
  %58 = load i32, ptr %4, align 4, !tbaa !9
  %59 = icmp ne i32 %58, 163
  br i1 %59, label %60, label %61

60:                                               ; preds = %57
  store i32 0, ptr %2, align 4
  store i32 1, ptr %9, align 4
  br label %81

61:                                               ; preds = %57
  %62 = load ptr, ptr %3, align 8, !tbaa !5
  %63 = load i32, ptr %7, align 4, !tbaa !9
  %64 = add nsw i32 %63, 1
  store i32 %64, ptr %7, align 4, !tbaa !9
  %65 = sext i32 %63 to i64
  %66 = getelementptr inbounds i8, ptr %62, i64 %65
  %67 = load i8, ptr %66, align 1, !tbaa !11
  %68 = zext i8 %67 to i32
  store i32 %68, ptr %5, align 4, !tbaa !9
  %69 = load i32, ptr %5, align 4, !tbaa !9
  %70 = icmp slt i32 %69, 176
  br i1 %70, label %74, label %71

71:                                               ; preds = %61
  %72 = load i32, ptr %5, align 4, !tbaa !9
  %73 = icmp sgt i32 %72, 185
  br i1 %73, label %74, label %75

74:                                               ; preds = %71, %61
  store i32 0, ptr %2, align 4
  store i32 1, ptr %9, align 4
  br label %81

75:                                               ; preds = %71
  br label %76

76:                                               ; preds = %75, %56
  br label %29, !llvm.loop !12

77:                                               ; preds = %29
  %78 = load i32, ptr %8, align 4, !tbaa !9
  %79 = icmp eq i32 %78, 1
  %80 = zext i1 %79 to i32
  store i32 %80, ptr %2, align 4
  store i32 1, ptr %9, align 4
  br label %81

81:                                               ; preds = %77, %74, %60, %55, %27
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #3
  %82 = load i32, ptr %2, align 4
  ret i32 %82
}

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

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 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 #3 = { nounwind }
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 = !{!"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 nounwind memory(argmem: read) uwtable
define dso_local range(i32 0, 2) i32 @gbk_decimal_string(ptr nocapture noundef readonly %0) local_unnamed_addr #0 {
  %2 = tail call i64 @strlen(ptr noundef nonnull dereferenceable(1) %0) #2
  %3 = trunc i64 %2 to i32
  %4 = load i8, ptr %0, align 1, !tbaa !5
  %5 = icmp eq i8 %4, 46
  br i1 %5, label %.loopexit, label %6

6:                                                ; preds = %1
  %7 = shl i64 %2, 32
  %sext = add i64 %7, -4294967296
  %8 = ashr exact i64 %sext, 32
  %9 = getelementptr inbounds i8, ptr %0, i64 %8
  %10 = load i8, ptr %9, align 1, !tbaa !5
  %11 = icmp eq i8 %10, 46
  br i1 %11, label %.loopexit, label %.preheader

.preheader:                                       ; preds = %6
  %12 = icmp sgt i32 %3, 0
  br i1 %12, label %.lr.ph, label %.outer._crit_edge

.lr.ph:                                           ; preds = %.preheader, %.outer
  %.0.ph30 = phi i32 [ %19, %.outer ], [ 0, %.preheader ]
  %.022.ph29 = phi i32 [ %14, %.outer ], [ 0, %.preheader ]
  br label %13

13:                                               ; preds = %.lr.ph, %32
  %.02227 = phi i32 [ %.022.ph29, %.lr.ph ], [ %.1, %32 ]
  %14 = add nsw i32 %.02227, 1
  %15 = sext i32 %.02227 to i64
  %16 = getelementptr inbounds i8, ptr %0, i64 %15
  %17 = load i8, ptr %16, align 1, !tbaa !5
  %18 = icmp eq i8 %17, 46
  br i1 %18, label %.outer, label %21

.outer:                                           ; preds = %13
  %19 = add nuw nsw i32 %.0.ph30, 1
  %20 = icmp slt i32 %14, %3
  br i1 %20, label %.lr.ph, label %.outer._crit_edge, !llvm.loop !8

21:                                               ; preds = %13
  %22 = icmp ult i8 %17, -127
  br i1 %22, label %23, label %25

23:                                               ; preds = %21
  %24 = add i8 %17, -58
  %or.cond = icmp ult i8 %24, -10
  br i1 %or.cond, label %.loopexit, label %32

25:                                               ; preds = %21
  %.not = icmp eq i8 %17, -93
  br i1 %.not, label %26, label %.loopexit

26:                                               ; preds = %25
  %27 = add nsw i32 %.02227, 2
  %28 = sext i32 %14 to i64
  %29 = getelementptr inbounds i8, ptr %0, i64 %28
  %30 = load i8, ptr %29, align 1, !tbaa !5
  %31 = add i8 %30, 70
  %or.cond3 = icmp ult i8 %31, -10
  br i1 %or.cond3, label %.loopexit, label %32

32:                                               ; preds = %26, %23
  %.1 = phi i32 [ %14, %23 ], [ %27, %26 ]
  %33 = icmp slt i32 %.1, %3
  br i1 %33, label %13, label %.outer._crit_edge, !llvm.loop !8

.outer._crit_edge:                                ; preds = %.outer, %32, %.preheader
  %.0.ph.lcssa26 = phi i32 [ 0, %.preheader ], [ %.0.ph30, %32 ], [ %19, %.outer ]
  %34 = icmp eq i32 %.0.ph.lcssa26, 1
  %35 = zext i1 %34 to i32
  br label %.loopexit

.loopexit:                                        ; preds = %26, %25, %23, %1, %6, %.outer._crit_edge
  %.023 = phi i32 [ %35, %.outer._crit_edge ], [ 0, %6 ], [ 0, %1 ], [ 0, %23 ], [ 0, %25 ], [ 0, %26 ]
  ret i32 %.023
}

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

attributes #0 = { nofree nounwind memory(argmem: read) 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 = { 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 = !{!"omnipotent char", !7, i64 0}
!7 = !{!"Simple C/C++ TBAA"}
!8 = distinct !{!8, !9}
!9 = !{!"llvm.loop.mustprogress"}


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