; LLVM IR from xhub/reshop :: gui/external/imguial/imguial_term.ll (ZN7ImGuiAl3Log4putsEhPKc)

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

%"struct.ImGuiAl::Crt::Info" = type { i32, i32, i32 }
%"class.ImGuiAl::Crt" = type <{ %"class.ImGuiAl::Fifo", i32, i32, i8, [7 x i8] }>
%"class.ImGuiAl::Fifo" = type { ptr, i64, i64, i64, i64 }
%"class.ImGuiAl::Log" = type { %"class.ImGuiAl::Crt.base", i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, i32, i8, [3 x i8], %struct.ImGuiTextFilter }
%"class.ImGuiAl::Crt.base" = type <{ %"class.ImGuiAl::Fifo", i32, i32, i8 }>
%struct.ImGuiTextFilter = type <{ [256 x i8], %struct.ImVector, i32, [4 x i8] }>
%struct.ImVector = type { i32, i32, ptr }

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN7ImGuiAl4Fifo4readEPvm(ptr noundef nonnull align 8 dereferenceable(40), ptr noundef, 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: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN7ImGuiAl4Fifo5writeEPKvm(ptr noundef nonnull align 8 dereferenceable(40), ptr noundef, i64 noundef) #0 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN7ImGuiAl4Fifo4skipEm(ptr noundef nonnull align 8 dereferenceable(40), i64 noundef) #0 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i64 @_ZNK7ImGuiAl4Fifo9availableEv(ptr noundef nonnull align 8 dereferenceable(40)) #0 align 2

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN7ImGuiAl3Log4putsEhPKc(ptr noundef nonnull align 8 dereferenceable(456) %0, i8 noundef zeroext %1, ptr noundef %2) #2 align 2 {
  %4 = alloca ptr, align 8
  %5 = alloca i8, align 1
  %6 = alloca ptr, align 8
  %7 = alloca i64, align 8
  %8 = alloca %"struct.ImGuiAl::Crt::Info", align 4
  %9 = alloca %"struct.ImGuiAl::Crt::Info", align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  store i8 %1, ptr %5, align 1, !tbaa !9
  store ptr %2, ptr %6, align 8, !tbaa !5
  %10 = load ptr, ptr %4, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #4
  %11 = load ptr, ptr %6, align 8, !tbaa !5
  %12 = call i64 @strlen(ptr noundef %11) #5
  store i64 %12, ptr %7, align 8, !tbaa !10
  br label %13

13:                                               ; preds = %19, %3
  %14 = load i64, ptr %7, align 8, !tbaa !10
  %15 = add i64 %14, 12
  %16 = getelementptr inbounds %"class.ImGuiAl::Crt", ptr %10, i32 0, i32 0
  %17 = call noundef i64 @_ZNK7ImGuiAl4Fifo9availableEv(ptr noundef nonnull align 8 dereferenceable(40) %16)
  %18 = icmp ugt i64 %15, %17
  br i1 %18, label %19, label %25

19:                                               ; preds = %13
  call void @llvm.lifetime.start.p0(i64 12, ptr %8) #4
  %20 = getelementptr inbounds %"class.ImGuiAl::Crt", ptr %10, i32 0, i32 0
  call void @_ZN7ImGuiAl4Fifo4readEPvm(ptr noundef nonnull align 8 dereferenceable(40) %20, ptr noundef %8, i64 noundef 12)
  %21 = getelementptr inbounds %"class.ImGuiAl::Crt", ptr %10, i32 0, i32 0
  %22 = getelementptr inbounds %"struct.ImGuiAl::Crt::Info", ptr %8, i32 0, i32 1
  %23 = load i32, ptr %22, align 4, !tbaa !12
  %24 = zext i32 %23 to i64
  call void @_ZN7ImGuiAl4Fifo4skipEm(ptr noundef nonnull align 8 dereferenceable(40) %21, i64 noundef %24)
  call void @llvm.lifetime.end.p0(i64 12, ptr %8) #4
  br label %13, !llvm.loop !15

25:                                               ; preds = %13
  call void @llvm.lifetime.start.p0(i64 12, ptr %9) #4
  %26 = load i64, ptr %7, align 8, !tbaa !10
  %27 = trunc i64 %26 to i32
  %28 = getelementptr inbounds %"struct.ImGuiAl::Crt::Info", ptr %9, i32 0, i32 1
  store i32 %27, ptr %28, align 4, !tbaa !12
  %29 = load i8, ptr %5, align 1, !tbaa !9
  %30 = zext i8 %29 to i32
  %31 = getelementptr inbounds %"struct.ImGuiAl::Crt::Info", ptr %9, i32 0, i32 2
  store i32 %30, ptr %31, align 4, !tbaa !17
  %32 = load i8, ptr %5, align 1, !tbaa !9
  %33 = zext i8 %32 to i32
  switch i32 %33, label %50 [
    i32 0, label %34
    i32 1, label %38
    i32 2, label %42
    i32 3, label %46
  ]

34:                                               ; preds = %25
  %35 = getelementptr inbounds %"class.ImGuiAl::Log", ptr %10, i32 0, i32 1
  %36 = load i32, ptr %35, align 4, !tbaa !18
  %37 = getelementptr inbounds %"struct.ImGuiAl::Crt::Info", ptr %9, i32 0, i32 0
  store i32 %36, ptr %37, align 4, !tbaa !26
  br label %50

38:                                               ; preds = %25
  %39 = getelementptr inbounds %"class.ImGuiAl::Log", ptr %10, i32 0, i32 4
  %40 = load i32, ptr %39, align 8, !tbaa !27
  %41 = getelementptr inbounds %"struct.ImGuiAl::Crt::Info", ptr %9, i32 0, i32 0
  store i32 %40, ptr %41, align 4, !tbaa !26
  br label %50

42:                                               ; preds = %25
  %43 = getelementptr inbounds %"class.ImGuiAl::Log", ptr %10, i32 0, i32 7
  %44 = load i32, ptr %43, align 4, !tbaa !28
  %45 = getelementptr inbounds %"struct.ImGuiAl::Crt::Info", ptr %9, i32 0, i32 0
  store i32 %44, ptr %45, align 4, !tbaa !26
  br label %50

46:                                               ; preds = %25
  %47 = getelementptr inbounds %"class.ImGuiAl::Log", ptr %10, i32 0, i32 10
  %48 = load i32, ptr %47, align 8, !tbaa !29
  %49 = getelementptr inbounds %"struct.ImGuiAl::Crt::Info", ptr %9, i32 0, i32 0
  store i32 %48, ptr %49, align 4, !tbaa !26
  br label %50

50:                                               ; preds = %46, %42, %38, %34, %25
  %51 = getelementptr inbounds %"class.ImGuiAl::Crt", ptr %10, i32 0, i32 0
  call void @_ZN7ImGuiAl4Fifo5writeEPKvm(ptr noundef nonnull align 8 dereferenceable(40) %51, ptr noundef %9, i64 noundef 12)
  %52 = getelementptr inbounds %"class.ImGuiAl::Crt", ptr %10, i32 0, i32 0
  %53 = load ptr, ptr %6, align 8, !tbaa !5
  %54 = load i64, ptr %7, align 8, !tbaa !10
  call void @_ZN7ImGuiAl4Fifo5writeEPKvm(ptr noundef nonnull align 8 dereferenceable(40) %52, ptr noundef %53, i64 noundef %54)
  call void @llvm.lifetime.end.p0(i64 12, ptr %9) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #4
  ret void
}

; Function Attrs: nounwind willreturn memory(read)
declare i64 @strlen(ptr noundef) #3

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" }
attributes #1 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 willreturn memory(read) "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 }
attributes #5 = { nounwind willreturn memory(read) }

!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 = !{!7, !7, i64 0}
!10 = !{!11, !11, i64 0}
!11 = !{!"long", !7, i64 0}
!12 = !{!13, !14, i64 4}
!13 = !{!"_ZTSN7ImGuiAl3Crt4InfoE", !14, i64 0, !14, i64 4, !14, i64 8}
!14 = !{!"int", !7, i64 0}
!15 = distinct !{!15, !16}
!16 = !{!"llvm.loop.mustprogress"}
!17 = !{!13, !14, i64 8}
!18 = !{!19, !14, i64 52}
!19 = !{!"_ZTSN7ImGuiAl3LogE", !20, i64 0, !14, i64 52, !14, i64 56, !14, i64 60, !14, i64 64, !14, i64 68, !14, i64 72, !14, i64 76, !14, i64 80, !14, i64 84, !14, i64 88, !14, i64 92, !14, i64 96, !6, i64 104, !6, i64 112, !6, i64 120, !6, i64 128, !6, i64 136, !6, i64 144, !6, i64 152, !6, i64 160, !23, i64 168, !22, i64 172, !24, i64 176}
!20 = !{!"_ZTSN7ImGuiAl3CrtE", !21, i64 0, !14, i64 40, !14, i64 44, !22, i64 48}
!21 = !{!"_ZTSN7ImGuiAl4FifoE", !6, i64 0, !11, i64 8, !11, i64 16, !11, i64 24, !11, i64 32}
!22 = !{!"bool", !7, i64 0}
!23 = !{!"_ZTSN7ImGuiAl3Log5LevelE", !7, i64 0}
!24 = !{!"_ZTS15ImGuiTextFilter", !7, i64 0, !25, i64 256, !14, i64 272}
!25 = !{!"_ZTS8ImVectorIN15ImGuiTextFilter14ImGuiTextRangeEE", !14, i64 0, !14, i64 4, !6, i64 8}
!26 = !{!13, !14, i64 0}
!27 = !{!19, !14, i64 64}
!28 = !{!19, !14, i64 76}
!29 = !{!19, !14, 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"

%"struct.ImGuiAl::Crt::Info" = type { i32, i32, i32 }

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN7ImGuiAl4Fifo4readEPvm(ptr noundef nonnull align 8 dereferenceable(40), ptr noundef, i64 noundef) local_unnamed_addr #0 align 2

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

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN7ImGuiAl4Fifo5writeEPKvm(ptr noundef nonnull align 8 dereferenceable(40), ptr noundef, i64 noundef) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN7ImGuiAl4Fifo4skipEm(ptr noundef nonnull align 8 dereferenceable(40), i64 noundef) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i64 @_ZNK7ImGuiAl4Fifo9availableEv(ptr noundef nonnull align 8 dereferenceable(40)) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @_ZN7ImGuiAl3Log4putsEhPKc(ptr noundef nonnull align 8 dereferenceable(456) %0, i8 noundef zeroext %1, ptr noundef %2) local_unnamed_addr #0 align 2 {
  %4 = alloca %"struct.ImGuiAl::Crt::Info", align 4
  %5 = alloca %"struct.ImGuiAl::Crt::Info", align 4
  %6 = tail call i64 @strlen(ptr noundef nonnull dereferenceable(1) %2) #3
  %7 = add i64 %6, 12
  %8 = tail call noundef i64 @_ZNK7ImGuiAl4Fifo9availableEv(ptr noundef nonnull align 8 dereferenceable(40) %0)
  %9 = icmp ugt i64 %7, %8
  br i1 %9, label %.lr.ph, label %._crit_edge

.lr.ph:                                           ; preds = %3
  %10 = getelementptr inbounds i8, ptr %4, i64 4
  br label %11

11:                                               ; preds = %.lr.ph, %11
  call void @llvm.lifetime.start.p0(i64 12, ptr nonnull %4) #4
  call void @_ZN7ImGuiAl4Fifo4readEPvm(ptr noundef nonnull align 8 dereferenceable(40) %0, ptr noundef nonnull %4, i64 noundef 12)
  %12 = load i32, ptr %10, align 4, !tbaa !5
  %13 = zext i32 %12 to i64
  call void @_ZN7ImGuiAl4Fifo4skipEm(ptr noundef nonnull align 8 dereferenceable(40) %0, i64 noundef %13)
  call void @llvm.lifetime.end.p0(i64 12, ptr nonnull %4) #4
  %14 = call noundef i64 @_ZNK7ImGuiAl4Fifo9availableEv(ptr noundef nonnull align 8 dereferenceable(40) %0)
  %15 = icmp ugt i64 %7, %14
  br i1 %15, label %11, label %._crit_edge, !llvm.loop !10

._crit_edge:                                      ; preds = %11, %3
  call void @llvm.lifetime.start.p0(i64 12, ptr nonnull %5) #4
  %16 = trunc i64 %6 to i32
  %17 = getelementptr inbounds i8, ptr %5, i64 4
  store i32 %16, ptr %17, align 4, !tbaa !5
  %18 = zext i8 %1 to i32
  %19 = getelementptr inbounds i8, ptr %5, i64 8
  store i32 %18, ptr %19, align 4, !tbaa !12
  switch i8 %1, label %32 [
    i8 0, label %20
    i8 1, label %23
    i8 2, label %26
    i8 3, label %29
  ]

20:                                               ; preds = %._crit_edge
  %21 = getelementptr inbounds i8, ptr %0, i64 52
  %22 = load i32, ptr %21, align 4, !tbaa !13
  store i32 %22, ptr %5, align 4, !tbaa !23
  br label %32

23:                                               ; preds = %._crit_edge
  %24 = getelementptr inbounds i8, ptr %0, i64 64
  %25 = load i32, ptr %24, align 8, !tbaa !24
  store i32 %25, ptr %5, align 4, !tbaa !23
  br label %32

26:                                               ; preds = %._crit_edge
  %27 = getelementptr inbounds i8, ptr %0, i64 76
  %28 = load i32, ptr %27, align 4, !tbaa !25
  store i32 %28, ptr %5, align 4, !tbaa !23
  br label %32

29:                                               ; preds = %._crit_edge
  %30 = getelementptr inbounds i8, ptr %0, i64 88
  %31 = load i32, ptr %30, align 8, !tbaa !26
  store i32 %31, ptr %5, align 4, !tbaa !23
  br label %32

32:                                               ; preds = %29, %26, %23, %20, %._crit_edge
  call void @_ZN7ImGuiAl4Fifo5writeEPKvm(ptr noundef nonnull align 8 dereferenceable(40) %0, ptr noundef nonnull %5, i64 noundef 12)
  call void @_ZN7ImGuiAl4Fifo5writeEPKvm(ptr noundef nonnull align 8 dereferenceable(40) %0, ptr noundef %2, i64 noundef %6)
  call void @llvm.lifetime.end.p0(i64 12, ptr nonnull %5) #4
  ret void
}

