; LLVM IR from ponylang/ponyc :: src/libponyc/ast (lexer)

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

@abstract = external hidden constant [72 x %struct.lextoken_t], align 16
@keywords = external hidden constant [78 x %struct.lextoken_t], align 16
@symbols = external hidden constant [60 x %struct.lextoken_t], align 16

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

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

; Function Attrs: nounwind uwtable
define dso_local ptr @lexer_print(i32 noundef %0) #1 {
  %2 = alloca ptr, align 8
  %3 = alloca i32, align 4
  %4 = alloca ptr, align 8
  %5 = alloca i32, align 4
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  store i32 %0, ptr %3, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #2
  store ptr @abstract, ptr %4, align 8, !tbaa !9
  br label %8

8:                                                ; preds = %25, %1
  %9 = load ptr, ptr %4, align 8, !tbaa !9
  %10 = getelementptr inbounds %struct.lextoken_t, ptr %9, i32 0, i32 0
  %11 = load ptr, ptr %10, align 8, !tbaa !11
  %12 = icmp ne ptr %11, null
  br i1 %12, label %14, label %13

13:                                               ; preds = %8
  store i32 2, ptr %5, align 4
  br label %28

14:                                               ; preds = %8
  %15 = load i32, ptr %3, align 4, !tbaa !5
  %16 = load ptr, ptr %4, align 8, !tbaa !9
  %17 = getelementptr inbounds %struct.lextoken_t, ptr %16, i32 0, i32 1
  %18 = load i32, ptr %17, align 8, !tbaa !13
  %19 = icmp eq i32 %15, %18
  br i1 %19, label %20, label %24

20:                                               ; preds = %14
  %21 = load ptr, ptr %4, align 8, !tbaa !9
  %22 = getelementptr inbounds %struct.lextoken_t, ptr %21, i32 0, i32 0
  %23 = load ptr, ptr %22, align 8, !tbaa !11
  store ptr %23, ptr %2, align 8
  store i32 1, ptr %5, align 4
  br label %28

24:                                               ; preds = %14
  br label %25

25:                                               ; preds = %24
  %26 = load ptr, ptr %4, align 8, !tbaa !9
  %27 = getelementptr inbounds %struct.lextoken_t, ptr %26, i32 1
  store ptr %27, ptr %4, align 8, !tbaa !9
  br label %8, !llvm.loop !14

28:                                               ; preds = %20, %13
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #2
  %29 = load i32, ptr %5, align 4
  switch i32 %29, label %79 [
    i32 2, label %30
    i32 1, label %77
  ]

30:                                               ; preds = %28
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #2
  store ptr @keywords, ptr %6, align 8, !tbaa !9
  br label %31

31:                                               ; preds = %48, %30
  %32 = load ptr, ptr %6, align 8, !tbaa !9
  %33 = getelementptr inbounds %struct.lextoken_t, ptr %32, i32 0, i32 0
  %34 = load ptr, ptr %33, align 8, !tbaa !11
  %35 = icmp ne ptr %34, null
  br i1 %35, label %37, label %36

36:                                               ; preds = %31
  store i32 5, ptr %5, align 4
  br label %51

37:                                               ; preds = %31
  %38 = load i32, ptr %3, align 4, !tbaa !5
  %39 = load ptr, ptr %6, align 8, !tbaa !9
  %40 = getelementptr inbounds %struct.lextoken_t, ptr %39, i32 0, i32 1
  %41 = load i32, ptr %40, align 8, !tbaa !13
  %42 = icmp eq i32 %38, %41
  br i1 %42, label %43, label %47

43:                                               ; preds = %37
  %44 = load ptr, ptr %6, align 8, !tbaa !9
  %45 = getelementptr inbounds %struct.lextoken_t, ptr %44, i32 0, i32 0
  %46 = load ptr, ptr %45, align 8, !tbaa !11
  store ptr %46, ptr %2, align 8
  store i32 1, ptr %5, align 4
  br label %51

47:                                               ; preds = %37
  br label %48

48:                                               ; preds = %47
  %49 = load ptr, ptr %6, align 8, !tbaa !9
  %50 = getelementptr inbounds %struct.lextoken_t, ptr %49, i32 1
  store ptr %50, ptr %6, align 8, !tbaa !9
  br label %31, !llvm.loop !16

51:                                               ; preds = %43, %36
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #2
  %52 = load i32, ptr %5, align 4
  switch i32 %52, label %79 [
    i32 5, label %53
    i32 1, label %77
  ]

53:                                               ; preds = %51
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #2
  store ptr @symbols, ptr %7, align 8, !tbaa !9
  br label %54

54:                                               ; preds = %71, %53
  %55 = load ptr, ptr %7, align 8, !tbaa !9
  %56 = getelementptr inbounds %struct.lextoken_t, ptr %55, i32 0, i32 0
  %57 = load ptr, ptr %56, align 8, !tbaa !11
  %58 = icmp ne ptr %57, null
  br i1 %58, label %60, label %59

59:                                               ; preds = %54
  store i32 8, ptr %5, align 4
  br label %74

60:                                               ; preds = %54
  %61 = load i32, ptr %3, align 4, !tbaa !5
  %62 = load ptr, ptr %7, align 8, !tbaa !9
  %63 = getelementptr inbounds %struct.lextoken_t, ptr %62, i32 0, i32 1
  %64 = load i32, ptr %63, align 8, !tbaa !13
  %65 = icmp eq i32 %61, %64
  br i1 %65, label %66, label %70

66:                                               ; preds = %60
  %67 = load ptr, ptr %7, align 8, !tbaa !9
  %68 = getelementptr inbounds %struct.lextoken_t, ptr %67, i32 0, i32 0
  %69 = load ptr, ptr %68, align 8, !tbaa !11
  store ptr %69, ptr %2, align 8
  store i32 1, ptr %5, align 4
  br label %74

70:                                               ; preds = %60
  br label %71

71:                                               ; preds = %70
  %72 = load ptr, ptr %7, align 8, !tbaa !9
  %73 = getelementptr inbounds %struct.lextoken_t, ptr %72, i32 1
  store ptr %73, ptr %7, align 8, !tbaa !9
  br label %54, !llvm.loop !17

74:                                               ; preds = %66, %59
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #2
  %75 = load i32, ptr %5, align 4
  switch i32 %75, label %79 [
    i32 8, label %76
    i32 1, label %77
  ]

76:                                               ; preds = %74
  store ptr null, ptr %2, align 8
  br label %77

77:                                               ; preds = %76, %74, %51, %28
  %78 = load ptr, ptr %2, align 8
  ret ptr %78

79:                                               ; preds = %74, %51, %28
  unreachable
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"any pointer", !7, i64 0}
!11 = !{!12, !10, i64 0}
!12 = !{!"lextoken_t", !10, i64 0, !6, i64 8}
!13 = !{!12, !6, i64 8}
!14 = distinct !{!14, !15}
!15 = !{!"llvm.loop.mustprogress"}
!16 = distinct !{!16, !15}
!17 = distinct !{!17, !15}


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

@abstract = external hidden local_unnamed_addr constant [72 x %struct.lextoken_t], align 16
@keywords = external hidden local_unnamed_addr constant [78 x %struct.lextoken_t], align 16
@symbols = external hidden local_unnamed_addr constant [60 x %struct.lextoken_t], align 16

; Function Attrs: nofree norecurse nosync nounwind memory(none) uwtable
define dso_local ptr @lexer_print(i32 noundef %0) local_unnamed_addr #0 {
  %2 = load ptr, ptr @abstract, align 16, !tbaa !5
  %.not45 = icmp eq ptr %2, null
  br i1 %.not45, label %.preheader40, label %.lr.ph.preheader

.lr.ph.preheader:                                 ; preds = %1
  %3 = load i32, ptr getelementptr inbounds (i8, ptr @abstract, i64 8), align 8, !tbaa !11
  %4 = icmp eq i32 %3, %0
  br i1 %4, label %.thread, label %.lr.ph71

.lr.ph71:                                         ; preds = %.lr.ph.preheader, %.lr.ph
  %.0204670 = phi ptr [ %5, %.lr.ph ], [ @abstract, %.lr.ph.preheader ]
  %5 = getelementptr inbounds i8, ptr %.0204670, i64 16
  %6 = load ptr, ptr %5, align 8, !tbaa !5
  %.not = icmp eq ptr %6, null
  br i1 %.not, label %.preheader40, label %.lr.ph, !llvm.loop !12

