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

; 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"

%class.Lexer = type { %class.TokenStream, %class.RcString, i32, i32, %"class.std::unique_ptr.5", ptr, i8, %struct.Codepoint, %"class.std::vector.13", i32, %"class.Ident::Hygiene" }
%class.TokenStream = type { ptr, i8, %class.Token, %"class.Ident::Hygiene", i32, %"class.std::vector", %struct.ParseState }
%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.std::vector" = type { %"struct.std::_Vector_base" }
%"struct.std::_Vector_base" = type { %"struct.std::_Vector_base<TokenStream::LookaheadEnt, std::allocator<TokenStream::LookaheadEnt>>::_Vector_impl" }
%"struct.std::_Vector_base<TokenStream::LookaheadEnt, std::allocator<TokenStream::LookaheadEnt>>::_Vector_impl" = type { %"struct.std::_Vector_base<TokenStream::LookaheadEnt, std::allocator<TokenStream::LookaheadEnt>>::_Vector_impl_data" }
%"struct.std::_Vector_base<TokenStream::LookaheadEnt, std::allocator<TokenStream::LookaheadEnt>>::_Vector_impl_data" = type { ptr, ptr, ptr }
%struct.ParseState = type { i8, i8, i8, ptr, ptr, ptr }
%class.RcString = type { ptr }
%"class.std::unique_ptr.5" = type { %"struct.std::__uniq_ptr_data.6" }
%"struct.std::__uniq_ptr_data.6" = type { %"class.std::__uniq_ptr_impl.7" }
%"class.std::__uniq_ptr_impl.7" = type { %"class.std::tuple.8" }
%"class.std::tuple.8" = type { %"struct.std::_Tuple_impl.9" }
%"struct.std::_Tuple_impl.9" = type { %"struct.std::_Head_base.12" }
%"struct.std::_Head_base.12" = type { ptr }
%struct.Codepoint = type { i32 }
%"class.std::vector.13" = type { %"struct.std::_Vector_base.14" }
%"struct.std::_Vector_base.14" = type { %"struct.std::_Vector_base<Token, std::allocator<Token>>::_Vector_impl" }
%"struct.std::_Vector_base<Token, std::allocator<Token>>::_Vector_impl" = type { %"struct.std::_Vector_base<Token, std::allocator<Token>>::_Vector_impl_data" }
%"struct.std::_Vector_base<Token, std::allocator<Token>>::_Vector_impl_data" = type { ptr, ptr, 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 }

@_ZTIN5Lexer9EndOfFileE = external dso_local constant { ptr, ptr }, align 8

declare ptr @__cxa_allocate_exception(i64)

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

declare void @__cxa_throw(ptr, ptr, ptr)

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

; Function Attrs: mustprogress uwtable
define dso_local noundef signext i8 @_ZN5Lexer9getc_byteEv(ptr noundef nonnull align 8 dereferenceable(256) %0) #1 align 2 {
  %2 = alloca ptr, align 8
  %3 = alloca i32, align 4
  store ptr %0, ptr %2, align 8, !tbaa !5
  %4 = load ptr, ptr %2, align 8
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #3
  %5 = getelementptr inbounds %class.Lexer, ptr %4, i32 0, i32 5
  %6 = load ptr, ptr %5, align 8, !tbaa !9
  %7 = call noundef i32 @_ZNSi3getEv(ptr noundef nonnull align 8 dereferenceable(16) %6)
  store i32 %7, ptr %3, align 4, !tbaa !45
  %8 = load i32, ptr %3, align 4, !tbaa !45
  %9 = icmp eq i32 %8, -1
  br i1 %9, label %10, label %12

10:                                               ; preds = %1
  %11 = call ptr @__cxa_allocate_exception(i64 1) #3
  call void @__cxa_throw(ptr %11, ptr @_ZTIN5Lexer9EndOfFileE, ptr null) #4
  unreachable

12:                                               ; preds = %1
  %13 = load i32, ptr %3, align 4, !tbaa !45
  %14 = icmp eq i32 %13, 13
  br i1 %14, label %15, label %26

15:                                               ; preds = %12
  %16 = getelementptr inbounds %class.Lexer, ptr %4, i32 0, i32 5
  %17 = load ptr, ptr %16, align 8, !tbaa !9
  %18 = call noundef i32 @_ZNSi3getEv(ptr noundef nonnull align 8 dereferenceable(16) %17)
  %19 = icmp ne i32 %18, 10
  br i1 %19, label %20, label %24

20:                                               ; preds = %15
  %21 = getelementptr inbounds %class.Lexer, ptr %4, i32 0, i32 5
  %22 = load ptr, ptr %21, align 8, !tbaa !9
  %23 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSi5ungetEv(ptr noundef nonnull align 8 dereferenceable(16) %22)
  br label %25

