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

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

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

; Function Attrs: nounwind
declare ptr @strcpy(ptr noundef, ptr noundef) #0

; Function Attrs: mustprogress uwtable
define dso_local noundef i32 @_ZN7CLogger11filter_confEPKc9eLogLevelPFjPhtEP11LogFilter_t(ptr noundef nonnull align 8 dereferenceable(344) %0, ptr noundef %1, i32 noundef %2, ptr noundef %3, ptr noundef %4) #1 align 2 {
  %6 = alloca i32, align 4
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca i32, align 4
  %10 = alloca ptr, align 8
  %11 = alloca ptr, align 8
  %12 = alloca ptr, align 8
  %13 = alloca ptr, align 8
  %14 = alloca i32, align 4
  store ptr %0, ptr %7, align 8, !tbaa !5
  store ptr %1, ptr %8, align 8, !tbaa !5
  store i32 %2, ptr %9, align 4, !tbaa !9
  store ptr %3, ptr %10, align 8, !tbaa !5
  store ptr %4, ptr %11, align 8, !tbaa !5
  %15 = load ptr, ptr %7, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #6
  %16 = getelementptr inbounds %class.CLogger, ptr %15, i32 0, i32 3
  %17 = getelementptr inbounds %struct.LogFilter_t, ptr %16, i32 0, i32 3
  store ptr %17, ptr %12, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #6
  store ptr null, ptr %13, align 8, !tbaa !5
  %18 = load ptr, ptr %8, align 8, !tbaa !5
  %19 = icmp eq ptr %18, null
  br i1 %19, label %23, label %20

20:                                               ; preds = %5
  %21 = load ptr, ptr %10, align 8, !tbaa !5
  %22 = icmp eq ptr %21, null
  br i1 %22, label %23, label %24

23:                                               ; preds = %20, %5
  store i32 0, ptr %6, align 4
  store i32 1, ptr %14, align 4
  br label %86

24:                                               ; preds = %20
  %25 = load ptr, ptr %8, align 8, !tbaa !5
  %26 = call noundef ptr @strstr(ptr noundef %25, ptr noundef @.str) #7
  %27 = icmp ne ptr %26, null
  br i1 %27, label %28, label %37

28:                                               ; preds = %24
  %29 = load i32, ptr %9, align 4, !tbaa !9
  %30 = getelementptr inbounds %class.CLogger, ptr %15, i32 0, i32 3
  %31 = getelementptr inbounds %struct.LogFilter_t, ptr %30, i32 0, i32 1
  store i32 %29, ptr %31, align 4, !tbaa !11
  %32 = load ptr, ptr %10, align 8, !tbaa !5
  %33 = getelementptr inbounds %class.CLogger, ptr %15, i32 0, i32 3
  %34 = getelementptr inbounds %struct.LogFilter_t, ptr %33, i32 0, i32 2
  store ptr %32, ptr %34, align 8, !tbaa !20
  %35 = getelementptr inbounds %class.CLogger, ptr %15, i32 0, i32 1
  %36 = getelementptr inbounds %struct.LogConfig_t, ptr %35, i32 0, i32 2
  store i8 1, ptr %36, align 1, !tbaa !21
  store i32 1, ptr %6, align 4
  store i32 1, ptr %14, align 4
  br label %86

37:                                               ; preds = %24
  %38 = load ptr, ptr %11, align 8, !tbaa !5
  %39 = icmp eq ptr %38, null
  br i1 %39, label %40, label %41

40:                                               ; preds = %37
  store i32 0, ptr %6, align 4
  store i32 1, ptr %14, align 4
  br label %86

41:                                               ; preds = %37
  %42 = load ptr, ptr %10, align 8, !tbaa !5
  %43 = load ptr, ptr %11, align 8, !tbaa !5
  %44 = getelementptr inbounds %struct.LogFilter_t, ptr %43, i32 0, i32 2
  store ptr %42, ptr %44, align 8, !tbaa !22
  %45 = load i32, ptr %9, align 4, !tbaa !9
  %46 = load ptr, ptr %11, align 8, !tbaa !5
  %47 = getelementptr inbounds %struct.LogFilter_t, ptr %46, i32 0, i32 1
  store i32 %45, ptr %47, align 4, !tbaa !23
  %48 = load ptr, ptr %11, align 8, !tbaa !5
  %49 = getelementptr inbounds %struct.LogFilter_t, ptr %48, i32 0, i32 0
  %50 = getelementptr inbounds [33 x i8], ptr %49, i64 0, i64 0
  %51 = load ptr, ptr %8, align 8, !tbaa !5
  %52 = call ptr @strcpy(ptr noundef %50, ptr noundef %51) #6
  br label %53

53:                                               ; preds = %74, %41
  %54 = load ptr, ptr %12, align 8, !tbaa !5
  %55 = getelementptr inbounds i8, ptr %54, i64 sub (i64 0, i64 ptrtoint (ptr getelementptr inbounds (%struct.LogFilter_t, ptr null, i32 0, i32 3) to i64))
  store ptr %55, ptr %13, align 8, !tbaa !5
  %56 = load ptr, ptr %8, align 8, !tbaa !5
  %57 = load ptr, ptr %13, align 8, !tbaa !5
  %58 = getelementptr inbounds %struct.LogFilter_t, ptr %57, i32 0, i32 0
  %59 = getelementptr inbounds [33 x i8], ptr %58, i64 0, i64 0
  %60 = call noundef ptr @strstr(ptr noundef %56, ptr noundef %59) #7
  %61 = icmp ne ptr %60, null
  br i1 %61, label %62, label %69

62:                                               ; preds = %53
  %63 = load ptr, ptr %13, align 8, !tbaa !5
  %64 = getelementptr inbounds %struct.LogFilter_t, ptr %63, i32 0, i32 3
  %65 = load ptr, ptr %11, align 8, !tbaa !5
  %66 = getelementptr inbounds %struct.LogFilter_t, ptr %65, i32 0, i32 3
  call void @_ZL12list_replaceP7_list_tS0_(ptr noundef %64, ptr noundef %66)
  %67 = getelementptr inbounds %class.CLogger, ptr %15, i32 0, i32 1
  %68 = getelementptr inbounds %struct.LogConfig_t, ptr %67, i32 0, i32 2
  store i8 1, ptr %68, align 1, !tbaa !21
  store i32 1, ptr %6, align 4
  store i32 1, ptr %14, align 4
  br label %86

69:                                               ; preds = %53
  %70 = load ptr, ptr %12, align 8, !tbaa !5
  %71 = getelementptr inbounds %struct._list_t, ptr %70, i32 0, i32 0
  %72 = load ptr, ptr %71, align 8, !tbaa !24
  store ptr %72, ptr %12, align 8, !tbaa !5
  br label %73

73:                                               ; preds = %69
  br label %74

74:                                               ; preds = %73
  %75 = load ptr, ptr %12, align 8, !tbaa !5
  %76 = getelementptr inbounds %class.CLogger, ptr %15, i32 0, i32 3
  %77 = getelementptr inbounds %struct.LogFilter_t, ptr %76, i32 0, i32 3
  %78 = icmp ne ptr %75, %77
  br i1 %78, label %53, label %79, !llvm.loop !25

79:                                               ; preds = %74
  %80 = load ptr, ptr %11, align 8, !tbaa !5
  %81 = getelementptr inbounds %struct.LogFilter_t, ptr %80, i32 0, i32 3
  %82 = getelementptr inbounds %class.CLogger, ptr %15, i32 0, i32 3
  %83 = getelementptr inbounds %struct.LogFilter_t, ptr %82, i32 0, i32 3
  call void @_ZL13list_add_tailP7_list_tS0_(ptr noundef %81, ptr noundef %83)
  %84 = getelementptr inbounds %class.CLogger, ptr %15, i32 0, i32 1
  %85 = getelementptr inbounds %struct.LogConfig_t, ptr %84, i32 0, i32 2
  store i8 1, ptr %85, align 1, !tbaa !21
  store i32 1, ptr %6, align 4
  store i32 1, ptr %14, align 4
  br label %86

86:                                               ; preds = %79, %62, %40, %28, %23
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #6
  %87 = load i32, ptr %6, align 4
  ret i32 %87
}

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #2

; Function Attrs: nounwind willreturn memory(read)
declare noundef ptr @strstr(ptr noundef, ptr noundef) #3

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare hidden void @_ZL12list_replaceP7_list_tS0_(ptr noundef, ptr noundef) #4

; Function Attrs: inlinehint mustprogress uwtable
declare hidden void @_ZL13list_add_tailP7_list_tS0_(ptr noundef, ptr noundef) #5

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #2

attributes #0 = { 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 #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 memory(argmem: readwrite) }
attributes #3 = { nounwind willreturn memory(read) "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 = { inlinehint 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 #5 = { inlinehint 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 #6 = { nounwind }
attributes #7 = { nounwind willreturn memory(read) }

!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, !10, i64 308}
!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 = !{!12, !6, i64 312}
!21 = !{!12, !16, i64 9}
!22 = !{!18, !6, i64 40}
!23 = !{!18, !10, i64 36}
!24 = !{!19, !6, i64 0}
!25 = distinct !{!25, !26}
!26 = !{!"llvm.loop.mustprogress"}


; 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 [8 x i8], align 1

; Function Attrs: mustprogress nofree nounwind willreturn memory(argmem: readwrite)
declare ptr @strcpy(ptr noalias noundef returned writeonly, ptr noalias nocapture noundef readonly) local_unnamed_addr #0

; Function Attrs: mustprogress uwtable
define dso_local noundef range(i32 0, 2) i32 @_ZN7CLogger11filter_confEPKc9eLogLevelPFjPhtEP11LogFilter_t(ptr noundef nonnull align 8 dereferenceable(344) %0, ptr noundef readonly %1, i32 noundef %2, ptr noundef %3, ptr noundef %4) local_unnamed_addr #1 align 2 {
  %6 = getelementptr inbounds i8, ptr %0, i64 320
  %7 = icmp eq ptr %1, null
  %8 = icmp eq ptr %3, null
  %or.cond = or i1 %7, %8
  br i1 %or.cond, label %30, label %9

9:                                                ; preds = %5
  %10 = tail call noundef ptr @strstr(ptr noundef nonnull dereferenceable(1) %1, ptr noundef nonnull dereferenceable(1) @.str) #5
  %.not = icmp eq ptr %10, null
  br i1 %.not, label %14, label %11

11:                                               ; preds = %9
  %12 = getelementptr inbounds i8, ptr %0, i64 308
  store i32 %2, ptr %12, align 4, !tbaa !5
  %13 = getelementptr inbounds i8, ptr %0, i64 312
  store ptr %3, ptr %13, align 8, !tbaa !18
  br label %.sink.split

14:                                               ; preds = %9
  %15 = icmp eq ptr %4, null
  br i1 %15, label %30, label %16

16:                                               ; preds = %14
  %17 = getelementptr inbounds i8, ptr %4, i64 40
  store ptr %3, ptr %17, align 8, !tbaa !19
  %18 = getelementptr inbounds i8, ptr %4, i64 36
  store i32 %2, ptr %18, align 4, !tbaa !20
  %19 = tail call ptr @strcpy(ptr noundef nonnull dereferenceable(1) %4, ptr noundef nonnull dereferenceable(1) %1) #6
  br label %20

20:                                               ; preds = %25, %16
  %.0 = phi ptr [ %6, %16 ], [ %26, %25 ]
  %21 = getelementptr inbounds i8, ptr %.0, i64 -48
  %22 = tail call noundef ptr @strstr(ptr noundef nonnull dereferenceable(1) %1, ptr noundef nonnull dereferenceable(1) %21) #5
  %.not28 = icmp eq ptr %22, null
  br i1 %.not28, label %25, label %23

23:                                               ; preds = %20
  %24 = getelementptr inbounds i8, ptr %4, i64 48
  tail call void @_ZL12list_replaceP7_list_tS0_(ptr noundef %.0, ptr noundef nonnull %24)
  br label %.sink.split

25:                                               ; preds = %20
  %26 = load ptr, ptr %.0, align 8, !tbaa !21
  %.not29 = icmp eq ptr %26, %6
  br i1 %.not29, label %27, label %20, !llvm.loop !22

27:                                               ; preds = %25
  %28 = getelementptr inbounds i8, ptr %4, i64 48
  tail call void @_ZL13list_add_tailP7_list_tS0_(ptr noundef nonnull %28, ptr noundef nonnull %6)
  br label %.sink.split

.sink.split:                                      ; preds = %11, %23, %27
  %29 = getelementptr inbounds i8, ptr %0, i64 9
  store i8 1, ptr %29, align 1, !tbaa !24
  br label %30

30:                                               ; preds = %.sink.split, %14, %5
  %.022 = phi i32 [ 0, %5 ], [ 0, %14 ], [ 1, %.sink.split ]
  ret i32 %.022
}

; Function Attrs: mustprogress nofree nounwind willreturn memory(argmem: read)
declare noundef ptr @strstr(ptr noundef, ptr nocapture noundef) local_unnamed_addr #2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare hidden void @_ZL12list_replaceP7_list_tS0_(ptr noundef, ptr noundef) local_unnamed_addr #3

; Function Attrs: inlinehint mustprogress uwtable
declare hidden void @_ZL13list_add_tailP7_list_tS0_(ptr noundef, ptr noundef) local_unnamed_addr #4

attributes #0 = { mustprogress nofree nounwind willreturn memory(argmem: readwrite) "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 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 nofree nounwind willreturn memory(argmem: read) "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 = { inlinehint 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 #4 = { inlinehint 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 #5 = { nounwind willreturn memory(read) }
attributes #6 = { 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, !12, i64 308}
!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, !16, i64 312}
!19 = !{!15, !16, i64 40}
!20 = !{!15, !12, i64 36}
!21 = !{!17, !16, i64 0}
!22 = distinct !{!22, !23}
!23 = !{!"llvm.loop.mustprogress"}
!24 = !{!6, !13, i64 9}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,LCSSAPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass