; LLVM IR from mwarning/KadNode :: src (utils)

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

@str_time.strdurationbuf = external hidden global [4 x [64 x i8]], align 16
@str_time.strdurationbuf_i = external hidden global i64, align 8
@.str.18 = external hidden unnamed_addr constant [1 x i8], align 1
@.str.19 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.20 = external hidden unnamed_addr constant [11 x i8], align 1
@.str.21 = external hidden unnamed_addr constant [11 x i8], align 1
@.str.22 = external hidden unnamed_addr constant [11 x i8], align 1
@.str.23 = external hidden unnamed_addr constant [11 x i8], align 1
@.str.24 = external hidden unnamed_addr constant [7 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: nounwind
declare i32 @snprintf(ptr noundef, i64 noundef, ptr noundef, ...) #1

; Function Attrs: nounwind uwtable
define dso_local ptr @str_time(i64 noundef %0) #2 {
  %2 = alloca i64, align 8
  %3 = alloca ptr, align 8
  %4 = alloca i64, align 8
  %5 = alloca i64, align 8
  %6 = alloca i64, align 8
  %7 = alloca i64, align 8
  %8 = alloca i64, align 8
  %9 = alloca ptr, align 8
  store i64 %0, ptr %2, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #3
  %10 = load i64, ptr @str_time.strdurationbuf_i, align 8, !tbaa !5
  %11 = add i64 %10, 1
  store i64 %11, ptr @str_time.strdurationbuf_i, align 8, !tbaa !5
  %12 = urem i64 %11, 4
  %13 = getelementptr inbounds [4 x [64 x i8]], ptr @str_time.strdurationbuf, i64 0, i64 %12
  %14 = getelementptr inbounds [64 x i8], ptr %13, i64 0, i64 0
  store ptr %14, ptr %3, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #3
  store ptr @.str.18, ptr %9, align 8, !tbaa !9
  %15 = load i64, ptr %2, align 8, !tbaa !5
  %16 = icmp slt i64 %15, 0
  br i1 %16, label %17, label %20

17:                                               ; preds = %1
  %18 = load i64, ptr %2, align 8, !tbaa !5
  %19 = sub nsw i64 0, %18
  store i64 %19, ptr %2, align 8, !tbaa !5
  store ptr @.str.19, ptr %9, align 8, !tbaa !9
  br label %20

20:                                               ; preds = %17, %1
  %21 = load i64, ptr %2, align 8, !tbaa !5
  %22 = sdiv i64 %21, 31536000
  store i64 %22, ptr %4, align 8, !tbaa !5
  %23 = load i64, ptr %4, align 8, !tbaa !5
  %24 = mul i64 %23, 31536000
  %25 = load i64, ptr %2, align 8, !tbaa !5
  %26 = sub i64 %25, %24
  store i64 %26, ptr %2, align 8, !tbaa !5
  %27 = load i64, ptr %2, align 8, !tbaa !5
  %28 = sdiv i64 %27, 86400
  store i64 %28, ptr %5, align 8, !tbaa !5
  %29 = load i64, ptr %5, align 8, !tbaa !5
  %30 = mul i64 %29, 86400
  %31 = load i64, ptr %2, align 8, !tbaa !5
  %32 = sub i64 %31, %30
  store i64 %32, ptr %2, align 8, !tbaa !5
  %33 = load i64, ptr %2, align 8, !tbaa !5
  %34 = sdiv i64 %33, 3600
  store i64 %34, ptr %6, align 8, !tbaa !5
  %35 = load i64, ptr %6, align 8, !tbaa !5
  %36 = mul i64 %35, 3600
  %37 = load i64, ptr %2, align 8, !tbaa !5
  %38 = sub i64 %37, %36
  store i64 %38, ptr %2, align 8, !tbaa !5
  %39 = load i64, ptr %2, align 8, !tbaa !5
  %40 = sdiv i64 %39, 60
  store i64 %40, ptr %7, align 8, !tbaa !5
  %41 = load i64, ptr %7, align 8, !tbaa !5
  %42 = mul i64 %41, 60
  %43 = load i64, ptr %2, align 8, !tbaa !5
  %44 = sub i64 %43, %42
  store i64 %44, ptr %2, align 8, !tbaa !5
  %45 = load i64, ptr %2, align 8, !tbaa !5
  store i64 %45, ptr %8, align 8, !tbaa !5
  %46 = load i64, ptr %4, align 8, !tbaa !5
  %47 = icmp ugt i64 %46, 0
  br i1 %47, label %48, label %54

48:                                               ; preds = %20
  %49 = load ptr, ptr %3, align 8, !tbaa !9
  %50 = load ptr, ptr %9, align 8, !tbaa !9
  %51 = load i64, ptr %4, align 8, !tbaa !5
  %52 = load i64, ptr %5, align 8, !tbaa !5
  %53 = call i32 (ptr, i64, ptr, ...) @snprintf(ptr noundef %49, i64 noundef 64, ptr noundef @.str.20, ptr noundef %50, i64 noundef %51, i64 noundef %52) #3
  br label %89

54:                                               ; preds = %20
  %55 = load i64, ptr %5, align 8, !tbaa !5
  %56 = icmp ugt i64 %55, 0
  br i1 %56, label %57, label %63

57:                                               ; preds = %54
  %58 = load ptr, ptr %3, align 8, !tbaa !9
  %59 = load ptr, ptr %9, align 8, !tbaa !9
  %60 = load i64, ptr %5, align 8, !tbaa !5
  %61 = load i64, ptr %6, align 8, !tbaa !5
  %62 = call i32 (ptr, i64, ptr, ...) @snprintf(ptr noundef %58, i64 noundef 64, ptr noundef @.str.21, ptr noundef %59, i64 noundef %60, i64 noundef %61) #3
  br label %88

63:                                               ; preds = %54
  %64 = load i64, ptr %6, align 8, !tbaa !5
  %65 = icmp ugt i64 %64, 0
  br i1 %65, label %66, label %72

66:                                               ; preds = %63
  %67 = load ptr, ptr %3, align 8, !tbaa !9
  %68 = load ptr, ptr %9, align 8, !tbaa !9
  %69 = load i64, ptr %6, align 8, !tbaa !5
  %70 = load i64, ptr %7, align 8, !tbaa !5
  %71 = call i32 (ptr, i64, ptr, ...) @snprintf(ptr noundef %67, i64 noundef 64, ptr noundef @.str.22, ptr noundef %68, i64 noundef %69, i64 noundef %70) #3
  br label %87

72:                                               ; preds = %63
  %73 = load i64, ptr %7, align 8, !tbaa !5
  %74 = icmp ugt i64 %73, 0
  br i1 %74, label %75, label %81

75:                                               ; preds = %72
  %76 = load ptr, ptr %3, align 8, !tbaa !9
  %77 = load ptr, ptr %9, align 8, !tbaa !9
  %78 = load i64, ptr %7, align 8, !tbaa !5
  %79 = load i64, ptr %8, align 8, !tbaa !5
  %80 = call i32 (ptr, i64, ptr, ...) @snprintf(ptr noundef %76, i64 noundef 64, ptr noundef @.str.23, ptr noundef %77, i64 noundef %78, i64 noundef %79) #3
  br label %86

81:                                               ; preds = %72
  %82 = load ptr, ptr %3, align 8, !tbaa !9
  %83 = load ptr, ptr %9, align 8, !tbaa !9
  %84 = load i64, ptr %8, align 8, !tbaa !5
  %85 = call i32 (ptr, i64, ptr, ...) @snprintf(ptr noundef %82, i64 noundef 64, ptr noundef @.str.24, ptr noundef %83, i64 noundef %84) #3
  br label %86

86:                                               ; preds = %81, %75
  br label %87

87:                                               ; preds = %86, %66
  br label %88

88:                                               ; preds = %87, %57
  br label %89

89:                                               ; preds = %88, %48
  %90 = load ptr, ptr %3, align 8, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #3
  ret ptr %90
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #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 = { 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 = !{!"long", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"any pointer", !7, i64 0}


; 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_time.strdurationbuf = external hidden global [4 x [64 x i8]], align 16
@str_time.strdurationbuf_i = external hidden local_unnamed_addr global i64, align 8
@.str.18 = external hidden unnamed_addr constant [1 x i8], align 1
@.str.19 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.20 = external hidden unnamed_addr constant [11 x i8], align 1
@.str.21 = external hidden unnamed_addr constant [11 x i8], align 1
@.str.22 = external hidden unnamed_addr constant [11 x i8], align 1
@.str.23 = external hidden unnamed_addr constant [11 x i8], align 1
@.str.24 = external hidden unnamed_addr constant [7 x i8], align 1

; Function Attrs: nofree nounwind
declare noundef i32 @snprintf(ptr noalias nocapture noundef writeonly, i64 noundef, ptr nocapture noundef readonly, ...) local_unnamed_addr #0

; Function Attrs: nofree nounwind uwtable
define dso_local nonnull ptr @str_time(i64 noundef %0) local_unnamed_addr #1 {
  %2 = load i64, ptr @str_time.strdurationbuf_i, align 8, !tbaa !5
  %3 = add i64 %2, 1
  store i64 %3, ptr @str_time.strdurationbuf_i, align 8, !tbaa !5
  %4 = and i64 %3, 3
  %5 = getelementptr inbounds [4 x [64 x i8]], ptr @str_time.strdurationbuf, i64 0, i64 %4
  %6 = icmp slt i64 %0, 0
  %spec.select = tail call i64 @llvm.abs.i64(i64 %0, i1 true)
  %spec.select52 = select i1 %6, ptr @.str.19, ptr @.str.18
  %7 = udiv i64 %spec.select, 31536000
  %.neg = mul nsw i64 %7, -31536000
  %8 = add nsw i64 %.neg, %spec.select
  %9 = sdiv i64 %8, 86400
  %.neg44 = mul nsw i64 %9, -86400
  %10 = add i64 %.neg44, %8
  %11 = sdiv i64 %10, 3600
  %.neg45 = mul nsw i64 %11, -3600
  %12 = add i64 %.neg45, %10
  %13 = sdiv i64 %12, 60
  %.neg46 = mul nsw i64 %13, -60
  %14 = add i64 %.neg46, %12
  %.not = icmp ult i64 %spec.select, 31536000
  br i1 %.not, label %17, label %15

15:                                               ; preds = %1
  %16 = tail call i32 (ptr, i64, ptr, ...) @snprintf(ptr noundef nonnull dereferenceable(1) %5, i64 noundef 64, ptr noundef nonnull @.str.20, ptr noundef nonnull %spec.select52, i64 noundef %7, i64 noundef %9) #3
  br label %28

17:                                               ; preds = %1
  %.off = add nsw i64 %8, 86399
  %.not47 = icmp ult i64 %.off, 172799
  br i1 %.not47, label %20, label %18

18:                                               ; preds = %17
  %19 = tail call i32 (ptr, i64, ptr, ...) @snprintf(ptr noundef nonnull dereferenceable(1) %5, i64 noundef 64, ptr noundef nonnull @.str.21, ptr noundef nonnull %spec.select52, i64 noundef %9, i64 noundef %11) #3
  br label %28

20:                                               ; preds = %17
  %.off49 = add i64 %10, 3599
  %.not48 = icmp ult i64 %.off49, 7199
  br i1 %.not48, label %23, label %21

21:                                               ; preds = %20
  %22 = tail call i32 (ptr, i64, ptr, ...) @snprintf(ptr noundef nonnull dereferenceable(1) %5, i64 noundef 64, ptr noundef nonnull @.str.22, ptr noundef nonnull %spec.select52, i64 noundef %11, i64 noundef %13) #3
  br label %28

23:                                               ; preds = %20
  %.off51 = add i64 %12, 59
  %.not50 = icmp ult i64 %.off51, 119
  br i1 %.not50, label %26, label %24

24:                                               ; preds = %23
  %25 = tail call i32 (ptr, i64, ptr, ...) @snprintf(ptr noundef nonnull dereferenceable(1) %5, i64 noundef 64, ptr noundef nonnull @.str.23, ptr noundef nonnull %spec.select52, i64 noundef %13, i64 noundef %14) #3
  br label %28

26:                                               ; preds = %23
  %27 = tail call i32 (ptr, i64, ptr, ...) @snprintf(ptr noundef nonnull dereferenceable(1) %5, i64 noundef 64, ptr noundef nonnull @.str.24, ptr noundef nonnull %spec.select52, i64 noundef %14) #3
  br label %28

28:                                               ; preds = %18, %24, %26, %21, %15
  ret ptr %5
}

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i64 @llvm.abs.i64(i64, i1 immarg) #2

attributes #0 = { nofree 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 = { nofree 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 #2 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
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 = !{!"long", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}


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