; LLVM IR from thepowersgang/mrustc :: src/parse (lex)

; 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.sRWORD = type { i8, ptr, i32 }
%class.Token = type { ptr, i32, %"class.Token::Data", %class.Position, %"class.Ident::Hygiene" }
%"class.Token::Data" = type { i32, %"union.Token::Data::DataUnion" }
%"union.Token::Data::DataUnion" = type { %"class.std::__cxx11::basic_string" }
%"class.std::__cxx11::basic_string" = type { %"struct.std::__cxx11::basic_string<char>::_Alloc_hider", i64, %union.anon }
%"struct.std::__cxx11::basic_string<char>::_Alloc_hider" = type { ptr }
%union.anon = type { i64, [8 x i8] }
%class.Position = type { %struct.Span, %class.RcString, i32, i32 }
%struct.Span = type { ptr }
%class.RcString = type { ptr }
%"class.Ident::Hygiene" = type { %"class.std::unique_ptr" }
%"class.std::unique_ptr" = type { %"struct.std::__uniq_ptr_data" }
%"struct.std::__uniq_ptr_data" = type { %"class.std::__uniq_ptr_impl" }
%"class.std::__uniq_ptr_impl" = type { %"class.std::tuple" }
%"class.std::tuple" = type { %"struct.std::_Tuple_impl" }
%"struct.std::_Tuple_impl" = type { %"struct.std::_Head_base.1" }
%"struct.std::_Head_base.1" = type { ptr }

@.str.7 = external hidden unnamed_addr constant [72 x i8], align 1
@_ZL11RWORDS_2015 = external hidden constant [47 x %struct.sRWORD], align 16
@_ZL11RWORDS_2018 = external hidden constant [51 x %struct.sRWORD], align 16
@.str.56 = external hidden unnamed_addr constant [8 x i8], align 1
@__PRETTY_FUNCTION__._Z20Lex_FindReservedWordRKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEN3AST7EditionE = external hidden unnamed_addr constant [64 x i8], align 1
@.str.57 = external hidden unnamed_addr constant [11 x i8], align 1

; 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

declare void @_ZN5TokenC1E10eTokenType(ptr noundef nonnull align 8 dereferenceable(88), i32 noundef) unnamed_addr #1

; Function Attrs: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) #2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZSteqIcSt11char_traitsIcESaIcEEbRKNSt7__cxx1112basic_stringIT_T0_T1_EEPKS5_(ptr noundef nonnull align 8 dereferenceable(32), ptr noundef) #3

; Function Attrs: mustprogress uwtable
define dso_local void @_Z20Lex_FindReservedWordRKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEN3AST7EditionE(ptr dead_on_unwind noalias writable sret(%class.Token) align 8 %0, ptr noundef nonnull align 8 dereferenceable(32) %1, i32 noundef %2) #4 {
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  %7 = alloca i64, align 8
  %8 = alloca ptr, align 8
  %9 = alloca i64, align 8
  %10 = alloca i32, align 4
  %11 = alloca ptr, align 8
  store ptr %0, ptr %4, align 8
  store ptr %1, ptr %5, align 8, !tbaa !5
  store i32 %2, ptr %6, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #5
  store i64 0, ptr %7, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #5
  store ptr null, ptr %8, align 8, !tbaa !5
  %12 = load i32, ptr %6, align 4, !tbaa !9
  switch i32 %12, label %15 [
    i32 0, label %13
    i32 1, label %14
    i32 2, label %14
  ]

13:                                               ; preds = %3
  store i64 47, ptr %7, align 8, !tbaa !11
  store ptr @_ZL11RWORDS_2015, ptr %8, align 8, !tbaa !5
  br label %15

14:                                               ; preds = %3, %3
  store i64 51, ptr %7, align 8, !tbaa !11
  store ptr @_ZL11RWORDS_2018, ptr %8, align 8, !tbaa !5
  br label %15

15:                                               ; preds = %14, %13, %3
  %16 = load i64, ptr %7, align 8, !tbaa !11
  %17 = icmp ugt i64 %16, 0
  br i1 %17, label %18, label %19

18:                                               ; preds = %15
  br label %21

19:                                               ; preds = %15
  call void @__assert_fail(ptr noundef @.str.56, ptr noundef @.str.7, i32 noundef 1356, ptr noundef @__PRETTY_FUNCTION__._Z20Lex_FindReservedWordRKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEN3AST7EditionE) #6
  unreachable

