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

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

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

; 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: nocallback nofree nosync nounwind willreturn
declare void @llvm.va_start.p0(ptr) #1

; 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) #2 align 2

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

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

16:                                               ; preds = %3
  store i32 1, ptr %8, align 4
  br label %23

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

23:                                               ; preds = %17, %16
  call void @llvm.lifetime.end.p0(i64 24, ptr %7) #3
  %24 = load i32, ptr %8, align 4
  switch i32 %24, label %26 [
    i32 0, label %25
    i32 1, label %25
  ]

25:                                               ; preds = %23, %23
  ret void

26:                                               ; preds = %23
  unreachable
}

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

!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 }

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

; 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 nocallback nofree nosync nounwind willreturn
declare void @llvm.va_start.p0(ptr) #1

; 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 #2 align 2

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

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

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

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

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

!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