; LLVM IR from niessner/Matterport :: code/gaps/pkgs/RNBasics/json.ll (ZN4Json6Reader17readCStyleCommentEv)

; 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.Json::Reader" = type <{ %"class.std::stack", %"class.std::deque.0", %"class.std::__cxx11::basic_string", ptr, ptr, ptr, ptr, ptr, %"class.std::__cxx11::basic_string", %"class.Json::Features", i8, [3 x i8] }>
%"class.std::stack" = type { %"class.std::deque" }
%"class.std::deque" = type { %"class.std::_Deque_base" }
%"class.std::_Deque_base" = type { %"struct.std::_Deque_base<Json::Value *, std::allocator<Json::Value *>>::_Deque_impl" }
%"struct.std::_Deque_base<Json::Value *, std::allocator<Json::Value *>>::_Deque_impl" = type { %"struct.std::_Deque_base<Json::Value *, std::allocator<Json::Value *>>::_Deque_impl_data" }
%"struct.std::_Deque_base<Json::Value *, std::allocator<Json::Value *>>::_Deque_impl_data" = type { ptr, i64, %"struct.std::_Deque_iterator", %"struct.std::_Deque_iterator" }
%"struct.std::_Deque_iterator" = type { ptr, ptr, ptr, ptr }
%"class.std::deque.0" = type { %"class.std::_Deque_base.1" }
%"class.std::_Deque_base.1" = type { %"struct.std::_Deque_base<Json::Reader::ErrorInfo, std::allocator<Json::Reader::ErrorInfo>>::_Deque_impl" }
%"struct.std::_Deque_base<Json::Reader::ErrorInfo, std::allocator<Json::Reader::ErrorInfo>>::_Deque_impl" = type { %"struct.std::_Deque_base<Json::Reader::ErrorInfo, std::allocator<Json::Reader::ErrorInfo>>::_Deque_impl_data" }
%"struct.std::_Deque_base<Json::Reader::ErrorInfo, std::allocator<Json::Reader::ErrorInfo>>::_Deque_impl_data" = type { ptr, i64, %"struct.std::_Deque_iterator.5", %"struct.std::_Deque_iterator.5" }
%"struct.std::_Deque_iterator.5" = type { ptr, ptr, ptr, ptr }
%"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.Json::Features" = type { i8, i8, i8, i8 }

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

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef signext i8 @_ZN4Json6Reader11getNextCharEv(ptr noundef nonnull align 8 dereferenceable(269)) #1 align 2

; Function Attrs: mustprogress uwtable
define dso_local noundef zeroext i1 @_ZN4Json6Reader17readCStyleCommentEv(ptr noundef nonnull align 8 dereferenceable(269) %0) #2 align 2 {
  %2 = alloca ptr, align 8
  %3 = alloca i8, align 1
  %4 = alloca i32, align 4
  store ptr %0, ptr %2, align 8, !tbaa !5
  %5 = load ptr, ptr %2, align 8
  br label %6

6:                                                ; preds = %27, %1
  %7 = getelementptr inbounds %"class.Json::Reader", ptr %5, i32 0, i32 5
  %8 = load ptr, ptr %7, align 8, !tbaa !9
  %9 = getelementptr inbounds %"class.Json::Reader", ptr %5, i32 0, i32 4
  %10 = load ptr, ptr %9, align 8, !tbaa !27
  %11 = icmp ne ptr %8, %10
  br i1 %11, label %12, label %28

12:                                               ; preds = %6
  call void @llvm.lifetime.start.p0(i64 1, ptr %3) #3
  %13 = call noundef signext i8 @_ZN4Json6Reader11getNextCharEv(ptr noundef nonnull align 8 dereferenceable(269) %5)
  store i8 %13, ptr %3, align 1, !tbaa !28
  %14 = load i8, ptr %3, align 1, !tbaa !28
  %15 = sext i8 %14 to i32
  %16 = icmp eq i32 %15, 42
  br i1 %16, label %17, label %24

17:                                               ; preds = %12
  %18 = getelementptr inbounds %"class.Json::Reader", ptr %5, i32 0, i32 5
  %19 = load ptr, ptr %18, align 8, !tbaa !9
  %20 = load i8, ptr %19, align 1, !tbaa !28
  %21 = sext i8 %20 to i32
  %22 = icmp eq i32 %21, 47
  br i1 %22, label %23, label %24