24:                                               ; preds = %15
  store i32 10, ptr %3, align 4, !tbaa !45
  br label %25

25:                                               ; preds = %24, %20
  br label %26

26:                                               ; preds = %25, %12
  %27 = load i32, ptr %3, align 4, !tbaa !45
  %28 = icmp eq i32 %27, 10
  br i1 %28, label %29, label %34

29:                                               ; preds = %26
  %30 = getelementptr inbounds %class.Lexer, ptr %4, i32 0, i32 2
  %31 = load i32, ptr %30, align 8, !tbaa !46
  %32 = add i32 %31, 1
  store i32 %32, ptr %30, align 8, !tbaa !46
  %33 = getelementptr inbounds %class.Lexer, ptr %4, i32 0, i32 3
  store i32 0, ptr %33, align 4, !tbaa !47
  br label %34

34:                                               ; preds = %29, %26
  %35 = load i32, ptr %3, align 4, !tbaa !45
  %36 = trunc i32 %35 to i8
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #3
  ret i8 %36
}

declare noundef nonnull align 8 dereferenceable(16) ptr @_ZNSi5ungetEv(ptr noundef nonnull align 8 dereferenceable(16)) #2

declare noundef i32 @_ZNSi3getEv(ptr noundef nonnull align 8 dereferenceable(16)) #2

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #2 = { "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 = { noreturn }

!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, !6, i64 200}
!10 = !{!"_ZTS5Lexer", !11, i64 0, !19, i64 176, !20, i64 184, !20, i64 188, !34, i64 192, !6, i64 200, !12, i64 208, !40, i64 212, !41, i64 216, !28, i64 240, !21, i64 248}
!11 = !{!"_ZTS11TokenStream", !12, i64 8, !13, i64 16, !21, i64 104, !28, i64 112, !29, i64 120, !33, i64 144}
!12 = !{!"bool", !7, i64 0}
!13 = !{!"_ZTS5Token", !14, i64 8, !15, i64 16, !17, i64 56, !21, i64 80}
!14 = !{!"_ZTS10eTokenType", !7, i64 0}
!15 = !{!"_ZTSN5Token4DataE", !16, i64 0, !7, i64 8}
!16 = !{!"_ZTSN5Token4Data3TagE", !7, i64 0}
!17 = !{!"_ZTS8Position", !18, i64 0, !19, i64 8, !20, i64 16, !20, i64 20}
!18 = !{!"_ZTS4Span", !6, i64 0}
!19 = !{!"_ZTS8RcString", !6, i64 0}
!20 = !{!"int", !7, i64 0}
!21 = !{!"_ZTSN5Ident7HygieneE", !22, i64 0}
!22 = !{!"_ZTSSt10unique_ptrIN5Ident7Hygiene5InnerESt14default_deleteIS2_EE", !23, i64 0}
!23 = !{!"_ZTSSt15__uniq_ptr_dataIN5Ident7Hygiene5InnerESt14default_deleteIS2_ELb1ELb1EE", !24, i64 0}
!24 = !{!"_ZTSSt15__uniq_ptr_implIN5Ident7Hygiene5InnerESt14default_deleteIS2_EE", !25, i64 0}
!25 = !{!"_ZTSSt5tupleIJPN5Ident7Hygiene5InnerESt14default_deleteIS2_EEE", !26, i64 0}
!26 = !{!"_ZTSSt11_Tuple_implILm0EJPN5Ident7Hygiene5InnerESt14default_deleteIS2_EEE", !27, i64 0}
!27 = !{!"_ZTSSt10_Head_baseILm0EPN5Ident7Hygiene5InnerELb0EE", !6, i64 0}
!28 = !{!"_ZTSN3AST7EditionE", !7, i64 0}
!29 = !{!"_ZTSSt6vectorIN11TokenStream12LookaheadEntESaIS1_EE", !30, i64 0}
!30 = !{!"_ZTSSt12_Vector_baseIN11TokenStream12LookaheadEntESaIS1_EE", !31, i64 0}
!31 = !{!"_ZTSNSt12_Vector_baseIN11TokenStream12LookaheadEntESaIS1_EE12_Vector_implE", !32, i64 0}
!32 = !{!"_ZTSNSt12_Vector_baseIN11TokenStream12LookaheadEntESaIS1_EE17_Vector_impl_dataE", !6, i64 0, !6, i64 8, !6, i64 16}
!33 = !{!"_ZTS10ParseState", !12, i64 0, !12, i64 1, !12, i64 2, !6, i64 8, !6, i64 16, !6, i64 24}
!34 = !{!"_ZTSSt10unique_ptrISt14basic_ifstreamIcSt11char_traitsIcEESt14default_deleteIS3_EE", !35, i64 0}
!35 = !{!"_ZTSSt15__uniq_ptr_dataISt14basic_ifstreamIcSt11char_traitsIcEESt14default_deleteIS3_ELb1ELb1EE", !36, i64 0}
!36 = !{!"_ZTSSt15__uniq_ptr_implISt14basic_ifstreamIcSt11char_traitsIcEESt14default_deleteIS3_EE", !37, i64 0}
!37 = !{!"_ZTSSt5tupleIJPSt14basic_ifstreamIcSt11char_traitsIcEESt14default_deleteIS3_EEE", !38, i64 0}
!38 = !{!"_ZTSSt11_Tuple_implILm0EJPSt14basic_ifstreamIcSt11char_traitsIcEESt14default_deleteIS3_EEE", !39, i64 0}
!39 = !{!"_ZTSSt10_Head_baseILm0EPSt14basic_ifstreamIcSt11char_traitsIcEELb0EE", !6, i64 0}
!40 = !{!"_ZTS9Codepoint", !20, i64 0}
!41 = !{!"_ZTSSt6vectorI5TokenSaIS0_EE", !42, i64 0}
!42 = !{!"_ZTSSt12_Vector_baseI5TokenSaIS0_EE", !43, i64 0}
!43 = !{!"_ZTSNSt12_Vector_baseI5TokenSaIS0_EE12_Vector_implE", !44, i64 0}
!44 = !{!"_ZTSNSt12_Vector_baseI5TokenSaIS0_EE17_Vector_impl_dataE", !6, i64 0, !6, i64 8, !6, i64 16}
!45 = !{!20, !20, i64 0}
!46 = !{!10, !20, i64 184}
!47 = !{!10, !20, i64 188}


