; LLVM IR from junhyeokahn/PyPnC :: external_source/yaml/src/stream.ll (ZNK4YAML6Stream13StreamInUtf32Ev)

; 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.YAML::Stream" = type { ptr, %"struct.YAML::Mark", i32, %"class.std::deque", ptr, i64, i64 }
%"struct.YAML::Mark" = type { i32, i32, i32 }
%"class.std::deque" = type { %"class.std::_Deque_base" }
%"class.std::_Deque_base" = type { %"struct.std::_Deque_base<char, std::allocator<char>>::_Deque_impl" }
%"struct.std::_Deque_base<char, std::allocator<char>>::_Deque_impl" = type { %"struct.std::_Deque_base<char, std::allocator<char>>::_Deque_impl_data" }
%"struct.std::_Deque_base<char, std::allocator<char>>::_Deque_impl_data" = type { ptr, i64, %"struct.std::_Deque_iterator", %"struct.std::_Deque_iterator" }
%"struct.std::_Deque_iterator" = type { ptr, ptr, ptr, ptr }

@_ZZNK4YAML6Stream13StreamInUtf32EvE7indexes = external hidden global [2 x [4 x i32]], align 16

; 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 noundef zeroext i1 @_ZNKSt9basic_iosIcSt11char_traitsIcEE4goodEv(ptr noundef nonnull align 8 dereferenceable(264)) #1 align 2

; Function Attrs: mustprogress uwtable
define dso_local void @_ZNK4YAML6Stream13StreamInUtf32Ev(ptr noundef nonnull align 8 dereferenceable(128) %0) #2 align 2 {
  %2 = alloca ptr, align 8
  %3 = alloca i64, align 8
  %4 = alloca [4 x i8], align 1
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  store ptr %0, ptr %2, align 8, !tbaa !5
  %8 = load ptr, ptr %2, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #4
  store i64 0, ptr %3, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #4
  %9 = getelementptr inbounds %"class.YAML::Stream", ptr %8, i32 0, i32 2
  %10 = load i32, ptr %9, align 4, !tbaa !11
  %11 = icmp eq i32 %10, 4
  br i1 %11, label %12, label %13

12:                                               ; preds = %1
  br label %14

13:                                               ; preds = %1
  br label %14

14:                                               ; preds = %13, %12
  %15 = phi ptr [ getelementptr inbounds ([2 x [4 x i32]], ptr @_ZZNK4YAML6Stream13StreamInUtf32EvE7indexes, i64 0, i64 1), %12 ], [ @_ZZNK4YAML6Stream13StreamInUtf32EvE7indexes, %13 ]
  %16 = getelementptr inbounds [4 x i32], ptr %15, i64 0, i64 0
  store ptr %16, ptr %5, align 8, !tbaa !5
  %17 = call noundef zeroext i8 @_ZNK4YAML6Stream11GetNextByteEv(ptr noundef nonnull align 8 dereferenceable(128) %8)
  %18 = getelementptr inbounds [4 x i8], ptr %4, i64 0, i64 0
  store i8 %17, ptr %18, align 1, !tbaa !21
  %19 = call noundef zeroext i8 @_ZNK4YAML6Stream11GetNextByteEv(ptr noundef nonnull align 8 dereferenceable(128) %8)
  %20 = getelementptr inbounds [4 x i8], ptr %4, i64 0, i64 1
  store i8 %19, ptr %20, align 1, !tbaa !21
  %21 = call noundef zeroext i8 @_ZNK4YAML6Stream11GetNextByteEv(ptr noundef nonnull align 8 dereferenceable(128) %8)
  %22 = getelementptr inbounds [4 x i8], ptr %4, i64 0, i64 2
  store i8 %21, ptr %22, align 1, !tbaa !21
  %23 = call noundef zeroext i8 @_ZNK4YAML6Stream11GetNextByteEv(ptr noundef nonnull align 8 dereferenceable(128) %8)
  %24 = getelementptr inbounds [4 x i8], ptr %4, i64 0, i64 3
  store i8 %23, ptr %24, align 1, !tbaa !21
  %25 = getelementptr inbounds %"class.YAML::Stream", ptr %8, i32 0, i32 0
  %26 = load ptr, ptr %25, align 8, !tbaa !22
  %27 = load ptr, ptr %26, align 8, !tbaa !23
  %28 = getelementptr i8, ptr %27, i64 -24
  %29 = load i64, ptr %28, align 8
  %30 = getelementptr inbounds i8, ptr %26, i64 %29
  %31 = call noundef zeroext i1 @_ZNKSt9basic_iosIcSt11char_traitsIcEE4goodEv(ptr noundef nonnull align 8 dereferenceable(264) %30)
  br i1 %31, label %33, label %32

32:                                               ; preds = %14
  store i32 1, ptr %6, align 4
  br label %58

33:                                               ; preds = %14
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #4
  store i32 0, ptr %7, align 4, !tbaa !25
  br label %34

34:                                               ; preds = %52, %33
  %35 = load i32, ptr %7, align 4, !tbaa !25
  %36 = icmp slt i32 %35, 4
  br i1 %36, label %38, label %37

37:                                               ; preds = %34
  store i32 2, ptr %6, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #4
  br label %55

38:                                               ; preds = %34
  %39 = load i64, ptr %3, align 8, !tbaa !9
  %40 = shl i64 %39, 8
  store i64 %40, ptr %3, align 8, !tbaa !9
  %41 = load ptr, ptr %5, align 8, !tbaa !5
  %42 = load i32, ptr %7, align 4, !tbaa !25
  %43 = sext i32 %42 to i64
  %44 = getelementptr inbounds i32, ptr %41, i64 %43
  %45 = load i32, ptr %44, align 4, !tbaa !25
  %46 = sext i32 %45 to i64
  %47 = getelementptr inbounds [4 x i8], ptr %4, i64 0, i64 %46
  %48 = load i8, ptr %47, align 1, !tbaa !21
  %49 = zext i8 %48 to i64
  %50 = load i64, ptr %3, align 8, !tbaa !9
  %51 = or i64 %50, %49
  store i64 %51, ptr %3, align 8, !tbaa !9
  br label %52

52:                                               ; preds = %38
  %53 = load i32, ptr %7, align 4, !tbaa !25
  %54 = add nsw i32 %53, 1
  store i32 %54, ptr %7, align 4, !tbaa !25
  br label %34, !llvm.loop !26

55:                                               ; preds = %37
  %56 = getelementptr inbounds %"class.YAML::Stream", ptr %8, i32 0, i32 3
  %57 = load i64, ptr %3, align 8, !tbaa !9
  call void @_ZN4YAML21QueueUnicodeCodepointERSt5dequeIcSaIcEEm(ptr noundef nonnull align 8 dereferenceable(80) %56, i64 noundef %57)
  store i32 0, ptr %6, align 4
  br label %58

58:                                               ; preds = %55, %32
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #4
  %59 = load i32, ptr %6, align 4
  switch i32 %59, label %61 [
    i32 0, label %60
    i32 1, label %60
  ]

60:                                               ; preds = %58, %58
  ret void

61:                                               ; preds = %58
  unreachable
}

