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

; 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.index_file_cache = type { ptr, %struct.strbuf }
%struct.strbuf = type { i64, i64, ptr }
%struct.commit = type { i16, [20 x i8], [50 x i8], [41 x i8], ptr, %struct.strbuf, %struct.strbuf, %struct.timestamp, i64, i64 }
%struct.timestamp = type { i64, ptr }
%struct.index_list = type { ptr, ptr }

@__const.make_index_list_from_commit.cache = external hidden unnamed_addr constant %struct.index_file_cache, 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 allocsize(0)
declare noalias ptr @malloc(i64 noundef) #1

declare void @strbuf_release(ptr noundef) #2

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

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

18:                                               ; preds = %2
  store i32 1, ptr %11, align 4
  br label %56

19:                                               ; preds = %2
  %20 = call i32 @cache_index_file(ptr noundef %5)
  br label %21

21:                                               ; preds = %53, %19
  %22 = load i64, ptr %9, align 8, !tbaa !15
  %23 = load ptr, ptr %3, align 8, !tbaa !5
  %24 = getelementptr inbounds %struct.commit, ptr %23, i32 0, i32 8
  %25 = load i64, ptr %24, align 8, !tbaa !9
  %26 = load ptr, ptr %3, align 8, !tbaa !5
  %27 = getelementptr inbounds %struct.commit, ptr %26, i32 0, i32 9
  %28 = load i64, ptr %27, align 8, !tbaa !16
  %29 = add i64 %25, %28
  %30 = icmp ne i64 %22, %29
  br i1 %30, label %31, label %54

31:                                               ; preds = %21
  %32 = load i64, ptr %9, align 8, !tbaa !15
  %33 = call ptr @make_index_from_cache(ptr noundef %5, i64 noundef %32)
  store ptr %33, ptr %6, align 8, !tbaa !5
  %34 = call noalias ptr @malloc(i64 noundef 16) #6
  store ptr %34, ptr %8, align 8, !tbaa !5
  %35 = load ptr, ptr %6, align 8, !tbaa !5
  %36 = load ptr, ptr %8, align 8, !tbaa !5
  %37 = getelementptr inbounds %struct.index_list, ptr %36, i32 0, i32 0
  store ptr %35, ptr %37, align 8, !tbaa !17
  %38 = load ptr, ptr %8, align 8, !tbaa !5
  %39 = getelementptr inbounds %struct.index_list, ptr %38, i32 0, i32 1
  store ptr null, ptr %39, align 8, !tbaa !19
  %40 = load i64, ptr %9, align 8, !tbaa !15
  %41 = add i64 %40, 432
  store i64 %41, ptr %9, align 8, !tbaa !15
  %42 = load i64, ptr %10, align 8, !tbaa !15
  %43 = add i64 %42, 1
  store i64 %43, ptr %10, align 8, !tbaa !15
  %44 = load ptr, ptr %4, align 8, !tbaa !5
  %45 = load ptr, ptr %44, align 8, !tbaa !5
  %46 = icmp ne ptr %45, null
  br i1 %46, label %47, label %49

47:                                               ; preds = %31
  %48 = load ptr, ptr %8, align 8, !tbaa !5
  call void @insert_index_list(ptr noundef %7, ptr noundef %48)
  br label %53

49:                                               ; preds = %31
  %50 = load ptr, ptr %8, align 8, !tbaa !5
  %51 = load ptr, ptr %4, align 8, !tbaa !5
  store ptr %50, ptr %51, align 8, !tbaa !5
  %52 = load ptr, ptr %8, align 8, !tbaa !5
  store ptr %52, ptr %7, align 8, !tbaa !5
  br label %53

53:                                               ; preds = %49, %47
  br label %21, !llvm.loop !20

54:                                               ; preds = %21
  %55 = getelementptr inbounds %struct.index_file_cache, ptr %5, i32 0, i32 1
  call void @strbuf_release(ptr noundef %55)
  store i32 0, ptr %11, align 4
  br label %56

56:                                               ; preds = %54, %18
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #5
  call void @llvm.lifetime.end.p0(i64 32, ptr %5) #5
  %57 = load i32, ptr %11, align 4
  switch i32 %57, label %59 [
    i32 0, label %58
    i32 1, label %58
  ]

58:                                               ; preds = %56, %56
  ret void

59:                                               ; preds = %56
  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) #4

declare i32 @cache_index_file(ptr noundef) #2

declare ptr @make_index_from_cache(ptr noundef, i64 noundef) #2

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

!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, !13, i64 192}
!10 = !{!"commit", !11, i64 0, !7, i64 2, !7, i64 22, !7, i64 72, !6, i64 120, !12, i64 128, !12, i64 152, !14, i64 176, !13, i64 192, !13, i64 200}
!11 = !{!"short", !7, i64 0}
!12 = !{!"strbuf", !13, i64 0, !13, i64 8, !6, i64 16}
!13 = !{!"long", !7, i64 0}
!14 = !{!"timestamp", !13, i64 0, !6, i64 8}
!15 = !{!13, !13, i64 0}
!16 = !{!10, !13, i64 200}
!17 = !{!18, !6, i64 0}
!18 = !{!"index_list", !6, i64 0, !6, i64 8}
!19 = !{!18, !6, i64 8}
!20 = distinct !{!20, !21}
!21 = !{!"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.index_file_cache = type { ptr, %struct.strbuf }
%struct.strbuf = type { i64, i64, ptr }

@__const.make_index_list_from_commit.cache = external hidden unnamed_addr constant %struct.index_file_cache, 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: mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite)
declare noalias noundef ptr @malloc(i64 noundef) local_unnamed_addr #1

declare void @strbuf_release(ptr noundef) local_unnamed_addr #2

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

; Function Attrs: nounwind uwtable
define dso_local void @make_index_list_from_commit(ptr nocapture noundef readonly %0, ptr nocapture noundef %1) local_unnamed_addr #3 {
  %3 = alloca %struct.index_file_cache, align 8
  %4 = alloca ptr, align 8
  call void @llvm.lifetime.start.p0(i64 32, ptr nonnull %3) #5
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 8 dereferenceable(32) %3, ptr noundef nonnull align 8 dereferenceable(32) @__const.make_index_list_from_commit.cache, i64 32, i1 false)
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %4) #5
  store ptr null, ptr %4, align 8, !tbaa !5
  %5 = getelementptr inbounds i8, ptr %0, i64 192
  %6 = load i64, ptr %5, align 8, !tbaa !9
  store ptr null, ptr %1, align 8, !tbaa !5
  %7 = call i32 @cache_index_file(ptr noundef nonnull %3) #5
  %8 = getelementptr inbounds i8, ptr %0, i64 200
  %9 = load i64, ptr %5, align 8, !tbaa !9
  %10 = load i64, ptr %8, align 8, !tbaa !15
  %11 = add i64 %10, %9
  %.not1820 = icmp eq i64 %6, %11
  br i1 %.not1820, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %2, %19
  %.01621 = phi i64 [ %15, %19 ], [ %6, %2 ]
  %12 = call ptr @make_index_from_cache(ptr noundef nonnull %3, i64 noundef %.01621) #5
  %13 = call noalias dereferenceable_or_null(16) ptr @malloc(i64 noundef 16) #6
  store ptr %12, ptr %13, align 8, !tbaa !16
  %14 = getelementptr inbounds i8, ptr %13, i64 8
  store ptr null, ptr %14, align 8, !tbaa !18
  %15 = add i64 %.01621, 432
  %16 = load ptr, ptr %1, align 8, !tbaa !5
  %.not19 = icmp eq ptr %16, null
  br i1 %.not19, label %18, label %17

17:                                               ; preds = %.lr.ph
  call void @insert_index_list(ptr noundef nonnull %4, ptr noundef nonnull %13)
  br label %19

18:                                               ; preds = %.lr.ph
  store ptr %13, ptr %1, align 8, !tbaa !5
  store ptr %13, ptr %4, align 8, !tbaa !5
  br label %19

19:                                               ; preds = %18, %17
  %20 = load i64, ptr %5, align 8, !tbaa !9
  %21 = load i64, ptr %8, align 8, !tbaa !15
  %22 = add i64 %21, %20
  %.not18 = icmp eq i64 %15, %22
  br i1 %.not18, label %._crit_edge, label %.lr.ph, !llvm.loop !19

._crit_edge:                                      ; preds = %19, %2
  %23 = getelementptr inbounds i8, ptr %3, i64 8
  call void @strbuf_release(ptr noundef nonnull %23) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %4) #5
  call void @llvm.lifetime.end.p0(i64 32, ptr nonnull %3) #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) #4

declare i32 @cache_index_file(ptr noundef) local_unnamed_addr #2

declare ptr @make_index_from_cache(ptr noundef, i64 noundef) local_unnamed_addr #2

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite) "alloc-family"="malloc" "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 = { "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 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 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #5 = { nounwind }
attributes #6 = { nounwind allocsize(0) }

!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, !13, i64 192}
!10 = !{!"commit", !11, i64 0, !7, i64 2, !7, i64 22, !7, i64 72, !6, i64 120, !12, i64 128, !12, i64 152, !14, i64 176, !13, i64 192, !13, i64 200}
!11 = !{!"short", !7, i64 0}
!12 = !{!"strbuf", !13, i64 0, !13, i64 8, !6, i64 16}
!13 = !{!"long", !7, i64 0}
!14 = !{!"timestamp", !13, i64 0, !6, i64 8}
!15 = !{!10, !13, i64 200}
!16 = !{!17, !6, i64 0}
!17 = !{!"index_list", !6, i64 0, !6, i64 8}
!18 = !{!17, !6, i64 8}
!19 = distinct !{!19, !20}
!20 = !{!"llvm.loop.mustprogress"}


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