; LLVM IR from mhsitu/welding_robot :: common/sys_log.ll (ZN7CLogger6RecordE9eLogLevelPKcS2_z)

; 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.__va_list_tag = type { i32, i32, ptr, ptr }
%class.CLogger = type { %struct.LogTimeStamp_t, %struct.LogConfig_t, %struct.LogBuff_t, %struct.LogFilter_t, ptr }
%struct.LogTimeStamp_t = type { i8, i8, i16 }
%struct.LogConfig_t = type { i32, i8, i8 }
%struct.LogBuff_t = type { [258 x i8], i16 }
%struct.LogFilter_t = type { [33 x i8], i32, ptr, %struct._list_t }
%struct._list_t = type { ptr, ptr }

; 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 uwtable
define dso_local void @_ZN7CLogger6RecordE9eLogLevelPKcS2_z(ptr noundef nonnull align 8 dereferenceable(344) %0, i32 noundef %1, ptr noundef %2, ptr noundef %3, ...) #1 align 2 {
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca [1 x %struct.__va_list_tag], align 16
  %10 = alloca i32, align 4
  store ptr %0, ptr %5, align 8, !tbaa !5
  store i32 %1, ptr %6, align 4, !tbaa !9
  store ptr %2, ptr %7, align 8, !tbaa !5
  store ptr %3, ptr %8, align 8, !tbaa !5
  %11 = load ptr, ptr %5, align 8
  call void @llvm.lifetime.start.p0(i64 24, ptr %9) #3
  %12 = getelementptr inbounds %class.CLogger, ptr %11, i32 0, i32 1
  %13 = getelementptr inbounds %struct.LogConfig_t, ptr %12, i32 0, i32 2
  %14 = load i8, ptr %13, align 1, !tbaa !11, !range !20, !noundef !21
  %15 = trunc i8 %14 to i1
  %16 = zext i1 %15 to i32
  %17 = icmp ne i32 %16, 1
  br i1 %17, label %18, label %19

18:                                               ; preds = %4
  store i32 1, ptr %10, align 4
  br label %26

19:                                               ; preds = %4
  %20 = getelementptr inbounds [1 x %struct.__va_list_tag], ptr %9, i64 0, i64 0
  call void @llvm.va_start.p0(ptr %20)
  %21 = load ptr, ptr %7, align 8, !tbaa !5
  %22 = load i32, ptr %6, align 4, !tbaa !9
  %23 = load ptr, ptr %8, align 8, !tbaa !5
  %24 = getelementptr inbounds [1 x %struct.__va_list_tag], ptr %9, i64 0, i64 0
  call void @_ZN7CLogger7managerEPKc9eLogLevelS1_P13__va_list_tag(ptr noundef nonnull align 8 dereferenceable(344) %11, ptr noundef %21, i32 noundef %22, ptr noundef %23, ptr noundef %24)
  %25 = getelementptr inbounds [1 x %struct.__va_list_tag], ptr %9, i64 0, i64 0
  call void @llvm.va_end.p0(ptr %25)
  store i32 0, ptr %10, align 4
  br label %26

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

28:                                               ; preds = %26, %26
  ret void

29:                                               ; preds = %26
  unreachable
}

; Function Attrs: nocallback nofree nosync nounwind willreturn
declare void @llvm.va_start.p0(ptr) #2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN7CLogger7managerEPKc9eLogLevelS1_P13__va_list_tag(ptr noundef nonnull align 8 dereferenceable(344), ptr noundef, i32 noundef, ptr noundef, ptr noundef) #1 align 2

; Function Attrs: nocallback nofree nosync nounwind willreturn
declare void @llvm.va_end.p0(ptr) #2

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #2 = { nocallback nofree nosync nounwind willreturn }
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, !10, i64 0}
!10 = !{!"_ZTS9eLogLevel", !7, i64 0}
!11 = !{!12, !16, i64 9}
!12 = !{!"_ZTS7CLogger", !13, i64 0, !15, i64 4, !17, i64 12, !18, i64 272, !6, i64 336}
!13 = !{!"_ZTS14LogTimeStamp_t", !7, i64 0, !7, i64 1, !14, i64 2}
!14 = !{!"short", !7, i64 0}
!15 = !{!"_ZTS11LogConfig_t", !10, i64 0, !16, i64 4, !16, i64 5}
!16 = !{!"bool", !7, i64 0}
!17 = !{!"_ZTS9LogBuff_t", !7, i64 0, !14, i64 258}
!18 = !{!"_ZTS11LogFilter_t", !7, i64 0, !10, i64 36, !6, i64 40, !19, i64 48}
!19 = !{!"_ZTS7_list_t", !6, i64 0, !6, i64 8}
!20 = !{i8 0, i8 2}
!21 = !{}


; 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.__va_list_tag = type { i32, i32, ptr, ptr }

; 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 uwtable
define dso_local void @_ZN7CLogger6RecordE9eLogLevelPKcS2_z(ptr noundef nonnull align 8 dereferenceable(344) %0, i32 noundef %1, ptr noundef %2, ptr noundef %3, ...) local_unnamed_addr #1 align 2 {
  %5 = alloca [1 x %struct.__va_list_tag], align 16
  call void @llvm.lifetime.start.p0(i64 24, ptr nonnull %5) #3
  %6 = getelementptr inbounds i8, ptr %0, i64 9
  %7 = load i8, ptr %6, align 1, !tbaa !5, !range !18, !noundef !19
  %.not.not = icmp eq i8 %7, 0
  br i1 %.not.not, label %9, label %8

8:                                                ; preds = %4
  call void @llvm.va_start.p0(ptr nonnull %5)
  call void @_ZN7CLogger7managerEPKc9eLogLevelS1_P13__va_list_tag(ptr noundef nonnull align 8 dereferenceable(344) %0, ptr noundef %2, i32 noundef %1, ptr noundef %3, ptr noundef nonnull %5)
  call void @llvm.va_end.p0(ptr nonnull %5)
  br label %9

9:                                                ; preds = %4, %8
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %5) #3
  ret void
}

; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn
declare void @llvm.va_start.p0(ptr) #2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN7CLogger7managerEPKc9eLogLevelS1_P13__va_list_tag(ptr noundef nonnull align 8 dereferenceable(344), ptr noundef, i32 noundef, ptr noundef, ptr noundef) local_unnamed_addr #1 align 2

; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn
declare void @llvm.va_end.p0(ptr) #2

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #2 = { mustprogress nocallback nofree nosync nounwind willreturn }
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, !13, i64 9}
!6 = !{!"_ZTS7CLogger", !7, i64 0, !11, i64 4, !14, i64 12, !15, i64 272, !16, i64 336}
!7 = !{!"_ZTS14LogTimeStamp_t", !8, i64 0, !8, i64 1, !10, i64 2}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"short", !8, i64 0}
!11 = !{!"_ZTS11LogConfig_t", !12, i64 0, !13, i64 4, !13, i64 5}
!12 = !{!"_ZTS9eLogLevel", !8, i64 0}
!13 = !{!"bool", !8, i64 0}
!14 = !{!"_ZTS9LogBuff_t", !8, i64 0, !10, i64 258}
!15 = !{!"_ZTS11LogFilter_t", !8, i64 0, !12, i64 36, !16, i64 40, !17, i64 48}
!16 = !{!"any pointer", !8, i64 0}
!17 = !{!"_ZTS7_list_t", !16, i64 0, !16, i64 8}
!18 = !{i8 0, i8 2}
!19 = !{}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,SROAPass,SimplifyCFGPass