; Function Attrs: mustprogress uwtable
declare dso_local noundef zeroext i8 @_ZNK4YAML6Stream11GetNextByteEv(ptr noundef nonnull align 8 dereferenceable(128)) #2 align 2

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZN4YAML21QueueUnicodeCodepointERSt5dequeIcSaIcEEm(ptr noundef nonnull align 8 dereferenceable(80), i64 noundef) #3

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 = { inlinehint 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 #4 = { 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 = !{!"long", !7, i64 0}
!11 = !{!12, !15, i64 20}
!12 = !{!"_ZTSN4YAML6StreamE", !6, i64 0, !13, i64 8, !15, i64 20, !16, i64 24, !6, i64 104, !10, i64 112, !10, i64 120}
!13 = !{!"_ZTSN4YAML4MarkE", !14, i64 0, !14, i64 4, !14, i64 8}
!14 = !{!"int", !7, i64 0}
!15 = !{!"_ZTSN4YAML6Stream12CharacterSetE", !7, i64 0}
!16 = !{!"_ZTSSt5dequeIcSaIcEE", !17, i64 0}
!17 = !{!"_ZTSSt11_Deque_baseIcSaIcEE", !18, i64 0}
!18 = !{!"_ZTSNSt11_Deque_baseIcSaIcEE11_Deque_implE", !19, i64 0}
!19 = !{!"_ZTSNSt11_Deque_baseIcSaIcEE16_Deque_impl_dataE", !6, i64 0, !10, i64 8, !20, i64 16, !20, i64 48}
!20 = !{!"_ZTSSt15_Deque_iteratorIcRcPcE", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24}
!21 = !{!7, !7, i64 0}
!22 = !{!12, !6, i64 0}
!23 = !{!24, !24, i64 0}
!24 = !{!"vtable pointer", !8, i64 0}
!25 = !{!14, !14, i64 0}
!26 = distinct !{!26, !27}
!27 = !{!"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"

@_ZZNK4YAML6Stream13StreamInUtf32EvE7indexes = external hidden local_unnamed_addr global [2 x [4 x i32]], align 16

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

; Function Attrs: mustprogress 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 noundef zeroext i1 @_ZNKSt9basic_iosIcSt11char_traitsIcEE4goodEv(ptr noundef nonnull align 8 dereferenceable(264)) local_unnamed_addr #1 align 2

; Function Attrs: mustprogress uwtable
define dso_local void @_ZNK4YAML6Stream13StreamInUtf32Ev(ptr noundef nonnull align 8 dereferenceable(128) %0) local_unnamed_addr #2 align 2 {
  %2 = alloca [4 x i8], align 1
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %2) #4
  %3 = getelementptr inbounds i8, ptr %0, i64 20
  %4 = load i32, ptr %3, align 4, !tbaa !5
  %5 = tail call noundef zeroext i8 @_ZNK4YAML6Stream11GetNextByteEv(ptr noundef nonnull align 8 dereferenceable(128) %0)
  store i8 %5, ptr %2, align 1, !tbaa !19
  %6 = tail call noundef zeroext i8 @_ZNK4YAML6Stream11GetNextByteEv(ptr noundef nonnull align 8 dereferenceable(128) %0)
  %7 = getelementptr inbounds i8, ptr %2, i64 1
  store i8 %6, ptr %7, align 1, !tbaa !19
  %8 = tail call noundef zeroext i8 @_ZNK4YAML6Stream11GetNextByteEv(ptr noundef nonnull align 8 dereferenceable(128) %0)
  %9 = getelementptr inbounds i8, ptr %2, i64 2
  store i8 %8, ptr %9, align 1, !tbaa !19
  %10 = tail call noundef zeroext i8 @_ZNK4YAML6Stream11GetNextByteEv(ptr noundef nonnull align 8 dereferenceable(128) %0)
  %11 = getelementptr inbounds i8, ptr %2, i64 3
  store i8 %10, ptr %11, align 1, !tbaa !19
  %12 = load ptr, ptr %0, align 8, !tbaa !20
  %13 = load ptr, ptr %12, align 8, !tbaa !21
  %14 = getelementptr i8, ptr %13, i64 -24
  %15 = load i64, ptr %14, align 8
  %16 = getelementptr inbounds i8, ptr %12, i64 %15
  %17 = tail call noundef zeroext i1 @_ZNKSt9basic_iosIcSt11char_traitsIcEE4goodEv(ptr noundef nonnull align 8 dereferenceable(264) %16)
  br i1 %17, label %.preheader.preheader, label %46

.preheader.preheader:                             ; preds = %1
  %18 = icmp eq i32 %4, 4
  %.val14 = load i32, ptr getelementptr inbounds (i8, ptr @_ZZNK4YAML6Stream13StreamInUtf32EvE7indexes, i64 16), align 16
  %_ZZNK4YAML6Stream13StreamInUtf32EvE7indexes.val = load i32, ptr @_ZZNK4YAML6Stream13StreamInUtf32EvE7indexes, align 16
  %19 = select i1 %18, i32 %.val14, i32 %_ZZNK4YAML6Stream13StreamInUtf32EvE7indexes.val
  %20 = sext i32 %19 to i64
  %21 = getelementptr inbounds [4 x i8], ptr %2, i64 0, i64 %20
  %22 = load i8, ptr %21, align 1, !tbaa !19
  %23 = zext i8 %22 to i64
  %.val = load i32, ptr getelementptr inbounds (i8, ptr @_ZZNK4YAML6Stream13StreamInUtf32EvE7indexes, i64 20), align 4
  %.val11 = load i32, ptr getelementptr inbounds (i8, ptr @_ZZNK4YAML6Stream13StreamInUtf32EvE7indexes, i64 4), align 4
  %24 = select i1 %18, i32 %.val, i32 %.val11
  %25 = sext i32 %24 to i64
  %26 = getelementptr inbounds [4 x i8], ptr %2, i64 0, i64 %25
  %27 = load i8, ptr %26, align 1, !tbaa !19
  %28 = zext i8 %27 to i64
  %29 = shl nuw nsw i64 %23, 16
  %30 = shl nuw nsw i64 %28, 8
  %31 = or disjoint i64 %29, %30
  %.val12 = load i32, ptr getelementptr inbounds (i8, ptr @_ZZNK4YAML6Stream13StreamInUtf32EvE7indexes, i64 24), align 8
  %.val13 = load i32, ptr getelementptr inbounds (i8, ptr @_ZZNK4YAML6Stream13StreamInUtf32EvE7indexes, i64 8), align 8
  %32 = select i1 %18, i32 %.val12, i32 %.val13
  %33 = sext i32 %32 to i64
  %34 = getelementptr inbounds [4 x i8], ptr %2, i64 0, i64 %33
  %35 = load i8, ptr %34, align 1, !tbaa !19
  %36 = zext i8 %35 to i64
  %37 = or disjoint i64 %31, %36
  %38 = shl nuw nsw i64 %37, 8
  %.val15 = load i32, ptr getelementptr inbounds (i8, ptr @_ZZNK4YAML6Stream13StreamInUtf32EvE7indexes, i64 28), align 4
  %.val16 = load i32, ptr getelementptr inbounds (i8, ptr @_ZZNK4YAML6Stream13StreamInUtf32EvE7indexes, i64 12), align 4
  %39 = select i1 %18, i32 %.val15, i32 %.val16
  %40 = sext i32 %39 to i64
  %41 = getelementptr inbounds [4 x i8], ptr %2, i64 0, i64 %40
  %42 = load i8, ptr %41, align 1, !tbaa !19
  %43 = zext i8 %42 to i64
  %44 = or disjoint i64 %38, %43
  %45 = getelementptr inbounds i8, ptr %0, i64 24
  tail call void @_ZN4YAML21QueueUnicodeCodepointERSt5dequeIcSaIcEEm(ptr noundef nonnull align 8 dereferenceable(80) %45, i64 noundef %44)
  br label %46

46:                                               ; preds = %1, %.preheader.preheader
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %2) #4
  ret void
}

