; 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
@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
@.str.39 = external hidden unnamed_addr constant [16 x i8], align 1
@directory_delta_var = external hidden global %struct.anon, align 8
@.str.51 = external hidden unnamed_addr constant [21 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

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

; Function Attrs: noreturn nounwind
declare void @exit(i32 noundef) #2

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

declare i64 @make_commit_list(ptr noundef) #4

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

; Function Attrs: nounwind uwtable
define dso_local void @prepare_file_delta(i1 noundef zeroext %0) #5 {
  %2 = alloca i8, align 1
  %3 = alloca ptr, align 8
  %4 = alloca i32, align 4
  %5 = zext i1 %0 to i8
  store i8 %5, ptr %2, align 1, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #6
  %6 = load i8, ptr getelementptr inbounds (%struct.anon, ptr @directory_delta_var, i32 0, i32 3), align 1, !tbaa !9, !range !16, !noundef !17
  %7 = trunc i8 %6 to i1
  br i1 %7, label %8, label %9

8:                                                ; preds = %1
  store i32 1, ptr %4, align 4
  br label %37

9:                                                ; preds = %1
  %10 = call i64 @make_commit_list(ptr noundef %3)
  %11 = load ptr, ptr %3, align 8, !tbaa !18
  %12 = icmp ne ptr %11, null
  br i1 %12, label %27, label %13

13:                                               ; preds = %9
  br label %14

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

25:                                               ; No predecessors!
  br label %26

26:                                               ; preds = %25
  br label %27

27:                                               ; preds = %26, %9
  store i64 0, ptr @directory_delta_var, align 8, !tbaa !19
  store i64 0, ptr getelementptr inbounds (%struct.delta_stat, ptr @directory_delta_var, i32 0, i32 1), align 8, !tbaa !20
  %28 = load i8, ptr %2, align 1, !tbaa !5, !range !16, !noundef !17
  %29 = trunc i8 %28 to i1
  %30 = zext i1 %29 to i8
  store i8 %30, ptr getelementptr inbounds (%struct.anon, ptr @directory_delta_var, i32 0, i32 2), align 8, !tbaa !21
  %31 = load ptr, ptr %3, align 8, !tbaa !18
  %32 = call ptr @get_head_commit_list(ptr noundef %31)
  store ptr %32, ptr getelementptr inbounds (%struct.anon, ptr @directory_delta_var, i32 0, i32 1), align 8, !tbaa !22
  store ptr @.str.39, ptr getelementptr inbounds (%struct.anon, ptr @directory_delta_var, i32 0, i32 5), align 8, !tbaa !23
  store ptr null, ptr getelementptr inbounds (%struct.anon, ptr @directory_delta_var, i32 0, i32 6), align 8, !tbaa !24
  %33 = load i8, ptr getelementptr inbounds (%struct.delta_options, ptr @d_opts, i32 0, i32 7), align 1, !tbaa !25, !range !16, !noundef !17
  %34 = trunc i8 %33 to i1
  %35 = zext i1 %34 to i8
  store i8 %35, ptr getelementptr inbounds (%struct.anon, ptr @directory_delta_var, i32 0, i32 4), align 2, !tbaa !27
  call void @strbuf_init(ptr noundef getelementptr inbounds (%struct.pack_file_cache, ptr getelementptr inbounds (%struct.anon, ptr @directory_delta_var, i32 0, i32 5), i32 0, i32 1), i64 noundef 0)
  %36 = call i32 @cache_pack_file(ptr noundef getelementptr inbounds (%struct.anon, ptr @directory_delta_var, i32 0, i32 5))
  store i8 1, ptr getelementptr inbounds (%struct.anon, ptr @directory_delta_var, i32 0, i32 3), align 1, !tbaa !9
  call void @commit_list_del(ptr noundef %3)
  store i32 0, ptr %4, align 4
  br label %37

37:                                               ; preds = %27, %8
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #6
  %38 = load i32, ptr %4, align 4
  switch i32 %38, label %40 [
    i32 0, label %39
    i32 1, label %39
  ]

39:                                               ; preds = %37, %37
  ret void

40:                                               ; preds = %37
  unreachable
}

declare ptr @get_head_commit_list(ptr noundef) #4

declare void @commit_list_del(ptr noundef) #4

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 = { 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 #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 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 = !{!"_Bool", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !6, i64 25}
!10 = !{!"", !11, i64 0, !13, i64 16, !6, i64 24, !6, i64 25, !6, i64 26, !14, i64 32, !13, i64 64}
!11 = !{!"delta_stat", !12, i64 0, !12, i64 8}
!12 = !{!"long", !7, i64 0}
!13 = !{!"any pointer", !7, i64 0}
!14 = !{!"pack_file_cache", !13, i64 0, !15, i64 8}
!15 = !{!"strbuf", !12, i64 0, !12, i64 8, !13, i64 16}
!16 = !{i8 0, i8 2}
!17 = !{}
!18 = !{!13, !13, i64 0}
!19 = !{!10, !12, i64 0}
!20 = !{!10, !12, i64 8}
!21 = !{!10, !6, i64 24}
!22 = !{!10, !13, i64 16}
!23 = !{!10, !13, i64 32}
!24 = !{!10, !13, i64 64}
!25 = !{!26, !6, i64 7}
!26 = !{!"delta_options", !6, i64 0, !6, i64 1, !6, i64 2, !6, i64 3, !6, i64 4, !6, i64 5, !6, i64 6, !6, i64 7, !6, i64 8, !6, i64 9, !13, i64 16, !13, i64 24, !13, i64 32}
!27 = !{!10, !6, i64 26}


; 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
@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
@.str.39 = external hidden unnamed_addr constant [16 x i8], align 1
@directory_delta_var = external hidden global %struct.anon, align 8
@.str.51 = external hidden unnamed_addr constant [21 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

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

; Function Attrs: noreturn nounwind
declare void @exit(i32 noundef) local_unnamed_addr #2

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

declare i64 @make_commit_list(ptr noundef) local_unnamed_addr #4

declare void @strbuf_init(ptr noundef, i64 noundef) local_unnamed_addr #4

; Function Attrs: nounwind uwtable
define dso_local void @prepare_file_delta(i1 noundef zeroext %0) local_unnamed_addr #5 {
  %2 = alloca ptr, align 8
  %3 = zext i1 %0 to i8
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %2) #7
  %4 = load i8, ptr getelementptr inbounds (i8, ptr @directory_delta_var, i64 25), align 1, !tbaa !5, !range !15, !noundef !16
  %5 = trunc nuw i8 %4 to i1
  br i1 %5, label %24, label %6

6:                                                ; preds = %1
  %7 = call i64 @make_commit_list(ptr noundef nonnull %2) #7
  %8 = load ptr, ptr %2, align 8, !tbaa !17
  %.not = icmp eq ptr %8, null
  br i1 %.not, label %9, label %20

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

20:                                               ; preds = %6
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(16) @directory_delta_var, i8 0, i64 16, i1 false)
  store i8 %3, ptr getelementptr inbounds (i8, ptr @directory_delta_var, i64 24), align 8, !tbaa !18
  %21 = call ptr @get_head_commit_list(ptr noundef nonnull %8) #7
  store ptr %21, ptr getelementptr inbounds (i8, ptr @directory_delta_var, i64 16), align 8, !tbaa !19
  store ptr @.str.39, ptr getelementptr inbounds (i8, ptr @directory_delta_var, i64 32), align 8, !tbaa !20
  store ptr null, ptr getelementptr inbounds (i8, ptr @directory_delta_var, i64 64), align 8, !tbaa !21
  %22 = load i8, ptr getelementptr inbounds (i8, ptr @d_opts, i64 7), align 1, !tbaa !22, !range !15, !noundef !16
  store i8 %22, ptr getelementptr inbounds (i8, ptr @directory_delta_var, i64 26), align 2, !tbaa !24
  call void @strbuf_init(ptr noundef nonnull getelementptr inbounds (i8, ptr @directory_delta_var, i64 40), i64 noundef 0) #7
  %23 = call i32 @cache_pack_file(ptr noundef nonnull getelementptr inbounds (i8, ptr @directory_delta_var, i64 32))
  store i8 1, ptr getelementptr inbounds (i8, ptr @directory_delta_var, i64 25), align 1, !tbaa !5
  call void @commit_list_del(ptr noundef nonnull %2) #7
  br label %24

24:                                               ; preds = %1, %20
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %2) #7
  ret void
}

declare ptr @get_head_commit_list(ptr noundef) local_unnamed_addr #4

declare void @commit_list_del(ptr noundef) local_unnamed_addr #4

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #6

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #2 = { 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 #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 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 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #7 = { nounwind }
attributes #8 = { cold nounwind }
attributes #9 = { 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, !12, i64 25}
!6 = !{!"", !7, i64 0, !11, i64 16, !12, i64 24, !12, i64 25, !12, i64 26, !13, i64 32, !11, i64 64}
!7 = !{!"delta_stat", !8, i64 0, !8, i64 8}
!8 = !{!"long", !9, i64 0}
!9 = !{!"omnipotent char", !10, i64 0}
!10 = !{!"Simple C/C++ TBAA"}
!11 = !{!"any pointer", !9, i64 0}
!12 = !{!"_Bool", !9, i64 0}
!13 = !{!"pack_file_cache", !11, i64 0, !14, i64 8}
!14 = !{!"strbuf", !8, i64 0, !8, i64 8, !11, i64 16}
!15 = !{i8 0, i8 2}
!16 = !{}
!17 = !{!11, !11, i64 0}
!18 = !{!6, !12, i64 24}
!19 = !{!6, !11, i64 16}
!20 = !{!6, !11, i64 32}
!21 = !{!6, !11, i64 64}
!22 = !{!23, !12, i64 7}
!23 = !{!"delta_options", !12, i64 0, !12, i64 1, !12, i64 2, !12, i64 3, !12, i64 4, !12, i64 5, !12, i64 6, !12, i64 7, !12, i64 8, !12, i64 9, !11, i64 16, !11, i64 24, !11, i64 32}
!24 = !{!6, !12, i64 26}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,MemCpyOptPass,SROAPass,SimplifyCFGPass