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

; 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.deltafile = type { %struct.strbuf, ptr, i64, i8 }
%struct.pack_file_cache = type { ptr, %struct.strbuf }
%struct.index = type { [256 x i8], %struct.stat, i8, i64, i64, i64 }
%struct.stat = type { i64, i64, i64, i32, i32, i32, i32, i64, i64, i64, i64, %struct.timespec, %struct.timespec, %struct.timespec, [3 x i64] }
%struct.timespec = type { i64, i64 }

@.str.4 = external hidden unnamed_addr constant [7 x i8], align 1
@stdout = external global ptr, align 8
@.str.28 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.34 = external hidden unnamed_addr constant [7 x i8], align 1
@__const.print_object_insertions.temp = external hidden unnamed_addr constant %struct.strbuf, align 8
@__const.print_object_insertions.out = external hidden unnamed_addr constant %struct.strbuf, align 8

; 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

declare void @deltafile_free(ptr noundef) #1

; Function Attrs: nounwind
declare i32 @fprintf(ptr noundef, ptr noundef, ...) #2

declare i32 @deltafile_init_strbuf(ptr noundef, ptr noundef, i8 noundef signext) #1

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

declare void @strbuf_add(ptr noundef, ptr noundef, i64 noundef) #1

; 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 void @strbuf_release(ptr noundef) #1

; Function Attrs: nounwind uwtable
define dso_local void @print_object_insertions(ptr noundef %0, ptr noundef %1) #5 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca %struct.strbuf, align 8
  %6 = alloca %struct.strbuf, align 8
  %7 = alloca %struct.deltafile, align 8
  %8 = alloca i32, align 4
  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 24, ptr %5) #6
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %5, ptr align 8 @__const.print_object_insertions.temp, i64 24, i1 false)
  call void @llvm.lifetime.start.p0(i64 24, ptr %6) #6
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %6, ptr align 8 @__const.print_object_insertions.out, i64 24, i1 false)
  call void @llvm.lifetime.start.p0(i64 48, ptr %7) #6
  %9 = load ptr, ptr %3, align 8, !tbaa !5
  %10 = getelementptr inbounds %struct.pack_file_cache, ptr %9, i32 0, i32 1
  %11 = getelementptr inbounds %struct.strbuf, ptr %10, i32 0, i32 2
  %12 = load ptr, ptr %11, align 8, !tbaa !9
  %13 = load ptr, ptr %4, align 8, !tbaa !5
  %14 = getelementptr inbounds %struct.index, ptr %13, i32 0, i32 4
  %15 = load i64, ptr %14, align 8, !tbaa !13
  %16 = getelementptr inbounds i8, ptr %12, i64 %15
  %17 = load ptr, ptr %4, align 8, !tbaa !5
  %18 = getelementptr inbounds %struct.index, ptr %17, i32 0, i32 5
  %19 = load i64, ptr %18, align 8, !tbaa !18
  call void @strbuf_add(ptr noundef %5, ptr noundef %16, i64 noundef %19)
  %20 = call i32 @deltafile_init_strbuf(ptr noundef %7, ptr noundef %5, i8 noundef signext 10)
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #6
  store i32 0, ptr %8, align 4, !tbaa !19
  br label %21

21:                                               ; preds = %54, %2
  %22 = load i32, ptr %8, align 4, !tbaa !19
  %23 = sext i32 %22 to i64
  %24 = getelementptr inbounds %struct.deltafile, ptr %7, i32 0, i32 2
  %25 = load i64, ptr %24, align 8, !tbaa !20
  %26 = sub i64 %25, 1
  %27 = icmp ult i64 %23, %26
  br i1 %27, label %29, label %28

28:                                               ; preds = %21
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #6
  br label %57

29:                                               ; preds = %21
  call void @strbuf_addstr(ptr noundef %6, ptr noundef @.str.34)
  %30 = getelementptr inbounds %struct.strbuf, ptr %5, i32 0, i32 2
  %31 = load ptr, ptr %30, align 8, !tbaa !22
  %32 = getelementptr inbounds %struct.deltafile, ptr %7, i32 0, i32 1
  %33 = load ptr, ptr %32, align 8, !tbaa !23
  %34 = load i32, ptr %8, align 4, !tbaa !19
  %35 = sext i32 %34 to i64
  %36 = getelementptr inbounds i64, ptr %33, i64 %35
  %37 = load i64, ptr %36, align 8, !tbaa !24
  %38 = getelementptr inbounds i8, ptr %31, i64 %37
  %39 = getelementptr inbounds i8, ptr %38, i64 1
  %40 = getelementptr inbounds %struct.deltafile, ptr %7, i32 0, i32 1
  %41 = load ptr, ptr %40, align 8, !tbaa !23
  %42 = load i32, ptr %8, align 4, !tbaa !19
  %43 = add nsw i32 %42, 1
  %44 = sext i32 %43 to i64
  %45 = getelementptr inbounds i64, ptr %41, i64 %44
  %46 = load i64, ptr %45, align 8, !tbaa !24
  %47 = getelementptr inbounds %struct.deltafile, ptr %7, i32 0, i32 1
  %48 = load ptr, ptr %47, align 8, !tbaa !23
  %49 = load i32, ptr %8, align 4, !tbaa !19
  %50 = sext i32 %49 to i64
  %51 = getelementptr inbounds i64, ptr %48, i64 %50
  %52 = load i64, ptr %51, align 8, !tbaa !24
  %53 = sub nsw i64 %46, %52
  call void @strbuf_add(ptr noundef %6, ptr noundef %39, i64 noundef %53)
  call void @strbuf_addstr(ptr noundef %6, ptr noundef @.str.4)
  br label %54

54:                                               ; preds = %29
  %55 = load i32, ptr %8, align 4, !tbaa !19
  %56 = add nsw i32 %55, 1
  store i32 %56, ptr %8, align 4, !tbaa !19
  br label %21, !llvm.loop !25

57:                                               ; preds = %28
  %58 = load ptr, ptr @stdout, align 8, !tbaa !5
  %59 = getelementptr inbounds %struct.strbuf, ptr %6, i32 0, i32 2
  %60 = load ptr, ptr %59, align 8, !tbaa !22
  %61 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %58, ptr noundef @.str.28, ptr noundef %60) #6
  call void @strbuf_release(ptr noundef %6)
  call void @strbuf_release(ptr noundef %5)
  call void @deltafile_free(ptr noundef %7)
  call void @llvm.lifetime.end.p0(i64 48, ptr %7) #6
  call void @llvm.lifetime.end.p0(i64 24, ptr %6) #6
  call void @llvm.lifetime.end.p0(i64 24, ptr %5) #6
  ret void
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { "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 "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 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 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #5 = { 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 #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, !6, i64 0}
!6 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !6, i64 24}
!10 = !{!"pack_file_cache", !6, i64 0, !11, i64 8}
!11 = !{!"strbuf", !12, i64 0, !12, i64 8, !6, i64 16}
!12 = !{!"long", !7, i64 0}
!13 = !{!14, !12, i64 416}
!14 = !{!"index", !7, i64 0, !15, i64 256, !7, i64 400, !12, i64 408, !12, i64 416, !12, i64 424}
!15 = !{!"stat", !12, i64 0, !12, i64 8, !12, i64 16, !16, i64 24, !16, i64 28, !16, i64 32, !16, i64 36, !12, i64 40, !12, i64 48, !12, i64 56, !12, i64 64, !17, i64 72, !17, i64 88, !17, i64 104, !7, i64 120}
!16 = !{!"int", !7, i64 0}
!17 = !{!"timespec", !12, i64 0, !12, i64 8}
!18 = !{!14, !12, i64 424}
!19 = !{!16, !16, i64 0}
!20 = !{!21, !12, i64 32}
!21 = !{!"deltafile", !11, i64 0, !6, i64 24, !12, i64 32, !7, i64 40}
!22 = !{!11, !6, i64 16}
!23 = !{!21, !6, i64 24}
!24 = !{!12, !12, 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"

%struct.strbuf = type { i64, i64, ptr }
%struct.deltafile = type { %struct.strbuf, ptr, i64, i8 }

@.str.4 = external hidden unnamed_addr constant [7 x i8], align 1
@stdout = external local_unnamed_addr global ptr, align 8
@.str.28 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.34 = external hidden unnamed_addr constant [7 x i8], align 1
@__const.print_object_insertions.temp = external hidden unnamed_addr constant %struct.strbuf, align 8
@__const.print_object_insertions.out = external hidden unnamed_addr constant %struct.strbuf, align 8

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

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

declare void @deltafile_free(ptr noundef) local_unnamed_addr #1

; Function Attrs: nofree nounwind
declare noundef i32 @fprintf(ptr nocapture noundef, ptr nocapture noundef readonly, ...) local_unnamed_addr #2

declare i32 @deltafile_init_strbuf(ptr noundef, ptr noundef, i8 noundef signext) local_unnamed_addr #1

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

declare void @strbuf_add(ptr noundef, ptr noundef, i64 noundef) local_unnamed_addr #1

; 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 void @strbuf_release(ptr noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
define dso_local void @print_object_insertions(ptr nocapture noundef readonly %0, ptr nocapture noundef readonly %1) local_unnamed_addr #5 {
  %3 = alloca %struct.strbuf, align 8
  %4 = alloca %struct.strbuf, align 8
  %5 = alloca %struct.deltafile, align 8
  call void @llvm.lifetime.start.p0(i64 24, ptr nonnull %3) #6
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 8 dereferenceable(24) %3, ptr noundef nonnull align 8 dereferenceable(24) @__const.print_object_insertions.temp, i64 24, i1 false)
  call void @llvm.lifetime.start.p0(i64 24, ptr nonnull %4) #6
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 8 dereferenceable(24) %4, ptr noundef nonnull align 8 dereferenceable(24) @__const.print_object_insertions.out, i64 24, i1 false)
  call void @llvm.lifetime.start.p0(i64 48, ptr nonnull %5) #6
  %6 = getelementptr inbounds i8, ptr %0, i64 24
  %7 = load ptr, ptr %6, align 8, !tbaa !5
  %8 = getelementptr inbounds i8, ptr %1, i64 416
  %9 = load i64, ptr %8, align 8, !tbaa !12
  %10 = getelementptr inbounds i8, ptr %7, i64 %9
  %11 = getelementptr inbounds i8, ptr %1, i64 424
  %12 = load i64, ptr %11, align 8, !tbaa !17
  call void @strbuf_add(ptr noundef nonnull %3, ptr noundef %10, i64 noundef %12) #6
  %13 = call i32 @deltafile_init_strbuf(ptr noundef nonnull %5, ptr noundef nonnull %3, i8 noundef signext 10) #6
  %14 = getelementptr inbounds i8, ptr %5, i64 32
  %15 = load i64, ptr %14, align 8, !tbaa !18
  %.not = icmp eq i64 %15, 1
  br i1 %.not, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %2
  %16 = getelementptr inbounds i8, ptr %3, i64 16
  %17 = getelementptr inbounds i8, ptr %5, i64 24
  br label %22

._crit_edge:                                      ; preds = %22, %2
  %18 = load ptr, ptr @stdout, align 8, !tbaa !20
  %19 = getelementptr inbounds i8, ptr %4, i64 16
  %20 = load ptr, ptr %19, align 8, !tbaa !21
  %21 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %18, ptr noundef nonnull @.str.28, ptr noundef %20) #6
  call void @strbuf_release(ptr noundef nonnull %4) #6
  call void @strbuf_release(ptr noundef nonnull %3) #6
  call void @deltafile_free(ptr noundef nonnull %5) #6
  call void @llvm.lifetime.end.p0(i64 48, ptr nonnull %5) #6
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %4) #6
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %3) #6
  ret void

22:                                               ; preds = %.lr.ph, %22
  %indvars.iv = phi i64 [ 0, %.lr.ph ], [ %indvars.iv.next, %22 ]
  call void @strbuf_addstr(ptr noundef nonnull %4, ptr noundef nonnull @.str.34)
  %23 = load ptr, ptr %16, align 8, !tbaa !21
  %24 = load ptr, ptr %17, align 8, !tbaa !22
  %25 = getelementptr inbounds i64, ptr %24, i64 %indvars.iv
  %26 = load i64, ptr %25, align 8, !tbaa !23
  %27 = getelementptr inbounds i8, ptr %23, i64 %26
  %28 = getelementptr inbounds i8, ptr %27, i64 1
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %29 = getelementptr inbounds i64, ptr %24, i64 %indvars.iv.next
  %30 = load i64, ptr %29, align 8, !tbaa !23
  %31 = sub nsw i64 %30, %26
  call void @strbuf_add(ptr noundef nonnull %4, ptr noundef nonnull %28, i64 noundef %31) #6
  call void @strbuf_addstr(ptr noundef nonnull %4, ptr noundef nonnull @.str.4)
  %32 = load i64, ptr %14, align 8, !tbaa !18
  %33 = add i64 %32, -1
  %34 = icmp ugt i64 %33, %indvars.iv.next
  br i1 %34, label %22, label %._crit_edge, !llvm.loop !24
}

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { "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 = { 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 #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 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #5 = { 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 #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, !7, i64 24}
!6 = !{!"pack_file_cache", !7, i64 0, !10, i64 8}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"strbuf", !11, i64 0, !11, i64 8, !7, i64 16}
!11 = !{!"long", !8, i64 0}
!12 = !{!13, !11, i64 416}
!13 = !{!"index", !8, i64 0, !14, i64 256, !8, i64 400, !11, i64 408, !11, i64 416, !11, i64 424}
!14 = !{!"stat", !11, i64 0, !11, i64 8, !11, i64 16, !15, i64 24, !15, i64 28, !15, i64 32, !15, i64 36, !11, i64 40, !11, i64 48, !11, i64 56, !11, i64 64, !16, i64 72, !16, i64 88, !16, i64 104, !8, i64 120}
!15 = !{!"int", !8, i64 0}
!16 = !{!"timespec", !11, i64 0, !11, i64 8}
!17 = !{!13, !11, i64 424}
!18 = !{!19, !11, i64 32}
!19 = !{!"deltafile", !10, i64 0, !7, i64 24, !11, i64 32, !8, i64 40}
!20 = !{!7, !7, i64 0}
!21 = !{!10, !7, i64 16}
!22 = !{!19, !7, i64 24}
!23 = !{!11, !11, i64 0}
!24 = distinct !{!24, !25}
!25 = !{!"llvm.loop.mustprogress"}


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