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

; 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.Codepoint = type { i32 }
%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 }
%"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 }

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #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: mustprogress uwtable
define dso_local i32 @_ZN5Lexer4getcEv(ptr noundef nonnull align 8 dereferenceable(256) %0) #2 align 2 {
  %2 = alloca %struct.Codepoint, align 4
  %3 = alloca ptr, align 8
  %4 = alloca %struct.Codepoint, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  %5 = load ptr, ptr %3, align 8
  %6 = getelementptr inbounds %class.Lexer, ptr %5, i32 0, i32 6
  %7 = load i8, ptr %6, align 8, !tbaa !9, !range !45, !noundef !46
  %8 = trunc i8 %7 to i1
  br i1 %8, label %9, label %11

9:                                                ; preds = %1
  %10 = getelementptr inbounds %class.Lexer, ptr %5, i32 0, i32 6
  store i8 0, ptr %10, align 8, !tbaa !9
  br label %18

11:                                               ; preds = %1
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #3
  %12 = call i32 @_ZN5Lexer7getc_cpEv(ptr noundef nonnull align 8 dereferenceable(256) %5)
  %13 = getelementptr inbounds %struct.Codepoint, ptr %4, i32 0, i32 0
  store i32 %12, ptr %13, align 4
  %14 = getelementptr inbounds %class.Lexer, ptr %5, i32 0, i32 7
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %14, ptr align 4 %4, i64 4, i1 false), !tbaa.struct !47
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #3
  %15 = getelementptr inbounds %class.Lexer, ptr %5, i32 0, i32 3
  %16 = load i32, ptr %15, align 4, !tbaa !49
  %17 = add i32 %16, 1
  store i32 %17, ptr %15, align 4, !tbaa !49
  br label %18

18:                                               ; preds = %11, %9
  %19 = getelementptr inbounds %class.Lexer, ptr %5, i32 0, i32 7
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %2, ptr align 4 %19, i64 4, i1 false), !tbaa.struct !47
  %20 = getelementptr inbounds %struct.Codepoint, ptr %2, i32 0, i32 0
  %21 = load i32, ptr %20, align 4
  ret i32 %21
}

; Function Attrs: mustprogress uwtable
declare dso_local i32 @_ZN5Lexer7getc_cpEv(ptr noundef nonnull align 8 dereferenceable(256)) #2 align 2

attributes #0 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { 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 #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++ TBAA"}
!9 = !{!10, !12, i64 208}
!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 = !{i8 0, i8 2}
!46 = !{}
!47 = !{i64 0, i64 4, !48}
!48 = !{!20, !20, i64 0}
!49 = !{!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"

; Function Attrs: mustprogress uwtable
define dso_local i32 @_ZN5Lexer4getcEv(ptr noundef nonnull align 8 dereferenceable(256) %0) local_unnamed_addr #0 align 2 {
  %2 = getelementptr inbounds i8, ptr %0, i64 208
  %3 = load i8, ptr %2, align 8, !tbaa !5, !range !44, !noundef !45
  %4 = trunc nuw i8 %3 to i1
  %.phi.trans.insert = getelementptr inbounds i8, ptr %0, i64 212
  br i1 %4, label %5, label %6

5:                                                ; preds = %1
  store i8 0, ptr %2, align 8, !tbaa !5
  %.sroa.01.0.copyload.pre = load i32, ptr %.phi.trans.insert, align 4, !tbaa !46
  br label %11

6:                                                ; preds = %1
  %7 = tail call i32 @_ZN5Lexer7getc_cpEv(ptr noundef nonnull align 8 dereferenceable(256) %0)
  store i32 %7, ptr %.phi.trans.insert, align 4, !tbaa !46
  %8 = getelementptr inbounds i8, ptr %0, i64 188
  %9 = load i32, ptr %8, align 4, !tbaa !47
  %10 = add i32 %9, 1
  store i32 %10, ptr %8, align 4, !tbaa !47
  br label %11

11:                                               ; preds = %6, %5
  %.sroa.01.0.copyload = phi i32 [ %7, %6 ], [ %.sroa.01.0.copyload.pre, %5 ]
  ret i32 %.sroa.01.0.copyload
}

; Function Attrs: mustprogress uwtable
declare dso_local i32 @_ZN5Lexer7getc_cpEv(ptr noundef nonnull align 8 dereferenceable(256)) local_unnamed_addr #0 align 2

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

!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, !8, i64 208}
!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 = !{i8 0, i8 2}
!45 = !{}
!46 = !{!19, !19, i64 0}
!47 = !{!6, !19, i64 188}


; Effective O3 passes: BDCEPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,SROAPass,SimplifyCFGPass,TailCallElimPass