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

@stderr = external global ptr, align 8
@.str.2 = external hidden unnamed_addr constant [6 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [6 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [7 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [3 x i8], align 1
@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.54 = external hidden unnamed_addr constant [42 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: noreturn nounwind
declare void @exit(i32 noundef) #3

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

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

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

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

; Function Attrs: nounwind uwtable
define dso_local void @do_directory_delta(ptr noundef %0, i1 noundef zeroext %1, ptr noundef %2) #5 {
  %4 = alloca ptr, align 8
  %5 = alloca i8, align 1
  %6 = alloca ptr, align 8
  %7 = alloca i64, align 8
  %8 = alloca i64, align 8
  store ptr %0, ptr %4, align 8, !tbaa !5
  %9 = zext i1 %1 to i8
  store i8 %9, ptr %5, align 1, !tbaa !9
  store ptr %2, ptr %6, align 8, !tbaa !5
  %10 = load i8, ptr %5, align 1, !tbaa !9, !range !11, !noundef !12
  %11 = trunc i8 %10 to i1
  call void @prepare_file_delta(i1 noundef zeroext %11)
  %12 = load ptr, ptr %4, align 8, !tbaa !5
  %13 = call i32 @for_each_file_in_directory_recurse(ptr noundef %12, ptr noundef @check_entry)
  %14 = icmp eq i32 %13, -1
  br i1 %14, label %15, label %29

15:                                               ; preds = %3
  br label %16

16:                                               ; preds = %15
  %17 = load ptr, ptr @stderr, align 8, !tbaa !5
  %18 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %17, ptr noundef @.str.2) #6
  %19 = load ptr, ptr @stderr, align 8, !tbaa !5
  %20 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %19, ptr noundef @.str.3) #6
  %21 = load ptr, ptr @stderr, align 8, !tbaa !5
  %22 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %21, ptr noundef @.str.4) #6
  %23 = load ptr, ptr @stderr, align 8, !tbaa !5
  %24 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %23, ptr noundef @.str.5) #6
  %25 = load ptr, ptr @stderr, align 8, !tbaa !5
  %26 = load ptr, ptr %4, align 8, !tbaa !5
  %27 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %25, ptr noundef @.str.54, ptr noundef %26) #6
  call void @exit(i32 noundef 1) #7
  unreachable

28:                                               ; No predecessors!
  br label %29

29:                                               ; preds = %28, %3
  %30 = load ptr, ptr %6, align 8, !tbaa !5
  %31 = getelementptr inbounds %struct.delta_options, ptr %30, i32 0, i32 8
  %32 = load i8, ptr %31, align 8, !tbaa !13, !range !11, !noundef !12
  %33 = trunc i8 %32 to i1
  br i1 %33, label %34, label %77

34:                                               ; preds = %29
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #6
  %35 = load i64, ptr @directory_delta_var, align 8, !tbaa !15
  store i64 %35, ptr %7, align 8, !tbaa !21
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #6
  %36 = load i64, ptr getelementptr inbounds (%struct.delta_stat, ptr @directory_delta_var, i32 0, i32 1), align 8, !tbaa !22
  store i64 %36, ptr %8, align 8, !tbaa !21
  %37 = load i64, ptr %7, align 8, !tbaa !21
  %38 = icmp ne i64 %37, 0
  br i1 %38, label %42, label %39

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

42:                                               ; preds = %39, %34
  %43 = load ptr, ptr @stdout, align 8, !tbaa !5
  %44 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %43, ptr noundef @.str.52) #6
  br label %45

45:                                               ; preds = %42, %39
  %46 = load i64, ptr %7, align 8, !tbaa !21
  %47 = icmp ne i64 %46, 0
  br i1 %47, label %48, label %56

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

56:                                               ; preds = %48, %45
  %57 = load i64, ptr %7, align 8, !tbaa !21
  %58 = icmp ne i64 %57, 0
  br i1 %58, label %59, label %64

59:                                               ; preds = %56
  %60 = load i64, ptr %8, align 8, !tbaa !21
  %61 = icmp ne i64 %60, 0
  br i1 %61, label %62, label %64

62:                                               ; preds = %59
  %63 = call i32 (ptr, ...) @printf(ptr noundef @.str.18)
  br label %64

64:                                               ; preds = %62, %59, %56
  %65 = load i64, ptr %8, align 8, !tbaa !21
  %66 = icmp ne i64 %65, 0
  br i1 %66, label %67, label %75

