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

; 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.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: mustprogress nounwind uwtable
define dso_local noundef i32 @_ZN7CLogger11global_confE9eLogLevelb(ptr noundef nonnull align 8 dereferenceable(344) %0, i32 noundef %1, i1 noundef zeroext %2) #0 align 2 {
  %4 = alloca ptr, align 8
  %5 = alloca i32, align 4
  %6 = alloca i8, align 1
  store ptr %0, ptr %4, align 8, !tbaa !5
  store i32 %1, ptr %5, align 4, !tbaa !9
  %7 = zext i1 %2 to i8
  store i8 %7, ptr %6, align 1, !tbaa !11
  %8 = load ptr, ptr %4, align 8
  %9 = load i32, ptr %5, align 4, !tbaa !9
  %10 = getelementptr inbounds %class.CLogger, ptr %8, i32 0, i32 1
  %11 = getelementptr inbounds %struct.LogConfig_t, ptr %10, i32 0, i32 0
  store i32 %9, ptr %11, align 4, !tbaa !13
  %12 = load i8, ptr %6, align 1, !tbaa !11, !range !21, !noundef !22
  %13 = trunc i8 %12 to i1
  %14 = getelementptr inbounds %class.CLogger, ptr %8, i32 0, i32 1
  %15 = getelementptr inbounds %struct.LogConfig_t, ptr %14, i32 0, i32 1
  %16 = zext i1 %13 to i8
  store i8 %16, ptr %15, align 4, !tbaa !23
  ret i32 1
}

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

!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, !12, i64 0}
!12 = !{!"bool", !7, i64 0}
!13 = !{!14, !10, i64 4}
!14 = !{!"_ZTS7CLogger", !15, i64 0, !17, i64 4, !18, i64 12, !19, i64 272, !6, i64 336}
!15 = !{!"_ZTS14LogTimeStamp_t", !7, i64 0, !7, i64 1, !16, i64 2}
!16 = !{!"short", !7, i64 0}
!17 = !{!"_ZTS11LogConfig_t", !10, i64 0, !12, i64 4, !12, i64 5}
!18 = !{!"_ZTS9LogBuff_t", !7, i64 0, !16, i64 258}
!19 = !{!"_ZTS11LogFilter_t", !7, i64 0, !10, i64 36, !6, i64 40, !20, i64 48}
!20 = !{!"_ZTS7_list_t", !6, i64 0, !6, i64 8}
!21 = !{i8 0, i8 2}
!22 = !{}
!23 = !{!14, !12, i64 8}


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

; Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: write) uwtable
define dso_local noundef i32 @_ZN7CLogger11global_confE9eLogLevelb(ptr nocapture noundef nonnull writeonly align 8 dereferenceable(344) %0, i32 noundef %1, i1 noundef zeroext %2) local_unnamed_addr #0 align 2 {
  %4 = zext i1 %2 to i8
  %5 = getelementptr inbounds i8, ptr %0, i64 4
  store i32 %1, ptr %5, align 4, !tbaa !5
  %6 = getelementptr inbounds i8, ptr %0, i64 8
  store i8 %4, ptr %6, align 8, !tbaa !18
  ret i32 1
}

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

!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, !12, i64 4}
!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 = !{!6, !13, i64 8}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,InferAlignmentPass,InstCombinePass,PostOrderFunctionAttrsPass,SROAPass