; 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.lexer_t = type { ptr, ptr, i8, i64, i64, i64, i64, i8, i64, i64, ptr, i64, i64 }

@.str.1 = external hidden unnamed_addr constant [73 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [14 x i8], align 1
@__func__.lexer_next = external hidden unnamed_addr constant [11 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [10 x i8], align 1

declare void @ponyint_assert_fail(ptr noundef, ptr noundef, i64 noundef, 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: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1

; Function Attrs: nounwind uwtable
define dso_local ptr @lexer_next(ptr noundef %0) #2 {
  %2 = alloca ptr, align 8
  %3 = alloca ptr, align 8
  %4 = alloca i8, align 1
  store ptr %0, ptr %2, align 8, !tbaa !5
  %5 = load ptr, ptr %2, align 8, !tbaa !5
  %6 = icmp ne ptr %5, null
  br i1 %6, label %7, label %8

7:                                                ; preds = %1
  br label %9

8:                                                ; preds = %1
  call void @ponyint_assert_fail(ptr noundef @.str.2, ptr noundef @.str.1, i64 noundef 1294, ptr noundef @__func__.lexer_next)
  br label %9

9:                                                ; preds = %8, %7
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #4
  store ptr null, ptr %3, align 8, !tbaa !5
  br label %10

10:                                               ; preds = %99, %9
  %11 = load ptr, ptr %3, align 8, !tbaa !5
  %12 = icmp eq ptr %11, null
  br i1 %12, label %13, label %100

13:                                               ; preds = %10
  %14 = load ptr, ptr %2, align 8, !tbaa !5
  %15 = getelementptr inbounds %struct.lexer_t, ptr %14, i32 0, i32 5
  %16 = load i64, ptr %15, align 8, !tbaa !9
  %17 = load ptr, ptr %2, align 8, !tbaa !5
  %18 = getelementptr inbounds %struct.lexer_t, ptr %17, i32 0, i32 8
  store i64 %16, ptr %18, align 8, !tbaa !13
  %19 = load ptr, ptr %2, align 8, !tbaa !5
  %20 = getelementptr inbounds %struct.lexer_t, ptr %19, i32 0, i32 6
  %21 = load i64, ptr %20, align 8, !tbaa !14
  %22 = load ptr, ptr %2, align 8, !tbaa !5
  %23 = getelementptr inbounds %struct.lexer_t, ptr %22, i32 0, i32 9
  store i64 %21, ptr %23, align 8, !tbaa !15
  %24 = load ptr, ptr %2, align 8, !tbaa !5
  %25 = getelementptr inbounds %struct.lexer_t, ptr %24, i32 0, i32 11
  store i64 0, ptr %25, align 8, !tbaa !16
  %26 = load ptr, ptr %2, align 8, !tbaa !5
  %27 = call zeroext i1 @is_eof(ptr noundef %26)
  br i1 %27, label %28, label %31

28:                                               ; preds = %13
  %29 = load ptr, ptr %2, align 8, !tbaa !5
  %30 = call ptr @make_token(ptr noundef %29, i32 noundef 0)
  store ptr %30, ptr %3, align 8, !tbaa !5
  br label %100

31:                                               ; preds = %13
  call void @llvm.lifetime.start.p0(i64 1, ptr %4) #4
  %32 = load ptr, ptr %2, align 8, !tbaa !5
  %33 = call signext i8 @look(ptr noundef %32)
  store i8 %33, ptr %4, align 1, !tbaa !17
  %34 = load i8, ptr %4, align 1, !tbaa !17
  %35 = sext i8 %34 to i32
  switch i32 %35, label %57 [
    i32 10, label %36
    i32 13, label %40
    i32 9, label %40
    i32 32, label %40
    i32 47, label %42
    i32 34, label %45
    i32 39, label %48
    i32 35, label %51
    i32 36, label %54
  ]

36:                                               ; preds = %31
  %37 = load ptr, ptr %2, align 8, !tbaa !5
  %38 = getelementptr inbounds %struct.lexer_t, ptr %37, i32 0, i32 7
  store i8 1, ptr %38, align 8, !tbaa !18
  %39 = load ptr, ptr %2, align 8, !tbaa !5
  call void @consume_chars(ptr noundef %39, i64 noundef 1)
  br label %99

40:                                               ; preds = %31, %31, %31
  %41 = load ptr, ptr %2, align 8, !tbaa !5
  call void @consume_chars(ptr noundef %41, i64 noundef 1)
  br label %99

42:                                               ; preds = %31
  %43 = load ptr, ptr %2, align 8, !tbaa !5
  %44 = call ptr @slash(ptr noundef %43)
  store ptr %44, ptr %3, align 8, !tbaa !5
  br label %99

45:                                               ; preds = %31
  %46 = load ptr, ptr %2, align 8, !tbaa !5
  %47 = call ptr @string(ptr noundef %46)
  store ptr %47, ptr %3, align 8, !tbaa !5
  br label %99

48:                                               ; preds = %31
  %49 = load ptr, ptr %2, align 8, !tbaa !5
  %50 = call ptr @character(ptr noundef %49)
  store ptr %50, ptr %3, align 8, !tbaa !5
  br label %99

51:                                               ; preds = %31
  %52 = load ptr, ptr %2, align 8, !tbaa !5
  %53 = call ptr @hash(ptr noundef %52)
  store ptr %53, ptr %3, align 8, !tbaa !5
  br label %99

54:                                               ; preds = %31
  %55 = load ptr, ptr %2, align 8, !tbaa !5
  %56 = call ptr @dollar(ptr noundef %55)
  store ptr %56, ptr %3, align 8, !tbaa !5
  br label %99

57:                                               ; preds = %31
  %58 = call ptr @__ctype_b_loc() #5
  %59 = load ptr, ptr %58, align 8, !tbaa !5
  %60 = load i8, ptr %4, align 1, !tbaa !17
  %61 = sext i8 %60 to i32
  %62 = sext i32 %61 to i64
  %63 = getelementptr inbounds i16, ptr %59, i64 %62
  %64 = load i16, ptr %63, align 2, !tbaa !19
  %65 = zext i16 %64 to i32
  %66 = and i32 %65, 2048
  %67 = icmp ne i32 %66, 0
  br i1 %67, label %68, label %71

68:                                               ; preds = %57
  %69 = load ptr, ptr %2, align 8, !tbaa !5
  %70 = call ptr @number(ptr noundef %69)
  store ptr %70, ptr %3, align 8, !tbaa !5
  br label %98

71:                                               ; preds = %57
  %72 = call ptr @__ctype_b_loc() #5
  %73 = load ptr, ptr %72, align 8, !tbaa !5
  %74 = load i8, ptr %4, align 1, !tbaa !17
  %75 = sext i8 %74 to i32
  %76 = sext i32 %75 to i64
  %77 = getelementptr inbounds i16, ptr %73, i64 %76
  %78 = load i16, ptr %77, align 2, !tbaa !19
  %79 = zext i16 %78 to i32
  %80 = and i32 %79, 1024
  %81 = icmp ne i32 %80, 0
  br i1 %81, label %86, label %82

82:                                               ; preds = %71
  %83 = load i8, ptr %4, align 1, !tbaa !17
  %84 = sext i8 %83 to i32
  %85 = icmp eq i32 %84, 95
  br i1 %85, label %86, label %94

86:                                               ; preds = %82, %71
  %87 = load ptr, ptr %2, align 8, !tbaa !5
  %88 = call ptr @keyword(ptr noundef %87, i1 noundef zeroext true)
  store ptr %88, ptr %3, align 8, !tbaa !5
  %89 = load ptr, ptr %3, align 8, !tbaa !5
  %90 = icmp ne ptr %89, null
  br i1 %90, label %91, label %92

91:                                               ; preds = %86
  br label %93

92:                                               ; preds = %86
  call void @ponyint_assert_fail(ptr noundef @.str.3, ptr noundef @.str.1, i64 noundef 1353, ptr noundef @__func__.lexer_next)
  br label %93

93:                                               ; preds = %92, %91
  br label %97

94:                                               ; preds = %82
  %95 = load ptr, ptr %2, align 8, !tbaa !5
  %96 = call ptr @symbol(ptr noundef %95)
  store ptr %96, ptr %3, align 8, !tbaa !5
  br label %97

97:                                               ; preds = %94, %93
  br label %98

98:                                               ; preds = %97, %68
  br label %99

99:                                               ; preds = %98, %54, %51, %48, %45, %42, %40, %36
  call void @llvm.lifetime.end.p0(i64 1, ptr %4) #4
  br label %10, !llvm.loop !21

100:                                              ; preds = %28, %10
  %101 = load ptr, ptr %2, align 8, !tbaa !5
  %102 = getelementptr inbounds %struct.lexer_t, ptr %101, i32 0, i32 7
  store i8 0, ptr %102, align 8, !tbaa !18
  %103 = load ptr, ptr %3, align 8, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #4
  ret ptr %103
}

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

; Function Attrs: nounwind uwtable
declare hidden ptr @make_token(ptr noundef, i32 noundef) #2

; Function Attrs: nounwind uwtable
declare hidden signext i8 @look(ptr noundef) #2

; Function Attrs: nounwind uwtable
declare hidden void @consume_chars(ptr noundef, i64 noundef) #2

; Function Attrs: nounwind uwtable
declare hidden ptr @slash(ptr noundef) #2

; Function Attrs: nounwind uwtable
declare hidden ptr @string(ptr noundef) #2

; Function Attrs: nounwind uwtable
declare hidden ptr @character(ptr noundef) #2

; Function Attrs: nounwind uwtable
declare hidden ptr @hash(ptr noundef) #2

; Function Attrs: nounwind uwtable
declare hidden ptr @dollar(ptr noundef) #2

; Function Attrs: nounwind willreturn memory(none)
declare ptr @__ctype_b_loc() #3

; Function Attrs: nounwind uwtable
declare hidden ptr @number(ptr noundef) #2

; Function Attrs: nounwind uwtable
declare hidden ptr @keyword(ptr noundef, i1 noundef zeroext) #2

; Function Attrs: nounwind uwtable
declare hidden ptr @symbol(ptr noundef) #2

attributes #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 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 #3 = { nounwind willreturn memory(none) "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 #4 = { nounwind }
attributes #5 = { nounwind willreturn memory(none) }

!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, !12, i64 40}
!10 = !{!"lexer_t", !6, i64 0, !6, i64 8, !11, i64 16, !12, i64 24, !12, i64 32, !12, i64 40, !12, i64 48, !11, i64 56, !12, i64 64, !12, i64 72, !6, i64 80, !12, i64 88, !12, i64 96}
!11 = !{!"_Bool", !7, i64 0}
!12 = !{!"long", !7, i64 0}
!13 = !{!10, !12, i64 64}
!14 = !{!10, !12, i64 48}
!15 = !{!10, !12, i64 72}
!16 = !{!10, !12, i64 88}
!17 = !{!7, !7, i64 0}
!18 = !{!10, !11, i64 56}
!19 = !{!20, !20, i64 0}
!20 = !{!"short", !7, i64 0}
!21 = distinct !{!21, !22}
!22 = !{!"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"

@.str.1 = external hidden unnamed_addr constant [73 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [14 x i8], align 1
@__func__.lexer_next = external hidden unnamed_addr constant [11 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [10 x i8], align 1

declare void @ponyint_assert_fail(ptr noundef, ptr noundef, i64 noundef, ptr noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local ptr @lexer_next(ptr noundef %0) local_unnamed_addr #1 {
  %.not = icmp eq ptr %0, null
  br i1 %.not, label %2, label %3

2:                                                ; preds = %1
  tail call void @ponyint_assert_fail(ptr noundef nonnull @.str.2, ptr noundef nonnull @.str.1, i64 noundef 1294, ptr noundef nonnull @__func__.lexer_next) #3
  br label %3

3:                                                ; preds = %1, %2
  %4 = getelementptr inbounds i8, ptr %0, i64 40
  %5 = getelementptr inbounds i8, ptr %0, i64 64
  %6 = getelementptr inbounds i8, ptr %0, i64 88
  %7 = getelementptr inbounds i8, ptr %0, i64 56
  br label %8

8:                                                ; preds = %3, %46
  %9 = load <2 x i64>, ptr %4, align 8, !tbaa !5
  store <2 x i64> %9, ptr %5, align 8, !tbaa !5
  store i64 0, ptr %6, align 8, !tbaa !9
  %10 = tail call zeroext i1 @is_eof(ptr noundef %0)
  br i1 %10, label %11, label %13

11:                                               ; preds = %8
  %12 = tail call ptr @make_token(ptr noundef nonnull %0, i32 noundef 0)
  br label %.loopexit

13:                                               ; preds = %8
  %14 = tail call signext i8 @look(ptr noundef nonnull %0)
  switch i8 %14, label %27 [
    i8 10, label %15
    i8 13, label %16
    i8 9, label %16
    i8 32, label %16
    i8 47, label %17
    i8 34, label %19
    i8 39, label %21
    i8 35, label %23
    i8 36, label %25
  ]

15:                                               ; preds = %13
  store i8 1, ptr %7, align 8, !tbaa !13
  tail call void @consume_chars(ptr noundef nonnull %0, i64 noundef 1)
  br label %46

16:                                               ; preds = %13, %13, %13
  tail call void @consume_chars(ptr noundef nonnull %0, i64 noundef 1)
  br label %46

17:                                               ; preds = %13
  %18 = tail call ptr @slash(ptr noundef nonnull %0)
  br label %46

19:                                               ; preds = %13
  %20 = tail call ptr @string(ptr noundef nonnull %0)
  br label %46

21:                                               ; preds = %13
  %22 = tail call ptr @character(ptr noundef nonnull %0)
  br label %46

23:                                               ; preds = %13
  %24 = tail call ptr @hash(ptr noundef nonnull %0)
  br label %46

25:                                               ; preds = %13
  %26 = tail call ptr @dollar(ptr noundef nonnull %0)
  br label %46

27:                                               ; preds = %13
  %28 = tail call ptr @__ctype_b_loc() #4
  %29 = load ptr, ptr %28, align 8, !tbaa !14
  %30 = sext i8 %14 to i64
  %31 = getelementptr inbounds i16, ptr %29, i64 %30
  %32 = load i16, ptr %31, align 2, !tbaa !15
  %33 = zext i16 %32 to i32
  %34 = and i32 %33, 2048
  %.not31 = icmp eq i32 %34, 0
  br i1 %.not31, label %37, label %35

35:                                               ; preds = %27
  %36 = tail call ptr @number(ptr noundef nonnull %0)
  br label %46

37:                                               ; preds = %27
  %38 = and i32 %33, 1024
  %39 = icmp ne i32 %38, 0
  %40 = icmp eq i8 %14, 95
  %or.cond = or i1 %40, %39
  br i1 %or.cond, label %41, label %44

41:                                               ; preds = %37
  %42 = tail call ptr @keyword(ptr noundef nonnull %0, i1 noundef zeroext true)
  %.not32 = icmp eq ptr %42, null
  br i1 %.not32, label %43, label %.loopexit

43:                                               ; preds = %41
  tail call void @ponyint_assert_fail(ptr noundef nonnull @.str.3, ptr noundef nonnull @.str.1, i64 noundef 1353, ptr noundef nonnull @__func__.lexer_next) #3
  br label %46

44:                                               ; preds = %37
  %45 = tail call ptr @symbol(ptr noundef nonnull %0)
  br label %46

46:                                               ; preds = %35, %43, %44, %25, %23, %21, %19, %17, %16, %15
  %.1 = phi ptr [ %36, %35 ], [ null, %43 ], [ %45, %44 ], [ %26, %25 ], [ %24, %23 ], [ %22, %21 ], [ %20, %19 ], [ %18, %17 ], [ null, %16 ], [ null, %15 ]
  %47 = icmp eq ptr %.1, null
  br i1 %47, label %8, label %.loopexit, !llvm.loop !17

.loopexit:                                        ; preds = %41, %46, %11
  %.2 = phi ptr [ %12, %11 ], [ %42, %41 ], [ %.1, %46 ]
  store i8 0, ptr %7, align 8, !tbaa !13
  ret ptr %.2
}

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

; Function Attrs: nounwind uwtable
declare hidden ptr @make_token(ptr noundef, i32 noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
declare hidden signext i8 @look(ptr noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
declare hidden void @consume_chars(ptr noundef, i64 noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
declare hidden ptr @slash(ptr noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
declare hidden ptr @string(ptr noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
declare hidden ptr @character(ptr noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
declare hidden ptr @hash(ptr noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
declare hidden ptr @dollar(ptr noundef) local_unnamed_addr #1

; Function Attrs: mustprogress nofree nosync nounwind willreturn memory(none)
declare ptr @__ctype_b_loc() local_unnamed_addr #2

; Function Attrs: nounwind uwtable
declare hidden ptr @number(ptr noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
declare hidden ptr @keyword(ptr noundef, i1 noundef zeroext) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
declare hidden ptr @symbol(ptr noundef) local_unnamed_addr #1

attributes #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 = { 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 = { mustprogress nofree nosync nounwind willreturn memory(none) "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 #3 = { nounwind }
attributes #4 = { nounwind willreturn memory(none) }

!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 = !{!"long", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !6, i64 88}
!10 = !{!"lexer_t", !11, i64 0, !11, i64 8, !12, i64 16, !6, i64 24, !6, i64 32, !6, i64 40, !6, i64 48, !12, i64 56, !6, i64 64, !6, i64 72, !11, i64 80, !6, i64 88, !6, i64 96}
!11 = !{!"any pointer", !7, i64 0}
!12 = !{!"_Bool", !7, i64 0}
!13 = !{!10, !12, i64 56}
!14 = !{!11, !11, i64 0}
!15 = !{!16, !16, i64 0}
!16 = !{!"short", !7, i64 0}
!17 = distinct !{!17, !18}
!18 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LCSSAPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,ReassociatePass,SLPVectorizerPass,SROAPass,SimplifyCFGPass,TailCallElimPass