; 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.revert_opts = type { i32, i32, %struct.strbuf_list, i32, i32, i8, i32, i32, i32 }
%struct.strbuf_list = type { ptr, ptr, i64 }
%struct.strbuf = type { i64, i64, ptr }
%struct.visitor = type { %struct.strbuf, ptr, ptr, i32, i32 }
%struct.dirent = type { i64, i64, i16, i8, [256 x i8] }

@.str.8 = external hidden unnamed_addr constant [5 x i8], align 1
@count_modified = external global i32, align 4
@count_new = external global i32, align 4
@rev_opts = external dso_local global %struct.revert_opts, align 8
@.str.27 = external hidden unnamed_addr constant [34 x i8], align 1
@__const.revert_directory.p = external hidden unnamed_addr constant %struct.strbuf, align 8
@.str.32 = external hidden unnamed_addr constant [33 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 nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #1

; Function Attrs: nounwind willreturn memory(read)
declare i32 @strcmp(ptr noundef, ptr noundef) #2

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

; 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, ...) #4

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

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

; Function Attrs: nounwind uwtable
define dso_local void @revert_directory(ptr noundef %0, ptr noundef %1, ptr noundef %2, i64 noundef %3) #5 {
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca i64, align 8
  %9 = alloca %struct.visitor, align 8
  %10 = alloca %struct.strbuf, align 8
  %11 = alloca ptr, align 8
  store ptr %0, ptr %5, align 8, !tbaa !5
  store ptr %1, ptr %6, align 8, !tbaa !5
  store ptr %2, ptr %7, align 8, !tbaa !5
  store i64 %3, ptr %8, align 8, !tbaa !9
  %12 = load i32, ptr @count_new, align 4, !tbaa !11
  %13 = icmp ne i32 %12, 0
  br i1 %13, label %14, label %22

14:                                               ; preds = %4
  %15 = load i32, ptr @count_modified, align 4, !tbaa !11
  %16 = icmp ne i32 %15, 0
  br i1 %16, label %17, label %22

17:                                               ; preds = %14
  %18 = load i32, ptr getelementptr inbounds (%struct.revert_opts, ptr @rev_opts, i32 0, i32 3), align 8, !tbaa !13
  %19 = icmp ne i32 %18, 0
  br i1 %19, label %22, label %20

20:                                               ; preds = %17
  %21 = call i32 (ptr, ...) @printf(ptr noundef @.str.27)
  br label %68

22:                                               ; preds = %17, %14, %4
  call void @llvm.lifetime.start.p0(i64 48, ptr %9) #6
  call void @llvm.lifetime.start.p0(i64 24, ptr %10) #6
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %10, ptr align 8 @__const.revert_directory.p, i64 24, i1 false)
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #6
  call void @visitor_init(ptr noundef %9)
  %23 = load ptr, ptr %7, align 8, !tbaa !5
  %24 = call i32 @visitor_visit(ptr noundef %9, ptr noundef %23)
  br label %25

25:                                               ; preds = %66, %35, %22
  %26 = call i32 @visitor_visit_next_entry(ptr noundef %9)
  %27 = icmp eq i32 %26, 0
  br i1 %27, label %28, label %67

28:                                               ; preds = %25
  call void @visitor_get_absolute_path(ptr noundef %9, ptr noundef %10)
  %29 = getelementptr inbounds %struct.visitor, ptr %9, i32 0, i32 1
  %30 = load ptr, ptr %29, align 8, !tbaa !16
  %31 = getelementptr inbounds %struct.dirent, ptr %30, i32 0, i32 4
  %32 = getelementptr inbounds [256 x i8], ptr %31, i64 0, i64 0
  %33 = call i32 @strcmp(ptr noundef %32, ptr noundef @.str.8) #7
  %34 = icmp ne i32 %33, 0
  br i1 %34, label %36, label %35

35:                                               ; preds = %28
  call void @strbuf_setlen(ptr noundef %10, i64 noundef 0)
  br label %25, !llvm.loop !19

36:                                               ; preds = %28
  %37 = getelementptr inbounds %struct.visitor, ptr %9, i32 0, i32 3
  %38 = load i32, ptr %37, align 8, !tbaa !21
  %39 = icmp eq i32 %38, 0
  br i1 %39, label %40, label %55

40:                                               ; preds = %36
  %41 = load ptr, ptr %6, align 8, !tbaa !5
  %42 = getelementptr inbounds %struct.strbuf, ptr %10, i32 0, i32 2
  %43 = load ptr, ptr %42, align 8, !tbaa !22
  %44 = call ptr @find_file_index_list(ptr noundef %41, ptr noundef %43)
  store ptr %44, ptr %11, align 8, !tbaa !5
  %45 = load ptr, ptr %11, align 8, !tbaa !5
  %46 = icmp ne ptr %45, null
  br i1 %46, label %51, label %47

47:                                               ; preds = %40
  %48 = getelementptr inbounds %struct.strbuf, ptr %10, i32 0, i32 2
  %49 = load ptr, ptr %48, align 8, !tbaa !22
  %50 = call i32 (ptr, ...) @printf(ptr noundef @.str.32, ptr noundef %49)
  br label %54

51:                                               ; preds = %40
  %52 = load ptr, ptr %5, align 8, !tbaa !5
  %53 = load ptr, ptr %11, align 8, !tbaa !5
  call void @revert_file(ptr noundef %52, ptr noundef %53)
  br label %54

54:                                               ; preds = %51, %47
  br label %66

55:                                               ; preds = %36
  %56 = getelementptr inbounds %struct.visitor, ptr %9, i32 0, i32 3
  %57 = load i32, ptr %56, align 8, !tbaa !21
  %58 = icmp eq i32 %57, 1
  br i1 %58, label %59, label %65

59:                                               ; preds = %55
  %60 = load ptr, ptr %5, align 8, !tbaa !5
  %61 = load ptr, ptr %6, align 8, !tbaa !5
  %62 = getelementptr inbounds %struct.strbuf, ptr %10, i32 0, i32 2
  %63 = load ptr, ptr %62, align 8, !tbaa !22
  %64 = load i64, ptr %8, align 8, !tbaa !9
  call void @revert_directory(ptr noundef %60, ptr noundef %61, ptr noundef %63, i64 noundef %64)
  br label %65

65:                                               ; preds = %59, %55
  br label %66

66:                                               ; preds = %65, %54
  call void @strbuf_setlen(ptr noundef %10, i64 noundef 0)
  br label %25, !llvm.loop !19

67:                                               ; preds = %25
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #6
  call void @llvm.lifetime.end.p0(i64 24, ptr %10) #6
  call void @llvm.lifetime.end.p0(i64 48, ptr %9) #6
  br label %68

68:                                               ; preds = %67, %20
  ret void
}

declare void @visitor_init(ptr noundef) #4

declare i32 @visitor_visit(ptr noundef, ptr noundef) #4

declare i32 @visitor_visit_next_entry(ptr noundef) #4

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

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

!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, !12, i64 32}
!14 = !{!"revert_opts", !12, i64 0, !12, i64 4, !15, i64 8, !12, i64 32, !12, i64 36, !7, i64 40, !12, i64 44, !12, i64 48, !12, i64 52}
!15 = !{!"strbuf_list", !6, i64 0, !6, i64 8, !10, i64 16}
!16 = !{!17, !6, i64 24}
!17 = !{!"visitor", !18, i64 0, !6, i64 24, !6, i64 32, !12, i64 40, !12, i64 44}
!18 = !{!"strbuf", !10, i64 0, !10, i64 8, !6, i64 16}
!19 = distinct !{!19, !20}
!20 = !{!"llvm.loop.mustprogress"}
!21 = !{!17, !12, i64 40}
!22 = !{!18, !6, i64 16}


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

@.str.8 = external hidden unnamed_addr constant [5 x i8], align 1
@count_modified = external local_unnamed_addr global i32, align 4
@count_new = external local_unnamed_addr global i32, align 4
@rev_opts = external dso_local local_unnamed_addr global %struct.revert_opts, align 8
@.str.27 = external hidden unnamed_addr constant [34 x i8], align 1
@__const.revert_directory.p = external hidden unnamed_addr constant %struct.strbuf, align 8
@.str.32 = external hidden unnamed_addr constant [33 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 nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #1

; Function Attrs: mustprogress nofree nounwind willreturn memory(argmem: read)
declare i32 @strcmp(ptr nocapture noundef, ptr nocapture noundef) local_unnamed_addr #2

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

; 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 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #4

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

declare ptr @find_file_index_list(ptr noundef, ptr noundef) local_unnamed_addr #6

; Function Attrs: nounwind uwtable
define dso_local void @revert_directory(ptr noundef %0, ptr noundef %1, ptr noundef %2, i64 noundef %3) local_unnamed_addr #5 {
  %5 = alloca %struct.visitor, align 8
  %6 = alloca %struct.strbuf, align 8
  %7 = load i32, ptr @count_new, align 4, !tbaa !5
  %8 = icmp eq i32 %7, 0
  %9 = load i32, ptr @count_modified, align 4
  %10 = icmp eq i32 %9, 0
  %or.cond.not12 = select i1 %8, i1 true, i1 %10
  %11 = load i32, ptr getelementptr inbounds (i8, ptr @rev_opts, i64 32), align 8
  %12 = icmp ne i32 %11, 0
  %or.cond3 = select i1 %or.cond.not12, i1 true, i1 %12
  br i1 %or.cond3, label %15, label %13

13:                                               ; preds = %4
  %14 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.27)
  br label %39

