; LLVM IR from evanxg852000/rockstartdev :: clox (compiler)

; 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.Parser = type { %struct.Token, %struct.Token, i8, i8 }
%struct.Token = type { i32, ptr, i32, i32 }
%struct.Compiler = type { ptr, ptr, i32, [256 x %struct.Local], i32, [256 x %struct.Upvalue], i32 }
%struct.Local = type { %struct.Token, i32, i8 }
%struct.Upvalue = type { i8, i8 }

@parser = external dso_local global %struct.Parser, align 8

; Function Attrs: nounwind uwtable
define dso_local ptr @compile(ptr noundef %0) #0 {
  %2 = alloca ptr, align 8
  %3 = alloca %struct.Compiler, align 8
  %4 = alloca ptr, align 8
  store ptr %0, ptr %2, align 8, !tbaa !5
  %5 = load ptr, ptr %2, align 8, !tbaa !5
  call void @initScanner(ptr noundef %5)
  call void @llvm.lifetime.start.p0(i64 8736, ptr %3) #3
  call void @initCompiler(ptr noundef %3, i32 noundef 3)
  store i8 0, ptr getelementptr inbounds (%struct.Parser, ptr @parser, i32 0, i32 2), align 8, !tbaa !9
  store i8 0, ptr getelementptr inbounds (%struct.Parser, ptr @parser, i32 0, i32 3), align 1, !tbaa !14
  call void @advance()
  br label %6

6:                                                ; preds = %9, %1
  %7 = call zeroext i1 @match(i32 noundef 39)
  %8 = xor i1 %7, true
  br i1 %8, label %9, label %10

9:                                                ; preds = %6
  call void @declaration()
  br label %6, !llvm.loop !15

10:                                               ; preds = %6
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #3
  %11 = call ptr @endCompiler()
  store ptr %11, ptr %4, align 8, !tbaa !5
  %12 = load i8, ptr getelementptr inbounds (%struct.Parser, ptr @parser, i32 0, i32 2), align 8, !tbaa !9, !range !17, !noundef !18
  %13 = trunc i8 %12 to i1
  br i1 %13, label %14, label %15

14:                                               ; preds = %10
  br label %17

15:                                               ; preds = %10
  %16 = load ptr, ptr %4, align 8, !tbaa !5
  br label %17

17:                                               ; preds = %15, %14
  %18 = phi ptr [ null, %14 ], [ %16, %15 ]
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #3
  call void @llvm.lifetime.end.p0(i64 8736, ptr %3) #3
  ret ptr %18
}

declare void @initScanner(ptr noundef) #1

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

; Function Attrs: nounwind uwtable
declare hidden void @initCompiler(ptr noundef, i32 noundef) #0

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

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

; Function Attrs: nounwind uwtable
declare hidden void @advance() #0

; Function Attrs: nounwind uwtable
declare hidden void @declaration() #0

; Function Attrs: nounwind uwtable
declare hidden ptr @endCompiler() #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" }
attributes #1 = { "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 #2 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { 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, !13, i64 48}
!10 = !{!"", !11, i64 0, !11, i64 24, !13, i64 48, !13, i64 49}
!11 = !{!"", !12, i64 0, !6, i64 8, !12, i64 16, !12, i64 20}
!12 = !{!"int", !7, i64 0}
!13 = !{!"_Bool", !7, i64 0}
!14 = !{!10, !13, i64 49}
!15 = distinct !{!15, !16}
!16 = !{!"llvm.loop.mustprogress"}
!17 = !{i8 0, i8 2}
!18 = !{}


; 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.Parser = type { %struct.Token, %struct.Token, i8, i8 }
%struct.Token = type { i32, ptr, i32, i32 }
%struct.Compiler = type { ptr, ptr, i32, [256 x %struct.Local], i32, [256 x %struct.Upvalue], i32 }
%struct.Local = type { %struct.Token, i32, i8 }
%struct.Upvalue = type { i8, i8 }

@parser = external dso_local local_unnamed_addr global %struct.Parser, align 8

; Function Attrs: nounwind uwtable
define dso_local ptr @compile(ptr noundef %0) local_unnamed_addr #0 {
  %2 = alloca %struct.Compiler, align 8
  tail call void @initScanner(ptr noundef %0) #3
  call void @llvm.lifetime.start.p0(i64 8736, ptr nonnull %2) #3
  call void @initCompiler(ptr noundef nonnull %2, i32 noundef 3)
  store i8 0, ptr getelementptr inbounds (i8, ptr @parser, i64 48), align 8, !tbaa !5
  store i8 0, ptr getelementptr inbounds (i8, ptr @parser, i64 49), align 1, !tbaa !13
  call void @advance()
  %3 = call zeroext i1 @match(i32 noundef 39)
  br i1 %3, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %1, %.lr.ph
  call void @declaration()
  %4 = call zeroext i1 @match(i32 noundef 39)
  br i1 %4, label %._crit_edge, label %.lr.ph, !llvm.loop !14

._crit_edge:                                      ; preds = %.lr.ph, %1
  %5 = call ptr @endCompiler()
  %6 = load i8, ptr getelementptr inbounds (i8, ptr @parser, i64 48), align 8, !tbaa !5, !range !16, !noundef !17
  %7 = trunc nuw i8 %6 to i1
  %8 = select i1 %7, ptr null, ptr %5
  call void @llvm.lifetime.end.p0(i64 8736, ptr nonnull %2) #3
  ret ptr %8
}

declare void @initScanner(ptr noundef) local_unnamed_addr #1

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

; Function Attrs: nounwind uwtable
declare hidden void @initCompiler(ptr noundef, i32 noundef) local_unnamed_addr #0

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

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

; Function Attrs: nounwind uwtable
declare hidden void @advance() local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare hidden void @declaration() local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare hidden ptr @endCompiler() 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" }
attributes #1 = { "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 #2 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { 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, !12, i64 48}
!6 = !{!"", !7, i64 0, !7, i64 24, !12, i64 48, !12, i64 49}
!7 = !{!"", !8, i64 0, !11, i64 8, !8, i64 16, !8, i64 20}
!8 = !{!"int", !9, i64 0}
!9 = !{!"omnipotent char", !10, i64 0}
!10 = !{!"Simple C/C++ TBAA"}
!11 = !{!"any pointer", !9, i64 0}
!12 = !{!"_Bool", !9, i64 0}
!13 = !{!6, !12, i64 49}
!14 = distinct !{!14, !15}
!15 = !{!"llvm.loop.mustprogress"}
!16 = !{i8 0, i8 2}
!17 = !{}


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