; LLVM IR from reddy-lab-code-research/XLCoST :: build/tree-sitter-javascript/src (scanner)

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

; Function Attrs: nounwind uwtable
define dso_local zeroext i1 @tree_sitter_javascript_external_scanner_scan(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
  %8 = alloca i8, align 1
  %9 = alloca i32, align 4
  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
  %10 = load ptr, ptr %7, align 8, !tbaa !5
  %11 = getelementptr inbounds i8, ptr %10, i64 1
  %12 = load i8, ptr %11, align 1, !tbaa !9, !range !11, !noundef !12
  %13 = trunc i8 %12 to i1
  br i1 %13, label %14, label %23

14:                                               ; preds = %3
  %15 = load ptr, ptr %7, align 8, !tbaa !5
  %16 = getelementptr inbounds i8, ptr %15, i64 0
  %17 = load i8, ptr %16, align 1, !tbaa !9, !range !11, !noundef !12
  %18 = trunc i8 %17 to i1
  br i1 %18, label %19, label %20

19:                                               ; preds = %14
  store i1 false, ptr %4, align 1
  br label %61

20:                                               ; preds = %14
  %21 = load ptr, ptr %6, align 8, !tbaa !5
  %22 = call zeroext i1 @scan_template_chars(ptr noundef %21)
  store i1 %22, ptr %4, align 1
  br label %61

23:                                               ; preds = %3
  %24 = load ptr, ptr %7, align 8, !tbaa !5
  %25 = getelementptr inbounds i8, ptr %24, i64 0
  %26 = load i8, ptr %25, align 1, !tbaa !9, !range !11, !noundef !12
  %27 = trunc i8 %26 to i1
  br i1 %27, label %28, label %51

28:                                               ; preds = %23
  call void @llvm.lifetime.start.p0(i64 1, ptr %8) #2
  %29 = load ptr, ptr %6, align 8, !tbaa !5
  %30 = call zeroext i1 @scan_automatic_semicolon(ptr noundef %29)
  %31 = zext i1 %30 to i8
  store i8 %31, ptr %8, align 1, !tbaa !9
  %32 = load i8, ptr %8, align 1, !tbaa !9, !range !11, !noundef !12
  %33 = trunc i8 %32 to i1
  br i1 %33, label %47, label %34

34:                                               ; preds = %28
  %35 = load ptr, ptr %7, align 8, !tbaa !5
  %36 = getelementptr inbounds i8, ptr %35, i64 2
  %37 = load i8, ptr %36, align 1, !tbaa !9, !range !11, !noundef !12
  %38 = trunc i8 %37 to i1
  br i1 %38, label %39, label %47

39:                                               ; preds = %34
  %40 = load ptr, ptr %6, align 8, !tbaa !5
  %41 = getelementptr inbounds %struct.TSLexer, ptr %40, i32 0, i32 0
  %42 = load i32, ptr %41, align 8, !tbaa !13
  %43 = icmp eq i32 %42, 63
  br i1 %43, label %44, label %47

44:                                               ; preds = %39
  %45 = load ptr, ptr %6, align 8, !tbaa !5
  %46 = call zeroext i1 @scan_ternary_qmark(ptr noundef %45)
  store i1 %46, ptr %4, align 1
  store i32 1, ptr %9, align 4
  br label %50

47:                                               ; preds = %39, %34, %28
  %48 = load i8, ptr %8, align 1, !tbaa !9, !range !11, !noundef !12
  %49 = trunc i8 %48 to i1
  store i1 %49, ptr %4, align 1
  store i32 1, ptr %9, align 4
  br label %50

50:                                               ; preds = %47, %44
  call void @llvm.lifetime.end.p0(i64 1, ptr %8) #2
  br label %61

51:                                               ; preds = %23
  br label %52

52:                                               ; preds = %51
  %53 = load ptr, ptr %7, align 8, !tbaa !5
  %54 = getelementptr inbounds i8, ptr %53, i64 2
  %55 = load i8, ptr %54, align 1, !tbaa !9, !range !11, !noundef !12
  %56 = trunc i8 %55 to i1
  br i1 %56, label %57, label %60

57:                                               ; preds = %52
  %58 = load ptr, ptr %6, align 8, !tbaa !5
  %59 = call zeroext i1 @scan_ternary_qmark(ptr noundef %58)
  store i1 %59, ptr %4, align 1
  br label %61

60:                                               ; preds = %52
  store i1 false, ptr %4, align 1
  br label %61

61:                                               ; preds = %60, %57, %50, %20, %19
  %62 = load i1, ptr %4, align 1
  ret i1 %62
}

; Function Attrs: nounwind uwtable
declare hidden zeroext i1 @scan_template_chars(ptr noundef) #0

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #1

; Function Attrs: nounwind uwtable
declare hidden zeroext i1 @scan_automatic_semicolon(ptr noundef) #0

; Function Attrs: nounwind uwtable
declare hidden zeroext i1 @scan_ternary_qmark(ptr noundef) #0

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1

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" }
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 = !{!"any pointer", !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, !15, i64 0}
!14 = !{!"TSLexer", !15, i64 0, !16, i64 4, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !6, i64 40}
!15 = !{!"int", !7, i64 0}
!16 = !{!"short", !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"

; Function Attrs: nounwind uwtable
define dso_local zeroext i1 @tree_sitter_javascript_external_scanner_scan(ptr nocapture noundef readnone %0, ptr noundef %1, ptr nocapture noundef readonly %2) local_unnamed_addr #0 {
  %4 = getelementptr inbounds i8, ptr %2, i64 1
  %5 = load i8, ptr %4, align 1, !tbaa !5, !range !9, !noundef !10
  %6 = trunc nuw i8 %5 to i1
  %7 = load i8, ptr %2, align 1, !tbaa !5, !range !9, !noundef !10
  %8 = trunc nuw i8 %7 to i1
  br i1 %6, label %9, label %12

9:                                                ; preds = %3
  br i1 %8, label %30, label %10

10:                                               ; preds = %9
  %11 = tail call zeroext i1 @scan_template_chars(ptr noundef %1)
  br label %30

12:                                               ; preds = %3
  br i1 %8, label %13, label %24

13:                                               ; preds = %12
  %14 = tail call zeroext i1 @scan_automatic_semicolon(ptr noundef %1)
  br i1 %14, label %30, label %15

15:                                               ; preds = %13
  %16 = getelementptr inbounds i8, ptr %2, i64 2
  %17 = load i8, ptr %16, align 1, !tbaa !5, !range !9, !noundef !10
  %18 = trunc nuw i8 %17 to i1
  br i1 %18, label %19, label %30

19:                                               ; preds = %15
  %20 = load i32, ptr %1, align 8, !tbaa !11
  %21 = icmp eq i32 %20, 63
  br i1 %21, label %22, label %30

22:                                               ; preds = %19
  %23 = tail call zeroext i1 @scan_ternary_qmark(ptr noundef nonnull %1)
  br label %30

24:                                               ; preds = %12
  %25 = getelementptr inbounds i8, ptr %2, i64 2
  %26 = load i8, ptr %25, align 1, !tbaa !5, !range !9, !noundef !10
  %27 = trunc nuw i8 %26 to i1
  br i1 %27, label %28, label %30

28:                                               ; preds = %24
  %29 = tail call zeroext i1 @scan_ternary_qmark(ptr noundef %1)
  br label %30

30:                                               ; preds = %24, %22, %19, %15, %13, %9, %28, %10
  %.1 = phi i1 [ %11, %10 ], [ %29, %28 ], [ false, %9 ], [ %23, %22 ], [ false, %19 ], [ false, %15 ], [ true, %13 ], [ false, %24 ]
  ret i1 %.1
}

; Function Attrs: nounwind uwtable
declare hidden zeroext i1 @scan_template_chars(ptr noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare hidden zeroext i1 @scan_automatic_semicolon(ptr noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare hidden zeroext i1 @scan_ternary_qmark(ptr noundef) local_unnamed_addr #0

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 = !{!"_Bool", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{i8 0, i8 2}
!10 = !{}
!11 = !{!12, !13, i64 0}
!12 = !{!"TSLexer", !13, i64 0, !14, i64 4, !15, i64 8, !15, i64 16, !15, i64 24, !15, i64 32, !15, i64 40}
!13 = !{!"int", !7, i64 0}
!14 = !{!"short", !7, i64 0}
!15 = !{!"any pointer", !7, i64 0}


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