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

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

@stderr = external global ptr, align 8
@__const.revert_files_commit.cache = external hidden unnamed_addr constant %struct.pack_file_cache, align 8
@.str.31 = external hidden unnamed_addr constant [33 x i8], align 1

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

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #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) #2

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

; Function Attrs: nounwind uwtable
declare dso_local void @revert_file(ptr noundef, ptr noundef) #3

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

declare i64 @make_commit_list(ptr noundef) #5

; Function Attrs: nounwind uwtable
declare dso_local ptr @get_nth_commit(ptr noundef, i64 noundef) #3

declare void @make_index_list_from_commit(ptr noundef, ptr noundef) #5

; Function Attrs: nounwind uwtable
define dso_local i32 @revert_files_commit(ptr noundef %0, i64 noundef %1) #3 {
  %3 = alloca ptr, align 8
  %4 = alloca i64, align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  %10 = alloca %struct.pack_file_cache, align 8
  store ptr %0, ptr %3, align 8, !tbaa !5
  store i64 %1, ptr %4, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #6
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #6
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #6
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #6
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #6
  %11 = load ptr, ptr %3, align 8, !tbaa !5
  %12 = getelementptr inbounds %struct.strbuf_list, ptr %11, i32 0, i32 0
  %13 = load ptr, ptr %12, align 8, !tbaa !11
  %14 = getelementptr inbounds %struct.strbuf_list_node, ptr %13, i32 0, i32 3
  %15 = load ptr, ptr %14, align 8, !tbaa !13
  store ptr %15, ptr %9, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 32, ptr %10) #6
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %10, ptr align 8 @__const.revert_files_commit.cache, i64 32, i1 false)
  %16 = call i64 @make_commit_list(ptr noundef %8)
  %17 = load ptr, ptr %8, align 8, !tbaa !5
  %18 = load i64, ptr %4, align 8, !tbaa !9
  %19 = call ptr @get_nth_commit(ptr noundef %17, i64 noundef %18)
  store ptr %19, ptr %7, align 8, !tbaa !5
  %20 = call i32 @cache_pack_file(ptr noundef %10)
  %21 = load ptr, ptr %7, align 8, !tbaa !5
  call void @make_index_list_from_commit(ptr noundef %21, ptr noundef %5)
  br label %22

22:                                               ; preds = %49, %2
  %23 = load ptr, ptr %9, align 8, !tbaa !5
  %24 = icmp ne ptr %23, null
  br i1 %24, label %25, label %53

25:                                               ; preds = %22
  %26 = load ptr, ptr %5, align 8, !tbaa !5
  %27 = load ptr, ptr %9, align 8, !tbaa !5
  %28 = getelementptr inbounds %struct.strbuf_list_node, ptr %27, i32 0, i32 0
  %29 = getelementptr inbounds %struct.strbuf, ptr %28, i32 0, i32 2
  %30 = load ptr, ptr %29, align 8, !tbaa !16
  %31 = call ptr @find_file_index_list(ptr noundef %26, ptr noundef %30)
  store ptr %31, ptr %6, align 8, !tbaa !5
  %32 = load ptr, ptr %6, align 8, !tbaa !5
  %33 = icmp ne ptr %32, null
  br i1 %33, label %41, label %34

34:                                               ; preds = %25
  %35 = load ptr, ptr @stderr, align 8, !tbaa !5
  %36 = load ptr, ptr %9, align 8, !tbaa !5
  %37 = getelementptr inbounds %struct.strbuf_list_node, ptr %36, i32 0, i32 0
  %38 = getelementptr inbounds %struct.strbuf, ptr %37, i32 0, i32 2
  %39 = load ptr, ptr %38, align 8, !tbaa !16
  %40 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %35, ptr noundef @.str.31, ptr noundef %39) #6
  br label %49

41:                                               ; preds = %25
  %42 = load ptr, ptr %6, align 8, !tbaa !5
  call void @revert_file(ptr noundef %10, ptr noundef %42)
  %43 = load ptr, ptr %6, align 8, !tbaa !5
  %44 = getelementptr inbounds %struct.index, ptr %43, i32 0, i32 2
  %45 = load i8, ptr %44, align 8, !tbaa !17
  %46 = zext i8 %45 to i32
  %47 = or i32 %46, 48
  %48 = trunc i32 %47 to i8
  store i8 %48, ptr %44, align 8, !tbaa !17
  br label %49

49:                                               ; preds = %41, %34
  %50 = load ptr, ptr %9, align 8, !tbaa !5
  %51 = getelementptr inbounds %struct.strbuf_list_node, ptr %50, i32 0, i32 3
  %52 = load ptr, ptr %51, align 8, !tbaa !13
  store ptr %52, ptr %9, align 8, !tbaa !5
  br label %22, !llvm.loop !22

53:                                               ; preds = %22
  call void @llvm.lifetime.end.p0(i64 32, ptr %10) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #6
  ret i32 0
}

declare ptr @find_file_index_list(ptr noundef, ptr noundef) #5

attributes #0 = { 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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
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 }