15:                                               ; preds = %4
  call void @llvm.lifetime.start.p0(i64 48, ptr nonnull %5) #7
  call void @llvm.lifetime.start.p0(i64 24, ptr nonnull %6) #7
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 8 dereferenceable(24) %6, ptr noundef nonnull align 8 dereferenceable(24) @__const.revert_directory.p, i64 24, i1 false)
  call void @visitor_init(ptr noundef nonnull %5) #7
  %16 = call i32 @visitor_visit(ptr noundef nonnull %5, ptr noundef %2) #7
  %17 = call i32 @visitor_visit_next_entry(ptr noundef nonnull %5) #7
  %18 = icmp eq i32 %17, 0
  br i1 %18, label %.lr.ph, label %._crit_edge

.lr.ph:                                           ; preds = %15
  %19 = getelementptr inbounds i8, ptr %5, i64 24
  %20 = getelementptr inbounds i8, ptr %5, i64 40
  %21 = getelementptr inbounds i8, ptr %6, i64 16
  br label %22

22:                                               ; preds = %.lr.ph, %.backedge
  call void @visitor_get_absolute_path(ptr noundef nonnull %5, ptr noundef nonnull %6)
  %23 = load ptr, ptr %19, align 8, !tbaa !9
  %24 = getelementptr inbounds i8, ptr %23, i64 19
  %25 = call i32 @strcmp(ptr noundef nonnull dereferenceable(1) %24, ptr noundef nonnull dereferenceable(1) @.str.8) #8
  %.not = icmp eq i32 %25, 0
  br i1 %.not, label %.backedge, label %28

.backedge:                                        ; preds = %22, %36, %33, %37, %28
  call void @strbuf_setlen(ptr noundef nonnull %6, i64 noundef 0)
  %26 = call i32 @visitor_visit_next_entry(ptr noundef nonnull %5) #7
  %27 = icmp eq i32 %26, 0
  br i1 %27, label %22, label %._crit_edge, !llvm.loop !14

28:                                               ; preds = %22
  %29 = load i32, ptr %20, align 8, !tbaa !16
  switch i32 %29, label %.backedge [
    i32 0, label %30
    i32 1, label %37
  ]

30:                                               ; preds = %28
  %31 = load ptr, ptr %21, align 8, !tbaa !17
  %32 = call ptr @find_file_index_list(ptr noundef %1, ptr noundef %31) #7
  %.not13 = icmp eq ptr %32, null
  br i1 %.not13, label %33, label %36

33:                                               ; preds = %30
  %34 = load ptr, ptr %21, align 8, !tbaa !17
  %35 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.32, ptr noundef %34)
  br label %.backedge

36:                                               ; preds = %30
  call void @revert_file(ptr noundef %0, ptr noundef nonnull %32)
  br label %.backedge

37:                                               ; preds = %28
  %38 = load ptr, ptr %21, align 8, !tbaa !17
  call void @revert_directory(ptr noundef %0, ptr noundef %1, ptr noundef %38, i64 noundef %3)
  br label %.backedge

._crit_edge:                                      ; preds = %.backedge, %15
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %6) #7
  call void @llvm.lifetime.end.p0(i64 48, ptr nonnull %5) #7
  br label %39

39:                                               ; preds = %._crit_edge, %13
  ret void
}

declare void @visitor_init(ptr noundef) local_unnamed_addr #6

declare i32 @visitor_visit(ptr noundef, ptr noundef) local_unnamed_addr #6

declare i32 @visitor_visit_next_entry(ptr noundef) local_unnamed_addr #6

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

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

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


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