23:                                               ; preds = %17
  store i32 3, ptr %4, align 4
  br label %25

24:                                               ; preds = %17, %12
  store i32 0, ptr %4, align 4
  br label %25

25:                                               ; preds = %24, %23
  call void @llvm.lifetime.end.p0(i64 1, ptr %3) #3
  %26 = load i32, ptr %4, align 4
  switch i32 %26, label %32 [
    i32 0, label %27
    i32 3, label %28
  ]

27:                                               ; preds = %25
  br label %6, !llvm.loop !29

28:                                               ; preds = %25, %6
  %29 = call noundef signext i8 @_ZN4Json6Reader11getNextCharEv(ptr noundef nonnull align 8 dereferenceable(269) %5)
  %30 = sext i8 %29 to i32
  %31 = icmp eq i32 %30, 47
  ret i1 %31

32:                                               ; preds = %25
  unreachable
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { 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, !6, i64 208}
!10 = !{!"_ZTSN4Json6ReaderE", !11, i64 0, !18, i64 80, !23, i64 160, !6, i64 192, !6, i64 200, !6, i64 208, !6, i64 216, !6, i64 224, !23, i64 232, !25, i64 264, !26, i64 268}
!11 = !{!"_ZTSSt5stackIPN4Json5ValueESt5dequeIS2_SaIS2_EEE", !12, i64 0}
!12 = !{!"_ZTSSt5dequeIPN4Json5ValueESaIS2_EE", !13, i64 0}
!13 = !{!"_ZTSSt11_Deque_baseIPN4Json5ValueESaIS2_EE", !14, i64 0}
!14 = !{!"_ZTSNSt11_Deque_baseIPN4Json5ValueESaIS2_EE11_Deque_implE", !15, i64 0}
!15 = !{!"_ZTSNSt11_Deque_baseIPN4Json5ValueESaIS2_EE16_Deque_impl_dataE", !6, i64 0, !16, i64 8, !17, i64 16, !17, i64 48}
!16 = !{!"long", !7, i64 0}
!17 = !{!"_ZTSSt15_Deque_iteratorIPN4Json5ValueERS2_PS2_E", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24}
!18 = !{!"_ZTSSt5dequeIN4Json6Reader9ErrorInfoESaIS2_EE", !19, i64 0}
!19 = !{!"_ZTSSt11_Deque_baseIN4Json6Reader9ErrorInfoESaIS2_EE", !20, i64 0}
!20 = !{!"_ZTSNSt11_Deque_baseIN4Json6Reader9ErrorInfoESaIS2_EE11_Deque_implE", !21, i64 0}
!21 = !{!"_ZTSNSt11_Deque_baseIN4Json6Reader9ErrorInfoESaIS2_EE16_Deque_impl_dataE", !6, i64 0, !16, i64 8, !22, i64 16, !22, i64 48}
!22 = !{!"_ZTSSt15_Deque_iteratorIN4Json6Reader9ErrorInfoERS2_PS2_E", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24}
!23 = !{!"_ZTSNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE", !24, i64 0, !16, i64 8, !7, i64 16}
!24 = !{!"_ZTSNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_Alloc_hiderE", !6, i64 0}
!25 = !{!"_ZTSN4Json8FeaturesE", !26, i64 0, !26, i64 1, !26, i64 2, !26, i64 3}
!26 = !{!"bool", !7, i64 0}
!27 = !{!10, !6, i64 200}
!28 = !{!7, !7, i64 0}
!29 = distinct !{!29, !30}
!30 = !{!"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"

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef signext i8 @_ZN4Json6Reader11getNextCharEv(ptr noundef nonnull align 8 dereferenceable(269)) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress nounwind uwtable
define dso_local noundef zeroext i1 @_ZN4Json6Reader17readCStyleCommentEv(ptr noundef nonnull align 8 dereferenceable(269) %0) local_unnamed_addr #0 align 2 {
  %2 = getelementptr inbounds i8, ptr %0, i64 208
  %3 = getelementptr inbounds i8, ptr %0, i64 200
  %4 = load ptr, ptr %2, align 8, !tbaa !5
  %5 = load ptr, ptr %3, align 8, !tbaa !26
  %.not4 = icmp eq ptr %4, %5
  br i1 %.not4, label %.thread, label %.lr.ph

.lr.ph:                                           ; preds = %1, %.lr.ph.backedge
  %6 = tail call noundef signext i8 @_ZN4Json6Reader11getNextCharEv(ptr noundef nonnull align 8 dereferenceable(269) %0)
  %7 = icmp eq i8 %6, 42
  %.pre = load ptr, ptr %2, align 8, !tbaa !5
  br i1 %7, label %8, label %12

8:                                                ; preds = %.lr.ph
  %9 = load i8, ptr %.pre, align 1, !tbaa !27
  %10 = icmp eq i8 %9, 47
  %11 = load ptr, ptr %3, align 8
  %.not = icmp eq ptr %.pre, %11
  %or.cond = select i1 %10, i1 true, i1 %.not
  br i1 %or.cond, label %.thread, label %.lr.ph.backedge

12:                                               ; preds = %.lr.ph
  %.old = load ptr, ptr %3, align 8, !tbaa !26
  %.not.old = icmp eq ptr %.pre, %.old
  br i1 %.not.old, label %.thread, label %.lr.ph.backedge

.lr.ph.backedge:                                  ; preds = %12, %8
  br label %.lr.ph

.thread:                                          ; preds = %12, %8, %1
  %13 = tail call noundef signext i8 @_ZN4Json6Reader11getNextCharEv(ptr noundef nonnull align 8 dereferenceable(269) %0)
  %14 = icmp eq i8 %13, 47
  ret i1 %14
}