!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, !6, i64 0}
!12 = !{!"strbuf_list", !6, i64 0, !6, i64 8, !10, i64 16}
!13 = !{!14, !6, i64 40}
!14 = !{!"strbuf_list_node", !15, i64 0, !7, i64 24, !10, i64 32, !6, i64 40}
!15 = !{!"strbuf", !10, i64 0, !10, i64 8, !6, i64 16}
!16 = !{!14, !6, i64 16}
!17 = !{!18, !7, i64 400}
!18 = !{!"index", !7, i64 0, !19, i64 256, !7, i64 400, !10, i64 408, !10, i64 416, !10, i64 424}
!19 = !{!"stat", !10, i64 0, !10, i64 8, !10, i64 16, !20, i64 24, !20, i64 28, !20, i64 32, !20, i64 36, !10, i64 40, !10, i64 48, !10, i64 56, !10, i64 64, !21, i64 72, !21, i64 88, !21, i64 104, !7, i64 120}
!20 = !{!"int", !7, i64 0}
!21 = !{!"timespec", !10, i64 0, !10, i64 8}
!22 = distinct !{!22, !23}
!23 = !{!"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.pack_file_cache = type { ptr, %struct.strbuf }
%struct.strbuf = type { i64, i64, ptr }

@stderr = external local_unnamed_addr global ptr, align 8
@__const.revert_files_commit.cache = external hidden unnamed_addr constant %struct.pack_file_cache, align 8
@.str.31 = external hidden unnamed_addr constant [33 x i8], align 1

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

; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #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) #2

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

; Function Attrs: nounwind uwtable
declare dso_local void @revert_file(ptr noundef, ptr noundef) local_unnamed_addr #3

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

declare i64 @make_commit_list(ptr noundef) local_unnamed_addr #5

; Function Attrs: nounwind uwtable
declare dso_local ptr @get_nth_commit(ptr noundef, i64 noundef) local_unnamed_addr #3

declare void @make_index_list_from_commit(ptr noundef, ptr noundef) local_unnamed_addr #5

; Function Attrs: nounwind uwtable
define dso_local noundef i32 @revert_files_commit(ptr nocapture noundef readonly %0, i64 noundef %1) local_unnamed_addr #3 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca %struct.pack_file_cache, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %3) #6
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %4) #6
  %6 = load ptr, ptr %0, align 8, !tbaa !5
  %7 = getelementptr inbounds i8, ptr %6, i64 40
  %8 = load ptr, ptr %7, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 32, ptr nonnull %5) #6
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 8 dereferenceable(32) %5, ptr noundef nonnull align 8 dereferenceable(32) @__const.revert_files_commit.cache, i64 32, i1 false)
  %9 = call i64 @make_commit_list(ptr noundef nonnull %4) #6
  %10 = load ptr, ptr %4, align 8, !tbaa !14
  %11 = call ptr @get_nth_commit(ptr noundef %10, i64 noundef %1)
  %12 = call i32 @cache_pack_file(ptr noundef nonnull %5)
  call void @make_index_list_from_commit(ptr noundef %11, ptr noundef nonnull %3) #6
  %.not11 = icmp eq ptr %8, null
  br i1 %.not11, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %2, %25
  %.012 = phi ptr [ %27, %25 ], [ %8, %2 ]
  %13 = load ptr, ptr %3, align 8, !tbaa !14
  %14 = getelementptr inbounds i8, ptr %.012, i64 16
  %15 = load ptr, ptr %14, align 8, !tbaa !15
  %16 = call ptr @find_file_index_list(ptr noundef %13, ptr noundef %15) #6
  %.not10 = icmp eq ptr %16, null
  br i1 %.not10, label %17, label %21

17:                                               ; preds = %.lr.ph
  %18 = load ptr, ptr @stderr, align 8, !tbaa !14
  %19 = load ptr, ptr %14, align 8, !tbaa !15
  %20 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %18, ptr noundef nonnull @.str.31, ptr noundef %19) #7
  br label %25

21:                                               ; preds = %.lr.ph
  call void @revert_file(ptr noundef nonnull %5, ptr noundef nonnull %16)
  %22 = getelementptr inbounds i8, ptr %16, i64 400
  %23 = load i8, ptr %22, align 8, !tbaa !16
  %24 = or i8 %23, 48
  store i8 %24, ptr %22, align 8, !tbaa !16
  br label %25

25:                                               ; preds = %21, %17
  %26 = getelementptr inbounds i8, ptr %.012, i64 40
  %27 = load ptr, ptr %26, align 8, !tbaa !11
  %.not = icmp eq ptr %27, null
  br i1 %.not, label %._crit_edge, label %.lr.ph, !llvm.loop !21

._crit_edge:                                      ; preds = %25, %2
  call void @llvm.lifetime.end.p0(i64 32, ptr nonnull %5) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %4) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %3) #6
  ret i32 0
}

declare ptr @find_file_index_list(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 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite) }
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 }

!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 0}
!6 = !{!"strbuf_list", !7, i64 0, !7, i64 8, !10, i64 16}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"long", !8, i64 0}
!11 = !{!12, !7, i64 40}
!12 = !{!"strbuf_list_node", !13, i64 0, !8, i64 24, !10, i64 32, !7, i64 40}
!13 = !{!"strbuf", !10, i64 0, !10, i64 8, !7, i64 16}
!14 = !{!7, !7, i64 0}
!15 = !{!12, !7, i64 16}
!16 = !{!17, !8, i64 400}
!17 = !{!"index", !8, i64 0, !18, i64 256, !8, i64 400, !10, i64 408, !10, i64 416, !10, i64 424}
!18 = !{!"stat", !10, i64 0, !10, i64 8, !10, i64 16, !19, i64 24, !19, i64 28, !19, i64 32, !19, i64 36, !10, i64 40, !10, i64 48, !10, i64 56, !10, i64 64, !20, i64 72, !20, i64 88, !20, i64 104, !8, i64 120}
!19 = !{!"int", !8, i64 0}
!20 = !{!"timespec", !10, i64 0, !10, i64 8}
!21 = distinct !{!21, !22}
!22 = !{!"llvm.loop.mustprogress"}


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