; 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.delta_options = type { i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, ptr, ptr, ptr }
%struct.anon = type { %struct.delta_stat, ptr, i8, i8, i8, %struct.pack_file_cache, ptr }
%struct.delta_stat = type { i64, i64 }
%struct.pack_file_cache = type { ptr, %struct.strbuf }
%struct.strbuf = type { i64, i64, ptr }

@d_opts = external dso_local global %struct.delta_options, align 8
@stdout = external global ptr, align 8
@.str.15 = external hidden unnamed_addr constant [7 x i8], align 1
@.str.16 = external hidden unnamed_addr constant [10 x i8], align 1
@.str.17 = external hidden unnamed_addr constant [11 x i8], align 1
@.str.18 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.19 = external hidden unnamed_addr constant [9 x i8], align 1
@.str.20 = external hidden unnamed_addr constant [10 x i8], align 1
@directory_delta_var = external hidden global %struct.anon, align 8
@.str.52 = external hidden unnamed_addr constant [11 x i8], align 1
@.str.53 = external hidden unnamed_addr constant [8 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 i32 @printf(ptr noundef, ...) #1

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

; Function Attrs: inlinehint nounwind uwtable
declare i32 @putchar(i32 noundef) #3

; Function Attrs: nounwind uwtable
declare dso_local i32 @check_entry(ptr noundef) #4

; Function Attrs: nounwind uwtable
declare dso_local void @prepare_file_delta(i1 noundef zeroext) #4

; Function Attrs: nounwind uwtable
define dso_local void @do_single_file_delta(ptr noundef %0, i1 noundef zeroext %1) #4 {
  %3 = alloca ptr, align 8
  %4 = alloca i8, align 1
  %5 = alloca i64, align 8
  %6 = alloca i64, align 8
  store ptr %0, ptr %3, align 8, !tbaa !5
  %7 = zext i1 %1 to i8
  store i8 %7, ptr %4, align 1, !tbaa !9
  %8 = load i8, ptr %4, align 1, !tbaa !9, !range !11, !noundef !12
  %9 = trunc i8 %8 to i1
  call void @prepare_file_delta(i1 noundef zeroext %9)
  %10 = load ptr, ptr %3, align 8, !tbaa !5
  %11 = call i32 @check_entry(ptr noundef %10)
  %12 = load i8, ptr getelementptr inbounds (%struct.delta_options, ptr @d_opts, i32 0, i32 8), align 8, !tbaa !13, !range !11, !noundef !12
  %13 = trunc i8 %12 to i1
  br i1 %13, label %14, label %57

14:                                               ; preds = %2
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #5
  %15 = load i64, ptr @directory_delta_var, align 8, !tbaa !15
  store i64 %15, ptr %5, align 8, !tbaa !21
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #5
  %16 = load i64, ptr getelementptr inbounds (%struct.delta_stat, ptr @directory_delta_var, i32 0, i32 1), align 8, !tbaa !22
  store i64 %16, ptr %6, align 8, !tbaa !21
  %17 = load i64, ptr %5, align 8, !tbaa !21
  %18 = icmp ne i64 %17, 0
  br i1 %18, label %22, label %19

19:                                               ; preds = %14
  %20 = load i64, ptr %6, align 8, !tbaa !21
  %21 = icmp ne i64 %20, 0
  br i1 %21, label %22, label %25

22:                                               ; preds = %19, %14
  %23 = load ptr, ptr @stdout, align 8, !tbaa !5
  %24 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %23, ptr noundef @.str.52) #5
  br label %25

25:                                               ; preds = %22, %19
  %26 = load i64, ptr %5, align 8, !tbaa !21
  %27 = icmp ne i64 %26, 0
  br i1 %27, label %28, label %36

28:                                               ; preds = %25
  %29 = load ptr, ptr @stdout, align 8, !tbaa !5
  %30 = load i64, ptr %5, align 8, !tbaa !21
  %31 = load i64, ptr %5, align 8, !tbaa !21
  %32 = icmp eq i64 %31, 1
  %33 = zext i1 %32 to i64
  %34 = select i1 %32, ptr @.str.16, ptr @.str.17
  %35 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %29, ptr noundef @.str.53, i64 noundef %30, ptr noundef %34) #5
  br label %36

36:                                               ; preds = %28, %25
  %37 = load i64, ptr %5, align 8, !tbaa !21
  %38 = icmp ne i64 %37, 0
  br i1 %38, label %39, label %44

39:                                               ; preds = %36
  %40 = load i64, ptr %6, align 8, !tbaa !21
  %41 = icmp ne i64 %40, 0
  br i1 %41, label %42, label %44

42:                                               ; preds = %39
  %43 = call i32 (ptr, ...) @printf(ptr noundef @.str.18)
  br label %44

44:                                               ; preds = %42, %39, %36
  %45 = load i64, ptr %6, align 8, !tbaa !21
  %46 = icmp ne i64 %45, 0
  br i1 %46, label %47, label %55

47:                                               ; preds = %44
  %48 = load ptr, ptr @stdout, align 8, !tbaa !5
  %49 = load i64, ptr %6, align 8, !tbaa !21
  %50 = load i64, ptr %6, align 8, !tbaa !21
  %51 = icmp eq i64 %50, 1
  %52 = zext i1 %51 to i64
  %53 = select i1 %51, ptr @.str.19, ptr @.str.20
  %54 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %48, ptr noundef @.str.15, i64 noundef %49, ptr noundef %53) #5
  br label %55

55:                                               ; preds = %47, %44
  %56 = call i32 @putchar(i32 noundef 10)
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #5
  br label %57

57:                                               ; preds = %55, %2
  call void @invalidate_cache(ptr noundef getelementptr inbounds (%struct.anon, ptr @directory_delta_var, i32 0, i32 5))
  ret void
}

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

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 = { 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 #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 = !{!"_Bool", !7, i64 0}
!11 = !{i8 0, i8 2}
!12 = !{}
!13 = !{!14, !10, i64 8}
!14 = !{!"delta_options", !10, i64 0, !10, i64 1, !10, i64 2, !10, i64 3, !10, i64 4, !10, i64 5, !10, i64 6, !10, i64 7, !10, i64 8, !10, i64 9, !6, i64 16, !6, i64 24, !6, i64 32}
!15 = !{!16, !18, i64 0}
!16 = !{!"", !17, i64 0, !6, i64 16, !10, i64 24, !10, i64 25, !10, i64 26, !19, i64 32, !6, i64 64}
!17 = !{!"delta_stat", !18, i64 0, !18, i64 8}
!18 = !{!"long", !7, i64 0}
!19 = !{!"pack_file_cache", !6, i64 0, !20, i64 8}
!20 = !{!"strbuf", !18, i64 0, !18, i64 8, !6, i64 16}
!21 = !{!18, !18, i64 0}
!22 = !{!16, !18, i64 8}


; 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.delta_options = type { i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, ptr, ptr, ptr }
%struct.anon = type { %struct.delta_stat, ptr, i8, i8, i8, %struct.pack_file_cache, ptr }
%struct.delta_stat = type { i64, i64 }
%struct.pack_file_cache = type { ptr, %struct.strbuf }
%struct.strbuf = type { i64, i64, ptr }

@d_opts = external dso_local local_unnamed_addr global %struct.delta_options, align 8
@stdout = external local_unnamed_addr global ptr, align 8
@.str.15 = external hidden unnamed_addr constant [7 x i8], align 1
@.str.16 = external hidden unnamed_addr constant [10 x i8], align 1
@.str.17 = external hidden unnamed_addr constant [11 x i8], align 1
@.str.18 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.19 = external hidden unnamed_addr constant [9 x i8], align 1
@.str.20 = external hidden unnamed_addr constant [10 x i8], align 1
@directory_delta_var = external hidden global %struct.anon, align 8
@.str.52 = external hidden unnamed_addr constant [11 x i8], align 1
@.str.53 = external hidden unnamed_addr constant [8 x i8], align 1

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

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

; Function Attrs: inlinehint nofree nounwind uwtable
declare noundef i32 @putchar(i32 noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
declare dso_local i32 @check_entry(ptr noundef) local_unnamed_addr #2

; Function Attrs: nounwind uwtable
declare dso_local void @prepare_file_delta(i1 noundef zeroext) local_unnamed_addr #2

; Function Attrs: nounwind uwtable
define dso_local void @do_single_file_delta(ptr noundef %0, i1 noundef zeroext %1) local_unnamed_addr #2 {
  tail call void @prepare_file_delta(i1 noundef zeroext %1)
  %3 = tail call i32 @check_entry(ptr noundef %0)
  %4 = load i8, ptr getelementptr inbounds (i8, ptr @d_opts, i64 8), align 8, !tbaa !5, !range !11, !noundef !12
  %5 = trunc nuw i8 %4 to i1
  br i1 %5, label %6, label %26

6:                                                ; preds = %2
  %7 = load i64, ptr @directory_delta_var, align 8, !tbaa !13
  %8 = load i64, ptr getelementptr inbounds (i8, ptr @directory_delta_var, i64 8), align 8, !tbaa !19
  %9 = icmp ne i64 %7, 0
  %10 = icmp ne i64 %8, 0
  %or.cond = select i1 %9, i1 true, i1 %10
  br i1 %or.cond, label %11, label %.critedge15

11:                                               ; preds = %6
  %12 = load ptr, ptr @stdout, align 8, !tbaa !20
  %13 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %12, ptr noundef nonnull @.str.52) #4
  br i1 %9, label %14, label %.critedge

14:                                               ; preds = %11
  %15 = load ptr, ptr @stdout, align 8, !tbaa !20
  %16 = icmp eq i64 %7, 1
  %17 = select i1 %16, ptr @.str.16, ptr @.str.17
  %18 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %15, ptr noundef nonnull @.str.53, i64 noundef %7, ptr noundef nonnull %17) #4
  br i1 %10, label %.critedge.thread, label %.critedge15

.critedge.thread:                                 ; preds = %14
  %19 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.18)
  br label %20

.critedge:                                        ; preds = %11
  br i1 %10, label %20, label %.critedge15

20:                                               ; preds = %.critedge.thread, %.critedge
  %21 = load ptr, ptr @stdout, align 8, !tbaa !20
  %22 = icmp eq i64 %8, 1
  %23 = select i1 %22, ptr @.str.19, ptr @.str.20
  %24 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %21, ptr noundef nonnull @.str.15, i64 noundef %8, ptr noundef nonnull %23) #4
  br label %.critedge15

.critedge15:                                      ; preds = %6, %14, %20, %.critedge
  %25 = tail call i32 @putchar(i32 noundef 10)
  br label %26

26:                                               ; preds = %.critedge15, %2
  tail call void @invalidate_cache(ptr noundef nonnull getelementptr inbounds (i8, ptr @directory_delta_var, i64 32))
  ret void
}

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

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 = { inlinehint 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 = { 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 = { 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 = { 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 = !{!"delta_options", !7, i64 0, !7, i64 1, !7, i64 2, !7, i64 3, !7, i64 4, !7, i64 5, !7, i64 6, !7, i64 7, !7, i64 8, !7, i64 9, !10, i64 16, !10, i64 24, !10, i64 32}
!7 = !{!"_Bool", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"any pointer", !8, i64 0}
!11 = !{i8 0, i8 2}
!12 = !{}
!13 = !{!14, !16, i64 0}
!14 = !{!"", !15, i64 0, !10, i64 16, !7, i64 24, !7, i64 25, !7, i64 26, !17, i64 32, !10, i64 64}
!15 = !{!"delta_stat", !16, i64 0, !16, i64 8}
!16 = !{!"long", !8, i64 0}
!17 = !{!"pack_file_cache", !10, i64 0, !18, i64 8}
!18 = !{!"strbuf", !16, i64 0, !16, i64 8, !10, i64 16}
!19 = !{!14, !16, i64 8}
!20 = !{!10, !10, i64 0}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,SROAPass,SimplifyCFGPass,TailCallElimPass