; LLVM IR from jspd-group/pegit :: src (timestamp)

; 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.strbuf = type { i64, i64, ptr }
%struct.timestamp = type { i64, ptr }

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

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

; Function Attrs: nounwind uwtable
define dso_local void @time_stamp_humanise(ptr noundef %0, ptr noundef %1) #1 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca i64, align 8
  %6 = alloca i64, align 8
  store ptr %0, ptr %3, align 8, !tbaa !5
  store ptr %1, ptr %4, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #5
  store i64 256, ptr %5, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #5
  %7 = load ptr, ptr %4, align 8, !tbaa !5
  %8 = getelementptr inbounds %struct.strbuf, ptr %7, i32 0, i32 1
  %9 = load i64, ptr %8, align 8, !tbaa !11
  store i64 %9, ptr %6, align 8, !tbaa !9
  %10 = load ptr, ptr %3, align 8, !tbaa !5
  %11 = getelementptr inbounds %struct.timestamp, ptr %10, i32 0, i32 0
  %12 = call ptr @localtime(ptr noundef %11) #5
  %13 = load ptr, ptr %3, align 8, !tbaa !5
  %14 = getelementptr inbounds %struct.timestamp, ptr %13, i32 0, i32 1
  store ptr %12, ptr %14, align 8, !tbaa !13
  %15 = load ptr, ptr %4, align 8, !tbaa !5
  %16 = call i64 @strbuf_avail(ptr noundef %15)
  %17 = icmp eq i64 %16, 0
  br i1 %17, label %18, label %21

18:                                               ; preds = %2
  %19 = load ptr, ptr %4, align 8, !tbaa !5
  %20 = load i64, ptr %5, align 8, !tbaa !9
  call void @strbuf_grow(ptr noundef %19, i64 noundef %20)
  br label %21

21:                                               ; preds = %18, %2
  br label %22

22:                                               ; preds = %41, %21
  %23 = load ptr, ptr %4, align 8, !tbaa !5
  %24 = getelementptr inbounds %struct.strbuf, ptr %23, i32 0, i32 2
  %25 = load ptr, ptr %24, align 8, !tbaa !15
  %26 = load i64, ptr %6, align 8, !tbaa !9
  %27 = getelementptr inbounds i8, ptr %25, i64 %26
  %28 = load ptr, ptr %4, align 8, !tbaa !5
  %29 = call i64 @strbuf_avail(ptr noundef %28)
  %30 = load ptr, ptr %3, align 8, !tbaa !5
  %31 = getelementptr inbounds %struct.timestamp, ptr %30, i32 0, i32 1
  %32 = load ptr, ptr %31, align 8, !tbaa !13
  %33 = call i64 @strftime(ptr noundef %27, i64 noundef %29, ptr noundef @.str, ptr noundef %32) #5
  %34 = icmp ne i64 %33, 0
  br i1 %34, label %35, label %36

35:                                               ; preds = %22
  br label %44

36:                                               ; preds = %22
  %37 = load ptr, ptr %4, align 8, !tbaa !5
  %38 = load i64, ptr %6, align 8, !tbaa !9
  call void @strbuf_setlen(ptr noundef %37, i64 noundef %38)
  %39 = load ptr, ptr %4, align 8, !tbaa !5
  %40 = load i64, ptr %5, align 8, !tbaa !9
  call void @strbuf_grow(ptr noundef %39, i64 noundef %40)
  br label %41

41:                                               ; preds = %36
  %42 = load i64, ptr %5, align 8, !tbaa !9
  %43 = mul i64 %42, 2
  store i64 %43, ptr %5, align 8, !tbaa !9
  br label %22

44:                                               ; preds = %35
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #5
  ret void
}

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

; Function Attrs: inlinehint nounwind uwtable
declare hidden i64 @strbuf_avail(ptr noundef) #3

declare void @strbuf_grow(ptr noundef, i64 noundef) #4

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

; Function Attrs: inlinehint nounwind uwtable
declare hidden void @strbuf_setlen(ptr noundef, i64 noundef) #3

; 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 = { 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 willreturn memory(argmem: readwrite) }
attributes #3 = { inlinehint 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 = { "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 }

!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/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"long", !7, i64 0}
!11 = !{!12, !10, i64 8}
!12 = !{!"strbuf", !10, i64 0, !10, i64 8, !6, i64 16}
!13 = !{!14, !6, i64 8}
!14 = !{!"timestamp", !10, i64 0, !6, i64 8}
!15 = !{!12, !6, 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"

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

; Function Attrs: nounwind
declare ptr @localtime(ptr noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local void @time_stamp_humanise(ptr noundef %0, ptr noundef %1) local_unnamed_addr #1 {
  %3 = getelementptr inbounds i8, ptr %1, i64 8
  %4 = load i64, ptr %3, align 8, !tbaa !5
  %5 = tail call ptr @localtime(ptr noundef %0) #4
  %6 = getelementptr inbounds i8, ptr %0, i64 8
  store ptr %5, ptr %6, align 8, !tbaa !11
  %7 = tail call i64 @strbuf_avail(ptr noundef %1)
  %8 = icmp eq i64 %7, 0
  br i1 %8, label %9, label %10

9:                                                ; preds = %2
  tail call void @strbuf_grow(ptr noundef nonnull %1, i64 noundef 256) #4
  br label %10

10:                                               ; preds = %9, %2
  %11 = getelementptr inbounds i8, ptr %1, i64 16
  %12 = load ptr, ptr %11, align 8, !tbaa !13
  %13 = getelementptr inbounds i8, ptr %12, i64 %4
  %14 = tail call i64 @strbuf_avail(ptr noundef nonnull %1)
  %15 = load ptr, ptr %6, align 8, !tbaa !11
  %16 = tail call i64 @strftime(ptr noundef %13, i64 noundef %14, ptr noundef nonnull @.str, ptr noundef %15) #4
  %.not14 = icmp eq i64 %16, 0
  br i1 %.not14, label %.lr.ph, label %._crit_edge

.lr.ph:                                           ; preds = %10, %.lr.ph
  %.015 = phi i64 [ %17, %.lr.ph ], [ 256, %10 ]
  tail call void @strbuf_setlen(ptr noundef nonnull %1, i64 noundef %4)
  tail call void @strbuf_grow(ptr noundef nonnull %1, i64 noundef %.015) #4
  %17 = shl i64 %.015, 1
  %18 = load ptr, ptr %11, align 8, !tbaa !13
  %19 = getelementptr inbounds i8, ptr %18, i64 %4
  %20 = tail call i64 @strbuf_avail(ptr noundef nonnull %1)
  %21 = load ptr, ptr %6, align 8, !tbaa !11
  %22 = tail call i64 @strftime(ptr noundef %19, i64 noundef %20, ptr noundef nonnull @.str, ptr noundef %21) #4
  %.not = icmp eq i64 %22, 0
  br i1 %.not, label %.lr.ph, label %._crit_edge

._crit_edge:                                      ; preds = %.lr.ph, %10
  ret void
}

; Function Attrs: inlinehint nounwind uwtable
declare hidden i64 @strbuf_avail(ptr noundef) local_unnamed_addr #2

declare void @strbuf_grow(ptr noundef, i64 noundef) local_unnamed_addr #3

; Function Attrs: nounwind
declare i64 @strftime(ptr noundef, i64 noundef, ptr noundef, ptr noundef) local_unnamed_addr #0

; Function Attrs: inlinehint nounwind uwtable
declare hidden void @strbuf_setlen(ptr noundef, i64 noundef) local_unnamed_addr #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 = { 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 = { inlinehint 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 = { "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 = { 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, !7, i64 8}
!6 = !{!"strbuf", !7, i64 0, !7, i64 8, !10, i64 16}
!7 = !{!"long", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"any pointer", !8, i64 0}
!11 = !{!12, !10, i64 8}
!12 = !{!"timestamp", !7, i64 0, !10, i64 8}
!13 = !{!6, !10, i64 16}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,SROAPass,SimplifyCFGPass,TailCallElimPass