attributes #0 = { 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" }

!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, !12, i64 208}
!6 = !{!"_ZTSN4Json6ReaderE", !7, i64 0, !17, i64 80, !22, i64 160, !12, i64 192, !12, i64 200, !12, i64 208, !12, i64 216, !12, i64 224, !22, i64 232, !24, i64 264, !25, i64 268}
!7 = !{!"_ZTSSt5stackIPN4Json5ValueESt5dequeIS2_SaIS2_EEE", !8, i64 0}
!8 = !{!"_ZTSSt5dequeIPN4Json5ValueESaIS2_EE", !9, i64 0}
!9 = !{!"_ZTSSt11_Deque_baseIPN4Json5ValueESaIS2_EE", !10, i64 0}
!10 = !{!"_ZTSNSt11_Deque_baseIPN4Json5ValueESaIS2_EE11_Deque_implE", !11, i64 0}
!11 = !{!"_ZTSNSt11_Deque_baseIPN4Json5ValueESaIS2_EE16_Deque_impl_dataE", !12, i64 0, !15, i64 8, !16, i64 16, !16, i64 48}
!12 = !{!"any pointer", !13, i64 0}
!13 = !{!"omnipotent char", !14, i64 0}
!14 = !{!"Simple C++ TBAA"}
!15 = !{!"long", !13, i64 0}
!16 = !{!"_ZTSSt15_Deque_iteratorIPN4Json5ValueERS2_PS2_E", !12, i64 0, !12, i64 8, !12, i64 16, !12, i64 24}
!17 = !{!"_ZTSSt5dequeIN4Json6Reader9ErrorInfoESaIS2_EE", !18, i64 0}
!18 = !{!"_ZTSSt11_Deque_baseIN4Json6Reader9ErrorInfoESaIS2_EE", !19, i64 0}
!19 = !{!"_ZTSNSt11_Deque_baseIN4Json6Reader9ErrorInfoESaIS2_EE11_Deque_implE", !20, i64 0}
!20 = !{!"_ZTSNSt11_Deque_baseIN4Json6Reader9ErrorInfoESaIS2_EE16_Deque_impl_dataE", !12, i64 0, !15, i64 8, !21, i64 16, !21, i64 48}
!21 = !{!"_ZTSSt15_Deque_iteratorIN4Json6Reader9ErrorInfoERS2_PS2_E", !12, i64 0, !12, i64 8, !12, i64 16, !12, i64 24}
!22 = !{!"_ZTSNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE", !23, i64 0, !15, i64 8, !13, i64 16}
!23 = !{!"_ZTSNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_Alloc_hiderE", !12, i64 0}
!24 = !{!"_ZTSN4Json8FeaturesE", !25, i64 0, !25, i64 1, !25, i64 2, !25, i64 3}
!25 = !{!"bool", !13, i64 0}
!26 = !{!6, !12, i64 200}
!27 = !{!13, !13, i64 0}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass