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

@__const.index_delta.a = external hidden unnamed_addr constant %struct.strbuf, align 8
@__const.index_delta.b = external hidden unnamed_addr constant %struct.strbuf, align 8

; 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 uwtable
declare dso_local void @basic_delta_result_init(ptr noundef, ptr noundef) #1

; Function Attrs: nounwind uwtable
declare dso_local zeroext i1 @strbuf_delta_minimal(ptr noundef, ptr noundef, ptr noundef, ptr noundef) #1

; Function Attrs: nounwind uwtable
declare dso_local zeroext i1 @strbuf_delta_enhanced(ptr noundef, ptr noundef, ptr noundef, ptr noundef) #1

; Function Attrs: nounwind uwtable
define dso_local void @index_delta(ptr noundef %0, ptr noundef %1, ptr noundef %2, ptr noundef %3, ptr noundef %4, i1 noundef zeroext %5) #1 {
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  %10 = alloca ptr, align 8
  %11 = alloca ptr, align 8
  %12 = alloca i8, align 1
  %13 = alloca %struct.strbuf, align 8
  %14 = alloca %struct.strbuf, align 8
  %15 = alloca %struct.basic_delta_result, align 8
  %16 = alloca i32, align 4
  store ptr %0, ptr %7, align 8, !tbaa !5
  store ptr %1, ptr %8, align 8, !tbaa !5
  store ptr %2, ptr %9, align 8, !tbaa !5
  store ptr %3, ptr %10, align 8, !tbaa !5
  store ptr %4, ptr %11, align 8, !tbaa !5
  %17 = zext i1 %5 to i8
  store i8 %17, ptr %12, align 1, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 24, ptr %13) #5
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %13, ptr align 8 @__const.index_delta.a, i64 24, i1 false)
  call void @llvm.lifetime.start.p0(i64 24, ptr %14) #5
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %14, ptr align 8 @__const.index_delta.b, i64 24, i1 false)
  call void @llvm.lifetime.start.p0(i64 80, ptr %15) #5
  call void @basic_delta_result_init(ptr noundef %15, ptr noundef null)
  %18 = load ptr, ptr %8, align 8, !tbaa !5
  %19 = load ptr, ptr %9, align 8, !tbaa !5
  %20 = call i32 @get_file_content(ptr noundef %18, ptr noundef %13, ptr noundef %19)
  %21 = load ptr, ptr %8, align 8, !tbaa !5
  %22 = load ptr, ptr %10, align 8, !tbaa !5
  %23 = call i32 @get_file_content(ptr noundef %21, ptr noundef %14, ptr noundef %22)
  %24 = load i8, ptr %12, align 1, !tbaa !9, !range !11, !noundef !12
  %25 = trunc i8 %24 to i1
  br i1 %25, label %26, label %43

26:                                               ; preds = %6
  %27 = load ptr, ptr %11, align 8, !tbaa !5
  %28 = call zeroext i1 @strbuf_delta_minimal(ptr noundef %27, ptr noundef %15, ptr noundef %13, ptr noundef %14)
  br i1 %28, label %30, label %29

29:                                               ; preds = %26
  call void @strbuf_release(ptr noundef %13)
  call void @strbuf_release(ptr noundef %14)
  store i32 1, ptr %16, align 4
  br label %66

30:                                               ; preds = %26
  %31 = getelementptr inbounds %struct.basic_delta_result, ptr %15, i32 0, i32 0
  %32 = load i64, ptr %31, align 8, !tbaa !13
  %33 = load ptr, ptr %7, align 8, !tbaa !5
  %34 = getelementptr inbounds %struct.basic_delta_result, ptr %33, i32 0, i32 0
  %35 = load i64, ptr %34, align 8, !tbaa !13
  %36 = add i64 %35, %32
  store i64 %36, ptr %34, align 8, !tbaa !13
  %37 = getelementptr inbounds %struct.basic_delta_result, ptr %15, i32 0, i32 1
  %38 = load i64, ptr %37, align 8, !tbaa !17
  %39 = load ptr, ptr %7, align 8, !tbaa !5
  %40 = getelementptr inbounds %struct.basic_delta_result, ptr %39, i32 0, i32 1
  %41 = load i64, ptr %40, align 8, !tbaa !17
  %42 = add i64 %41, %38
  store i64 %42, ptr %40, align 8, !tbaa !17
  br label %65

43:                                               ; preds = %6
  %44 = load ptr, ptr %11, align 8, !tbaa !5
  %45 = load ptr, ptr %7, align 8, !tbaa !5
  %46 = call zeroext i1 @strbuf_delta_enhanced(ptr noundef %44, ptr noundef %45, ptr noundef %13, ptr noundef %14)
  %47 = load ptr, ptr %7, align 8, !tbaa !5
  %48 = getelementptr inbounds %struct.basic_delta_result, ptr %47, i32 0, i32 5
  %49 = getelementptr inbounds %struct.basic_delta_result, ptr %15, i32 0, i32 5
  call void @strbuf_list_append(ptr noundef %48, ptr noundef %49)
  %50 = load ptr, ptr %7, align 8, !tbaa !5
  %51 = getelementptr inbounds %struct.basic_delta_result, ptr %50, i32 0, i32 4
  %52 = getelementptr inbounds %struct.basic_delta_result, ptr %15, i32 0, i32 4
  call void @strbuf_list_append(ptr noundef %51, ptr noundef %52)
  %53 = getelementptr inbounds %struct.basic_delta_result, ptr %15, i32 0, i32 0
  %54 = load i64, ptr %53, align 8, !tbaa !13
  %55 = load ptr, ptr %7, align 8, !tbaa !5
  %56 = getelementptr inbounds %struct.basic_delta_result, ptr %55, i32 0, i32 0
  %57 = load i64, ptr %56, align 8, !tbaa !13
  %58 = add i64 %57, %54
  store i64 %58, ptr %56, align 8, !tbaa !13
  %59 = getelementptr inbounds %struct.basic_delta_result, ptr %15, i32 0, i32 1
  %60 = load i64, ptr %59, align 8, !tbaa !17
  %61 = load ptr, ptr %7, align 8, !tbaa !5
  %62 = getelementptr inbounds %struct.basic_delta_result, ptr %61, i32 0, i32 1
  %63 = load i64, ptr %62, align 8, !tbaa !17
  %64 = add i64 %63, %60
  store i64 %64, ptr %62, align 8, !tbaa !17
  br label %65

65:                                               ; preds = %43, %30
  call void @strbuf_release(ptr noundef %13)
  call void @strbuf_release(ptr noundef %14)
  store i32 0, ptr %16, align 4
  br label %66

66:                                               ; preds = %65, %29
  call void @llvm.lifetime.end.p0(i64 80, ptr %15) #5
  call void @llvm.lifetime.end.p0(i64 24, ptr %14) #5
  call void @llvm.lifetime.end.p0(i64 24, ptr %13) #5
  %67 = load i32, ptr %16, align 4
  switch i32 %67, label %69 [
    i32 0, label %68
    i32 1, label %68
  ]

68:                                               ; preds = %66, %66
  ret void

69:                                               ; preds = %66
  unreachable
}

; 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: inlinehint nounwind uwtable
declare hidden i32 @get_file_content(ptr noundef, ptr noundef, ptr noundef) #3

declare void @strbuf_release(ptr noundef) #4

; Function Attrs: nounwind uwtable
declare hidden void @strbuf_list_append(ptr noundef, ptr noundef) #1

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

