; LLVM IR from ctlst-tech/catpilot :: os/freertos/services/misc (log)

; 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.log_module_t = type { ptr, i64, i32, i32, ptr, i32 }
%struct.timespec = type { i64, i64 }
%struct.__va_list_tag = type { i32, i32, ptr, ptr }

@log = external hidden global %struct.log_module_t, align 8
@.str.1 = external hidden unnamed_addr constant [6 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [8 x i8], align 1
@msg_color = external hidden global [5 x ptr], align 16
@msg_types = external hidden global [4 x ptr], align 16
@.str.3 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [22 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [3 x i8], align 1

; Function Attrs: nounwind willreturn memory(read)
declare i64 @strlen(ptr noundef) #0

; 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 nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1

; Function Attrs: nounwind uwtable
define dso_local void @log_module(i8 noundef zeroext %0, ptr noundef %1, ptr noundef %2, ...) #2 {
  %4 = alloca i8, align 1
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca i32, align 4
  %8 = alloca [255 x i8], align 16
  %9 = alloca [20 x i8], align 16
  %10 = alloca %struct.timespec, align 8
  %11 = alloca i32, align 4
  %12 = alloca [1 x %struct.__va_list_tag], align 16
  store i8 %0, ptr %4, align 1, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !8
  store ptr %2, ptr %6, align 8, !tbaa !8
  %13 = load i32, ptr getelementptr inbounds (%struct.log_module_t, ptr @log, i32 0, i32 3), align 4, !tbaa !10
  %14 = icmp sle i32 %13, 0
  br i1 %14, label %15, label %18

15:                                               ; preds = %3
  %16 = load i32, ptr getelementptr inbounds (%struct.log_module_t, ptr @log, i32 0, i32 5), align 8, !tbaa !14
  %17 = icmp eq i32 %16, 1
  br i1 %17, label %21, label %18

18:                                               ; preds = %15, %3
  %19 = load ptr, ptr @log, align 8, !tbaa !15
  %20 = icmp eq ptr %19, null
  br i1 %20, label %21, label %22

21:                                               ; preds = %18, %15
  br label %144

22:                                               ; preds = %18
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #8
  store i32 0, ptr %7, align 4, !tbaa !16
  call void @llvm.lifetime.start.p0(i64 255, ptr %8) #8
  call void @llvm.memset.p0.i64(ptr align 16 %8, i8 0, i64 255, i1 false)
  call void @llvm.lifetime.start.p0(i64 20, ptr %9) #8
  call void @llvm.memset.p0.i64(ptr align 16 %9, i8 0, i64 20, i1 false)
  call void @llvm.lifetime.start.p0(i64 16, ptr %10) #8
  %23 = load i8, ptr %4, align 1, !tbaa !5
  %24 = zext i8 %23 to i32
  %25 = icmp eq i32 %24, 4
  br i1 %25, label %26, label %27

26:                                               ; preds = %22
  store i32 1, ptr %11, align 4
  br label %142

27:                                               ; preds = %22
  %28 = getelementptr inbounds [20 x i8], ptr %9, i64 0, i64 0
  call void @llvm.memset.p0.i64(ptr align 16 %28, i8 32, i64 9, i1 false)
  %29 = getelementptr inbounds [20 x i8], ptr %9, i64 0, i64 0
  %30 = load ptr, ptr %5, align 8, !tbaa !8
  %31 = load ptr, ptr %5, align 8, !tbaa !8
  %32 = call i64 @strlen(ptr noundef %31) #9
  %33 = icmp ult i64 %32, 10
  br i1 %33, label %34, label %37

34:                                               ; preds = %27
  %35 = load ptr, ptr %5, align 8, !tbaa !8
  %36 = call i64 @strlen(ptr noundef %35) #9
  br label %38

37:                                               ; preds = %27
  br label %38

38:                                               ; preds = %37, %34
  %39 = phi i64 [ %36, %34 ], [ 10, %37 ]
  call void @llvm.memcpy.p0.p0.i64(ptr align 16 %29, ptr align 1 %30, i64 %39, i1 false)
  %40 = call i32 @clock_gettime(i32 noundef 1, ptr noundef %10)
  %41 = load ptr, ptr getelementptr inbounds (%struct.log_module_t, ptr @log, i32 0, i32 4), align 8, !tbaa !17
  %42 = call i64 @xQueueSemaphoreTake(ptr noundef %41, i32 noundef -1)
  %43 = getelementptr inbounds [255 x i8], ptr %8, i64 0, i64 0
  %44 = load i32, ptr %7, align 4, !tbaa !16
  %45 = sext i32 %44 to i64
  %46 = getelementptr inbounds i8, ptr %43, i64 %45
  %47 = getelementptr inbounds %struct.timespec, ptr %10, i32 0, i32 0
  %48 = load i64, ptr %47, align 8, !tbaa !18
  %49 = sitofp i64 %48 to double
  %50 = getelementptr inbounds %struct.timespec, ptr %10, i32 0, i32 1
  %51 = load i64, ptr %50, align 8, !tbaa !20
  %52 = sitofp i64 %51 to double
  %53 = call double @llvm.fmuladd.f64(double %52, double 1.000000e-09, double %49)
  %54 = call i32 (ptr, ptr, ...) @sprintf_(ptr noundef %46, ptr noundef @.str.1, double noundef %53)
  %55 = load i32, ptr %7, align 4, !tbaa !16
  %56 = add nsw i32 %55, %54
  store i32 %56, ptr %7, align 4, !tbaa !16
  %57 = getelementptr inbounds [255 x i8], ptr %8, i64 0, i64 0
  %58 = load i32, ptr %7, align 4, !tbaa !16
  %59 = sext i32 %58 to i64
  %60 = getelementptr inbounds i8, ptr %57, i64 %59
  %61 = load i8, ptr %4, align 1, !tbaa !5
  %62 = zext i8 %61 to i64
  %63 = getelementptr inbounds [5 x ptr], ptr @msg_color, i64 0, i64 %62
  %64 = load ptr, ptr %63, align 8, !tbaa !8
  %65 = load i8, ptr %4, align 1, !tbaa !5
  %66 = zext i8 %65 to i64
  %67 = getelementptr inbounds [4 x ptr], ptr @msg_types, i64 0, i64 %66
  %68 = load ptr, ptr %67, align 8, !tbaa !8
  %69 = load ptr, ptr getelementptr inbounds ([5 x ptr], ptr @msg_color, i64 0, i64 4), align 16, !tbaa !8
  %70 = call i32 (ptr, ptr, ...) @sprintf_(ptr noundef %60, ptr noundef @.str.2, ptr noundef %64, ptr noundef %68, ptr noundef %69)
  %71 = load i32, ptr %7, align 4, !tbaa !16
  %72 = add nsw i32 %71, %70
  store i32 %72, ptr %7, align 4, !tbaa !16
  %73 = getelementptr inbounds [255 x i8], ptr %8, i64 0, i64 0
  %74 = load i32, ptr %7, align 4, !tbaa !16
  %75 = sext i32 %74 to i64
  %76 = getelementptr inbounds i8, ptr %73, i64 %75
  %77 = getelementptr inbounds [20 x i8], ptr %9, i64 0, i64 0
  %78 = call i32 (ptr, ptr, ...) @sprintf_(ptr noundef %76, ptr noundef @.str.3, ptr noundef %77)
  %79 = load i32, ptr %7, align 4, !tbaa !16
  %80 = add nsw i32 %79, %78
  store i32 %80, ptr %7, align 4, !tbaa !16
  call void @llvm.lifetime.start.p0(i64 24, ptr %12) #8
  %81 = getelementptr inbounds [1 x %struct.__va_list_tag], ptr %12, i64 0, i64 0
  call void @llvm.va_start.p0(ptr %81)
  %82 = getelementptr inbounds [255 x i8], ptr %8, i64 0, i64 0
  %83 = load i32, ptr %7, align 4, !tbaa !16
  %84 = sext i32 %83 to i64
  %85 = getelementptr inbounds i8, ptr %82, i64 %84
  %86 = load i32, ptr %7, align 4, !tbaa !16
  %87 = sub nsw i32 255, %86
  %88 = icmp sgt i32 %87, 0
  br i1 %88, label %89, label %92

89:                                               ; preds = %38
  %90 = load i32, ptr %7, align 4, !tbaa !16
  %91 = sub nsw i32 255, %90
  br label %93

92:                                               ; preds = %38
  br label %93

93:                                               ; preds = %92, %89
  %94 = phi i32 [ %91, %89 ], [ 0, %92 ]
  %95 = sext i32 %94 to i64
  %96 = load ptr, ptr %6, align 8, !tbaa !8
  %97 = getelementptr inbounds [1 x %struct.__va_list_tag], ptr %12, i64 0, i64 0
  %98 = call i32 @vsnprintf_(ptr noundef %85, i64 noundef %95, ptr noundef %96, ptr noundef %97)
  %99 = load i32, ptr %7, align 4, !tbaa !16
  %100 = add nsw i32 %99, %98
  store i32 %100, ptr %7, align 4, !tbaa !16
  %101 = getelementptr inbounds [1 x %struct.__va_list_tag], ptr %12, i64 0, i64 0
  call void @llvm.va_end.p0(ptr %101)
  %102 = getelementptr inbounds [255 x i8], ptr %8, i64 0, i64 0
  %103 = load i32, ptr %7, align 4, !tbaa !16
  %104 = sext i32 %103 to i64
  %105 = getelementptr inbounds i8, ptr %102, i64 %104
  %106 = call i32 (ptr, ptr, ...) @sprintf_(ptr noundef %105, ptr noundef @.str.4)
  %107 = load i32, ptr %7, align 4, !tbaa !16
  %108 = add nsw i32 %107, %106
  store i32 %108, ptr %7, align 4, !tbaa !16
  %109 = load i32, ptr getelementptr inbounds (%struct.log_module_t, ptr @log, i32 0, i32 5), align 8, !tbaa !14
  %110 = icmp eq i32 %109, 1
  br i1 %110, label %111, label %119

111:                                              ; preds = %93
  %112 = load i32, ptr getelementptr inbounds (%struct.log_module_t, ptr @log, i32 0, i32 3), align 4, !tbaa !10
  %113 = getelementptr inbounds [255 x i8], ptr %8, i64 0, i64 0
  %114 = load i32, ptr %7, align 4, !tbaa !16
  %115 = sext i32 %114 to i64
  %116 = call i32 @write(i32 noundef %112, ptr noundef %113, i64 noundef %115)
  %117 = load i32, ptr getelementptr inbounds (%struct.log_module_t, ptr @log, i32 0, i32 3), align 4, !tbaa !10
  %118 = call i32 @fsync(i32 noundef %117)
  br label %139

119:                                              ; preds = %93
  %120 = getelementptr inbounds [255 x i8], ptr %8, i64 0, i64 0
  %121 = call i64 @strlen(ptr noundef %120) #9
  %122 = load i64, ptr getelementptr inbounds (%struct.log_module_t, ptr @log, i32 0, i32 1), align 8, !tbaa !21
  %123 = load i32, ptr getelementptr inbounds (%struct.log_module_t, ptr @log, i32 0, i32 2), align 8, !tbaa !22
  %124 = zext i32 %123 to i64
  %125 = sub i64 %122, %124
  %126 = icmp ugt i64 %121, %125
  br i1 %126, label %127, label %129

127:                                              ; preds = %119
  %128 = call i32 (ptr, ...) @printf_(ptr noundef @.str.5)
  br label %138

129:                                              ; preds = %119
  %130 = load ptr, ptr @log, align 8, !tbaa !15
  %131 = load i32, ptr getelementptr inbounds (%struct.log_module_t, ptr @log, i32 0, i32 2), align 8, !tbaa !22
  %132 = zext i32 %131 to i64
  %133 = getelementptr inbounds i8, ptr %130, i64 %132
  %134 = getelementptr inbounds [255 x i8], ptr %8, i64 0, i64 0
  %135 = call i32 (ptr, ptr, ...) @sprintf_(ptr noundef %133, ptr noundef @.str.6, ptr noundef %134)
  %136 = load i32, ptr getelementptr inbounds (%struct.log_module_t, ptr @log, i32 0, i32 2), align 8, !tbaa !22
  %137 = add i32 %136, %135
  store i32 %137, ptr getelementptr inbounds (%struct.log_module_t, ptr @log, i32 0, i32 2), align 8, !tbaa !22
  br label %138

138:                                              ; preds = %129, %127
  br label %139

139:                                              ; preds = %138, %111
  %140 = load ptr, ptr getelementptr inbounds (%struct.log_module_t, ptr @log, i32 0, i32 4), align 8, !tbaa !17
  %141 = call i64 @xQueueGenericSend(ptr noundef %140, ptr noundef null, i32 noundef 0, i64 noundef 0)
  call void @llvm.lifetime.end.p0(i64 24, ptr %12) #8
  store i32 0, ptr %11, align 4
  br label %142

142:                                              ; preds = %139, %26
  call void @llvm.lifetime.end.p0(i64 16, ptr %10) #8
  call void @llvm.lifetime.end.p0(i64 20, ptr %9) #8
  call void @llvm.lifetime.end.p0(i64 255, ptr %8) #8
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #8
  %143 = load i32, ptr %11, align 4
  switch i32 %143, label %145 [
    i32 0, label %144
    i32 1, label %144
  ]

144:                                              ; preds = %142, %142, %21
  ret void

145:                                              ; preds = %142
  unreachable
}

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #3

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #4

declare i32 @clock_gettime(i32 noundef, ptr noundef) #5

declare i64 @xQueueSemaphoreTake(ptr noundef, i32 noundef) #5

declare i32 @sprintf_(ptr noundef, ptr noundef, ...) #5

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare double @llvm.fmuladd.f64(double, double, double) #6

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

declare i32 @vsnprintf_(ptr noundef, i64 noundef, ptr noundef, ptr noundef) #5

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

declare i32 @write(i32 noundef, ptr noundef, i64 noundef) #5

declare i32 @fsync(i32 noundef) #5

declare i32 @printf_(ptr noundef, ...) #5

declare i64 @xQueueGenericSend(ptr noundef, ptr noundef, i32 noundef, i64 noundef) #5

attributes #0 = { 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 #1 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { 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 #3 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #4 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #5 = { "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 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #7 = { nocallback nofree nosync nounwind willreturn }
attributes #8 = { nounwind }
attributes #9 = { 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 = !{!"omnipotent char", !7, i64 0}
!7 = !{!"Simple C/C++ TBAA"}
!8 = !{!9, !9, i64 0}
!9 = !{!"any pointer", !6, i64 0}
!10 = !{!11, !13, i64 20}
!11 = !{!"", !9, i64 0, !12, i64 8, !13, i64 16, !13, i64 20, !9, i64 24, !13, i64 32}
!12 = !{!"long", !6, i64 0}
!13 = !{!"int", !6, i64 0}
!14 = !{!11, !13, i64 32}
!15 = !{!11, !9, i64 0}
!16 = !{!13, !13, i64 0}
!17 = !{!11, !9, i64 24}
!18 = !{!19, !12, i64 0}
!19 = !{!"timespec", !12, i64 0, !12, i64 8}
!20 = !{!19, !12, i64 8}
!21 = !{!11, !12, i64 8}
!22 = !{!11, !13, i64 16}


; 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.log_module_t = type { ptr, i64, i32, i32, ptr, i32 }
%struct.timespec = type { i64, i64 }
%struct.__va_list_tag = type { i32, i32, ptr, ptr }

@log = external hidden local_unnamed_addr global %struct.log_module_t, align 8
@.str.1 = external hidden unnamed_addr constant [6 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [8 x i8], align 1
@msg_color = external hidden local_unnamed_addr global [5 x ptr], align 16
@msg_types = external hidden local_unnamed_addr global [4 x ptr], align 16
@.str.3 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [22 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [3 x i8], align 1

; Function Attrs: mustprogress nofree nounwind willreturn memory(argmem: read)
declare i64 @strlen(ptr nocapture noundef) local_unnamed_addr #0

; 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 nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1

; Function Attrs: nounwind uwtable
define dso_local void @log_module(i8 noundef zeroext %0, ptr nocapture noundef readonly %1, ptr noundef %2, ...) local_unnamed_addr #2 {
  %4 = alloca [255 x i8], align 16
  %5 = alloca [20 x i8], align 16
  %6 = alloca %struct.timespec, align 8
  %7 = alloca [1 x %struct.__va_list_tag], align 16
  %8 = load i32, ptr getelementptr inbounds (i8, ptr @log, i64 20), align 4, !tbaa !5
  %9 = icmp slt i32 %8, 1
  %10 = load i32, ptr getelementptr inbounds (i8, ptr @log, i64 32), align 8
  %11 = icmp eq i32 %10, 1
  %or.cond = select i1 %9, i1 %11, i1 false
  %12 = load ptr, ptr @log, align 8
  %13 = icmp eq ptr %12, null
  %or.cond3 = select i1 %or.cond, i1 true, i1 %13
  br i1 %or.cond3, label %80, label %14

14:                                               ; preds = %3
  call void @llvm.lifetime.start.p0(i64 255, ptr nonnull %4) #9
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 16 dereferenceable(255) %4, i8 0, i64 255, i1 false)
  call void @llvm.lifetime.start.p0(i64 20, ptr nonnull %5) #9
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 16 dereferenceable(20) %5, i8 0, i64 20, i1 false)
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %6) #9
  %15 = icmp eq i8 %0, 4
  br i1 %15, label %79, label %16

16:                                               ; preds = %14
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 16 dereferenceable(9) %5, i8 32, i64 9, i1 false)
  %17 = tail call i64 @strlen(ptr noundef nonnull dereferenceable(1) %1) #10
  %spec.select = tail call i64 @llvm.umin.i64(i64 %17, i64 10)
  call void @llvm.memcpy.p0.p0.i64(ptr nonnull align 16 %5, ptr align 1 %1, i64 %spec.select, i1 false)
  %18 = call i32 @clock_gettime(i32 noundef 1, ptr noundef nonnull %6) #9
  %19 = load ptr, ptr getelementptr inbounds (i8, ptr @log, i64 24), align 8, !tbaa !12
  %20 = call i64 @xQueueSemaphoreTake(ptr noundef %19, i32 noundef -1) #9
  %21 = load i64, ptr %6, align 8, !tbaa !13
  %22 = sitofp i64 %21 to double
  %23 = getelementptr inbounds i8, ptr %6, i64 8
  %24 = load i64, ptr %23, align 8, !tbaa !15
  %25 = sitofp i64 %24 to double
  %26 = call double @llvm.fmuladd.f64(double %25, double 1.000000e-09, double %22)
  %27 = call i32 (ptr, ptr, ...) @sprintf_(ptr noundef nonnull %4, ptr noundef nonnull @.str.1, double noundef %26) #9
  %28 = sext i32 %27 to i64
  %29 = getelementptr inbounds i8, ptr %4, i64 %28
  %30 = zext i8 %0 to i64
  %31 = getelementptr inbounds [5 x ptr], ptr @msg_color, i64 0, i64 %30
  %32 = load ptr, ptr %31, align 8, !tbaa !16
  %33 = getelementptr inbounds [4 x ptr], ptr @msg_types, i64 0, i64 %30
  %34 = load ptr, ptr %33, align 8, !tbaa !16
  %35 = load ptr, ptr getelementptr inbounds (i8, ptr @msg_color, i64 32), align 16, !tbaa !16
  %36 = call i32 (ptr, ptr, ...) @sprintf_(ptr noundef nonnull %29, ptr noundef nonnull @.str.2, ptr noundef %32, ptr noundef %34, ptr noundef %35) #9
  %37 = add nsw i32 %36, %27
  %38 = sext i32 %37 to i64
  %39 = getelementptr inbounds i8, ptr %4, i64 %38
  %40 = call i32 (ptr, ptr, ...) @sprintf_(ptr noundef nonnull %39, ptr noundef nonnull @.str.3, ptr noundef nonnull %5) #9
  %41 = add nsw i32 %37, %40
  call void @llvm.lifetime.start.p0(i64 24, ptr nonnull %7) #9
  call void @llvm.va_start.p0(ptr nonnull %7)
  %42 = sext i32 %41 to i64
  %43 = getelementptr inbounds i8, ptr %4, i64 %42
  %44 = sub nsw i32 255, %41
  %45 = call i32 @llvm.smax.i32(i32 %44, i32 0)
  %46 = zext nneg i32 %45 to i64
  %47 = call i32 @vsnprintf_(ptr noundef nonnull %43, i64 noundef %46, ptr noundef %2, ptr noundef nonnull %7) #9
  %48 = add nsw i32 %47, %41
  call void @llvm.va_end.p0(ptr nonnull %7)
  %49 = sext i32 %48 to i64
  %50 = getelementptr inbounds i8, ptr %4, i64 %49
  %51 = call i32 (ptr, ptr, ...) @sprintf_(ptr noundef nonnull %50, ptr noundef nonnull @.str.4) #9
  %52 = load i32, ptr getelementptr inbounds (i8, ptr @log, i64 32), align 8, !tbaa !17
  %53 = icmp eq i32 %52, 1
  br i1 %53, label %54, label %61

54:                                               ; preds = %16
  %55 = add nsw i32 %51, %48
  %56 = load i32, ptr getelementptr inbounds (i8, ptr @log, i64 20), align 4, !tbaa !5
  %57 = sext i32 %55 to i64
  %58 = call i32 @write(i32 noundef %56, ptr noundef nonnull %4, i64 noundef %57) #9
  %59 = load i32, ptr getelementptr inbounds (i8, ptr @log, i64 20), align 4, !tbaa !5
  %60 = call i32 @fsync(i32 noundef %59) #9
  br label %76

61:                                               ; preds = %16
  %62 = call i64 @strlen(ptr noundef nonnull dereferenceable(1) %4) #10
  %63 = load i64, ptr getelementptr inbounds (i8, ptr @log, i64 8), align 8, !tbaa !18
  %64 = load i32, ptr getelementptr inbounds (i8, ptr @log, i64 16), align 8, !tbaa !19
  %65 = zext i32 %64 to i64
  %66 = sub i64 %63, %65
  %67 = icmp ugt i64 %62, %66
  br i1 %67, label %68, label %70

68:                                               ; preds = %61
  %69 = call i32 (ptr, ...) @printf_(ptr noundef nonnull @.str.5) #9
  br label %76

70:                                               ; preds = %61
  %71 = load ptr, ptr @log, align 8, !tbaa !20
  %72 = getelementptr inbounds i8, ptr %71, i64 %65
  %73 = call i32 (ptr, ptr, ...) @sprintf_(ptr noundef %72, ptr noundef nonnull @.str.6, ptr noundef nonnull %4) #9
  %74 = load i32, ptr getelementptr inbounds (i8, ptr @log, i64 16), align 8, !tbaa !19
  %75 = add i32 %74, %73
  store i32 %75, ptr getelementptr inbounds (i8, ptr @log, i64 16), align 8, !tbaa !19
  br label %76

76:                                               ; preds = %68, %70, %54
  %77 = load ptr, ptr getelementptr inbounds (i8, ptr @log, i64 24), align 8, !tbaa !12
  %78 = call i64 @xQueueGenericSend(ptr noundef %77, ptr noundef null, i32 noundef 0, i64 noundef 0) #9
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %7) #9
  br label %79

79:                                               ; preds = %14, %76
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %6) #9
  call void @llvm.lifetime.end.p0(i64 20, ptr nonnull %5) #9
  call void @llvm.lifetime.end.p0(i64 255, ptr nonnull %4) #9
  br label %80

80:                                               ; preds = %3, %79
  ret void
}

; Function Attrs: mustprogress nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #3

; Function Attrs: mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #4

declare i32 @clock_gettime(i32 noundef, ptr noundef) local_unnamed_addr #5

declare i64 @xQueueSemaphoreTake(ptr noundef, i32 noundef) local_unnamed_addr #5

declare i32 @sprintf_(ptr noundef, ptr noundef, ...) local_unnamed_addr #5

; Function Attrs: mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare double @llvm.fmuladd.f64(double, double, double) #6

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

declare i32 @vsnprintf_(ptr noundef, i64 noundef, ptr noundef, ptr noundef) local_unnamed_addr #5

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

