; LLVM IR from Aeternum-Veritas/Merry :: legacy/MerryAssembler/src/lexer.ll (ZN5merry9front_end5Lexer4peekEv)

; 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.merry::front_end::Token" = type { %"class.merry::core::Loc", i32, %"class.std::__cxx11::basic_string" }
%"class.merry::core::Loc" = type { i64, i64, %"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.merry::front_end::Lexer" = type <{ %"class.merry::core::Loc", %"class.std::__cxx11::basic_string", i64, i8, [7 x i8] }>

; Function Attrs: mustprogress uwtable
declare noundef nonnull align 1 dereferenceable(1) ptr @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE2atEm(ptr noundef nonnull align 8 dereferenceable(32), i64 noundef) #0 align 2

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

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

declare i32 @__gxx_personality_v0(...)

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local void @_ZN5merry9front_end5TokenD2Ev(ptr noundef nonnull align 8 dereferenceable(88)) unnamed_addr #2 align 2

; 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 void @_ZN5merry9front_end5Lexer4peekEv(ptr dead_on_unwind noalias writable sret(%"class.merry::front_end::Token") align 8 %0, ptr noundef nonnull align 8 dereferenceable(89) %1) #0 align 2 personality ptr @__gxx_personality_v0 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca i64, align 8
  %6 = alloca i1, align 1
  %7 = alloca ptr, align 8
  %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
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #3
  %10 = getelementptr inbounds %"class.merry::front_end::Lexer", ptr %9, i32 0, i32 2
  %11 = load i64, ptr %10, align 8, !tbaa !9
  store i64 %11, ptr %5, align 8, !tbaa !15
  store i1 false, ptr %6, align 1
  call void @_ZN5merry9front_end5Lexer10next_tokenEv(ptr dead_on_unwind writable sret(%"class.merry::front_end::Token") align 8 %0, ptr noundef nonnull align 8 dereferenceable(89) %9)
  %12 = load i64, ptr %5, align 8, !tbaa !15
  %13 = getelementptr inbounds %"class.merry::front_end::Lexer", ptr %9, i32 0, i32 2
  store i64 %12, ptr %13, align 8, !tbaa !9
  %14 = getelementptr inbounds %"class.merry::front_end::Lexer", ptr %9, i32 0, i32 1
  %15 = getelementptr inbounds %"class.merry::front_end::Lexer", ptr %9, i32 0, i32 2
  %16 = load i64, ptr %15, align 8, !tbaa !9
  %17 = invoke noundef nonnull align 1 dereferenceable(1) ptr @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE2atEm(ptr noundef nonnull align 8 dereferenceable(32) %14, i64 noundef %16)
          to label %18 unwind label %22

18:                                               ; preds = %2
  %19 = load i8, ptr %17, align 1, !tbaa !16
  %20 = getelementptr inbounds %"class.merry::front_end::Lexer", ptr %9, i32 0, i32 3
  store i8 %19, ptr %20, align 8, !tbaa !17
  store i1 true, ptr %6, align 1
  %21 = load i1, ptr %6, align 1
  br i1 %21, label %27, label %26

22:                                               ; preds = %2
  %23 = landingpad { ptr, i32 }
          cleanup
  %24 = extractvalue { ptr, i32 } %23, 0
  store ptr %24, ptr %7, align 8
  %25 = extractvalue { ptr, i32 } %23, 1
  store i32 %25, ptr %8, align 4
  call void @_ZN5merry9front_end5TokenD2Ev(ptr noundef nonnull align 8 dereferenceable(88) %0) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #3
  br label %28

26:                                               ; preds = %18
  call void @_ZN5merry9front_end5TokenD2Ev(ptr noundef nonnull align 8 dereferenceable(88) %0) #3
  br label %27

27:                                               ; preds = %26, %18
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #3
  ret void

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

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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { 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 80}
!10 = !{!"_ZTSN5merry9front_end5LexerE", !11, i64 0, !13, i64 48, !12, i64 80, !7, i64 88}
!11 = !{!"_ZTSN5merry4core3LocE", !12, i64 0, !12, i64 8, !13, i64 16}
!12 = !{!"long", !7, i64 0}
!13 = !{!"_ZTSNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE", !14, i64 0, !12, i64 8, !7, i64 16}
!14 = !{!"_ZTSNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_Alloc_hiderE", !6, i64 0}
!15 = !{!12, !12, i64 0}
!16 = !{!7, !7, i64 0}
!17 = !{!10, !7, i64 88}


; 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.merry::front_end::Token" = type { %"class.merry::core::Loc", i32, %"class.std::__cxx11::basic_string" }
%"class.merry::core::Loc" = type { i64, i64, %"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] }

; Function Attrs: mustprogress uwtable
declare noundef nonnull align 1 dereferenceable(1) ptr @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE2atEm(ptr noundef nonnull align 8 dereferenceable(32), i64 noundef) local_unnamed_addr #0 align 2

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

declare i32 @__gxx_personality_v0(...)

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local void @_ZN5merry9front_end5TokenD2Ev(ptr noundef nonnull align 8 dereferenceable(88)) unnamed_addr #1 align 2

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN5merry9front_end5Lexer4peekEv(ptr dead_on_unwind noalias writable sret(%"class.merry::front_end::Token") align 8 %0, ptr noundef nonnull align 8 dereferenceable(89) %1) local_unnamed_addr #0 align 2 personality ptr @__gxx_personality_v0 {
  %3 = getelementptr inbounds i8, ptr %1, i64 80
  %4 = load i64, ptr %3, align 8, !tbaa !5
  tail call void @_ZN5merry9front_end5Lexer10next_tokenEv(ptr dead_on_unwind writable sret(%"class.merry::front_end::Token") align 8 %0, ptr noundef nonnull align 8 dereferenceable(89) %1)
  store i64 %4, ptr %3, align 8, !tbaa !5
  %5 = getelementptr inbounds i8, ptr %1, i64 48
  %6 = invoke noundef nonnull align 1 dereferenceable(1) ptr @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE2atEm(ptr noundef nonnull align 8 dereferenceable(32) %5, i64 noundef %4)
          to label %7 unwind label %10

7:                                                ; preds = %2
  %8 = load i8, ptr %6, align 1, !tbaa !14
  %9 = getelementptr inbounds i8, ptr %1, i64 88
  store i8 %8, ptr %9, align 8, !tbaa !15
  ret void

10:                                               ; preds = %2
  %11 = landingpad { ptr, i32 }
          cleanup
  tail call void @_ZN5merry9front_end5TokenD2Ev(ptr noundef nonnull align 8 dereferenceable(88) %0) #2
  resume { ptr, i32 } %11
}

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 = { 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 #2 = { 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, !8, i64 80}
!6 = !{!"_ZTSN5merry9front_end5LexerE", !7, i64 0, !11, i64 48, !8, i64 80, !9, i64 88}
!7 = !{!"_ZTSN5merry4core3LocE", !8, i64 0, !8, i64 8, !11, i64 16}
!8 = !{!"long", !9, i64 0}
!9 = !{!"omnipotent char", !10, i64 0}
!10 = !{!"Simple C++ TBAA"}
!11 = !{!"_ZTSNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE", !12, i64 0, !8, i64 8, !9, i64 16}
!12 = !{!"_ZTSNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_Alloc_hiderE", !13, i64 0}
!13 = !{!"any pointer", !9, i64 0}
!14 = !{!9, !9, i64 0}
!15 = !{!6, !9, i64 88}


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