.preheader40:                                     ; preds = %.lr.ph71, %1
  %7 = load ptr, ptr @keywords, align 16, !tbaa !5
  %.not2647 = icmp eq ptr %7, null
  br i1 %.not2647, label %.preheader, label %.lr.ph49.preheader

.lr.ph49.preheader:                               ; preds = %.preheader40
  %8 = load i32, ptr getelementptr inbounds (i8, ptr @keywords, i64 8), align 8, !tbaa !11
  %9 = icmp eq i32 %8, %0
  br i1 %9, label %.thread, label %.lr.ph73

.lr.ph:                                           ; preds = %.lr.ph71
  %10 = getelementptr inbounds i8, ptr %.0204670, i64 24
  %11 = load i32, ptr %10, align 8, !tbaa !11
  %12 = icmp eq i32 %11, %0
  br i1 %12, label %.thread, label %.lr.ph71, !llvm.loop !12

.lr.ph73:                                         ; preds = %.lr.ph49.preheader, %.lr.ph49
  %.0184872 = phi ptr [ %13, %.lr.ph49 ], [ @keywords, %.lr.ph49.preheader ]
  %13 = getelementptr inbounds i8, ptr %.0184872, i64 16
  %14 = load ptr, ptr %13, align 8, !tbaa !5
  %.not26 = icmp eq ptr %14, null
  br i1 %.not26, label %.preheader, label %.lr.ph49, !llvm.loop !14

.preheader:                                       ; preds = %.lr.ph73, %.preheader40
  %15 = load ptr, ptr @symbols, align 16, !tbaa !5
  %.not2750 = icmp eq ptr %15, null
  br i1 %.not2750, label %.thread, label %.lr.ph52.preheader

.lr.ph52.preheader:                               ; preds = %.preheader
  %16 = load i32, ptr getelementptr inbounds (i8, ptr @symbols, i64 8), align 8, !tbaa !11
  %17 = icmp eq i32 %16, %0
  br i1 %17, label %.thread, label %.lr.ph76

.lr.ph49:                                         ; preds = %.lr.ph73
  %18 = getelementptr inbounds i8, ptr %.0184872, i64 24
  %19 = load i32, ptr %18, align 8, !tbaa !11
  %20 = icmp eq i32 %19, %0
  br i1 %20, label %.thread, label %.lr.ph73, !llvm.loop !14

.lr.ph76:                                         ; preds = %.lr.ph52.preheader, %.lr.ph52
  %.05175 = phi ptr [ %21, %.lr.ph52 ], [ @symbols, %.lr.ph52.preheader ]
  %21 = getelementptr inbounds i8, ptr %.05175, i64 16
  %22 = load ptr, ptr %21, align 8, !tbaa !5
  %.not27 = icmp eq ptr %22, null
  br i1 %.not27, label %.thread, label %.lr.ph52, !llvm.loop !15

.lr.ph52:                                         ; preds = %.lr.ph76
  %23 = getelementptr inbounds i8, ptr %.05175, i64 24
  %24 = load i32, ptr %23, align 8, !tbaa !11
  %25 = icmp eq i32 %24, %0
  br i1 %25, label %.thread, label %.lr.ph76, !llvm.loop !15

.thread:                                          ; preds = %.lr.ph, %.lr.ph49, %.lr.ph76, %.lr.ph52, %.lr.ph.preheader, %.lr.ph49.preheader, %.lr.ph52.preheader, %.preheader
  %.3 = phi ptr [ null, %.preheader ], [ %15, %.lr.ph52.preheader ], [ %7, %.lr.ph49.preheader ], [ %2, %.lr.ph.preheader ], [ %22, %.lr.ph52 ], [ null, %.lr.ph76 ], [ %14, %.lr.ph49 ], [ %6, %.lr.ph ]
  ret ptr %.3
}

attributes #0 = { nofree norecurse nosync nounwind memory(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, !7, i64 0}
!6 = !{!"lextoken_t", !7, i64 0, !10, i64 8}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"int", !8, i64 0}
!11 = !{!6, !10, i64 8}
!12 = distinct !{!12, !13}
!13 = !{!"llvm.loop.mustprogress"}
!14 = distinct !{!14, !13}
!15 = distinct !{!15, !13}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass