; 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 zeroext i1 @lex_isatend(ptr noundef) #0

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

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

; Function Attrs: nounwind uwtable
define dso_local zeroext i1 @lex_skipshebang(ptr noundef %0) #0 {
  %2 = alloca ptr, align 8
  store ptr %0, ptr %2, align 8, !tbaa !5
  %3 = load ptr, ptr %2, align 8, !tbaa !5
  %4 = call signext i8 @lex_peek(ptr noundef %3)
  %5 = sext i8 %4 to i32
  %6 = icmp eq i32 %5, 35
  br i1 %6, label %7, label %28

7:                                                ; preds = %1
  %8 = load ptr, ptr %2, align 8, !tbaa !5
  %9 = call signext i8 @lex_peekahead(ptr noundef %8, i32 noundef 1)
  %10 = sext i8 %9 to i32
  %11 = icmp eq i32 %10, 33
  br i1 %11, label %12, label %28

12:                                               ; preds = %7
  br label %13

13:                                               ; preds = %24, %12
  %14 = load ptr, ptr %2, align 8, !tbaa !5
  %15 = call signext i8 @lex_peek(ptr noundef %14)
  %16 = sext i8 %15 to i32
  %17 = icmp ne i32 %16, 10
  br i1 %17, label %18, label %22

18:                                               ; preds = %13
  %19 = load ptr, ptr %2, align 8, !tbaa !5
  %20 = call zeroext i1 @lex_isatend(ptr noundef %19)
  %21 = xor i1 %20, true
  br label %22

22:                                               ; preds = %18, %13
  %23 = phi i1 [ false, %13 ], [ %21, %18 ]
  br i1 %23, label %24, label %27

24:                                               ; preds = %22
  %25 = load ptr, ptr %2, align 8, !tbaa !5
  %26 = call signext i8 @lex_advance(ptr noundef %25)
  br label %13, !llvm.loop !9

27:                                               ; preds = %22
  br label %28

28:                                               ; preds = %27, %7, %1
  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)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = distinct !{!9, !10}
!10 = !{!"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: nounwind uwtable
declare dso_local signext i8 @lex_advance(ptr noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare dso_local zeroext i1 @lex_isatend(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 signext i8 @lex_peekahead(ptr noundef, i32 noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local noundef zeroext i1 @lex_skipshebang(ptr noundef %0) local_unnamed_addr #0 {
  %2 = tail call signext i8 @lex_peek(ptr noundef %0)
  %3 = icmp eq i8 %2, 35
  br i1 %3, label %4, label %.critedge

4:                                                ; preds = %1
  %5 = tail call signext i8 @lex_peekahead(ptr noundef %0, i32 noundef 1)
  %6 = icmp eq i8 %5, 33
  br i1 %6, label %.preheader, label %.critedge

.preheader:                                       ; preds = %4
  %7 = tail call signext i8 @lex_peek(ptr noundef %0)
  %.not5 = icmp eq i8 %7, 10
  br i1 %.not5, label %.critedge, label %.lr.ph

.lr.ph:                                           ; preds = %.preheader, %9
  %8 = tail call zeroext i1 @lex_isatend(ptr noundef %0)
  br i1 %8, label %.critedge, label %9

9:                                                ; preds = %.lr.ph
  %10 = tail call signext i8 @lex_advance(ptr noundef %0)
  %11 = tail call signext i8 @lex_peek(ptr noundef %0)
  %.not = icmp eq i8 %11, 10
  br i1 %.not, label %.critedge, label %.lr.ph, !llvm.loop !5

.critedge:                                        ; preds = %9, %.lr.ph, %.preheader, %4, %1
  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)"}
!5 = distinct !{!5, !6}
!6 = !{!"llvm.loop.mustprogress"}


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