; LLVM IR from Morpho-lang/morpho :: src/support (lex)

; 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.tokendefn = type { ptr, i32, ptr }
%struct.slexer = type { ptr, ptr, i32, i32, i8, i8, ptr, ptr, i32, i32, i32, i32, i32, i32, ptr, i32, %struct.varray_tokendefn }
%struct.varray_tokendefn = type { i32, i32, ptr }

@standardtokens = external dso_local global [67 x %struct.tokendefn], align 16
@nstandardtokens = external dso_local global i32, align 4

; Function Attrs: nounwind uwtable
declare dso_local void @varray_tokendefninit(ptr noundef) #0

; Function Attrs: nounwind uwtable
declare dso_local zeroext i1 @lex_skipwhitespace(ptr noundef, ptr noundef, ptr noundef) #0

; Function Attrs: nounwind uwtable
declare dso_local zeroext i1 @lex_preprocess(ptr noundef, ptr noundef, ptr noundef) #0

; Function Attrs: nounwind uwtable
define dso_local void @lex_init(ptr noundef %0, ptr noundef %1, i32 noundef %2) #0 {
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  store i32 %2, ptr %6, align 4, !tbaa !9
  %7 = load ptr, ptr %5, align 8, !tbaa !5
  %8 = load ptr, ptr %4, align 8, !tbaa !5
  %9 = getelementptr inbounds %struct.slexer, ptr %8, i32 0, i32 1
  store ptr %7, ptr %9, align 8, !tbaa !11
  %10 = load ptr, ptr %5, align 8, !tbaa !5
  %11 = load ptr, ptr %4, align 8, !tbaa !5
  %12 = getelementptr inbounds %struct.slexer, ptr %11, i32 0, i32 0
  store ptr %10, ptr %12, align 8, !tbaa !15
  %13 = load i32, ptr %6, align 4, !tbaa !9
  %14 = load ptr, ptr %4, align 8, !tbaa !5
  %15 = getelementptr inbounds %struct.slexer, ptr %14, i32 0, i32 2
  store i32 %13, ptr %15, align 8, !tbaa !16
  %16 = load ptr, ptr %4, align 8, !tbaa !5
  %17 = getelementptr inbounds %struct.slexer, ptr %16, i32 0, i32 3
  store i32 0, ptr %17, align 4, !tbaa !17
  %18 = load ptr, ptr %4, align 8, !tbaa !5
  %19 = getelementptr inbounds %struct.slexer, ptr %18, i32 0, i32 4
  store i8 1, ptr %19, align 8, !tbaa !18
  %20 = load ptr, ptr %4, align 8, !tbaa !5
  %21 = getelementptr inbounds %struct.slexer, ptr %20, i32 0, i32 5
  store i8 1, ptr %21, align 1, !tbaa !19
  %22 = load ptr, ptr %4, align 8, !tbaa !5
  %23 = getelementptr inbounds %struct.slexer, ptr %22, i32 0, i32 13
  store i32 0, ptr %23, align 4, !tbaa !20
  %24 = load ptr, ptr %4, align 8, !tbaa !5
  %25 = getelementptr inbounds %struct.slexer, ptr %24, i32 0, i32 7
  store ptr @lex_preprocess, ptr %25, align 8, !tbaa !21
  %26 = load ptr, ptr %4, align 8, !tbaa !5
  %27 = getelementptr inbounds %struct.slexer, ptr %26, i32 0, i32 6
  store ptr @lex_skipwhitespace, ptr %27, align 8, !tbaa !22
  %28 = load ptr, ptr %4, align 8, !tbaa !5
  %29 = getelementptr inbounds %struct.slexer, ptr %28, i32 0, i32 8
  store i32 72, ptr %29, align 8, !tbaa !23
  %30 = load ptr, ptr %4, align 8, !tbaa !5
  %31 = getelementptr inbounds %struct.slexer, ptr %30, i32 0, i32 9
  store i32 4, ptr %31, align 4, !tbaa !24
  %32 = load ptr, ptr %4, align 8, !tbaa !5
  %33 = getelementptr inbounds %struct.slexer, ptr %32, i32 0, i32 10
  store i32 5, ptr %33, align 8, !tbaa !25
  %34 = load ptr, ptr %4, align 8, !tbaa !5
  %35 = getelementptr inbounds %struct.slexer, ptr %34, i32 0, i32 11
  store i32 50, ptr %35, align 4, !tbaa !26
  %36 = load ptr, ptr %4, align 8, !tbaa !5
  %37 = getelementptr inbounds %struct.slexer, ptr %36, i32 0, i32 12
  store i32 6, ptr %37, align 8, !tbaa !27
  %38 = load ptr, ptr %4, align 8, !tbaa !5
  %39 = getelementptr inbounds %struct.slexer, ptr %38, i32 0, i32 14
  store ptr @standardtokens, ptr %39, align 8, !tbaa !28
  %40 = load i32, ptr @nstandardtokens, align 4, !tbaa !9
  %41 = load ptr, ptr %4, align 8, !tbaa !5
  %42 = getelementptr inbounds %struct.slexer, ptr %41, i32 0, i32 15
  store i32 %40, ptr %42, align 8, !tbaa !29
  %43 = load ptr, ptr %4, align 8, !tbaa !5
  %44 = getelementptr inbounds %struct.slexer, ptr %43, i32 0, i32 16
  call void @varray_tokendefninit(ptr noundef %44)
  ret void
}

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

!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 = !{!12, !6, i64 8}
!12 = !{!"slexer", !6, i64 0, !6, i64 8, !10, i64 16, !10, i64 20, !13, i64 24, !13, i64 25, !6, i64 32, !6, i64 40, !10, i64 48, !10, i64 52, !10, i64 56, !10, i64 60, !10, i64 64, !10, i64 68, !6, i64 72, !10, i64 80, !14, i64 88}
!13 = !{!"_Bool", !7, i64 0}
!14 = !{!"", !10, i64 0, !10, i64 4, !6, i64 8}
!15 = !{!12, !6, i64 0}
!16 = !{!12, !10, i64 16}
!17 = !{!12, !10, i64 20}
!18 = !{!12, !13, i64 24}
!19 = !{!12, !13, i64 25}
!20 = !{!12, !10, i64 68}
!21 = !{!12, !6, i64 40}
!22 = !{!12, !6, i64 32}
!23 = !{!12, !10, i64 48}
!24 = !{!12, !10, i64 52}
!25 = !{!12, !10, i64 56}
!26 = !{!12, !10, i64 60}
!27 = !{!12, !10, i64 64}
!28 = !{!12, !6, i64 72}
!29 = !{!12, !10, i64 80}


; 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.tokendefn = type { ptr, i32, ptr }

@standardtokens = external dso_local global [67 x %struct.tokendefn], align 16
@nstandardtokens = external dso_local local_unnamed_addr global i32, align 4

; Function Attrs: nounwind uwtable
declare dso_local void @varray_tokendefninit(ptr noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare dso_local zeroext i1 @lex_skipwhitespace(ptr noundef, ptr noundef, ptr noundef) #0

; Function Attrs: nounwind uwtable
declare dso_local zeroext i1 @lex_preprocess(ptr noundef, ptr noundef, ptr noundef) #0

; Function Attrs: nounwind uwtable
define dso_local void @lex_init(ptr noundef %0, ptr noundef %1, i32 noundef %2) local_unnamed_addr #0 {
  %4 = getelementptr inbounds i8, ptr %0, i64 8
  store ptr %1, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %0, align 8, !tbaa !13
  %5 = getelementptr inbounds i8, ptr %0, i64 16
  store i32 %2, ptr %5, align 8, !tbaa !14
  %6 = getelementptr inbounds i8, ptr %0, i64 20
  store i32 0, ptr %6, align 4, !tbaa !15
  %7 = getelementptr inbounds i8, ptr %0, i64 24
  store i8 1, ptr %7, align 8, !tbaa !16
  %8 = getelementptr inbounds i8, ptr %0, i64 25
  store i8 1, ptr %8, align 1, !tbaa !17
  %9 = getelementptr inbounds i8, ptr %0, i64 68
  store i32 0, ptr %9, align 4, !tbaa !18
  %10 = getelementptr inbounds i8, ptr %0, i64 40
  store ptr @lex_preprocess, ptr %10, align 8, !tbaa !19
  %11 = getelementptr inbounds i8, ptr %0, i64 32
  store ptr @lex_skipwhitespace, ptr %11, align 8, !tbaa !20
  %12 = getelementptr inbounds i8, ptr %0, i64 48
  store <4 x i32> <i32 72, i32 4, i32 5, i32 50>, ptr %12, align 8, !tbaa !21
  %13 = getelementptr inbounds i8, ptr %0, i64 64
  store i32 6, ptr %13, align 8, !tbaa !22
  %14 = getelementptr inbounds i8, ptr %0, i64 72
  store ptr @standardtokens, ptr %14, align 8, !tbaa !23
  %15 = load i32, ptr @nstandardtokens, align 4, !tbaa !21
  %16 = getelementptr inbounds i8, ptr %0, i64 80
  store i32 %15, ptr %16, align 8, !tbaa !24
  %17 = getelementptr inbounds i8, ptr %0, i64 88
  tail call void @varray_tokendefninit(ptr noundef nonnull %17)
  ret void
}

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

!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 8}
!6 = !{!"slexer", !7, i64 0, !7, i64 8, !10, i64 16, !10, i64 20, !11, i64 24, !11, i64 25, !7, i64 32, !7, i64 40, !10, i64 48, !10, i64 52, !10, i64 56, !10, i64 60, !10, i64 64, !10, i64 68, !7, i64 72, !10, i64 80, !12, i64 88}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"int", !8, i64 0}
!11 = !{!"_Bool", !8, i64 0}
!12 = !{!"", !10, i64 0, !10, i64 4, !7, i64 8}
!13 = !{!6, !7, i64 0}
!14 = !{!6, !10, i64 16}
!15 = !{!6, !10, i64 20}
!16 = !{!6, !11, i64 24}
!17 = !{!6, !11, i64 25}
!18 = !{!6, !10, i64 68}
!19 = !{!6, !7, i64 40}
!20 = !{!6, !7, i64 32}
!21 = !{!10, !10, i64 0}
!22 = !{!6, !10, i64 64}
!23 = !{!6, !7, i64 72}
!24 = !{!6, !10, i64 80}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,InstCombinePass,SLPVectorizerPass,SROAPass,TailCallElimPass