67:                                               ; preds = %64
  %68 = load ptr, ptr @stdout, align 8, !tbaa !5
  %69 = load i64, ptr %8, align 8, !tbaa !21
  %70 = load i64, ptr %8, align 8, !tbaa !21
  %71 = icmp eq i64 %70, 1
  %72 = zext i1 %71 to i64
  %73 = select i1 %71, ptr @.str.19, ptr @.str.20
  %74 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %68, ptr noundef @.str.15, i64 noundef %69, ptr noundef %73) #6
  br label %75

75:                                               ; preds = %67, %64
  %76 = call i32 @putchar(i32 noundef 10)
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #6
  br label %77

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

declare i32 @for_each_file_in_directory_recurse(ptr noundef, ptr noundef) #1

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 = { noreturn 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 #4 = { 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 #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 }
attributes #7 = { noreturn 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.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 }

@stderr = external local_unnamed_addr global ptr, align 8
@.str.2 = external hidden unnamed_addr constant [6 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [6 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [7 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [3 x i8], align 1
@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.54 = external hidden unnamed_addr constant [42 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: noreturn nounwind
declare void @exit(i32 noundef) local_unnamed_addr #1

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

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

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

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

; Function Attrs: nounwind uwtable
define dso_local void @do_directory_delta(ptr noundef %0, i1 noundef zeroext %1, ptr nocapture noundef readonly %2) local_unnamed_addr #3 {
  tail call void @prepare_file_delta(i1 noundef zeroext %1)
  %4 = tail call i32 @for_each_file_in_directory_recurse(ptr noundef %0, ptr noundef nonnull @check_entry) #6
  %5 = icmp eq i32 %4, -1
  br i1 %5, label %6, label %17

6:                                                ; preds = %3
  %7 = load ptr, ptr @stderr, align 8, !tbaa !5
  %8 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %7, ptr noundef nonnull @.str.2) #7
  %9 = load ptr, ptr @stderr, align 8, !tbaa !5
  %10 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %9, ptr noundef nonnull @.str.3) #7
  %11 = load ptr, ptr @stderr, align 8, !tbaa !5
  %12 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %11, ptr noundef nonnull @.str.4) #7
  %13 = load ptr, ptr @stderr, align 8, !tbaa !5
  %14 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %13, ptr noundef nonnull @.str.5) #7
  %15 = load ptr, ptr @stderr, align 8, !tbaa !5
  %16 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %15, ptr noundef nonnull @.str.54, ptr noundef %0) #7
  tail call void @exit(i32 noundef 1) #8
  unreachable

17:                                               ; preds = %3
  %18 = getelementptr inbounds i8, ptr %2, i64 8
  %19 = load i8, ptr %18, align 8, !tbaa !9, !range !12, !noundef !13
  %20 = trunc nuw i8 %19 to i1
  br i1 %20, label %21, label %41

21:                                               ; preds = %17
  %22 = load i64, ptr @directory_delta_var, align 8, !tbaa !14
  %23 = load i64, ptr getelementptr inbounds (i8, ptr @directory_delta_var, i64 8), align 8, !tbaa !20
  %24 = icmp ne i64 %22, 0
  %25 = icmp ne i64 %23, 0
  %or.cond = select i1 %24, i1 true, i1 %25
  br i1 %or.cond, label %26, label %.critedge17

26:                                               ; preds = %21
  %27 = load ptr, ptr @stdout, align 8, !tbaa !5
  %28 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %27, ptr noundef nonnull @.str.52) #6
  br i1 %24, label %29, label %.critedge

29:                                               ; preds = %26
  %30 = load ptr, ptr @stdout, align 8, !tbaa !5
  %31 = icmp eq i64 %22, 1
  %32 = select i1 %31, ptr @.str.16, ptr @.str.17
  %33 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %30, ptr noundef nonnull @.str.15, i64 noundef %22, ptr noundef nonnull %32) #6
  br i1 %25, label %.critedge.thread, label %.critedge17

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

.critedge:                                        ; preds = %26
  br i1 %25, label %35, label %.critedge17

35:                                               ; preds = %.critedge.thread, %.critedge
  %36 = load ptr, ptr @stdout, align 8, !tbaa !5
  %37 = icmp eq i64 %23, 1
  %38 = select i1 %37, ptr @.str.19, ptr @.str.20
  %39 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %36, ptr noundef nonnull @.str.15, i64 noundef %23, ptr noundef nonnull %38) #6
  br label %.critedge17

.critedge17:                                      ; preds = %21, %29, %35, %.critedge
  %40 = tail call i32 @putchar(i32 noundef 10)
  br label %41

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

declare i32 @for_each_file_in_directory_recurse(ptr noundef, ptr noundef) local_unnamed_addr #5

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


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