; Function Attrs: mustprogress uwtable
declare dso_local noundef zeroext i8 @_ZNK4YAML6Stream11GetNextByteEv(ptr noundef nonnull align 8 dereferenceable(128)) local_unnamed_addr #2 align 2

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZN4YAML21QueueUnicodeCodepointERSt5dequeIcSaIcEEm(ptr noundef nonnull align 8 dereferenceable(80), i64 noundef) local_unnamed_addr #3

attributes #0 = { mustprogress 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 = { inlinehint 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 #4 = { 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, !12, i64 20}
!6 = !{!"_ZTSN4YAML6StreamE", !7, i64 0, !10, i64 8, !12, i64 20, !13, i64 24, !7, i64 104, !17, i64 112, !17, i64 120}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"_ZTSN4YAML4MarkE", !11, i64 0, !11, i64 4, !11, i64 8}
!11 = !{!"int", !8, i64 0}
!12 = !{!"_ZTSN4YAML6Stream12CharacterSetE", !8, i64 0}
!13 = !{!"_ZTSSt5dequeIcSaIcEE", !14, i64 0}
!14 = !{!"_ZTSSt11_Deque_baseIcSaIcEE", !15, i64 0}
!15 = !{!"_ZTSNSt11_Deque_baseIcSaIcEE11_Deque_implE", !16, i64 0}
!16 = !{!"_ZTSNSt11_Deque_baseIcSaIcEE16_Deque_impl_dataE", !7, i64 0, !17, i64 8, !18, i64 16, !18, i64 48}
!17 = !{!"long", !8, i64 0}
!18 = !{!"_ZTSSt15_Deque_iteratorIcRcPcE", !7, i64 0, !7, i64 8, !7, i64 16, !7, i64 24}
!19 = !{!8, !8, i64 0}
!20 = !{!6, !7, i64 0}
!21 = !{!22, !22, i64 0}
!22 = !{!"vtable pointer", !9, i64 0}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IndVarSimplifyPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,LCSSAPass,LoopRotatePass,LoopSimplifyPass,ReassociatePass,SCCPPass,SROAPass,SimplifyCFGPass,TailCallElimPass