; LLVM IR from Nykakin/chompjs :: _chompjs (parser)

; 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.Lexer = type { ptr, i64, %struct.CharBuffer, i64, i32, ptr, %struct.CharBuffer, i64, i8 }
%struct.CharBuffer = type { ptr, i64, i64 }

; Function Attrs: nounwind uwtable
define dso_local void @handle_comments(ptr noundef %0) #0 {
  %2 = alloca ptr, align 8
  %3 = alloca i8, align 1
  %4 = alloca i8, align 1
  store ptr %0, ptr %2, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 1, ptr %3) #2
  call void @llvm.lifetime.start.p0(i64 1, ptr %4) #2
  %5 = load ptr, ptr %2, align 8, !tbaa !5
  %6 = getelementptr inbounds %struct.Lexer, ptr %5, i32 0, i32 3
  %7 = load i64, ptr %6, align 8, !tbaa !9
  %8 = add i64 %7, 1
  store i64 %8, ptr %6, align 8, !tbaa !9
  %9 = load ptr, ptr %2, align 8, !tbaa !5
  %10 = getelementptr inbounds %struct.Lexer, ptr %9, i32 0, i32 0
  %11 = load ptr, ptr %10, align 8, !tbaa !15
  %12 = load ptr, ptr %2, align 8, !tbaa !5
  %13 = getelementptr inbounds %struct.Lexer, ptr %12, i32 0, i32 3
  %14 = load i64, ptr %13, align 8, !tbaa !9
  %15 = getelementptr inbounds i8, ptr %11, i64 %14
  %16 = load i8, ptr %15, align 1, !tbaa !16
  %17 = sext i8 %16 to i32
  %18 = icmp eq i32 %17, 47
  br i1 %18, label %19, label %43

19:                                               ; preds = %1
  br label %20

20:                                               ; preds = %41, %19
  %21 = load ptr, ptr %2, align 8, !tbaa !5
  %22 = getelementptr inbounds %struct.Lexer, ptr %21, i32 0, i32 3
  %23 = load i64, ptr %22, align 8, !tbaa !9
  %24 = add i64 %23, 1
  store i64 %24, ptr %22, align 8, !tbaa !9
  %25 = load ptr, ptr %2, align 8, !tbaa !5
  %26 = getelementptr inbounds %struct.Lexer, ptr %25, i32 0, i32 0
  %27 = load ptr, ptr %26, align 8, !tbaa !15
  %28 = load ptr, ptr %2, align 8, !tbaa !5
  %29 = getelementptr inbounds %struct.Lexer, ptr %28, i32 0, i32 3
  %30 = load i64, ptr %29, align 8, !tbaa !9
  %31 = getelementptr inbounds i8, ptr %27, i64 %30
  %32 = load i8, ptr %31, align 1, !tbaa !16
  store i8 %32, ptr %3, align 1, !tbaa !16
  %33 = load i8, ptr %3, align 1, !tbaa !16
  %34 = sext i8 %33 to i32
  %35 = icmp eq i32 %34, 0
  br i1 %35, label %40, label %36

36:                                               ; preds = %20
  %37 = load i8, ptr %3, align 1, !tbaa !16
  %38 = sext i8 %37 to i32
  %39 = icmp eq i32 %38, 10
  br i1 %39, label %40, label %41

40:                                               ; preds = %36, %20
  br label %42

41:                                               ; preds = %36
  br label %20

42:                                               ; preds = %40
  br label %96

43:                                               ; preds = %1
  %44 = load ptr, ptr %2, align 8, !tbaa !5
  %45 = getelementptr inbounds %struct.Lexer, ptr %44, i32 0, i32 0
  %46 = load ptr, ptr %45, align 8, !tbaa !15
  %47 = load ptr, ptr %2, align 8, !tbaa !5
  %48 = getelementptr inbounds %struct.Lexer, ptr %47, i32 0, i32 3
  %49 = load i64, ptr %48, align 8, !tbaa !9
  %50 = getelementptr inbounds i8, ptr %46, i64 %49
  %51 = load i8, ptr %50, align 1, !tbaa !16
  %52 = sext i8 %51 to i32
  %53 = icmp eq i32 %52, 42
  br i1 %53, label %54, label %95

54:                                               ; preds = %43
  br label %55

55:                                               ; preds = %89, %54
  %56 = load ptr, ptr %2, align 8, !tbaa !5
  %57 = getelementptr inbounds %struct.Lexer, ptr %56, i32 0, i32 3
  %58 = load i64, ptr %57, align 8, !tbaa !9
  %59 = add i64 %58, 1
  store i64 %59, ptr %57, align 8, !tbaa !9
  %60 = load ptr, ptr %2, align 8, !tbaa !5
  %61 = getelementptr inbounds %struct.Lexer, ptr %60, i32 0, i32 0
  %62 = load ptr, ptr %61, align 8, !tbaa !15
  %63 = load ptr, ptr %2, align 8, !tbaa !5
  %64 = getelementptr inbounds %struct.Lexer, ptr %63, i32 0, i32 3
  %65 = load i64, ptr %64, align 8, !tbaa !9
  %66 = getelementptr inbounds i8, ptr %62, i64 %65
  %67 = load i8, ptr %66, align 1, !tbaa !16
  store i8 %67, ptr %3, align 1, !tbaa !16
  %68 = load ptr, ptr %2, align 8, !tbaa !5
  %69 = getelementptr inbounds %struct.Lexer, ptr %68, i32 0, i32 0
  %70 = load ptr, ptr %69, align 8, !tbaa !15
  %71 = load ptr, ptr %2, align 8, !tbaa !5
  %72 = getelementptr inbounds %struct.Lexer, ptr %71, i32 0, i32 3
  %73 = load i64, ptr %72, align 8, !tbaa !9
  %74 = add i64 %73, 1
  %75 = getelementptr inbounds i8, ptr %70, i64 %74
  %76 = load i8, ptr %75, align 1, !tbaa !16
  store i8 %76, ptr %4, align 1, !tbaa !16
  %77 = load i8, ptr %3, align 1, !tbaa !16
  %78 = sext i8 %77 to i32
  %79 = icmp eq i32 %78, 0
  br i1 %79, label %88, label %80