declare i32 @write(i32 noundef, ptr noundef, i64 noundef) local_unnamed_addr #5

declare i32 @fsync(i32 noundef) local_unnamed_addr #5

declare i32 @printf_(ptr noundef, ...) local_unnamed_addr #5

declare i64 @xQueueGenericSend(ptr noundef, ptr noundef, i32 noundef, i64 noundef) local_unnamed_addr #5

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i32 @llvm.smax.i32(i32, i32) #8

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i64 @llvm.umin.i64(i64, i64) #8

attributes #0 = { 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 #1 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { 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 #3 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #4 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #5 = { "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 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #7 = { mustprogress nocallback nofree nosync nounwind willreturn }
attributes #8 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #9 = { nounwind }
attributes #10 = { 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, !11, i64 20}
!6 = !{!"", !7, i64 0, !10, i64 8, !11, i64 16, !11, i64 20, !7, i64 24, !11, i64 32}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"long", !8, i64 0}
!11 = !{!"int", !8, i64 0}
!12 = !{!6, !7, i64 24}
!13 = !{!14, !10, i64 0}
!14 = !{!"timespec", !10, i64 0, !10, i64 8}
!15 = !{!14, !10, i64 8}
!16 = !{!7, !7, i64 0}
!17 = !{!6, !11, i64 32}
!18 = !{!6, !10, i64 8}
!19 = !{!6, !11, i64 16}
!20 = !{!6, !7, i64 0}


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