; Function Attrs: mustprogress nofree nounwind willreturn memory(argmem: read)
declare i64 @strlen(ptr nocapture noundef) local_unnamed_addr #2

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" }
attributes #1 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { mustprogress nofree nounwind willreturn memory(argmem: read) "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 willreturn memory(read) }
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, !7, i64 4}
!6 = !{!"_ZTSN7ImGuiAl3Crt4InfoE", !7, i64 0, !7, i64 4, !7, i64 8}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = distinct !{!10, !11}
!11 = !{!"llvm.loop.mustprogress"}
!12 = !{!6, !7, i64 8}
!13 = !{!14, !7, i64 52}
!14 = !{!"_ZTSN7ImGuiAl3LogE", !15, i64 0, !7, i64 52, !7, i64 56, !7, i64 60, !7, i64 64, !7, i64 68, !7, i64 72, !7, i64 76, !7, i64 80, !7, i64 84, !7, i64 88, !7, i64 92, !7, i64 96, !17, i64 104, !17, i64 112, !17, i64 120, !17, i64 128, !17, i64 136, !17, i64 144, !17, i64 152, !17, i64 160, !20, i64 168, !19, i64 172, !21, i64 176}
!15 = !{!"_ZTSN7ImGuiAl3CrtE", !16, i64 0, !7, i64 40, !7, i64 44, !19, i64 48}
!16 = !{!"_ZTSN7ImGuiAl4FifoE", !17, i64 0, !18, i64 8, !18, i64 16, !18, i64 24, !18, i64 32}
!17 = !{!"any pointer", !8, i64 0}
!18 = !{!"long", !8, i64 0}
!19 = !{!"bool", !8, i64 0}
!20 = !{!"_ZTSN7ImGuiAl3Log5LevelE", !8, i64 0}
!21 = !{!"_ZTS15ImGuiTextFilter", !8, i64 0, !22, i64 256, !7, i64 272}
!22 = !{!"_ZTS8ImVectorIN15ImGuiTextFilter14ImGuiTextRangeEE", !7, i64 0, !7, i64 4, !17, i64 8}
!23 = !{!6, !7, i64 0}
!24 = !{!14, !7, i64 64}
!25 = !{!14, !7, i64 76}
!26 = !{!14, !7, i64 88}


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