; 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.basic_delta_result = type { i64, i64, i64, ptr, %struct.strbuf_list, %struct.strbuf_list }
%struct.strbuf_list = type { ptr, ptr, i64 }
%struct.delta_input = type { ptr, ptr, %struct.deltafile, %struct.deltafile }
%struct.deltafile = type { %struct.strbuf, ptr, i64, i8 }
%struct.strbuf = type { i64, i64, ptr }
%struct.filespec = type { %struct.strbuf, ptr, i64, %struct.stat, %struct.filecache, [20 x i8], i64, %struct.strbuf, i32 }
%struct.stat = type { i64, i64, i64, i32, i32, i32, i32, i64, i64, i64, i64, %struct.timespec, %struct.timespec, %struct.timespec, [3 x i64] }
%struct.timespec = type { i64, i64 }
%struct.filecache = type { ptr }

@.str.7 = external hidden unnamed_addr constant [21 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [15 x i8], align 1
@.str.9 = external hidden unnamed_addr constant [21 x i8], align 1
@.str.10 = external hidden unnamed_addr constant [13 x i8], align 1
@.str.11 = external hidden unnamed_addr constant [14 x i8], align 1
@.str.12 = external hidden unnamed_addr constant [21 x i8], align 1
@.str.13 = external hidden unnamed_addr constant [12 x i8], align 1
@.str.14 = external hidden unnamed_addr constant [13 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local void @delta_stat(ptr noundef %0, ptr noundef %1) #0 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  store ptr %0, ptr %3, align 8, !tbaa !5
  store ptr %1, ptr %4, align 8, !tbaa !5
  %5 = load ptr, ptr %3, align 8, !tbaa !5
  %6 = getelementptr inbounds %struct.basic_delta_result, ptr %5, i32 0, i32 3
  %7 = load ptr, ptr %6, align 8, !tbaa !9
  %8 = icmp ne ptr %7, null
  br i1 %8, label %9, label %27

9:                                                ; preds = %2
  %10 = load ptr, ptr %4, align 8, !tbaa !5
  %11 = load ptr, ptr %3, align 8, !tbaa !5
  %12 = getelementptr inbounds %struct.basic_delta_result, ptr %11, i32 0, i32 3
  %13 = load ptr, ptr %12, align 8, !tbaa !9
  %14 = getelementptr inbounds %struct.delta_input, ptr %13, i32 0, i32 0
  %15 = load ptr, ptr %14, align 8, !tbaa !13
  %16 = getelementptr inbounds %struct.filespec, ptr %15, i32 0, i32 0
  %17 = getelementptr inbounds %struct.strbuf, ptr %16, i32 0, i32 2
  %18 = load ptr, ptr %17, align 8, !tbaa !17
  %19 = load ptr, ptr %3, align 8, !tbaa !5
  %20 = getelementptr inbounds %struct.basic_delta_result, ptr %19, i32 0, i32 3
  %21 = load ptr, ptr %20, align 8, !tbaa !9
  %22 = getelementptr inbounds %struct.delta_input, ptr %21, i32 0, i32 1
  %23 = load ptr, ptr %22, align 8, !tbaa !23
  %24 = getelementptr inbounds %struct.filespec, ptr %23, i32 0, i32 0
  %25 = getelementptr inbounds %struct.strbuf, ptr %24, i32 0, i32 2
  %26 = load ptr, ptr %25, align 8, !tbaa !17
  call void (ptr, ptr, ...) @strbuf_addf(ptr noundef %10, ptr noundef @.str.7, ptr noundef %18, ptr noundef %26)
  br label %27

27:                                               ; preds = %9, %2
  %28 = load ptr, ptr %3, align 8, !tbaa !5
  %29 = getelementptr inbounds %struct.basic_delta_result, ptr %28, i32 0, i32 0
  %30 = load i64, ptr %29, align 8, !tbaa !24
  %31 = icmp eq i64 %30, 0
  br i1 %31, label %32, label %39

32:                                               ; preds = %27
  %33 = load ptr, ptr %3, align 8, !tbaa !5
  %34 = getelementptr inbounds %struct.basic_delta_result, ptr %33, i32 0, i32 1
  %35 = load i64, ptr %34, align 8, !tbaa !25
  %36 = icmp eq i64 %35, 0
  br i1 %36, label %37, label %39

37:                                               ; preds = %32
  %38 = load ptr, ptr %4, align 8, !tbaa !5
  call void (ptr, ptr, ...) @strbuf_addf(ptr noundef %38, ptr noundef @.str.8)
  br label %83

39:                                               ; preds = %32, %27
  %40 = load ptr, ptr %3, align 8, !tbaa !5
  %41 = getelementptr inbounds %struct.basic_delta_result, ptr %40, i32 0, i32 0
  %42 = load i64, ptr %41, align 8, !tbaa !24
  %43 = icmp ne i64 %42, 0
  br i1 %43, label %49, label %44

44:                                               ; preds = %39
  %45 = load ptr, ptr %3, align 8, !tbaa !5
  %46 = getelementptr inbounds %struct.basic_delta_result, ptr %45, i32 0, i32 1
  %47 = load i64, ptr %46, align 8, !tbaa !25
  %48 = icmp eq i64 %47, 0
  br i1 %48, label %49, label %60

49:                                               ; preds = %44, %39
  %50 = load ptr, ptr %4, align 8, !tbaa !5
  %51 = load ptr, ptr %3, align 8, !tbaa !5
  %52 = getelementptr inbounds %struct.basic_delta_result, ptr %51, i32 0, i32 0
  %53 = load i64, ptr %52, align 8, !tbaa !24
  %54 = load ptr, ptr %3, align 8, !tbaa !5
  %55 = getelementptr inbounds %struct.basic_delta_result, ptr %54, i32 0, i32 0
  %56 = load i64, ptr %55, align 8, !tbaa !24
  %57 = icmp eq i64 %56, 1
  %58 = zext i1 %57 to i64
  %59 = select i1 %57, ptr @.str.10, ptr @.str.11
  call void (ptr, ptr, ...) @strbuf_addf(ptr noundef %50, ptr noundef @.str.9, i64 noundef %53, ptr noundef %59)
  br label %60

60:                                               ; preds = %49, %44
  %61 = load ptr, ptr %3, 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 !25
  %64 = icmp ne i64 %63, 0
  br i1 %64, label %70, label %65

65:                                               ; preds = %60
  %66 = load ptr, ptr %3, align 8, !tbaa !5
  %67 = getelementptr inbounds %struct.basic_delta_result, ptr %66, i32 0, i32 0
  %68 = load i64, ptr %67, align 8, !tbaa !24
  %69 = icmp eq i64 %68, 0
  br i1 %69, label %70, label %81

70:                                               ; preds = %65, %60
  %71 = load ptr, ptr %4, align 8, !tbaa !5
  %72 = load ptr, ptr %3, align 8, !tbaa !5
  %73 = getelementptr inbounds %struct.basic_delta_result, ptr %72, i32 0, i32 1
  %74 = load i64, ptr %73, align 8, !tbaa !25
  %75 = load ptr, ptr %3, align 8, !tbaa !5
  %76 = getelementptr inbounds %struct.basic_delta_result, ptr %75, i32 0, i32 1
  %77 = load i64, ptr %76, align 8, !tbaa !25
  %78 = icmp eq i64 %77, 1
  %79 = zext i1 %78 to i64
  %80 = select i1 %78, ptr @.str.13, ptr @.str.14
  call void (ptr, ptr, ...) @strbuf_addf(ptr noundef %71, ptr noundef @.str.12, i64 noundef %74, ptr noundef %80)
  br label %81

81:                                               ; preds = %70, %65
  %82 = load ptr, ptr %4, align 8, !tbaa !5
  call void @strbuf_addch(ptr noundef %82, i32 noundef 10)
  br label %83

83:                                               ; preds = %81, %37
  ret void
}

declare void @strbuf_addf(ptr noundef, ptr noundef, ...) #1

; Function Attrs: inlinehint nounwind uwtable
declare hidden void @strbuf_addch(ptr noundef, i32 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 = { "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 = { 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" }

!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, !6, i64 24}
!10 = !{!"basic_delta_result", !11, i64 0, !11, i64 8, !11, i64 16, !6, i64 24, !12, i64 32, !12, i64 56}
!11 = !{!"long", !7, i64 0}
!12 = !{!"strbuf_list", !6, i64 0, !6, i64 8, !11, i64 16}
!13 = !{!14, !6, i64 0}
!14 = !{!"delta_input", !6, i64 0, !6, i64 8, !15, i64 16, !15, i64 64}
!15 = !{!"deltafile", !16, i64 0, !6, i64 24, !11, i64 32, !7, i64 40}
!16 = !{!"strbuf", !11, i64 0, !11, i64 8, !6, i64 16}
!17 = !{!18, !6, i64 16}
!18 = !{!"filespec", !16, i64 0, !6, i64 24, !11, i64 32, !19, i64 40, !22, i64 184, !7, i64 192, !11, i64 216, !16, i64 224, !20, i64 248}
!19 = !{!"stat", !11, i64 0, !11, i64 8, !11, i64 16, !20, i64 24, !20, i64 28, !20, i64 32, !20, i64 36, !11, i64 40, !11, i64 48, !11, i64 56, !11, i64 64, !21, i64 72, !21, i64 88, !21, i64 104, !7, i64 120}
!20 = !{!"int", !7, i64 0}
!21 = !{!"timespec", !11, i64 0, !11, i64 8}
!22 = !{!"filecache", !6, i64 0}
!23 = !{!14, !6, i64 8}
!24 = !{!10, !11, i64 0}
!25 = !{!10, !11, 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"

@.str.7 = external hidden unnamed_addr constant [21 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [15 x i8], align 1
@.str.9 = external hidden unnamed_addr constant [21 x i8], align 1
@.str.10 = external hidden unnamed_addr constant [13 x i8], align 1
@.str.11 = external hidden unnamed_addr constant [14 x i8], align 1
@.str.12 = external hidden unnamed_addr constant [21 x i8], align 1
@.str.13 = external hidden unnamed_addr constant [12 x i8], align 1
@.str.14 = external hidden unnamed_addr constant [13 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local void @delta_stat(ptr nocapture noundef readonly %0, ptr noundef %1) local_unnamed_addr #0 {
  %3 = getelementptr inbounds i8, ptr %0, i64 24
  %4 = load ptr, ptr %3, align 8, !tbaa !5
  %.not = icmp eq ptr %4, null
  br i1 %.not, label %13, label %5

5:                                                ; preds = %2
  %6 = load ptr, ptr %4, align 8, !tbaa !12
  %7 = getelementptr inbounds i8, ptr %6, i64 16
  %8 = load ptr, ptr %7, align 8, !tbaa !16
  %9 = getelementptr inbounds i8, ptr %4, i64 8
  %10 = load ptr, ptr %9, align 8, !tbaa !22
  %11 = getelementptr inbounds i8, ptr %10, i64 16
  %12 = load ptr, ptr %11, align 8, !tbaa !16
  tail call void (ptr, ptr, ...) @strbuf_addf(ptr noundef %1, ptr noundef nonnull @.str.7, ptr noundef %8, ptr noundef %12) #3
  br label %13

13:                                               ; preds = %5, %2
  %14 = load i64, ptr %0, align 8, !tbaa !23
  %15 = icmp eq i64 %14, 0
  br i1 %15, label %16, label %21

16:                                               ; preds = %13
  %17 = getelementptr inbounds i8, ptr %0, i64 8
  %18 = load i64, ptr %17, align 8, !tbaa !24
  %19 = icmp eq i64 %18, 0
  br i1 %19, label %20, label %.thread

20:                                               ; preds = %16
  tail call void (ptr, ptr, ...) @strbuf_addf(ptr noundef %1, ptr noundef nonnull @.str.8) #3
  br label %31

21:                                               ; preds = %13
  %22 = icmp eq i64 %14, 1
  %23 = select i1 %22, ptr @.str.10, ptr @.str.11
  tail call void (ptr, ptr, ...) @strbuf_addf(ptr noundef %1, ptr noundef nonnull @.str.9, i64 noundef %14, ptr noundef nonnull %23) #3
  %.phi.trans.insert = getelementptr inbounds i8, ptr %0, i64 8
  %.pre = load i64, ptr %.phi.trans.insert, align 8, !tbaa !24
  %.not19 = icmp eq i64 %.pre, 0
  br i1 %.not19, label %24, label %.thread

24:                                               ; preds = %21
  %25 = load i64, ptr %0, align 8, !tbaa !23
  %26 = icmp eq i64 %25, 0
  br i1 %26, label %.thread, label %30

.thread:                                          ; preds = %16, %24, %21
  %27 = phi i64 [ 0, %24 ], [ %.pre, %21 ], [ %18, %16 ]
  %28 = icmp eq i64 %27, 1
  %29 = select i1 %28, ptr @.str.13, ptr @.str.14
  tail call void (ptr, ptr, ...) @strbuf_addf(ptr noundef %1, ptr noundef nonnull @.str.12, i64 noundef %27, ptr noundef nonnull %29) #3
  br label %30

30:                                               ; preds = %.thread, %24
  tail call void @strbuf_addch(ptr noundef %1, i32 noundef 10)
  br label %31

31:                                               ; preds = %30, %20
  ret void
}

declare void @strbuf_addf(ptr noundef, ptr noundef, ...) local_unnamed_addr #1

; Function Attrs: inlinehint nounwind uwtable
declare hidden void @strbuf_addch(ptr noundef, i32 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 = { "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 = { 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 #3 = { 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, !10, i64 24}
!6 = !{!"basic_delta_result", !7, i64 0, !7, i64 8, !7, i64 16, !10, i64 24, !11, i64 32, !11, i64 56}
!7 = !{!"long", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"any pointer", !8, i64 0}
!11 = !{!"strbuf_list", !10, i64 0, !10, i64 8, !7, i64 16}
!12 = !{!13, !10, i64 0}
!13 = !{!"delta_input", !10, i64 0, !10, i64 8, !14, i64 16, !14, i64 64}
!14 = !{!"deltafile", !15, i64 0, !10, i64 24, !7, i64 32, !8, i64 40}
!15 = !{!"strbuf", !7, i64 0, !7, i64 8, !10, i64 16}
!16 = !{!17, !10, i64 16}
!17 = !{!"filespec", !15, i64 0, !10, i64 24, !7, i64 32, !18, i64 40, !21, i64 184, !8, i64 192, !7, i64 216, !15, i64 224, !19, i64 248}
!18 = !{!"stat", !7, i64 0, !7, i64 8, !7, i64 16, !19, i64 24, !19, i64 28, !19, i64 32, !19, i64 36, !7, i64 40, !7, i64 48, !7, i64 56, !7, i64 64, !20, i64 72, !20, i64 88, !20, i64 104, !8, i64 120}
!19 = !{!"int", !8, i64 0}
!20 = !{!"timespec", !7, i64 0, !7, i64 8}
!21 = !{!"filecache", !10, i64 0}
!22 = !{!13, !10, i64 8}
!23 = !{!6, !7, i64 0}
!24 = !{!6, !7, i64 8}


; Effective O3 passes: BDCEPass,CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,InstCombinePass,JumpThreadingPass,PostOrderFunctionAttrsPass,SCCPPass,SROAPass,TailCallElimPass