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

@stderr = external global ptr, align 8
@.str.23 = external hidden unnamed_addr constant [14 x i8], align 1

; Function Attrs: nounwind uwtable
declare dso_local i32 @delta_table_init(ptr noundef, i32 noundef, i32 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 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 @delta_table_free(ptr noundef) #0

declare void @deltafile_free(ptr noundef) #2

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

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

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

; Function Attrs: nounwind uwtable
declare dso_local i32 @delta_backtrace_table_minimal(ptr noundef, ptr noundef, ptr noundef, ptr noundef) #0

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

; Function Attrs: nounwind uwtable
define dso_local zeroext i1 @strbuf_delta_minimal(ptr noundef %0, ptr noundef %1, ptr noundef %2, ptr noundef %3) #0 {
  %5 = alloca i1, align 1
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  %10 = alloca %struct.deltafile, align 8
  %11 = alloca %struct.deltafile, align 8
  %12 = alloca %struct.delta_table, align 8
  %13 = alloca %struct.basic_delta_result, align 8
  %14 = alloca i8, align 1
  %15 = alloca i32, align 4
  store ptr %0, ptr %6, align 8, !tbaa !5
  store ptr %1, ptr %7, align 8, !tbaa !5
  store ptr %2, ptr %8, align 8, !tbaa !5
  store ptr %3, ptr %9, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 48, ptr %10) #4
  call void @llvm.lifetime.start.p0(i64 48, ptr %11) #4
  call void @llvm.lifetime.start.p0(i64 32, ptr %12) #4
  call void @llvm.lifetime.start.p0(i64 80, ptr %13) #4
  call void @llvm.lifetime.start.p0(i64 1, ptr %14) #4
  store i8 0, ptr %14, align 1, !tbaa !9
  %16 = load ptr, ptr %9, align 8, !tbaa !5
  %17 = call i32 @deltafile_init_strbuf(ptr noundef %10, ptr noundef %16, i8 noundef signext 10)
  %18 = load ptr, ptr %8, align 8, !tbaa !5
  %19 = call i32 @deltafile_init_strbuf(ptr noundef %11, ptr noundef %18, i8 noundef signext 10)
  %20 = getelementptr inbounds %struct.deltafile, ptr %10, i32 0, i32 2
  %21 = load i64, ptr %20, align 8, !tbaa !11
  %22 = getelementptr inbounds %struct.deltafile, ptr %11, i32 0, i32 2
  %23 = load i64, ptr %22, align 8, !tbaa !11
  %24 = icmp eq i64 %21, %23
  br i1 %24, label %25, label %35

25:                                               ; preds = %4
  %26 = load ptr, ptr %9, align 8, !tbaa !5
  %27 = load ptr, ptr %8, align 8, !tbaa !5
  %28 = call i32 @strbuf_cmp(ptr noundef %26, ptr noundef %27)
  %29 = icmp ne i32 %28, 0
  %30 = zext i1 %29 to i8
  store i8 %30, ptr %14, align 1, !tbaa !9
  %31 = load i8, ptr %14, align 1, !tbaa !9, !range !15, !noundef !16
  %32 = trunc i8 %31 to i1
  br i1 %32, label %34, label %33

33:                                               ; preds = %25
  store i1 false, ptr %5, align 1
  store i32 1, ptr %15, align 4
  br label %75

34:                                               ; preds = %25
  br label %35

35:                                               ; preds = %34, %4
  %36 = getelementptr inbounds %struct.deltafile, ptr %10, i32 0, i32 2
  %37 = load i64, ptr %36, align 8, !tbaa !11
  %38 = trunc i64 %37 to i32
  %39 = getelementptr inbounds %struct.deltafile, ptr %11, i32 0, i32 2
  %40 = load i64, ptr %39, align 8, !tbaa !11
  %41 = trunc i64 %40 to i32
  %42 = call i32 @delta_table_init(ptr noundef %12, i32 noundef %38, i32 noundef %41)
  %43 = icmp eq i32 %42, 1
  br i1 %43, label %44, label %47

44:                                               ; preds = %35
  %45 = load ptr, ptr @stderr, align 8, !tbaa !5
  %46 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %45, ptr noundef @.str.23) #4
  store i1 false, ptr %5, align 1
  store i32 1, ptr %15, align 4
  br label %75

47:                                               ; preds = %35
  %48 = call i64 @delta_basic_comparison_m(ptr noundef %12, ptr noundef %10, ptr noundef %11)
  %49 = load ptr, ptr %7, align 8, !tbaa !5
  %50 = icmp ne ptr %49, null
  br i1 %50, label %51, label %54

51:                                               ; preds = %47
  %52 = load ptr, ptr %7, align 8, !tbaa !5
  %53 = call i32 @delta_backtrace_table_minimal(ptr noundef %52, ptr noundef %12, ptr noundef %10, ptr noundef %11)
  br label %57

54:                                               ; preds = %47
  call void @basic_delta_result_init(ptr noundef %13, ptr noundef null)
  %55 = load ptr, ptr %7, align 8, !tbaa !5
  %56 = call i32 @delta_backtrace_table_minimal(ptr noundef %55, ptr noundef %12, ptr noundef %10, ptr noundef %11)
  br label %57

57:                                               ; preds = %54, %51
  %58 = load ptr, ptr %7, align 8, !tbaa !5
  %59 = getelementptr inbounds %struct.basic_delta_result, ptr %58, i32 0, i32 0
  %60 = load i64, ptr %59, align 8, !tbaa !17
  %61 = icmp ne i64 %60, 0
  br i1 %61, label %68, label %62

62:                                               ; preds = %57
  %63 = load ptr, ptr %7, align 8, !tbaa !5
  %64 = getelementptr inbounds %struct.basic_delta_result, ptr %63, i32 0, i32 1
  %65 = load i64, ptr %64, align 8, !tbaa !20
  %66 = icmp ne i64 %65, 0
  br i1 %66, label %68, label %67

67:                                               ; preds = %62
  call void @deltafile_free(ptr noundef %10)
  call void @deltafile_free(ptr noundef %11)
  store i1 false, ptr %5, align 1
  store i32 1, ptr %15, align 4
  br label %75

68:                                               ; preds = %62, %57
  %69 = load ptr, ptr %6, align 8, !tbaa !5
  %70 = icmp ne ptr %69, null
  br i1 %70, label %71, label %74

71:                                               ; preds = %68
  %72 = load ptr, ptr %7, align 8, !tbaa !5
  %73 = load ptr, ptr %6, align 8, !tbaa !5
  call void @delta_stat(ptr noundef %72, ptr noundef %73)
  br label %74

74:                                               ; preds = %71, %68
  call void @deltafile_free(ptr noundef %10)
  call void @deltafile_free(ptr noundef %11)
  call void @delta_table_free(ptr noundef %12)
  store i1 true, ptr %5, align 1
  store i32 1, ptr %15, align 4
  br label %75

75:                                               ; preds = %74, %67, %44, %33
  call void @llvm.lifetime.end.p0(i64 1, ptr %14) #4
  call void @llvm.lifetime.end.p0(i64 80, ptr %13) #4
  call void @llvm.lifetime.end.p0(i64 32, ptr %12) #4
  call void @llvm.lifetime.end.p0(i64 48, ptr %11) #4
  call void @llvm.lifetime.end.p0(i64 48, ptr %10) #4
  %76 = load i1, ptr %5, align 1
  ret i1 %76
}

declare i32 @deltafile_init_strbuf(ptr noundef, ptr noundef, i8 noundef signext) #2

declare i32 @strbuf_cmp(ptr noundef, ptr noundef) #2

attributes #0 = { 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 #1 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { "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 "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, !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 = !{!12, !14, i64 32}
!12 = !{!"deltafile", !13, i64 0, !6, i64 24, !14, i64 32, !7, i64 40}
!13 = !{!"strbuf", !14, i64 0, !14, i64 8, !6, i64 16}
!14 = !{!"long", !7, i64 0}
!15 = !{i8 0, i8 2}
!16 = !{}
!17 = !{!18, !14, i64 0}
!18 = !{!"basic_delta_result", !14, i64 0, !14, i64 8, !14, i64 16, !6, i64 24, !19, i64 32, !19, i64 56}
!19 = !{!"strbuf_list", !6, i64 0, !6, i64 8, !14, i64 16}
!20 = !{!18, !14, 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.deltafile = type { %struct.strbuf, ptr, i64, i8 }
%struct.strbuf = type { i64, i64, ptr }
%struct.delta_table = type { ptr, ptr, ptr, i32, i32 }
%struct.basic_delta_result = type { i64, i64, i64, ptr, %struct.strbuf_list, %struct.strbuf_list }
%struct.strbuf_list = type { ptr, ptr, i64 }

@stderr = external local_unnamed_addr global ptr, align 8
@.str.23 = external hidden unnamed_addr constant [14 x i8], align 1

; Function Attrs: nounwind uwtable
declare dso_local i32 @delta_table_init(ptr noundef, i32 noundef, i32 noundef) 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 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 @delta_table_free(ptr noundef) local_unnamed_addr #0

declare void @deltafile_free(ptr noundef) local_unnamed_addr #2

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

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

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

; Function Attrs: nounwind uwtable
declare dso_local i32 @delta_backtrace_table_minimal(ptr noundef, ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #0

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

; Function Attrs: nounwind uwtable
define dso_local noundef zeroext i1 @strbuf_delta_minimal(ptr noundef %0, ptr noundef %1, ptr noundef %2, ptr noundef %3) local_unnamed_addr #0 {
  %5 = alloca %struct.deltafile, align 8
  %6 = alloca %struct.deltafile, align 8
  %7 = alloca %struct.delta_table, align 8
  %8 = alloca %struct.basic_delta_result, align 8
  call void @llvm.lifetime.start.p0(i64 48, ptr nonnull %5) #4
  call void @llvm.lifetime.start.p0(i64 48, ptr nonnull %6) #4
  call void @llvm.lifetime.start.p0(i64 32, ptr nonnull %7) #4
  call void @llvm.lifetime.start.p0(i64 80, ptr nonnull %8) #4
  %9 = call i32 @deltafile_init_strbuf(ptr noundef nonnull %5, ptr noundef %3, i8 noundef signext 10) #4
  %10 = call i32 @deltafile_init_strbuf(ptr noundef nonnull %6, ptr noundef %2, i8 noundef signext 10) #4
  %11 = getelementptr inbounds i8, ptr %5, i64 32
  %12 = load i64, ptr %11, align 8, !tbaa !5
  %13 = getelementptr inbounds i8, ptr %6, i64 32
  %14 = load i64, ptr %13, align 8, !tbaa !5
  %15 = icmp eq i64 %12, %14
  br i1 %15, label %16, label %18

16:                                               ; preds = %4
  %17 = call i32 @strbuf_cmp(ptr noundef %3, ptr noundef %2) #4
  %.not = icmp eq i32 %17, 0
  br i1 %.not, label %43, label %._crit_edge

._crit_edge:                                      ; preds = %16
  %.pre = load i64, ptr %11, align 8, !tbaa !5
  %.pre19 = load i64, ptr %13, align 8, !tbaa !5
  br label %18

18:                                               ; preds = %._crit_edge, %4
  %19 = phi i64 [ %.pre19, %._crit_edge ], [ %14, %4 ]
  %20 = phi i64 [ %.pre, %._crit_edge ], [ %12, %4 ]
  %21 = trunc i64 %20 to i32
  %22 = trunc i64 %19 to i32
  %23 = call i32 @delta_table_init(ptr noundef nonnull %7, i32 noundef %21, i32 noundef %22)
  %24 = icmp eq i32 %23, 1
  br i1 %24, label %25, label %28

25:                                               ; preds = %18
  %26 = load ptr, ptr @stderr, align 8, !tbaa !12
  %27 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %26, ptr noundef nonnull @.str.23) #5
  br label %43

28:                                               ; preds = %18
  %29 = call i64 @delta_basic_comparison_m(ptr noundef nonnull %7, ptr noundef nonnull %5, ptr noundef nonnull %6)
  %.not15 = icmp eq ptr %1, null
  br i1 %.not15, label %32, label %30

30:                                               ; preds = %28
  %31 = call i32 @delta_backtrace_table_minimal(ptr noundef nonnull %1, ptr noundef nonnull %7, ptr noundef nonnull %5, ptr noundef nonnull %6)
  br label %34

32:                                               ; preds = %28
  call void @basic_delta_result_init(ptr noundef nonnull %8, ptr noundef null)
  %33 = call i32 @delta_backtrace_table_minimal(ptr noundef null, ptr noundef nonnull %7, ptr noundef nonnull %5, ptr noundef nonnull %6)
  br label %34

34:                                               ; preds = %32, %30
  %35 = load i64, ptr %1, align 8, !tbaa !13
  %.not16 = icmp eq i64 %35, 0
  br i1 %.not16, label %36, label %40

36:                                               ; preds = %34
  %37 = getelementptr inbounds i8, ptr %1, i64 8
  %38 = load i64, ptr %37, align 8, !tbaa !16
  %.not17 = icmp eq i64 %38, 0
  br i1 %.not17, label %39, label %40

39:                                               ; preds = %36
  call void @deltafile_free(ptr noundef nonnull %5) #4
  call void @deltafile_free(ptr noundef nonnull %6) #4
  br label %43

40:                                               ; preds = %36, %34
  %.not18 = icmp eq ptr %0, null
  br i1 %.not18, label %42, label %41

41:                                               ; preds = %40
  call void @delta_stat(ptr noundef nonnull %1, ptr noundef nonnull %0)
  br label %42

42:                                               ; preds = %41, %40
  call void @deltafile_free(ptr noundef nonnull %5) #4
  call void @deltafile_free(ptr noundef nonnull %6) #4
  call void @delta_table_free(ptr noundef nonnull %7)
  br label %43

43:                                               ; preds = %16, %42, %39, %25
  %.0 = phi i1 [ false, %25 ], [ true, %42 ], [ false, %39 ], [ false, %16 ]
  call void @llvm.lifetime.end.p0(i64 80, ptr nonnull %8) #4
  call void @llvm.lifetime.end.p0(i64 32, ptr nonnull %7) #4
  call void @llvm.lifetime.end.p0(i64 48, ptr nonnull %6) #4
  call void @llvm.lifetime.end.p0(i64 48, ptr nonnull %5) #4
  ret i1 %.0
}

declare i32 @deltafile_init_strbuf(ptr noundef, ptr noundef, i8 noundef signext) local_unnamed_addr #2

declare i32 @strbuf_cmp(ptr noundef, ptr noundef) local_unnamed_addr #2

attributes #0 = { 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 #1 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { "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 = { 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 #4 = { nounwind }
attributes #5 = { 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, !8, i64 32}
!6 = !{!"deltafile", !7, i64 0, !11, i64 24, !8, i64 32, !9, i64 40}
!7 = !{!"strbuf", !8, i64 0, !8, i64 8, !11, i64 16}
!8 = !{!"long", !9, i64 0}
!9 = !{!"omnipotent char", !10, i64 0}
!10 = !{!"Simple C/C++ TBAA"}
!11 = !{!"any pointer", !9, i64 0}
!12 = !{!11, !11, i64 0}
!13 = !{!14, !8, i64 0}
!14 = !{!"basic_delta_result", !8, i64 0, !8, i64 8, !8, i64 16, !11, i64 24, !15, i64 32, !15, i64 56}
!15 = !{!"strbuf_list", !11, i64 0, !11, i64 8, !8, i64 16}
!16 = !{!14, !8, i64 8}


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