; LLVM IR from aagdev/mlimgsynth :: src/ccommon (unicode_data)

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

%struct.UnicodeMapEntry = type { i32, i32 }

@g_unicode_lower = external hidden constant [1460 x %struct.UnicodeMapEntry], align 16

; 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 @unicode_lower(i32 noundef %0) #1 {
  %2 = alloca i32, align 4
  %3 = alloca i8, align 1
  %4 = alloca i64, align 8
  %5 = alloca i64, align 8
  %6 = alloca i64, align 8
  %7 = alloca i64, align 8
  %8 = alloca i32, align 4
  store i32 %0, ptr %2, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 1, ptr %3) #2
  store i8 0, ptr %3, align 1, !tbaa !9
  %9 = load i8, ptr %3, align 1, !tbaa !9, !range !11, !noundef !12
  %10 = trunc i8 %9 to i1
  %11 = zext i1 %10 to i8
  store i8 %11, ptr %3, align 1, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #2
  store i64 0, ptr %4, align 8, !tbaa !13
  %12 = load i64, ptr %4, align 8, !tbaa !13
  store i64 %12, ptr %4, align 8, !tbaa !13
  br label %13

13:                                               ; preds = %1
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #2
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #2
  store i64 0, ptr %6, align 8, !tbaa !13
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #2
  store i64 1460, ptr %7, align 8, !tbaa !13
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #2
  store i32 -1, ptr %8, align 4, !tbaa !5
  br label %14

14:                                               ; preds = %42, %13
  %15 = load i64, ptr %6, align 8, !tbaa !13
  %16 = load i64, ptr %7, align 8, !tbaa !13
  %17 = icmp ult i64 %15, %16
  br i1 %17, label %18, label %43

18:                                               ; preds = %14
  %19 = load i64, ptr %6, align 8, !tbaa !13
  %20 = load i64, ptr %7, align 8, !tbaa !13
  %21 = add i64 %19, %20
  %22 = udiv i64 %21, 2
  store i64 %22, ptr %5, align 8, !tbaa !13
  %23 = load i64, ptr %5, align 8, !tbaa !13
  %24 = getelementptr inbounds [1460 x %struct.UnicodeMapEntry], ptr @g_unicode_lower, i64 0, i64 %23
  %25 = getelementptr inbounds %struct.UnicodeMapEntry, ptr %24, i32 0, i32 0
  %26 = load i32, ptr %25, align 8, !tbaa !15
  %27 = load i32, ptr %2, align 4, !tbaa !5
  %28 = sub i32 %26, %27
  store i32 %28, ptr %8, align 4, !tbaa !5
  %29 = load i32, ptr %8, align 4, !tbaa !5
  %30 = icmp slt i32 %29, 0
  br i1 %30, label %31, label %34

31:                                               ; preds = %18
  %32 = load i64, ptr %5, align 8, !tbaa !13
  %33 = add i64 %32, 1
  store i64 %33, ptr %6, align 8, !tbaa !13
  br label %42

34:                                               ; preds = %18
  %35 = load i32, ptr %8, align 4, !tbaa !5
  %36 = icmp sgt i32 %35, 0
  br i1 %36, label %37, label %39

37:                                               ; preds = %34
  %38 = load i64, ptr %5, align 8, !tbaa !13
  store i64 %38, ptr %7, align 8, !tbaa !13
  br label %41

39:                                               ; preds = %34
  %40 = load i64, ptr %5, align 8, !tbaa !13
  store i64 %40, ptr %6, align 8, !tbaa !13
  br label %43

41:                                               ; preds = %37
  br label %42

42:                                               ; preds = %41, %31
  br label %14, !llvm.loop !17

43:                                               ; preds = %39, %14
  %44 = load i32, ptr %8, align 4, !tbaa !5
  %45 = icmp eq i32 %44, 0
  %46 = zext i1 %45 to i8
  store i8 %46, ptr %3, align 1, !tbaa !9
  %47 = load i64, ptr %6, align 8, !tbaa !13
  store i64 %47, ptr %4, align 8, !tbaa !13
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #2
  br label %48

48:                                               ; preds = %43
  br label %49

49:                                               ; preds = %48
  %50 = load i8, ptr %3, align 1, !tbaa !9, !range !11, !noundef !12
  %51 = trunc i8 %50 to i1
  br i1 %51, label %52, label %57

52:                                               ; preds = %49
  %53 = load i64, ptr %4, align 8, !tbaa !13
  %54 = getelementptr inbounds [1460 x %struct.UnicodeMapEntry], ptr @g_unicode_lower, i64 0, i64 %53
  %55 = getelementptr inbounds %struct.UnicodeMapEntry, ptr %54, i32 0, i32 1
  %56 = load i32, ptr %55, align 4, !tbaa !19
  br label %59

57:                                               ; preds = %49
  %58 = load i32, ptr %2, align 4, !tbaa !5
  br label %59

59:                                               ; preds = %57, %52
  %60 = phi i32 [ %56, %52 ], [ %58, %57 ]
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #2
  call void @llvm.lifetime.end.p0(i64 1, ptr %3) #2
  ret i32 %60
}

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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/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 = !{!16, !6, i64 0}
!16 = !{!"UnicodeMapEntry", !6, i64 0, !6, i64 4}
!17 = distinct !{!17, !18}
!18 = !{!"llvm.loop.mustprogress"}
!19 = !{!16, !6, i64 4}


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

%struct.UnicodeMapEntry = type { i32, i32 }

@g_unicode_lower = external hidden local_unnamed_addr constant [1460 x %struct.UnicodeMapEntry], align 16

; Function Attrs: nofree norecurse nosync nounwind memory(none) uwtable
define dso_local i32 @unicode_lower(i32 noundef %0) local_unnamed_addr #0 {
  br label %2

2:                                                ; preds = %1, %12
  %.01827 = phi i64 [ 1460, %1 ], [ %.119, %12 ]
  %.02026 = phi i64 [ 0, %1 ], [ %.121, %12 ]
  %3 = add i64 %.01827, %.02026
  %4 = lshr i64 %3, 1
  %5 = getelementptr inbounds [1460 x %struct.UnicodeMapEntry], ptr @g_unicode_lower, i64 0, i64 %4
  %6 = load i32, ptr %5, align 8, !tbaa !5
  %7 = sub i32 %6, %0
  %8 = icmp slt i32 %7, 0
  br i1 %8, label %9, label %11

9:                                                ; preds = %2
  %10 = add nuw i64 %4, 1
  br label %12

11:                                               ; preds = %2
  %.not = icmp eq i32 %6, %0
  br i1 %.not, label %14, label %12

12:                                               ; preds = %11, %9
  %.121 = phi i64 [ %10, %9 ], [ %.02026, %11 ]
  %.119 = phi i64 [ %.01827, %9 ], [ %4, %11 ]
  %13 = icmp ult i64 %.121, %.119
  br i1 %13, label %2, label %.loopexit, !llvm.loop !10

14:                                               ; preds = %11
  %15 = getelementptr inbounds [1460 x %struct.UnicodeMapEntry], ptr @g_unicode_lower, i64 0, i64 %4, i32 1
  %16 = load i32, ptr %15, align 4, !tbaa !12
  br label %.loopexit

.loopexit:                                        ; preds = %12, %14
  %17 = phi i32 [ %16, %14 ], [ %0, %12 ]
  ret i32 %17
}

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 = !{!6, !7, i64 0}
!6 = !{!"UnicodeMapEntry", !7, i64 0, !7, i64 4}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = distinct !{!10, !11}
!11 = !{!"llvm.loop.mustprogress"}
!12 = !{!6, !7, i64 4}


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