; 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"

@_ZTIN5Lexer9EndOfFileE = external dso_local constant { ptr, ptr }, align 8

declare ptr @__cxa_allocate_exception(i64) local_unnamed_addr

declare void @__cxa_throw(ptr, ptr, ptr) local_unnamed_addr

; Function Attrs: mustprogress uwtable
define dso_local noundef signext i8 @_ZN5Lexer9getc_byteEv(ptr nocapture noundef nonnull align 8 dereferenceable(256) %0) local_unnamed_addr #0 align 2 {
  %2 = getelementptr inbounds i8, ptr %0, i64 200
  %3 = load ptr, ptr %2, align 8, !tbaa !5
  %4 = tail call noundef i32 @_ZNSi3getEv(ptr noundef nonnull align 8 dereferenceable(16) %3)
  switch i32 %4, label %16 [
    i32 -1, label %5
    i32 13, label %7
    i32 10, label %.thread
  ]

5:                                                ; preds = %1
  %6 = tail call ptr @__cxa_allocate_exception(i64 1) #2
  tail call void @__cxa_throw(ptr %6, ptr nonnull @_ZTIN5Lexer9EndOfFileE, ptr null) #3
  unreachable

7:                                                ; preds = %1
  %8 = load ptr, ptr %2, align 8, !tbaa !5
  %9 = tail call noundef i32 @_ZNSi3getEv(ptr noundef nonnull align 8 dereferenceable(16) %8)
  %.not = icmp eq i32 %9, 10
  br i1 %.not, label %.thread, label %.thread8

.thread8:                                         ; preds = %7
  %10 = load ptr, ptr %2, align 8, !tbaa !5
  %11 = tail call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSi5ungetEv(ptr noundef nonnull align 8 dereferenceable(16) %10)
  br label %16

.thread:                                          ; preds = %1, %7
  %12 = getelementptr inbounds i8, ptr %0, i64 184
  %13 = load i32, ptr %12, align 8, !tbaa !44
  %14 = add i32 %13, 1
  store i32 %14, ptr %12, align 8, !tbaa !44
  %15 = getelementptr inbounds i8, ptr %0, i64 188
  store i32 0, ptr %15, align 4, !tbaa !45
  br label %16

16:                                               ; preds = %1, %.thread8, %.thread
  %.06 = phi i32 [ 10, %.thread ], [ 13, %.thread8 ], [ %4, %1 ]
  %17 = trunc i32 %.06 to i8
  ret i8 %17
}

declare noundef nonnull align 8 dereferenceable(16) ptr @_ZNSi5ungetEv(ptr noundef nonnull align 8 dereferenceable(16)) local_unnamed_addr #1

declare noundef i32 @_ZNSi3getEv(ptr noundef nonnull align 8 dereferenceable(16)) local_unnamed_addr #1

attributes #0 = { 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 #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 = { nounwind }
attributes #3 = { noreturn }

