; LLVM IR from thuhcsi/Crystal.TTVS :: Xface/XFace/src/XFaceApp (ApplicationBase)

; 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.XFaceApp::ApplicationBase" = type { %"class.XFaceApp::TaskHandlerBase", i8, i8, ptr, ptr, ptr, ptr, ptr, ptr }
%"class.XFaceApp::TaskHandlerBase" = type { ptr, %"class.std::queue", ptr }
%"class.std::queue" = type { %"class.std::deque" }
%"class.std::deque" = type { %"class.std::_Deque_base" }
%"class.std::_Deque_base" = type { %"struct.std::_Deque_base<XFaceApp::Task, std::allocator<XFaceApp::Task>>::_Deque_impl" }
%"struct.std::_Deque_base<XFaceApp::Task, std::allocator<XFaceApp::Task>>::_Deque_impl" = type { %"struct.std::_Deque_base<XFaceApp::Task, std::allocator<XFaceApp::Task>>::_Deque_impl_data" }
%"struct.std::_Deque_base<XFaceApp::Task, std::allocator<XFaceApp::Task>>::_Deque_impl_data" = type { ptr, i64, %"struct.std::_Deque_iterator", %"struct.std::_Deque_iterator" }
%"struct.std::_Deque_iterator" = type { ptr, ptr, ptr, ptr }

@.str = external hidden unnamed_addr constant [13 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [99 x i8], align 1
@__PRETTY_FUNCTION__._ZN8XFaceApp15ApplicationBase5queryERKNS0_5QUERYE = external hidden unnamed_addr constant [53 x i8], align 1

; Function Attrs: mustprogress uwtable
define dso_local noundef zeroext i1 @_ZN8XFaceApp15ApplicationBase5queryERKNS0_5QUERYE(ptr noundef nonnull align 8 dereferenceable(152) %0, ptr noundef nonnull align 4 dereferenceable(4) %1) #0 align 2 {
  %3 = alloca i1, align 1
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  %6 = load ptr, ptr %4, align 8
  %7 = load ptr, ptr %5, align 8, !tbaa !5
  %8 = load i32, ptr %7, align 4, !tbaa !9
  switch i32 %8, label %37 [
    i32 0, label %9
    i32 1, label %23
  ]

9:                                                ; preds = %2
  %10 = getelementptr inbounds %"class.XFaceApp::ApplicationBase", ptr %6, i32 0, i32 7
  %11 = load ptr, ptr %10, align 8, !tbaa !11
  %12 = icmp ne ptr %11, null
  br i1 %12, label %13, label %14

13:                                               ; preds = %9
  br label %16

14:                                               ; preds = %9
  call void @__assert_fail(ptr noundef @.str, ptr noundef @.str.1, i32 noundef 65, ptr noundef @__PRETTY_FUNCTION__._ZN8XFaceApp15ApplicationBase5queryERKNS0_5QUERYE) #2
  unreachable

15:                                               ; No predecessors!
  br label %16

16:                                               ; preds = %15, %13
  %17 = getelementptr inbounds %"class.XFaceApp::ApplicationBase", ptr %6, i32 0, i32 7
  %18 = load ptr, ptr %17, align 8, !tbaa !11
  %19 = load ptr, ptr %18, align 8, !tbaa !22
  %20 = getelementptr inbounds ptr, ptr %19, i64 0
  %21 = load ptr, ptr %20, align 8
  %22 = call noundef zeroext i1 %21(ptr noundef nonnull align 8 dereferenceable(40) %18)
  store i1 %22, ptr %3, align 1
  br label %38

23:                                               ; preds = %2
  %24 = getelementptr inbounds %"class.XFaceApp::ApplicationBase", ptr %6, i32 0, i32 7
  %25 = load ptr, ptr %24, align 8, !tbaa !11
  %26 = icmp ne ptr %25, null
  br i1 %26, label %27, label %28

27:                                               ; preds = %23
  br label %30

28:                                               ; preds = %23
  call void @__assert_fail(ptr noundef @.str, ptr noundef @.str.1, i32 noundef 69, ptr noundef @__PRETTY_FUNCTION__._ZN8XFaceApp15ApplicationBase5queryERKNS0_5QUERYE) #2
  unreachable

29:                                               ; No predecessors!
  br label %30

30:                                               ; preds = %29, %27
  %31 = getelementptr inbounds %"class.XFaceApp::ApplicationBase", ptr %6, i32 0, i32 7
  %32 = load ptr, ptr %31, align 8, !tbaa !11
  %33 = load ptr, ptr %32, align 8, !tbaa !22
  %34 = getelementptr inbounds ptr, ptr %33, i64 1
  %35 = load ptr, ptr %34, align 8
  %36 = call noundef zeroext i1 %35(ptr noundef nonnull align 8 dereferenceable(40) %32)
  store i1 %36, ptr %3, align 1
  br label %38

37:                                               ; preds = %2
  store i1 false, ptr %3, align 1
  br label %38

38:                                               ; preds = %37, %30, %16
  %39 = load i1, ptr %3, align 1
  ret i1 %39
}

; Function Attrs: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) #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 = { 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 = { 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 = !{!"_ZTSN8XFaceApp15ApplicationBase5QUERYE", !7, i64 0}
!11 = !{!12, !6, i64 136}
!12 = !{!"_ZTSN8XFaceApp15ApplicationBaseE", !13, i64 0, !21, i64 96, !21, i64 97, !6, i64 104, !6, i64 112, !6, i64 120, !6, i64 128, !6, i64 136, !6, i64 144}
!13 = !{!"_ZTSN8XFaceApp15TaskHandlerBaseE", !14, i64 8, !6, i64 88}
!14 = !{!"_ZTSSt5queueIN8XFaceApp4TaskESt5dequeIS1_SaIS1_EEE", !15, i64 0}
!15 = !{!"_ZTSSt5dequeIN8XFaceApp4TaskESaIS1_EE", !16, i64 0}
!16 = !{!"_ZTSSt11_Deque_baseIN8XFaceApp4TaskESaIS1_EE", !17, i64 0}
!17 = !{!"_ZTSNSt11_Deque_baseIN8XFaceApp4TaskESaIS1_EE11_Deque_implE", !18, i64 0}
!18 = !{!"_ZTSNSt11_Deque_baseIN8XFaceApp4TaskESaIS1_EE16_Deque_impl_dataE", !6, i64 0, !19, i64 8, !20, i64 16, !20, i64 48}
!19 = !{!"long", !7, i64 0}
!20 = !{!"_ZTSSt15_Deque_iteratorIN8XFaceApp4TaskERS1_PS1_E", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24}
!21 = !{!"bool", !7, i64 0}
!22 = !{!23, !23, i64 0}
!23 = !{!"vtable pointer", !8, i64 0}


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

@.str = external hidden unnamed_addr constant [13 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [99 x i8], align 1
@__PRETTY_FUNCTION__._ZN8XFaceApp15ApplicationBase5queryERKNS0_5QUERYE = external hidden unnamed_addr constant [53 x i8], align 1

; Function Attrs: mustprogress uwtable
define dso_local noundef zeroext i1 @_ZN8XFaceApp15ApplicationBase5queryERKNS0_5QUERYE(ptr nocapture noundef nonnull readonly align 8 dereferenceable(152) %0, ptr nocapture noundef nonnull readonly align 4 dereferenceable(4) %1) local_unnamed_addr #0 align 2 {
  %3 = load i32, ptr %1, align 4, !tbaa !5
  switch i32 %3, label %19 [
    i32 0, label %4
    i32 1, label %10
  ]

4:                                                ; preds = %2
  %5 = getelementptr inbounds i8, ptr %0, i64 136
  %6 = load ptr, ptr %5, align 8, !tbaa !9
  %.not5 = icmp eq ptr %6, null
  br i1 %.not5, label %7, label %8

7:                                                ; preds = %4
  tail call void @__assert_fail(ptr noundef nonnull @.str, ptr noundef nonnull @.str.1, i32 noundef 65, ptr noundef nonnull @__PRETTY_FUNCTION__._ZN8XFaceApp15ApplicationBase5queryERKNS0_5QUERYE) #2
  unreachable

8:                                                ; preds = %4
  %9 = load ptr, ptr %6, align 8, !tbaa !21
  br label %.sink.split

10:                                               ; preds = %2
  %11 = getelementptr inbounds i8, ptr %0, i64 136
  %12 = load ptr, ptr %11, align 8, !tbaa !9
  %.not = icmp eq ptr %12, null
  br i1 %.not, label %13, label %14

13:                                               ; preds = %10
  tail call void @__assert_fail(ptr noundef nonnull @.str, ptr noundef nonnull @.str.1, i32 noundef 69, ptr noundef nonnull @__PRETTY_FUNCTION__._ZN8XFaceApp15ApplicationBase5queryERKNS0_5QUERYE) #2
  unreachable

14:                                               ; preds = %10
  %15 = load ptr, ptr %12, align 8, !tbaa !21
  %16 = getelementptr inbounds i8, ptr %15, i64 8
  br label %.sink.split

.sink.split:                                      ; preds = %8, %14
  %.sink7 = phi ptr [ %16, %14 ], [ %9, %8 ]
  %.sink = phi ptr [ %12, %14 ], [ %6, %8 ]
  %17 = load ptr, ptr %.sink7, align 8
  %18 = tail call noundef zeroext i1 %17(ptr noundef nonnull align 8 dereferenceable(40) %.sink)
  br label %19

19:                                               ; preds = %.sink.split, %2
  %.0 = phi i1 [ false, %2 ], [ %18, %.sink.split ]
  ret i1 %.0
}

; Function Attrs: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) 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 = { 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 = { 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 = !{!"_ZTSN8XFaceApp15ApplicationBase5QUERYE", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !17, i64 136}
!10 = !{!"_ZTSN8XFaceApp15ApplicationBaseE", !11, i64 0, !20, i64 96, !20, i64 97, !17, i64 104, !17, i64 112, !17, i64 120, !17, i64 128, !17, i64 136, !17, i64 144}
!11 = !{!"_ZTSN8XFaceApp15TaskHandlerBaseE", !12, i64 8, !17, i64 88}
!12 = !{!"_ZTSSt5queueIN8XFaceApp4TaskESt5dequeIS1_SaIS1_EEE", !13, i64 0}
!13 = !{!"_ZTSSt5dequeIN8XFaceApp4TaskESaIS1_EE", !14, i64 0}
!14 = !{!"_ZTSSt11_Deque_baseIN8XFaceApp4TaskESaIS1_EE", !15, i64 0}
!15 = !{!"_ZTSNSt11_Deque_baseIN8XFaceApp4TaskESaIS1_EE11_Deque_implE", !16, i64 0}
!16 = !{!"_ZTSNSt11_Deque_baseIN8XFaceApp4TaskESaIS1_EE16_Deque_impl_dataE", !17, i64 0, !18, i64 8, !19, i64 16, !19, i64 48}
!17 = !{!"any pointer", !7, i64 0}
!18 = !{!"long", !7, i64 0}
!19 = !{!"_ZTSSt15_Deque_iteratorIN8XFaceApp4TaskERS1_PS1_E", !17, i64 0, !17, i64 8, !17, i64 16, !17, i64 24}
!20 = !{!"bool", !7, i64 0}
!21 = !{!22, !22, i64 0}
!22 = !{!"vtable pointer", !8, i64 0}


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