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

; 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.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 }

declare i32 @__gxx_personality_v0(...)

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN5Lexer12realGetTokenEv(ptr dead_on_unwind noalias writable sret(%class.Token) align 8 %0, ptr noundef nonnull align 8 dereferenceable(256) %1) unnamed_addr #0 align 2 personality ptr @__gxx_personality_v0 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca i1, align 1
  %6 = alloca ptr, align 8
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  store ptr %0, ptr %3, align 8
  store ptr %1, ptr %4, align 8, !tbaa !5
  %9 = load ptr, ptr %4, align 8
  br label %10

10:                                               ; preds = %24, %2
  store i1 false, ptr %5, align 1
  call void @_ZN5Lexer11getTokenIntEv(ptr dead_on_unwind writable sret(%class.Token) align 8 %0, ptr noundef nonnull align 8 dereferenceable(256) %9)
  %11 = invoke noundef i32 @_ZNK5Token4typeEv(ptr noundef nonnull align 8 dereferenceable(88) %0)
          to label %12 unwind label %13

12:                                               ; preds = %10
  switch i32 %11, label %20 [
    i32 2, label %17
    i32 3, label %18
    i32 4, label %19
  ]

13:                                               ; preds = %10
  %14 = landingpad { ptr, i32 }
          cleanup
  %15 = extractvalue { ptr, i32 } %14, 0
  store ptr %15, ptr %6, align 8
  %16 = extractvalue { ptr, i32 } %14, 1
  store i32 %16, ptr %7, align 4
  call void @_ZN5TokenD1Ev(ptr noundef nonnull align 8 dereferenceable(88) %0) #3
  br label %27

17:                                               ; preds = %12
  store i32 2, ptr %8, align 4
  br label %21, !llvm.loop !9

18:                                               ; preds = %12
  store i32 2, ptr %8, align 4
  br label %21, !llvm.loop !9

19:                                               ; preds = %12
  store i32 2, ptr %8, align 4
  br label %21, !llvm.loop !9

20:                                               ; preds = %12
  store i1 true, ptr %5, align 1
  store i32 1, ptr %8, align 4
  br label %21

21:                                               ; preds = %20, %19, %18, %17
  %22 = load i1, ptr %5, align 1
  br i1 %22, label %24, label %23

23:                                               ; preds = %21
  call void @_ZN5TokenD1Ev(ptr noundef nonnull align 8 dereferenceable(88) %0) #3
  br label %24

24:                                               ; preds = %23, %21
  %25 = load i32, ptr %8, align 4
  switch i32 %25, label %32 [
    i32 2, label %10
    i32 1, label %26
  ]

26:                                               ; preds = %24
  ret void

27:                                               ; preds = %13
  %28 = load ptr, ptr %6, align 8
  %29 = load i32, ptr %7, align 4
  %30 = insertvalue { ptr, i32 } poison, ptr %28, 0
  %31 = insertvalue { ptr, i32 } %30, i32 %29, 1
  resume { ptr, i32 } %31

32:                                               ; preds = %24
  unreachable
}

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN5Lexer11getTokenIntEv(ptr dead_on_unwind noalias writable sret(%class.Token) align 8, ptr noundef nonnull align 8 dereferenceable(256)) #0 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZNK5Token4typeEv(ptr noundef nonnull align 8 dereferenceable(88)) #1 align 2

; Function Attrs: nounwind
declare void @_ZN5TokenD1Ev(ptr noundef nonnull align 8 dereferenceable(88)) unnamed_addr #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" }
attributes #1 = { 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 #2 = { 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 = { 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 = distinct !{!9, !10}
!10 = !{!"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"

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

declare i32 @__gxx_personality_v0(...)

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN5Lexer12realGetTokenEv(ptr dead_on_unwind noalias writable sret(%class.Token) align 8 %0, ptr noundef nonnull align 8 dereferenceable(256) %1) unnamed_addr #0 align 2 personality ptr @__gxx_personality_v0 {
  br label %3

3:                                                ; preds = %7, %2
  tail call void @_ZN5Lexer11getTokenIntEv(ptr dead_on_unwind writable sret(%class.Token) align 8 %0, ptr noundef nonnull align 8 dereferenceable(256) %1)
  %4 = tail call noundef i32 @_ZNK5Token4typeEv(ptr noundef nonnull align 8 dereferenceable(88) %0)
  switch i32 %4, label %8 [
    i32 2, label %7
    i32 3, label %5
    i32 4, label %6
  ], !llvm.loop !5

5:                                                ; preds = %3
  br label %7, !llvm.loop !5

6:                                                ; preds = %3
  br label %7, !llvm.loop !5

7:                                                ; preds = %3, %5, %6
  tail call void @_ZN5TokenD1Ev(ptr noundef nonnull align 8 dereferenceable(88) %0) #3
  br label %3

8:                                                ; preds = %3
  ret void
}

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN5Lexer11getTokenIntEv(ptr dead_on_unwind noalias writable sret(%class.Token) align 8, ptr noundef nonnull align 8 dereferenceable(256)) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZNK5Token4typeEv(ptr noundef nonnull align 8 dereferenceable(88)) local_unnamed_addr #1 align 2

; Function Attrs: nounwind
declare void @_ZN5TokenD1Ev(ptr noundef nonnull align 8 dereferenceable(88)) unnamed_addr #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" }
attributes #1 = { 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 #2 = { 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 = { 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"}


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