80:                                               ; preds = %55
  %81 = load i8, ptr %3, align 1, !tbaa !16
  %82 = sext i8 %81 to i32
  %83 = icmp eq i32 %82, 42
  br i1 %83, label %84, label %89

84:                                               ; preds = %80
  %85 = load i8, ptr %4, align 1, !tbaa !16
  %86 = sext i8 %85 to i32
  %87 = icmp eq i32 %86, 47
  br i1 %87, label %88, label %89

88:                                               ; preds = %84, %55
  br label %90

89:                                               ; preds = %84, %80
  br label %55

90:                                               ; preds = %88
  %91 = load ptr, ptr %2, align 8, !tbaa !5
  %92 = getelementptr inbounds %struct.Lexer, ptr %91, i32 0, i32 3
  %93 = load i64, ptr %92, align 8, !tbaa !9
  %94 = add i64 %93, 2
  store i64 %94, ptr %92, align 8, !tbaa !9
  br label %95

95:                                               ; preds = %90, %43
  br label %96

96:                                               ; preds = %95, %42
  call void @llvm.lifetime.end.p0(i64 1, ptr %4) #2
  call void @llvm.lifetime.end.p0(i64 1, ptr %3) #2
  ret void
}

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

; 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, !11, i64 40}
!10 = !{!"Lexer", !6, i64 0, !11, i64 8, !12, i64 16, !11, i64 40, !13, i64 48, !6, i64 56, !12, i64 64, !11, i64 88, !14, i64 96}
!11 = !{!"long", !7, i64 0}
!12 = !{!"CharBuffer", !6, i64 0, !11, i64 8, !11, i64 16}
!13 = !{!"int", !7, i64 0}
!14 = !{!"_Bool", !7, i64 0}
!15 = !{!10, !6, i64 0}
!16 = !{!7, !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: nofree norecurse nosync nounwind memory(read, argmem: readwrite, inaccessiblemem: none) uwtable
define dso_local void @handle_comments(ptr nocapture noundef %0) local_unnamed_addr #0 {
  %2 = getelementptr inbounds i8, ptr %0, i64 40
  %3 = load i64, ptr %2, align 8, !tbaa !5
  %4 = add i64 %3, 1
  store i64 %4, ptr %2, align 8, !tbaa !5
  %5 = load ptr, ptr %0, align 8, !tbaa !14
  %6 = getelementptr inbounds i8, ptr %5, i64 %4
  %7 = load i8, ptr %6, align 1, !tbaa !15
  switch i8 %7, label %.loopexit [
    i8 47, label %.preheader
    i8 42, label %.preheader24
  ]

.preheader24:                                     ; preds = %1
  %invariant.gep = getelementptr i8, ptr %5, i64 2
  br label %12

.preheader:                                       ; preds = %1, %.preheader
  %8 = phi i64 [ %9, %.preheader ], [ %4, %1 ]
  %9 = add i64 %8, 1
  store i64 %9, ptr %2, align 8, !tbaa !5
  %10 = getelementptr inbounds i8, ptr %5, i64 %9
  %11 = load i8, ptr %10, align 1, !tbaa !15
  switch i8 %11, label %.preheader [
    i8 10, label %.loopexit
    i8 0, label %.loopexit
  ]

12:                                               ; preds = %.preheader24, %18
  %13 = phi i64 [ %4, %.preheader24 ], [ %14, %18 ]
  %14 = add i64 %13, 1
  store i64 %14, ptr %2, align 8, !tbaa !5
  %15 = getelementptr inbounds i8, ptr %5, i64 %14
  %16 = load i8, ptr %15, align 1, !tbaa !15
  %17 = icmp eq i8 %16, 0
  br i1 %17, label %22, label %18

18:                                               ; preds = %12
  %gep = getelementptr i8, ptr %invariant.gep, i64 %13
  %19 = load i8, ptr %gep, align 1, !tbaa !15
  %20 = icmp eq i8 %16, 42
  %21 = icmp eq i8 %19, 47
  %or.cond5 = select i1 %20, i1 %21, i1 false
  br i1 %or.cond5, label %22, label %12

22:                                               ; preds = %12, %18
  %23 = add i64 %13, 3
  store i64 %23, ptr %2, align 8, !tbaa !5
  br label %.loopexit

.loopexit:                                        ; preds = %.preheader, %.preheader, %1, %22
  ret void
}

attributes #0 = { nofree norecurse nosync nounwind memory(read, argmem: readwrite, inaccessiblemem: 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, !10, i64 40}
!6 = !{!"Lexer", !7, i64 0, !10, i64 8, !11, i64 16, !10, i64 40, !12, i64 48, !7, i64 56, !11, i64 64, !10, i64 88, !13, i64 96}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"long", !8, i64 0}
!11 = !{!"CharBuffer", !7, i64 0, !10, i64 8, !10, i64 16}
!12 = !{!"int", !8, i64 0}
!13 = !{!"_Bool", !8, i64 0}
!14 = !{!6, !7, i64 0}
!15 = !{!8, !8, i64 0}


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