!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, !15, i64 0}
!14 = !{!"basic_delta_result", !15, i64 0, !15, i64 8, !15, i64 16, !6, i64 24, !16, i64 32, !16, i64 56}
!15 = !{!"long", !7, i64 0}
!16 = !{!"strbuf_list", !6, i64 0, !6, i64 8, !15, i64 16}
!17 = !{!14, !15, 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.strbuf = type { i64, i64, ptr }
%struct.basic_delta_result = type { i64, i64, i64, ptr, %struct.strbuf_list, %struct.strbuf_list }
%struct.strbuf_list = type { ptr, ptr, i64 }

@__const.index_delta.a = external hidden unnamed_addr constant %struct.strbuf, align 8
@__const.index_delta.b = external hidden unnamed_addr constant %struct.strbuf, align 8

; 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: nounwind uwtable
declare dso_local void @basic_delta_result_init(ptr noundef, ptr noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
declare dso_local zeroext i1 @strbuf_delta_minimal(ptr noundef, ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
declare dso_local zeroext i1 @strbuf_delta_enhanced(ptr noundef, ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
define dso_local void @index_delta(ptr noundef %0, ptr noundef %1, ptr noundef %2, ptr noundef %3, ptr noundef %4, i1 noundef zeroext %5) local_unnamed_addr #1 {
  %7 = alloca %struct.strbuf, align 8
  %8 = alloca %struct.strbuf, align 8
  %9 = alloca %struct.basic_delta_result, align 16
  call void @llvm.lifetime.start.p0(i64 24, ptr nonnull %7) #5
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 8 dereferenceable(24) %7, ptr noundef nonnull align 8 dereferenceable(24) @__const.index_delta.a, i64 24, i1 false)
  call void @llvm.lifetime.start.p0(i64 24, ptr nonnull %8) #5
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 8 dereferenceable(24) %8, ptr noundef nonnull align 8 dereferenceable(24) @__const.index_delta.b, i64 24, i1 false)
  call void @llvm.lifetime.start.p0(i64 80, ptr nonnull %9) #5
  call void @basic_delta_result_init(ptr noundef nonnull %9, ptr noundef null)
  %10 = call i32 @get_file_content(ptr noundef %1, ptr noundef nonnull %7, ptr noundef %2)
  %11 = call i32 @get_file_content(ptr noundef %1, ptr noundef nonnull %8, ptr noundef %3)
  br i1 %5, label %12, label %14

12:                                               ; preds = %6
  %13 = call zeroext i1 @strbuf_delta_minimal(ptr noundef %4, ptr noundef nonnull %9, ptr noundef nonnull %7, ptr noundef nonnull %8)
  br i1 %13, label %20, label %24

14:                                               ; preds = %6
  %15 = call zeroext i1 @strbuf_delta_enhanced(ptr noundef %4, ptr noundef %0, ptr noundef nonnull %7, ptr noundef nonnull %8)
  %16 = getelementptr inbounds i8, ptr %0, i64 56
  %17 = getelementptr inbounds i8, ptr %9, i64 56
  call void @strbuf_list_append(ptr noundef nonnull %16, ptr noundef nonnull %17)
  %18 = getelementptr inbounds i8, ptr %0, i64 32
  %19 = getelementptr inbounds i8, ptr %9, i64 32
  call void @strbuf_list_append(ptr noundef nonnull %18, ptr noundef nonnull %19)
  br label %20

20:                                               ; preds = %12, %14
  %21 = load <2 x i64>, ptr %9, align 16, !tbaa !5
  %22 = load <2 x i64>, ptr %0, align 8, !tbaa !5
  %23 = add <2 x i64> %22, %21
  store <2 x i64> %23, ptr %0, align 8, !tbaa !5
  br label %24

24:                                               ; preds = %12, %20
  call void @strbuf_release(ptr noundef nonnull %7) #5
  call void @strbuf_release(ptr noundef nonnull %8) #5
  call void @llvm.lifetime.end.p0(i64 80, ptr nonnull %9) #5
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %8) #5
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %7) #5
  ret void
}

; 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: inlinehint nounwind uwtable
declare hidden i32 @get_file_content(ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #3

declare void @strbuf_release(ptr noundef) local_unnamed_addr #4

; Function Attrs: nounwind uwtable
declare hidden void @strbuf_list_append(ptr noundef, ptr noundef) local_unnamed_addr #1

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

!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 = !{!"long", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,SLPVectorizerPass,SROAPass,SimplifyCFGPass