20:                                               ; No predecessors!
  br label %21

21:                                               ; preds = %20, %18
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #5
  store i64 0, ptr %9, align 8, !tbaa !11
  br label %22

22:                                               ; preds = %59, %21
  %23 = load i64, ptr %9, align 8, !tbaa !11
  %24 = load i64, ptr %7, align 8, !tbaa !11
  %25 = icmp ult i64 %23, %24
  br i1 %25, label %27, label %26

26:                                               ; preds = %22
  store i32 3, ptr %10, align 4
  br label %62

27:                                               ; preds = %22
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #5
  %28 = load ptr, ptr %8, align 8, !tbaa !5
  %29 = load i64, ptr %9, align 8, !tbaa !11
  %30 = getelementptr inbounds %struct.sRWORD, ptr %28, i64 %29
  store ptr %30, ptr %11, align 8, !tbaa !5
  %31 = load ptr, ptr %5, align 8, !tbaa !5
  %32 = load ptr, ptr %11, align 8, !tbaa !5
  %33 = getelementptr inbounds %struct.sRWORD, ptr %32, i32 0, i32 1
  %34 = load ptr, ptr %33, align 8, !tbaa !13
  %35 = call noundef zeroext i1 @_ZStltIcSt11char_traitsIcESaIcEEbRKNSt7__cxx1112basic_stringIT_T0_T1_EEPKS5_(ptr noundef nonnull align 8 dereferenceable(32) %31, ptr noundef %34)
  br i1 %35, label %36, label %37

36:                                               ; preds = %27
  store i32 3, ptr %10, align 4
  br label %56

37:                                               ; preds = %27
  %38 = load ptr, ptr %5, align 8, !tbaa !5
  %39 = load ptr, ptr %11, align 8, !tbaa !5
  %40 = getelementptr inbounds %struct.sRWORD, ptr %39, i32 0, i32 1
  %41 = load ptr, ptr %40, align 8, !tbaa !13
  %42 = call noundef zeroext i1 @_ZSteqIcSt11char_traitsIcESaIcEEbRKNSt7__cxx1112basic_stringIT_T0_T1_EEPKS5_(ptr noundef nonnull align 8 dereferenceable(32) %38, ptr noundef %41)
  br i1 %42, label %43, label %55

43:                                               ; preds = %37
  %44 = load ptr, ptr %11, align 8, !tbaa !5
  %45 = getelementptr inbounds %struct.sRWORD, ptr %44, i32 0, i32 2
  %46 = load i32, ptr %45, align 8, !tbaa !16
  %47 = icmp sgt i32 %46, 0
  br i1 %47, label %48, label %49

48:                                               ; preds = %43
  br label %51

49:                                               ; preds = %43
  call void @__assert_fail(ptr noundef @.str.57, ptr noundef @.str.7, i32 noundef 1364, ptr noundef @__PRETTY_FUNCTION__._Z20Lex_FindReservedWordRKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEN3AST7EditionE) #6
  unreachable

50:                                               ; No predecessors!
  br label %51

51:                                               ; preds = %50, %48
  %52 = load ptr, ptr %11, align 8, !tbaa !5
  %53 = getelementptr inbounds %struct.sRWORD, ptr %52, i32 0, i32 2
  %54 = load i32, ptr %53, align 8, !tbaa !16
  call void @_ZN5TokenC1E10eTokenType(ptr noundef nonnull align 8 dereferenceable(88) %0, i32 noundef %54)
  store i32 1, ptr %10, align 4
  br label %56

55:                                               ; preds = %37
  store i32 0, ptr %10, align 4
  br label %56

56:                                               ; preds = %55, %51, %36
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #5
  %57 = load i32, ptr %10, align 4
  switch i32 %57, label %62 [
    i32 0, label %58
  ]

58:                                               ; preds = %56
  br label %59

59:                                               ; preds = %58
  %60 = load i64, ptr %9, align 8, !tbaa !11
  %61 = add i64 %60, 1
  store i64 %61, ptr %9, align 8, !tbaa !11
  br label %22, !llvm.loop !17

62:                                               ; preds = %56, %26
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #5
  %63 = load i32, ptr %10, align 4
  switch i32 %63, label %65 [
    i32 3, label %64
  ]

64:                                               ; preds = %62
  call void @_ZN5TokenC1E10eTokenType(ptr noundef nonnull align 8 dereferenceable(88) %0, i32 noundef 0)
  store i32 1, ptr %10, align 4
  br label %65

65:                                               ; preds = %64, %62
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #5
  ret void
}

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZStltIcSt11char_traitsIcESaIcEEbRKNSt7__cxx1112basic_stringIT_T0_T1_EEPKS5_(ptr noundef nonnull align 8 dereferenceable(32), ptr noundef) #3

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { noreturn nounwind "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 = { inlinehint mustprogress 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 #4 = { mustprogress 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 #5 = { nounwind }
attributes #6 = { noreturn 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++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"_ZTSN3AST7EditionE", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"long", !7, i64 0}
!13 = !{!14, !6, i64 8}
!14 = !{!"_ZTS6sRWORD", !7, i64 0, !6, i64 8, !15, i64 16}
!15 = !{!"int", !7, i64 0}
!16 = !{!14, !15, i64 16}
!17 = distinct !{!17, !18}
!18 = !{!"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"

%struct.sRWORD = type { i8, ptr, i32 }
%class.Token = type { ptr, i32, %"class.Token::Data", %class.Position, %"class.Ident::Hygiene" }
%"class.Token::Data" = type { i32, %"union.Token::Data::DataUnion" }
%"union.Token::Data::DataUnion" = type { %"class.std::__cxx11::basic_string" }
%"class.std::__cxx11::basic_string" = type { %"struct.std::__cxx11::basic_string<char>::_Alloc_hider", i64, %union.anon }
%"struct.std::__cxx11::basic_string<char>::_Alloc_hider" = type { ptr }
%union.anon = type { i64, [8 x i8] }
%class.Position = type { %struct.Span, %class.RcString, i32, i32 }
%struct.Span = type { ptr }
%class.RcString = type { ptr }
%"class.Ident::Hygiene" = type { %"class.std::unique_ptr" }
%"class.std::unique_ptr" = type { %"struct.std::__uniq_ptr_data" }
%"struct.std::__uniq_ptr_data" = type { %"class.std::__uniq_ptr_impl" }
%"class.std::__uniq_ptr_impl" = type { %"class.std::tuple" }
%"class.std::tuple" = type { %"struct.std::_Tuple_impl" }
%"struct.std::_Tuple_impl" = type { %"struct.std::_Head_base.1" }
%"struct.std::_Head_base.1" = type { ptr }

@.str.7 = external hidden unnamed_addr constant [72 x i8], align 1
@_ZL11RWORDS_2015 = external hidden local_unnamed_addr constant [47 x %struct.sRWORD], align 16
@_ZL11RWORDS_2018 = external hidden local_unnamed_addr constant [51 x %struct.sRWORD], align 16
@.str.56 = external hidden unnamed_addr constant [8 x i8], align 1
@__PRETTY_FUNCTION__._Z20Lex_FindReservedWordRKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEN3AST7EditionE = external hidden unnamed_addr constant [64 x i8], align 1
@.str.57 = external hidden unnamed_addr constant [11 x i8], align 1
@switch.table._Z20Lex_FindReservedWordRKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEN3AST7EditionE = private unnamed_addr constant [3 x ptr] [ptr @_ZL11RWORDS_2015, ptr @_ZL11RWORDS_2018, ptr @_ZL11RWORDS_2018], align 8
@switch.table._Z20Lex_FindReservedWordRKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEN3AST7EditionE.1 = private unnamed_addr constant [3 x i64] [i64 47, i64 51, i64 51], align 8

declare void @_ZN5TokenC1E10eTokenType(ptr noundef nonnull align 8 dereferenceable(88), i32 noundef) unnamed_addr #0

; Function Attrs: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) local_unnamed_addr #1

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZSteqIcSt11char_traitsIcESaIcEEbRKNSt7__cxx1112basic_stringIT_T0_T1_EEPKS5_(ptr noundef nonnull align 8 dereferenceable(32), ptr noundef) local_unnamed_addr #2

; Function Attrs: mustprogress uwtable
define dso_local void @_Z20Lex_FindReservedWordRKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEN3AST7EditionE(ptr dead_on_unwind noalias writable sret(%class.Token) align 8 %0, ptr noundef nonnull align 8 dereferenceable(32) %1, i32 noundef %2) local_unnamed_addr #3 {
  %4 = icmp ult i32 %2, 3
  br i1 %4, label %switch.lookup, label %7

switch.lookup:                                    ; preds = %3
  %5 = zext nneg i32 %2 to i64
  %switch.gep = getelementptr inbounds [3 x ptr], ptr @switch.table._Z20Lex_FindReservedWordRKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEN3AST7EditionE, i64 0, i64 %5
  %switch.load = load ptr, ptr %switch.gep, align 8
  %6 = zext nneg i32 %2 to i64
  %switch.gep34 = getelementptr inbounds [3 x i64], ptr @switch.table._Z20Lex_FindReservedWordRKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEN3AST7EditionE.1, i64 0, i64 %6
  %switch.load35 = load i64, ptr %switch.gep34, align 8
  br label %10

7:                                                ; preds = %3
  tail call void @__assert_fail(ptr noundef nonnull @.str.56, ptr noundef nonnull @.str.7, i32 noundef 1356, ptr noundef nonnull @__PRETTY_FUNCTION__._Z20Lex_FindReservedWordRKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEN3AST7EditionE) #4
  unreachable

8:                                                ; preds = %15
  %9 = add nuw nsw i64 %.01630, 1
  %exitcond.not = icmp eq i64 %9, %switch.load35
  br i1 %exitcond.not, label %.thread24, label %10, !llvm.loop !5

10:                                               ; preds = %switch.lookup, %8
  %.01630 = phi i64 [ 0, %switch.lookup ], [ %9, %8 ]
  %11 = getelementptr inbounds %struct.sRWORD, ptr %switch.load, i64 %.01630
  %12 = getelementptr inbounds i8, ptr %11, i64 8
  %13 = load ptr, ptr %12, align 8, !tbaa !7
  %14 = tail call noundef zeroext i1 @_ZStltIcSt11char_traitsIcESaIcEEbRKNSt7__cxx1112basic_stringIT_T0_T1_EEPKS5_(ptr noundef nonnull align 8 dereferenceable(32) %1, ptr noundef %13)
  br i1 %14, label %.thread24, label %15

15:                                               ; preds = %10
  %16 = tail call noundef zeroext i1 @_ZSteqIcSt11char_traitsIcESaIcEEbRKNSt7__cxx1112basic_stringIT_T0_T1_EEPKS5_(ptr noundef nonnull align 8 dereferenceable(32) %1, ptr noundef %13)
  br i1 %16, label %17, label %8

17:                                               ; preds = %15
  %18 = getelementptr inbounds i8, ptr %11, i64 16
  %19 = load i32, ptr %18, align 8, !tbaa !13
  %20 = icmp sgt i32 %19, 0
  br i1 %20, label %.thread24, label %21

21:                                               ; preds = %17
  tail call void @__assert_fail(ptr noundef nonnull @.str.57, ptr noundef nonnull @.str.7, i32 noundef 1364, ptr noundef nonnull @__PRETTY_FUNCTION__._Z20Lex_FindReservedWordRKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEN3AST7EditionE) #4
  unreachable

.thread24:                                        ; preds = %8, %10, %17
  %.sink = phi i32 [ %19, %17 ], [ 0, %10 ], [ 0, %8 ]
  tail call void @_ZN5TokenC1E10eTokenType(ptr noundef nonnull align 8 dereferenceable(88) %0, i32 noundef %.sink)
  ret void
}

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZStltIcSt11char_traitsIcESaIcEEbRKNSt7__cxx1112basic_stringIT_T0_T1_EEPKS5_(ptr noundef nonnull align 8 dereferenceable(32), ptr noundef) local_unnamed_addr #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 = { noreturn nounwind "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 = { inlinehint mustprogress 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 = { mustprogress 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 #4 = { noreturn 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 = distinct !{!5, !6}
!6 = !{!"llvm.loop.mustprogress"}
!7 = !{!8, !11, i64 8}
!8 = !{!"_ZTS6sRWORD", !9, i64 0, !11, i64 8, !12, i64 16}
!9 = !{!"omnipotent char", !10, i64 0}
!10 = !{!"Simple C++ TBAA"}
!11 = !{!"any pointer", !9, i64 0}
!12 = !{!"int", !9, i64 0}
!13 = !{!8, !12, i64 16}


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