!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, !17, i64 200}
!6 = !{!"_ZTS5Lexer", !7, i64 0, !18, i64 176, !19, i64 184, !19, i64 188, !33, i64 192, !17, i64 200, !8, i64 208, !39, i64 212, !40, i64 216, !27, i64 240, !20, i64 248}
!7 = !{!"_ZTS11TokenStream", !8, i64 8, !11, i64 16, !20, i64 104, !27, i64 112, !28, i64 120, !32, i64 144}
!8 = !{!"bool", !9, i64 0}
!9 = !{!"omnipotent char", !10, i64 0}
!10 = !{!"Simple C++ TBAA"}
!11 = !{!"_ZTS5Token", !12, i64 8, !13, i64 16, !15, i64 56, !20, i64 80}
!12 = !{!"_ZTS10eTokenType", !9, i64 0}
!13 = !{!"_ZTSN5Token4DataE", !14, i64 0, !9, i64 8}
!14 = !{!"_ZTSN5Token4Data3TagE", !9, i64 0}
!15 = !{!"_ZTS8Position", !16, i64 0, !18, i64 8, !19, i64 16, !19, i64 20}
!16 = !{!"_ZTS4Span", !17, i64 0}
!17 = !{!"any pointer", !9, i64 0}
!18 = !{!"_ZTS8RcString", !17, i64 0}
!19 = !{!"int", !9, i64 0}
!20 = !{!"_ZTSN5Ident7HygieneE", !21, i64 0}
!21 = !{!"_ZTSSt10unique_ptrIN5Ident7Hygiene5InnerESt14default_deleteIS2_EE", !22, i64 0}
!22 = !{!"_ZTSSt15__uniq_ptr_dataIN5Ident7Hygiene5InnerESt14default_deleteIS2_ELb1ELb1EE", !23, i64 0}
!23 = !{!"_ZTSSt15__uniq_ptr_implIN5Ident7Hygiene5InnerESt14default_deleteIS2_EE", !24, i64 0}
!24 = !{!"_ZTSSt5tupleIJPN5Ident7Hygiene5InnerESt14default_deleteIS2_EEE", !25, i64 0}
!25 = !{!"_ZTSSt11_Tuple_implILm0EJPN5Ident7Hygiene5InnerESt14default_deleteIS2_EEE", !26, i64 0}
!26 = !{!"_ZTSSt10_Head_baseILm0EPN5Ident7Hygiene5InnerELb0EE", !17, i64 0}
!27 = !{!"_ZTSN3AST7EditionE", !9, i64 0}
!28 = !{!"_ZTSSt6vectorIN11TokenStream12LookaheadEntESaIS1_EE", !29, i64 0}
!29 = !{!"_ZTSSt12_Vector_baseIN11TokenStream12LookaheadEntESaIS1_EE", !30, i64 0}
!30 = !{!"_ZTSNSt12_Vector_baseIN11TokenStream12LookaheadEntESaIS1_EE12_Vector_implE", !31, i64 0}
!31 = !{!"_ZTSNSt12_Vector_baseIN11TokenStream12LookaheadEntESaIS1_EE17_Vector_impl_dataE", !17, i64 0, !17, i64 8, !17, i64 16}
!32 = !{!"_ZTS10ParseState", !8, i64 0, !8, i64 1, !8, i64 2, !17, i64 8, !17, i64 16, !17, i64 24}
!33 = !{!"_ZTSSt10unique_ptrISt14basic_ifstreamIcSt11char_traitsIcEESt14default_deleteIS3_EE", !34, i64 0}
!34 = !{!"_ZTSSt15__uniq_ptr_dataISt14basic_ifstreamIcSt11char_traitsIcEESt14default_deleteIS3_ELb1ELb1EE", !35, i64 0}
!35 = !{!"_ZTSSt15__uniq_ptr_implISt14basic_ifstreamIcSt11char_traitsIcEESt14default_deleteIS3_EE", !36, i64 0}
!36 = !{!"_ZTSSt5tupleIJPSt14basic_ifstreamIcSt11char_traitsIcEESt14default_deleteIS3_EEE", !37, i64 0}
!37 = !{!"_ZTSSt11_Tuple_implILm0EJPSt14basic_ifstreamIcSt11char_traitsIcEESt14default_deleteIS3_EEE", !38, i64 0}
!38 = !{!"_ZTSSt10_Head_baseILm0EPSt14basic_ifstreamIcSt11char_traitsIcEELb0EE", !17, i64 0}
!39 = !{!"_ZTS9Codepoint", !19, i64 0}
!40 = !{!"_ZTSSt6vectorI5TokenSaIS0_EE", !41, i64 0}
!41 = !{!"_ZTSSt12_Vector_baseI5TokenSaIS0_EE", !42, i64 0}
!42 = !{!"_ZTSNSt12_Vector_baseI5TokenSaIS0_EE12_Vector_implE", !43, i64 0}
!43 = !{!"_ZTSNSt12_Vector_baseI5TokenSaIS0_EE17_Vector_impl_dataE", !17, i64 0, !17, i64 8, !17, i64 16}
!44 = !{!6, !19, i64 184}
!45 = !{!6, !19, i64 188}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass