; LLVM IR from PepcyCh/bisemutum-engine :: bisemutum/thirdparty/pep-cprep/src/unicode_ident.ll (ZN3pep5cprep6v0_1_012is_xid_startEi)

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

@_ZN3pep5cprep6v0_1_012_GLOBAL__N_111ASCII_STARTE = external hidden constant [128 x i8], align 16
@_ZN3pep5cprep6v0_1_012_GLOBAL__N_110TRIE_STARTE = external hidden constant [402 x i8], align 16
@_ZN3pep5cprep6v0_1_012_GLOBAL__N_14LEAFE = external hidden constant <{ [7460 x i8], [60 x i8] }>, align 16

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

9:                                                ; preds = %1
  %10 = load i32, ptr %3, align 4, !tbaa !5
  %11 = sext i32 %10 to i64
  %12 = getelementptr inbounds [128 x i8], ptr @_ZN3pep5cprep6v0_1_012_GLOBAL__N_111ASCII_STARTE, i64 0, i64 %11
  %13 = load i8, ptr %12, align 1, !tbaa !9, !range !11, !noundef !12
  %14 = trunc i8 %13 to i1
  store i1 %14, ptr %2, align 1
  br label %48

15:                                               ; preds = %1
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #2
  %16 = load i32, ptr %3, align 4, !tbaa !5
  %17 = sdiv i32 %16, 8
  %18 = sext i32 %17 to i64
  %19 = udiv i64 %18, 64
  store i64 %19, ptr %4, align 8, !tbaa !13
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #2
  %20 = load i64, ptr %4, align 8, !tbaa !13
  %21 = icmp ult i64 %20, 402
  br i1 %21, label %22, label %27

22:                                               ; preds = %15
  %23 = load i64, ptr %4, align 8, !tbaa !13
  %24 = getelementptr inbounds [402 x i8], ptr @_ZN3pep5cprep6v0_1_012_GLOBAL__N_110TRIE_STARTE, i64 0, i64 %23
  %25 = load i8, ptr %24, align 1, !tbaa !15
  %26 = zext i8 %25 to i32
  br label %28

27:                                               ; preds = %15
  br label %28

28:                                               ; preds = %27, %22
  %29 = phi i32 [ %26, %22 ], [ 0, %27 ]
  store i32 %29, ptr %5, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #2
  %30 = load i32, ptr %5, align 4, !tbaa !5
  %31 = sext i32 %30 to i64
  %32 = mul i64 %31, 64
  %33 = udiv i64 %32, 2
  %34 = load i32, ptr %3, align 4, !tbaa !5
  %35 = sdiv i32 %34, 8
  %36 = sext i32 %35 to i64
  %37 = urem i64 %36, 64
  %38 = add i64 %33, %37
  store i64 %38, ptr %6, align 8, !tbaa !13
  %39 = load i64, ptr %6, align 8, !tbaa !13
  %40 = getelementptr inbounds [7520 x i8], ptr @_ZN3pep5cprep6v0_1_012_GLOBAL__N_14LEAFE, i64 0, i64 %39
  %41 = load i8, ptr %40, align 1, !tbaa !15
  %42 = zext i8 %41 to i32
  %43 = load i32, ptr %3, align 4, !tbaa !5
  %44 = srem i32 %43, 8
  %45 = ashr i32 %42, %44
  %46 = and i32 %45, 1
  %47 = icmp ne i32 %46, 0
  store i1 %47, ptr %2, align 1
  call void @llvm.lifetime.end.p0(i64 8, 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
  br label %48

48:                                               ; preds = %28, %9
  %49 = load i1, ptr %2, align 1
  ret i1 %49
}

; 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 = { mustprogress 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++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"bool", !7, i64 0}
!11 = !{i8 0, i8 2}
!12 = !{}
!13 = !{!14, !14, i64 0}
!14 = !{!"long", !7, i64 0}
!15 = !{!7, !7, i64 0}


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

@_ZN3pep5cprep6v0_1_012_GLOBAL__N_111ASCII_STARTE = external hidden local_unnamed_addr constant [128 x i8], align 16
@_ZN3pep5cprep6v0_1_012_GLOBAL__N_110TRIE_STARTE = external hidden local_unnamed_addr constant [402 x i8], align 16
@_ZN3pep5cprep6v0_1_012_GLOBAL__N_14LEAFE = external hidden local_unnamed_addr constant <{ [7460 x i8], [60 x i8] }>, align 16

; Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(none) uwtable
define dso_local noundef zeroext i1 @_ZN3pep5cprep6v0_1_012is_xid_startEi(i32 noundef %0) local_unnamed_addr #0 {
  %2 = icmp slt i32 %0, 128
  br i1 %2, label %3, label %8

3:                                                ; preds = %1
  %4 = sext i32 %0 to i64
  %5 = getelementptr inbounds [128 x i8], ptr @_ZN3pep5cprep6v0_1_012_GLOBAL__N_111ASCII_STARTE, i64 0, i64 %4
  %6 = load i8, ptr %5, align 1, !tbaa !5, !range !9, !noundef !10
  %7 = trunc nuw i8 %6 to i1
  br label %29

8:                                                ; preds = %1
  %9 = lshr i32 %0, 3
  %10 = zext nneg i32 %9 to i64
  %11 = icmp ult i32 %0, 205824
  br i1 %11, label %12, label %18

12:                                               ; preds = %8
  %13 = lshr i64 %10, 6
  %14 = getelementptr inbounds [402 x i8], ptr @_ZN3pep5cprep6v0_1_012_GLOBAL__N_110TRIE_STARTE, i64 0, i64 %13
  %15 = load i8, ptr %14, align 1, !tbaa !11
  %16 = zext i8 %15 to i64
  %17 = shl nuw nsw i64 %16, 5
  br label %18

18:                                               ; preds = %8, %12
  %19 = phi i64 [ %17, %12 ], [ 0, %8 ]
  %20 = and i64 %10, 63
  %21 = add nuw nsw i64 %19, %20
  %22 = getelementptr inbounds [7520 x i8], ptr @_ZN3pep5cprep6v0_1_012_GLOBAL__N_14LEAFE, i64 0, i64 %21
  %23 = load i8, ptr %22, align 1, !tbaa !11
  %24 = zext i8 %23 to i32
  %25 = and i32 %0, 7
  %26 = shl nuw nsw i32 1, %25
  %27 = and i32 %26, %24
  %28 = icmp ne i32 %27, 0
  br label %29

29:                                               ; preds = %18, %3
  %.0 = phi i1 [ %7, %3 ], [ %28, %18 ]
  ret i1 %.0
}

attributes #0 = { mustprogress nofree norecurse nosync nounwind willreturn 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 = !{!6, !6, i64 0}
!6 = !{!"bool", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{i8 0, i8 2}
!10 = !{}
!11 = !{!7, !7, i64 0}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,SimplifyCFGPass