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

; Function Attrs: nounwind uwtable
declare dso_local signext i8 @lex_advance(ptr noundef) #0

; Function Attrs: nounwind uwtable
declare dso_local signext i8 @lex_peek(ptr noundef) #0

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

; Function Attrs: nounwind uwtable
define dso_local zeroext i1 @lex_skipwhitespace(ptr noundef %0, ptr noundef %1, ptr noundef %2) #0 {
  %4 = alloca i1, align 1
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  store ptr %0, ptr %5, align 8, !tbaa !5
  store ptr %1, ptr %6, align 8, !tbaa !5
  store ptr %2, ptr %7, align 8, !tbaa !5
  br label %8

8:                                                ; preds = %24, %3
  %9 = load ptr, ptr %5, align 8, !tbaa !5
  %10 = call signext i8 @lex_peek(ptr noundef %9)
  %11 = sext i8 %10 to i32
  switch i32 %11, label %22 [
    i32 32, label %12
    i32 9, label %12
    i32 13, label %12
    i32 47, label %15
  ]

12:                                               ; preds = %8, %8, %8
  %13 = load ptr, ptr %5, align 8, !tbaa !5
  %14 = call signext i8 @lex_advance(ptr noundef %13)
  br label %23

15:                                               ; preds = %8
  %16 = load ptr, ptr %5, align 8, !tbaa !5
  %17 = load ptr, ptr %6, align 8, !tbaa !5
  %18 = load ptr, ptr %7, align 8, !tbaa !5
  %19 = call zeroext i1 @lex_skipcomment(ptr noundef %16, ptr noundef %17, ptr noundef %18)
  br i1 %19, label %21, label %20

20:                                               ; preds = %15
  store i1 true, ptr %4, align 1
  br label %26

21:                                               ; preds = %15
  br label %23

22:                                               ; preds = %8
  store i1 true, ptr %4, align 1
  br label %26

23:                                               ; preds = %21, %12
  br label %24

24:                                               ; preds = %23
  br i1 true, label %8, label %25

25:                                               ; preds = %24
  store i1 true, ptr %4, align 1
  br label %26

26:                                               ; preds = %25, %22, %20
  %27 = load i1, ptr %4, align 1
  ret i1 %27
}

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


; 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: nounwind uwtable
declare dso_local signext i8 @lex_advance(ptr noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare dso_local signext i8 @lex_peek(ptr noundef) local_unnamed_addr #0

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

; Function Attrs: nounwind uwtable
define dso_local noundef zeroext i1 @lex_skipwhitespace(ptr noundef %0, ptr noundef %1, ptr noundef %2) local_unnamed_addr #0 {
  br label %4

4:                                                ; preds = %.backedge, %3
  %5 = tail call signext i8 @lex_peek(ptr noundef %0)
  switch i8 %5, label %10 [
    i8 32, label %6
    i8 9, label %6
    i8 13, label %6
    i8 47, label %8
  ]

6:                                                ; preds = %4, %4, %4
  %7 = tail call signext i8 @lex_advance(ptr noundef %0)
  br label %.backedge

.backedge:                                        ; preds = %6, %8
  br label %4

8:                                                ; preds = %4
  %9 = tail call zeroext i1 @lex_skipcomment(ptr noundef %0, ptr noundef %1, ptr noundef %2)
  br i1 %9, label %.backedge, label %10

10:                                               ; preds = %4, %8
  ret i1 true
}

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


; Effective O3 passes: GlobalOptPass,InstCombinePass,LoopUnrollPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass