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

@.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
@__const.print_deletion_lines.out = external hidden unnamed_addr constant %struct.strbuf, align 8
@.str.38 = 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

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

declare i64 @count_lines(ptr noundef) #1

; Function Attrs: nounwind uwtable
define dso_local void @print_deletion_lines(ptr noundef %0) #5 {
  %2 = alloca ptr, align 8
  %3 = alloca i64, align 8
  %4 = alloca %struct.deltafile, align 8
  %5 = alloca %struct.strbuf, align 8
  %6 = alloca i32, align 4
  store ptr %0, ptr %2, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #6
  %7 = load ptr, ptr %2, align 8, !tbaa !5
  %8 = call i64 @count_lines(ptr noundef %7)
  store i64 %8, ptr %3, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 48, ptr %4) #6
  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_deletion_lines.out, i64 24, i1 false)
  %9 = load ptr, ptr %2, align 8, !tbaa !5
  %10 = call i32 @deltafile_init_strbuf(ptr noundef %4, ptr noundef %9, i8 noundef signext 10)
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #6
  store i32 0, ptr %6, align 4, !tbaa !11
  br label %11

11:                                               ; preds = %45, %1
  %12 = load i32, ptr %6, align 4, !tbaa !11
  %13 = sext i32 %12 to i64
  %14 = getelementptr inbounds %struct.deltafile, ptr %4, i32 0, i32 2
  %15 = load i64, ptr %14, align 8, !tbaa !13
  %16 = sub i64 %15, 1
  %17 = icmp ult i64 %13, %16
  br i1 %17, label %19, label %18

18:                                               ; preds = %11
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #6
  br label %48

19:                                               ; preds = %11
  call void @strbuf_addstr(ptr noundef %5, ptr noundef @.str.38)
  %20 = load ptr, ptr %2, align 8, !tbaa !5
  %21 = getelementptr inbounds %struct.strbuf, ptr %20, i32 0, i32 2
  %22 = load ptr, ptr %21, align 8, !tbaa !16
  %23 = getelementptr inbounds %struct.deltafile, ptr %4, i32 0, i32 1
  %24 = load ptr, ptr %23, align 8, !tbaa !17
  %25 = load i32, ptr %6, align 4, !tbaa !11
  %26 = sext i32 %25 to i64
  %27 = getelementptr inbounds i64, ptr %24, i64 %26
  %28 = load i64, ptr %27, align 8, !tbaa !9
  %29 = getelementptr inbounds i8, ptr %22, i64 %28
  %30 = getelementptr inbounds i8, ptr %29, i64 1
  %31 = getelementptr inbounds %struct.deltafile, ptr %4, i32 0, i32 1
  %32 = load ptr, ptr %31, align 8, !tbaa !17
  %33 = load i32, ptr %6, align 4, !tbaa !11
  %34 = add nsw i32 %33, 1
  %35 = sext i32 %34 to i64
  %36 = getelementptr inbounds i64, ptr %32, i64 %35
  %37 = load i64, ptr %36, align 8, !tbaa !9
  %38 = getelementptr inbounds %struct.deltafile, ptr %4, i32 0, i32 1
  %39 = load ptr, ptr %38, align 8, !tbaa !17
  %40 = load i32, ptr %6, align 4, !tbaa !11
  %41 = sext i32 %40 to i64
  %42 = getelementptr inbounds i64, ptr %39, i64 %41
  %43 = load i64, ptr %42, align 8, !tbaa !9
  %44 = sub nsw i64 %37, %43
  call void @strbuf_add(ptr noundef %5, ptr noundef %30, i64 noundef %44)
  call void @strbuf_addstr(ptr noundef %5, ptr noundef @.str.4)
  br label %45

45:                                               ; preds = %19
  %46 = load i32, ptr %6, align 4, !tbaa !11
  %47 = add nsw i32 %46, 1
  store i32 %47, ptr %6, align 4, !tbaa !11
  br label %11, !llvm.loop !18

48:                                               ; preds = %18
  %49 = load ptr, ptr @stdout, align 8, !tbaa !5
  %50 = getelementptr inbounds %struct.strbuf, ptr %5, i32 0, i32 2
  %51 = load ptr, ptr %50, align 8, !tbaa !16
  %52 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %49, ptr noundef @.str.28, ptr noundef %51) #6
  call void @strbuf_release(ptr noundef %5)
  call void @deltafile_free(ptr noundef %4)
  call void @llvm.lifetime.end.p0(i64 24, ptr %5) #6
  call void @llvm.lifetime.end.p0(i64 48, ptr %4) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #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, !10, i64 0}
!10 = !{!"long", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = !{!14, !10, i64 32}
!14 = !{!"deltafile", !15, i64 0, !6, i64 24, !10, i64 32, !7, i64 40}
!15 = !{!"strbuf", !10, i64 0, !10, i64 8, !6, i64 16}
!16 = !{!15, !6, i64 16}
!17 = !{!14, !6, i64 24}
!18 = distinct !{!18, !19}
!19 = !{!"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
@__const.print_deletion_lines.out = external hidden unnamed_addr constant %struct.strbuf, align 8
@.str.38 = external hidden unnamed_addr constant [7 x i8], align 1

; 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

declare i64 @count_lines(ptr noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
define dso_local void @print_deletion_lines(ptr noundef %0) local_unnamed_addr #5 {
  %2 = alloca %struct.deltafile, align 8
  %3 = alloca %struct.strbuf, align 8
  %4 = tail call i64 @count_lines(ptr noundef %0) #6
  call void @llvm.lifetime.start.p0(i64 48, ptr nonnull %2) #6
  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_deletion_lines.out, i64 24, i1 false)
  %5 = call i32 @deltafile_init_strbuf(ptr noundef nonnull %2, ptr noundef %0, i8 noundef signext 10) #6
  %6 = getelementptr inbounds i8, ptr %2, i64 32
  %7 = load i64, ptr %6, align 8, !tbaa !5
  %.not = icmp eq i64 %7, 1
  br i1 %.not, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %1
  %8 = getelementptr inbounds i8, ptr %0, i64 16
  %9 = getelementptr inbounds i8, ptr %2, i64 24
  br label %14

._crit_edge:                                      ; preds = %14, %1
  %10 = load ptr, ptr @stdout, align 8, !tbaa !12
  %11 = getelementptr inbounds i8, ptr %3, i64 16
  %12 = load ptr, ptr %11, align 8, !tbaa !13
  %13 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %10, ptr noundef nonnull @.str.28, ptr noundef %12) #6
  call void @strbuf_release(ptr noundef nonnull %3) #6
  call void @deltafile_free(ptr noundef nonnull %2) #6
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %3) #6
  call void @llvm.lifetime.end.p0(i64 48, ptr nonnull %2) #6
  ret void

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

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, !8, i64 32}
!6 = !{!"deltafile", !7, i64 0, !11, i64 24, !8, i64 32, !9, i64 40}
!7 = !{!"strbuf", !8, i64 0, !8, i64 8, !11, i64 16}
!8 = !{!"long", !9, i64 0}
!9 = !{!"omnipotent char", !10, i64 0}
!10 = !{!"Simple C/C++ TBAA"}
!11 = !{!"any pointer", !9, i64 0}
!12 = !{!11, !11, i64 0}
!13 = !{!7, !11, i64 16}
!14 = !{!6, !11, i64 24}
!15 = !{!8, !8, i64 0}
!16 = distinct !{!16, !17}
!17 = !{!"llvm.loop.mustprogress"}


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