; LLVM IR from kmilo17pet/QuarkTS-cpp :: src/logger.ll (ZN3qOS6logger7_loggerlsERKNS0_9lout_baseE)

; 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.qOS::logger::lout_base" = type { i8 }
%"class.qOS::logger::_logger" = type { [7 x ptr], i8, i64, i8, [36 x i8], [5 x i8], ptr }

@.str.19 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.20 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.21 = external hidden unnamed_addr constant [3 x i8], align 1

; Function Attrs: mustprogress nounwind uwtable
define dso_local noundef nonnull align 8 dereferenceable(128) ptr @_ZN3qOS6logger7_loggerlsERKNS0_9lout_baseE(ptr noundef nonnull align 8 dereferenceable(128) %0, ptr noundef nonnull align 1 dereferenceable(1) %1) #0 align 2 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  store ptr %0, ptr %3, align 8, !tbaa !5
  store ptr %1, ptr %4, align 8, !tbaa !5
  %5 = load ptr, ptr %3, align 8
  %6 = load ptr, ptr %4, align 8, !tbaa !5
  %7 = getelementptr inbounds %"class.qOS::logger::lout_base", ptr %6, i32 0, i32 0
  %8 = load i8, ptr %7, align 1, !tbaa !9
  %9 = getelementptr inbounds %"class.qOS::logger::_logger", ptr %5, i32 0, i32 1
  store i8 %8, ptr %9, align 8, !tbaa !11
  %10 = load ptr, ptr %4, align 8, !tbaa !5
  %11 = getelementptr inbounds %"class.qOS::logger::lout_base", ptr %10, i32 0, i32 0
  %12 = load i8, ptr %11, align 1, !tbaa !9
  %13 = zext i8 %12 to i32
  switch i32 %13, label %26 [
    i32 2, label %14
    i32 8, label %18
    i32 16, label %22
  ]

14:                                               ; preds = %2
  %15 = getelementptr inbounds %"class.qOS::logger::_logger", ptr %5, i32 0, i32 5
  %16 = getelementptr inbounds [5 x i8], ptr %15, i64 0, i64 0
  %17 = call noundef i64 @_ZN3qOS4util6strcpyEPcPKcm(ptr noundef %16, ptr noundef @.str.19, i64 noundef 5) #3
  br label %29

18:                                               ; preds = %2
  %19 = getelementptr inbounds %"class.qOS::logger::_logger", ptr %5, i32 0, i32 5
  %20 = getelementptr inbounds [5 x i8], ptr %19, i64 0, i64 0
  %21 = call noundef i64 @_ZN3qOS4util6strcpyEPcPKcm(ptr noundef %20, ptr noundef @.str.20, i64 noundef 5) #3
  br label %29

22:                                               ; preds = %2
  %23 = getelementptr inbounds %"class.qOS::logger::_logger", ptr %5, i32 0, i32 5
  %24 = getelementptr inbounds [5 x i8], ptr %23, i64 0, i64 0
  %25 = call noundef i64 @_ZN3qOS4util6strcpyEPcPKcm(ptr noundef %24, ptr noundef @.str.21, i64 noundef 5) #3
  br label %29

26:                                               ; preds = %2
  %27 = getelementptr inbounds %"class.qOS::logger::_logger", ptr %5, i32 0, i32 5
  %28 = getelementptr inbounds [5 x i8], ptr %27, i64 0, i64 0
  call void @llvm.memset.p0.i64(ptr align 1 %28, i8 0, i64 5, i1 false)
  br label %29

29:                                               ; preds = %26, %22, %18, %14
  ret ptr %5
}

; Function Attrs: nounwind
declare noundef i64 @_ZN3qOS4util6strcpyEPcPKcm(ptr noundef, ptr noundef, i64 noundef) #1

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #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 = { 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 = { nocallback nofree nounwind willreturn memory(argmem: write) }
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, !7, i64 0}
!10 = !{!"_ZTSN3qOS6logger9lout_baseE", !7, i64 0}
!11 = !{!12, !7, i64 56}
!12 = !{!"_ZTSN3qOS6logger7_loggerE", !7, i64 0, !7, i64 56, !13, i64 64, !7, i64 72, !7, i64 73, !7, i64 109, !6, i64 120}
!13 = !{!"long", !7, 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.19 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.20 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.21 = external hidden unnamed_addr constant [3 x i8], align 1

; Function Attrs: mustprogress nounwind uwtable
define dso_local noundef nonnull align 8 dereferenceable(128) ptr @_ZN3qOS6logger7_loggerlsERKNS0_9lout_baseE(ptr noundef nonnull returned align 8 dereferenceable(128) %0, ptr nocapture noundef nonnull readonly align 1 dereferenceable(1) %1) local_unnamed_addr #0 align 2 {
  %3 = load i8, ptr %1, align 1, !tbaa !5
  %4 = getelementptr inbounds i8, ptr %0, i64 56
  store i8 %3, ptr %4, align 8, !tbaa !9
  %5 = getelementptr inbounds i8, ptr %0, i64 109
  switch i8 %3, label %12 [
    i8 2, label %6
    i8 8, label %8
    i8 16, label %10
  ]

6:                                                ; preds = %2
  %7 = tail call noundef i64 @_ZN3qOS4util6strcpyEPcPKcm(ptr noundef nonnull %5, ptr noundef nonnull @.str.19, i64 noundef 5) #3
  br label %13

8:                                                ; preds = %2
  %9 = tail call noundef i64 @_ZN3qOS4util6strcpyEPcPKcm(ptr noundef nonnull %5, ptr noundef nonnull @.str.20, i64 noundef 5) #3
  br label %13

10:                                               ; preds = %2
  %11 = tail call noundef i64 @_ZN3qOS4util6strcpyEPcPKcm(ptr noundef nonnull %5, ptr noundef nonnull @.str.21, i64 noundef 5) #3
  br label %13

12:                                               ; preds = %2
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 1 dereferenceable(5) %5, i8 0, i64 5, i1 false)
  br label %13

13:                                               ; preds = %12, %10, %8, %6
  ret ptr %0
}

; Function Attrs: nounwind
declare noundef i64 @_ZN3qOS4util6strcpyEPcPKcm(ptr noundef, ptr noundef, i64 noundef) local_unnamed_addr #1

; Function Attrs: mustprogress nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #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 = { 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 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: write) }
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, !7, i64 0}
!6 = !{!"_ZTSN3qOS6logger9lout_baseE", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !7, i64 56}
!10 = !{!"_ZTSN3qOS6logger7_loggerE", !7, i64 0, !7, i64 56, !11, i64 64, !7, i64 72, !7, i64 73, !7, i64 109, !12, i64 120}
!11 = !{!"long", !7, i64 0}
!12 = !{!"any pointer", !7, i64 0}


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