; LLVM IR from XiaoMi/mace :: micro/base/logger.ll (ZN5micro4base6LoggerC2EPKcjNS_8LogLevelE)

; 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.micro::base::Logger" = type { i32 }

@.str = external hidden unnamed_addr constant [12 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [3 x i8], align 1

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN5micro4base6LoggerC2EPKcjNS_8LogLevelE(ptr noundef nonnull align 4 dereferenceable(4) %0, ptr noundef %1, i32 noundef %2, i32 noundef %3) unnamed_addr #0 align 2 {
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca [15 x i8], align 1
  %10 = alloca ptr, align 8
  store ptr %0, ptr %5, align 8, !tbaa !5
  store ptr %1, ptr %6, align 8, !tbaa !5
  store i32 %2, ptr %7, align 4, !tbaa !9
  store i32 %3, ptr %8, align 4, !tbaa !11
  %11 = load ptr, ptr %5, align 8
  %12 = getelementptr inbounds %"class.micro::base::Logger", ptr %11, i32 0, i32 0
  %13 = load i32, ptr %8, align 4, !tbaa !11
  store i32 %13, ptr %12, align 4, !tbaa !13
  %14 = load i32, ptr %8, align 4, !tbaa !11
  %15 = icmp eq i32 %14, 0
  br i1 %15, label %16, label %17

16:                                               ; preds = %4
  br label %35

17:                                               ; preds = %4
  call void @llvm.lifetime.start.p0(i64 15, ptr %9) #4
  call void @llvm.memset.p0.i64(ptr align 1 %9, i8 0, i64 15, i1 false)
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #4
  %18 = getelementptr inbounds [15 x i8], ptr %9, i64 0, i64 0
  %19 = getelementptr inbounds i8, ptr %18, i64 15
  store ptr %19, ptr %10, align 8, !tbaa !5
  %20 = load i32, ptr %8, align 4, !tbaa !11
  %21 = call noundef signext i8 @_ZN5micro4base12_GLOBAL__N_118LogLevelToShortStrENS_8LogLevelE(i32 noundef %20)
  %22 = getelementptr inbounds [15 x i8], ptr %9, i64 0, i64 0
  store i8 %21, ptr %22, align 1, !tbaa !15
  %23 = getelementptr inbounds [15 x i8], ptr %9, i64 0, i64 1
  store i8 32, ptr %23, align 1, !tbaa !15
  call void @_ZN5micro4port3api8DebugLogEPKc(ptr noundef @.str)
  %24 = getelementptr inbounds [15 x i8], ptr %9, i64 0, i64 0
  call void @_ZN5micro4port3api8DebugLogEPKc(ptr noundef %24)
  %25 = load ptr, ptr %6, align 8, !tbaa !5
  call void @_ZN5micro4port3api8DebugLogEPKc(ptr noundef %25)
  %26 = getelementptr inbounds [15 x i8], ptr %9, i64 0, i64 0
  store i8 58, ptr %26, align 1, !tbaa !15
  %27 = load i32, ptr %7, align 4, !tbaa !9
  %28 = getelementptr inbounds [15 x i8], ptr %9, i64 0, i64 0
  %29 = getelementptr inbounds i8, ptr %28, i64 1
  %30 = load ptr, ptr %10, align 8, !tbaa !5
  %31 = call noundef ptr @_ZN5micro4base8ToStringIjEEPcT_S2_S2_(i32 noundef %27, ptr noundef %29, ptr noundef %30)
  %32 = load ptr, ptr %10, align 8, !tbaa !5
  %33 = call noundef ptr @_ZN5micro4base8ToStringIPKcEEPcT_S4_S4_(ptr noundef @.str.1, ptr noundef %31, ptr noundef %32)
  %34 = getelementptr inbounds [15 x i8], ptr %9, i64 0, i64 0
  call void @_ZN5micro4port3api8DebugLogEPKc(ptr noundef %34)
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #4
  call void @llvm.lifetime.end.p0(i64 15, ptr %9) #4
  br label %35

35:                                               ; preds = %17, %16
  ret void
}

; 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 nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #2

; Function Attrs: mustprogress uwtable
declare hidden noundef signext i8 @_ZN5micro4base12_GLOBAL__N_118LogLevelToShortStrENS_8LogLevelE(i32 noundef) #0

declare void @_ZN5micro4port3api8DebugLogEPKc(ptr noundef) #3

declare noundef ptr @_ZN5micro4base8ToStringIPKcEEPcT_S4_S4_(ptr noundef, ptr noundef, ptr noundef) #3

; Function Attrs: mustprogress uwtable
declare dso_local noundef ptr @_ZN5micro4base8ToStringIjEEPcT_S2_S2_(i32 noundef, ptr noundef, ptr noundef) #0

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #3 = { "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 = !{!"int", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"_ZTSN5micro8LogLevelE", !7, i64 0}
!13 = !{!14, !12, i64 0}
!14 = !{!"_ZTSN5micro4base6LoggerE", !12, i64 0}
!15 = !{!7, !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 = external hidden unnamed_addr constant [12 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [3 x i8], align 1

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN5micro4base6LoggerC2EPKcjNS_8LogLevelE(ptr nocapture noundef nonnull writeonly align 4 dereferenceable(4) %0, ptr noundef %1, i32 noundef %2, i32 noundef %3) unnamed_addr #0 align 2 {
  %5 = alloca [15 x i8], align 1
  store i32 %3, ptr %0, align 4, !tbaa !5
  %6 = icmp eq i32 %3, 0
  br i1 %6, label %14, label %7

7:                                                ; preds = %4
  call void @llvm.lifetime.start.p0(i64 15, ptr nonnull %5) #4
  %8 = getelementptr inbounds i8, ptr %5, i64 2
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 1 dereferenceable(15) %8, i8 0, i64 13, i1 false)
  %9 = getelementptr inbounds i8, ptr %5, i64 15
  %10 = tail call noundef signext i8 @_ZN5micro4base12_GLOBAL__N_118LogLevelToShortStrENS_8LogLevelE(i32 noundef %3)
  store i8 %10, ptr %5, align 1, !tbaa !10
  %11 = getelementptr inbounds i8, ptr %5, i64 1
  store i8 32, ptr %11, align 1, !tbaa !10
  tail call void @_ZN5micro4port3api8DebugLogEPKc(ptr noundef nonnull @.str)
  call void @_ZN5micro4port3api8DebugLogEPKc(ptr noundef nonnull %5)
  call void @_ZN5micro4port3api8DebugLogEPKc(ptr noundef %1)
  store i8 58, ptr %5, align 1, !tbaa !10
  %12 = call noundef ptr @_ZN5micro4base8ToStringIjEEPcT_S2_S2_(i32 noundef %2, ptr noundef nonnull %11, ptr noundef nonnull %9)
  %13 = call noundef ptr @_ZN5micro4base8ToStringIPKcEEPcT_S4_S4_(ptr noundef nonnull @.str.1, ptr noundef %12, ptr noundef nonnull %9)
  call void @_ZN5micro4port3api8DebugLogEPKc(ptr noundef nonnull %5)
  call void @llvm.lifetime.end.p0(i64 15, ptr nonnull %5) #4
  br label %14

14:                                               ; preds = %4, %7
  ret void
}

; 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 nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #2

; Function Attrs: mustprogress uwtable
declare hidden noundef signext i8 @_ZN5micro4base12_GLOBAL__N_118LogLevelToShortStrENS_8LogLevelE(i32 noundef) local_unnamed_addr #0

declare void @_ZN5micro4port3api8DebugLogEPKc(ptr noundef) local_unnamed_addr #3

declare noundef ptr @_ZN5micro4base8ToStringIPKcEEPcT_S4_S4_(ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #3

; Function Attrs: mustprogress uwtable
declare dso_local noundef ptr @_ZN5micro4base8ToStringIjEEPcT_S2_S2_(i32 noundef, ptr noundef, ptr noundef) local_unnamed_addr #0

; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #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 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #3 = { "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, !7, i64 0}
!6 = !{!"_ZTSN5micro4base6LoggerE", !7, i64 0}
!7 = !{!"_ZTSN5micro8LogLevelE", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!8, !8, i64 0}


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