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

; 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.d_node = type { %struct.strbuf, ptr, ptr, ptr }
%struct.strbuf = type { i64, i64, ptr }
%struct.dirent = type { i64, i64, i16, i8, [256 x i8] }

@d_root = external dso_local global ptr, align 8
@d_sptr = external dso_local global ptr, align 8
@d_ptr = external dso_local global ptr, align 8

declare void @strbuf_init(ptr noundef, i64 noundef) #0

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

; Function Attrs: nounwind uwtable
define dso_local void @push(ptr noundef %0, ptr noundef %1) #2 {
  %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 = call noalias ptr @malloc(i64 noundef 48) #4
  store ptr %5, ptr @d_ptr, align 8, !tbaa !5
  %6 = load ptr, ptr @d_ptr, align 8, !tbaa !5
  %7 = getelementptr inbounds %struct.d_node, ptr %6, i32 0, i32 0
  call void @strbuf_init(ptr noundef %7, i64 noundef 0)
  %8 = load ptr, ptr @d_ptr, align 8, !tbaa !5
  %9 = getelementptr inbounds %struct.d_node, ptr %8, i32 0, i32 0
  %10 = load ptr, ptr %3, align 8, !tbaa !5
  %11 = getelementptr inbounds %struct.dirent, ptr %10, i32 0, i32 4
  %12 = getelementptr inbounds [256 x i8], ptr %11, i64 0, i64 0
  call void @strbuf_addstr(ptr noundef %9, ptr noundef %12)
  %13 = load ptr, ptr %4, align 8, !tbaa !5
  %14 = load ptr, ptr @d_ptr, align 8, !tbaa !5
  %15 = getelementptr inbounds %struct.d_node, ptr %14, i32 0, i32 1
  store ptr %13, ptr %15, align 8, !tbaa !9
  %16 = load ptr, ptr @d_ptr, align 8, !tbaa !5
  %17 = getelementptr inbounds %struct.d_node, ptr %16, i32 0, i32 2
  store ptr null, ptr %17, align 8, !tbaa !13
  %18 = load ptr, ptr @d_root, align 8, !tbaa !5
  %19 = icmp eq ptr %18, null
  br i1 %19, label %20, label %25

20:                                               ; preds = %2
  %21 = load ptr, ptr @d_ptr, align 8, !tbaa !5
  store ptr %21, ptr @d_root, align 8, !tbaa !5
  %22 = load ptr, ptr @d_ptr, align 8, !tbaa !5
  store ptr %22, ptr @d_sptr, align 8, !tbaa !5
  %23 = load ptr, ptr @d_ptr, align 8, !tbaa !5
  %24 = getelementptr inbounds %struct.d_node, ptr %23, i32 0, i32 3
  store ptr null, ptr %24, align 8, !tbaa !14
  br label %33

25:                                               ; preds = %2
  %26 = load ptr, ptr @d_ptr, align 8, !tbaa !5
  %27 = load ptr, ptr @d_sptr, align 8, !tbaa !5
  %28 = getelementptr inbounds %struct.d_node, ptr %27, i32 0, i32 2
  store ptr %26, ptr %28, align 8, !tbaa !13
  %29 = load ptr, ptr @d_sptr, align 8, !tbaa !5
  %30 = load ptr, ptr @d_ptr, align 8, !tbaa !5
  %31 = getelementptr inbounds %struct.d_node, ptr %30, i32 0, i32 3
  store ptr %29, ptr %31, align 8, !tbaa !14
  %32 = load ptr, ptr @d_ptr, align 8, !tbaa !5
  store ptr %32, ptr @d_sptr, align 8, !tbaa !5
  br label %33

33:                                               ; preds = %25, %20
  ret void
}

; Function Attrs: nounwind allocsize(0)
declare noalias ptr @malloc(i64 noundef) #3

attributes #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 = { 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 #2 = { 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 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 #4 = { 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, !6, i64 24}
!10 = !{!"d_node", !11, i64 0, !6, i64 24, !6, i64 32, !6, i64 40}
!11 = !{!"strbuf", !12, i64 0, !12, i64 8, !6, i64 16}
!12 = !{!"long", !7, i64 0}
!13 = !{!10, !6, i64 32}
!14 = !{!10, !6, i64 40}


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

@d_root = external dso_local local_unnamed_addr global ptr, align 8
@d_sptr = external dso_local local_unnamed_addr global ptr, align 8
@d_ptr = external dso_local local_unnamed_addr global ptr, align 8

declare void @strbuf_init(ptr noundef, i64 noundef) local_unnamed_addr #0

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

; Function Attrs: nounwind uwtable
define dso_local void @push(ptr noundef %0, ptr noundef %1) local_unnamed_addr #2 {
  %3 = tail call noalias dereferenceable_or_null(48) ptr @malloc(i64 noundef 48) #4
  store ptr %3, ptr @d_ptr, align 8, !tbaa !5
  tail call void @strbuf_init(ptr noundef %3, i64 noundef 0) #5
  %4 = load ptr, ptr @d_ptr, align 8, !tbaa !5
  %5 = getelementptr inbounds i8, ptr %0, i64 19
  tail call void @strbuf_addstr(ptr noundef %4, ptr noundef nonnull %5)
  %6 = load ptr, ptr @d_ptr, align 8, !tbaa !5
  %7 = getelementptr inbounds i8, ptr %6, i64 24
  store ptr %1, ptr %7, align 8, !tbaa !9
  %8 = getelementptr inbounds i8, ptr %6, i64 32
  store ptr null, ptr %8, align 8, !tbaa !13
  %9 = load ptr, ptr @d_root, align 8, !tbaa !5
  %10 = icmp eq ptr %9, null
  %11 = load ptr, ptr @d_sptr, align 8
  %12 = getelementptr inbounds i8, ptr %11, i64 32
  %.sink2 = select i1 %10, ptr @d_root, ptr %12
  %.sink = select i1 %10, ptr null, ptr %11
  store ptr %6, ptr %.sink2, align 8, !tbaa !5
  store ptr %6, ptr @d_sptr, align 8
  %13 = getelementptr inbounds i8, ptr %6, i64 40
  store ptr %.sink, ptr %13, align 8
  ret void
}

; Function Attrs: mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite)
declare noalias noundef ptr @malloc(i64 noundef) local_unnamed_addr #3

attributes #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 = { 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 #2 = { 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 = { 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 #4 = { nounwind allocsize(0) }
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, !6, i64 24}
!10 = !{!"d_node", !11, i64 0, !6, i64 24, !6, i64 32, !6, i64 40}
!11 = !{!"strbuf", !12, i64 0, !12, i64 8, !6, i64 16}
!12 = !{!"long", !7, i64 0}
!13 = !{!10, !6, i64 32}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,MergedLoadStoreMotionPass,SROAPass,SimplifyCFGPass,TailCallElimPass