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

; 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 }

; 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
define dso_local i32 @split_in_place(ptr noundef %0, ptr noundef %1, i8 noundef signext %2) #1 {
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca i8, align 1
  %7 = alloca ptr, align 8
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  store i8 %2, ptr %6, align 1, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #2
  %10 = load ptr, ptr %4, align 8, !tbaa !5
  %11 = getelementptr inbounds %struct.strbuf, ptr %10, i32 0, i32 2
  %12 = load ptr, ptr %11, align 8, !tbaa !10
  store ptr %12, ptr %7, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #2
  store i32 0, ptr %8, align 4, !tbaa !13
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #2
  store i32 0, ptr %9, align 4, !tbaa !13
  %13 = load ptr, ptr %5, align 8, !tbaa !5
  %14 = load i32, ptr %8, align 4, !tbaa !13
  %15 = add nsw i32 %14, 1
  store i32 %15, ptr %8, align 4, !tbaa !13
  %16 = sext i32 %14 to i64
  %17 = getelementptr inbounds i64, ptr %13, i64 %16
  store i64 -1, ptr %17, align 8, !tbaa !15
  store i32 0, ptr %9, align 4, !tbaa !13
  br label %18

18:                                               ; preds = %42, %3
  %19 = load i32, ptr %9, align 4, !tbaa !13
  %20 = sext i32 %19 to i64
  %21 = load ptr, ptr %4, align 8, !tbaa !5
  %22 = getelementptr inbounds %struct.strbuf, ptr %21, i32 0, i32 1
  %23 = load i64, ptr %22, align 8, !tbaa !16
  %24 = icmp ult i64 %20, %23
  br i1 %24, label %25, label %45

25:                                               ; preds = %18
  %26 = load ptr, ptr %7, align 8, !tbaa !5
  %27 = load i32, ptr %9, align 4, !tbaa !13
  %28 = sext i32 %27 to i64
  %29 = getelementptr inbounds i8, ptr %26, i64 %28
  %30 = load i8, ptr %29, align 1, !tbaa !9
  %31 = sext i8 %30 to i32
  %32 = icmp eq i32 %31, 10
  br i1 %32, label %33, label %41

33:                                               ; preds = %25
  %34 = load i32, ptr %9, align 4, !tbaa !13
  %35 = sext i32 %34 to i64
  %36 = load ptr, ptr %5, align 8, !tbaa !5
  %37 = load i32, ptr %8, align 4, !tbaa !13
  %38 = add nsw i32 %37, 1
  store i32 %38, ptr %8, align 4, !tbaa !13
  %39 = sext i32 %37 to i64
  %40 = getelementptr inbounds i64, ptr %36, i64 %39
  store i64 %35, ptr %40, align 8, !tbaa !15
  br label %41

41:                                               ; preds = %33, %25
  br label %42

42:                                               ; preds = %41
  %43 = load i32, ptr %9, align 4, !tbaa !13
  %44 = add nsw i32 %43, 1
  store i32 %44, ptr %9, align 4, !tbaa !13
  br label %18, !llvm.loop !17

45:                                               ; preds = %18
  %46 = load ptr, ptr %7, align 8, !tbaa !5
  %47 = load i32, ptr %9, align 4, !tbaa !13
  %48 = add nsw i32 %47, -1
  store i32 %48, ptr %9, align 4, !tbaa !13
  %49 = sext i32 %48 to i64
  %50 = getelementptr inbounds i8, ptr %46, i64 %49
  %51 = load i8, ptr %50, align 1, !tbaa !9
  %52 = sext i8 %51 to i32
  %53 = icmp ne i32 %52, 10
  br i1 %53, label %54, label %62

54:                                               ; preds = %45
  %55 = load i32, ptr %9, align 4, !tbaa !13
  %56 = sext i32 %55 to i64
  %57 = load ptr, ptr %5, align 8, !tbaa !5
  %58 = load i32, ptr %8, align 4, !tbaa !13
  %59 = add nsw i32 %58, 1
  store i32 %59, ptr %8, align 4, !tbaa !13
  %60 = sext i32 %58 to i64
  %61 = getelementptr inbounds i64, ptr %57, i64 %60
  store i64 %56, ptr %61, align 8, !tbaa !15
  br label %62

62:                                               ; preds = %54, %45
  %63 = load i32, ptr %8, align 4, !tbaa !13
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #2
  ret i32 %63
}

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 = { 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 = !{!7, !7, i64 0}
!10 = !{!11, !6, i64 16}
!11 = !{!"strbuf", !12, i64 0, !12, i64 8, !6, i64 16}
!12 = !{!"long", !7, i64 0}
!13 = !{!14, !14, i64 0}
!14 = !{!"int", !7, i64 0}
!15 = !{!12, !12, i64 0}
!16 = !{!11, !12, i64 8}
!17 = distinct !{!17, !18}
!18 = !{!"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"

; Function Attrs: nofree norecurse nosync nounwind memory(read, argmem: readwrite, inaccessiblemem: none) uwtable
define dso_local i32 @split_in_place(ptr nocapture noundef readonly %0, ptr nocapture noundef writeonly %1, i8 noundef signext %2) local_unnamed_addr #0 {
  %4 = getelementptr inbounds i8, ptr %0, i64 16
  %5 = load ptr, ptr %4, align 8, !tbaa !5
  store i64 -1, ptr %1, align 8, !tbaa !11
  %6 = getelementptr inbounds i8, ptr %0, i64 8
  %7 = load i64, ptr %6, align 8, !tbaa !12
  %.not21 = icmp eq i64 %7, 0
  br i1 %.not21, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %3, %16
  %8 = phi i64 [ %17, %16 ], [ %7, %3 ]
  %indvars.iv = phi i64 [ %indvars.iv.next, %16 ], [ 0, %3 ]
  %.01618 = phi i32 [ %.1, %16 ], [ 1, %3 ]
  %9 = getelementptr inbounds i8, ptr %5, i64 %indvars.iv
  %10 = load i8, ptr %9, align 1, !tbaa !13
  %11 = icmp eq i8 %10, 10
  br i1 %11, label %12, label %16

12:                                               ; preds = %.lr.ph
  %13 = add nsw i32 %.01618, 1
  %14 = sext i32 %.01618 to i64
  %15 = getelementptr inbounds i64, ptr %1, i64 %14
  store i64 %indvars.iv, ptr %15, align 8, !tbaa !11
  %.pre = load i64, ptr %6, align 8, !tbaa !12
  br label %16

16:                                               ; preds = %.lr.ph, %12
  %17 = phi i64 [ %.pre, %12 ], [ %8, %.lr.ph ]
  %.1 = phi i32 [ %13, %12 ], [ %.01618, %.lr.ph ]
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %18 = icmp ugt i64 %17, %indvars.iv.next
  br i1 %18, label %.lr.ph, label %._crit_edge.loopexit, !llvm.loop !14

._crit_edge.loopexit:                             ; preds = %16
  %sext = shl i64 %indvars.iv, 32
  %19 = ashr exact i64 %sext, 32
  br label %._crit_edge

._crit_edge:                                      ; preds = %._crit_edge.loopexit, %3
  %.016.lcssa = phi i32 [ 1, %3 ], [ %.1, %._crit_edge.loopexit ]
  %.0.lcssa = phi i64 [ -1, %3 ], [ %19, %._crit_edge.loopexit ]
  %20 = getelementptr inbounds i8, ptr %5, i64 %.0.lcssa
  %21 = load i8, ptr %20, align 1, !tbaa !13
  %.not = icmp eq i8 %21, 10
  br i1 %.not, label %26, label %22

22:                                               ; preds = %._crit_edge
  %23 = add nsw i32 %.016.lcssa, 1
  %24 = sext i32 %.016.lcssa to i64
  %25 = getelementptr inbounds i64, ptr %1, i64 %24
  store i64 %.0.lcssa, ptr %25, align 8, !tbaa !11
  br label %26

26:                                               ; preds = %22, %._crit_edge
  %.2 = phi i32 [ %23, %22 ], [ %.016.lcssa, %._crit_edge ]
  ret i32 %.2
}

attributes #0 = { nofree norecurse nosync nounwind memory(read, argmem: readwrite, inaccessiblemem: none) 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" }

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


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,LCSSAPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass