; LLVM IR from Water-Melon/Melon :: src (mln_parser_generator)

; 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.mln_rbtree_attr = type { ptr, ptr, ptr, ptr, ptr }
%struct.mln_pg_item_s = type { ptr, ptr, ptr, ptr, i64, ptr, i32 }

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #0

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

; Function Attrs: nounwind uwtable
declare dso_local i32 @mln_pg_token_rbtree_cmp(ptr noundef, ptr noundef) #2

declare ptr @mln_rbtree_new(ptr noundef) #3

; 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 ptr @mln_pg_item_new() #2 {
  %1 = alloca ptr, align 8
  %2 = alloca ptr, align 8
  %3 = alloca i32, align 4
  %4 = alloca %struct.mln_rbtree_attr, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr %2) #4
  %5 = call noalias ptr @malloc(i64 noundef 56) #5
  store ptr %5, ptr %2, align 8, !tbaa !5
  %6 = load ptr, ptr %2, align 8, !tbaa !5
  %7 = icmp eq ptr %6, null
  br i1 %7, label %8, label %9

8:                                                ; preds = %0
  store ptr null, ptr %1, align 8
  store i32 1, ptr %3, align 4
  br label %41

9:                                                ; preds = %0
  %10 = load ptr, ptr %2, align 8, !tbaa !5
  %11 = getelementptr inbounds %struct.mln_pg_item_s, ptr %10, i32 0, i32 0
  store ptr null, ptr %11, align 8, !tbaa !9
  %12 = load ptr, ptr %2, align 8, !tbaa !5
  %13 = getelementptr inbounds %struct.mln_pg_item_s, ptr %12, i32 0, i32 1
  store ptr null, ptr %13, align 8, !tbaa !13
  %14 = load ptr, ptr %2, align 8, !tbaa !5
  %15 = getelementptr inbounds %struct.mln_pg_item_s, ptr %14, i32 0, i32 2
  store ptr null, ptr %15, align 8, !tbaa !14
  %16 = load ptr, ptr %2, align 8, !tbaa !5
  %17 = getelementptr inbounds %struct.mln_pg_item_s, ptr %16, i32 0, i32 3
  store ptr null, ptr %17, align 8, !tbaa !15
  %18 = load ptr, ptr %2, align 8, !tbaa !5
  %19 = getelementptr inbounds %struct.mln_pg_item_s, ptr %18, i32 0, i32 4
  store i64 -1, ptr %19, align 8, !tbaa !16
  %20 = load ptr, ptr %2, align 8, !tbaa !5
  %21 = getelementptr inbounds %struct.mln_pg_item_s, ptr %20, i32 0, i32 5
  store ptr null, ptr %21, align 8, !tbaa !17
  %22 = load ptr, ptr %2, align 8, !tbaa !5
  %23 = getelementptr inbounds %struct.mln_pg_item_s, ptr %22, i32 0, i32 6
  store i32 0, ptr %23, align 8, !tbaa !18
  call void @llvm.lifetime.start.p0(i64 40, ptr %4) #4
  %24 = getelementptr inbounds %struct.mln_rbtree_attr, ptr %4, i32 0, i32 0
  store ptr null, ptr %24, align 8, !tbaa !19
  %25 = getelementptr inbounds %struct.mln_rbtree_attr, ptr %4, i32 0, i32 1
  store ptr null, ptr %25, align 8, !tbaa !21
  %26 = getelementptr inbounds %struct.mln_rbtree_attr, ptr %4, i32 0, i32 2
  store ptr null, ptr %26, align 8, !tbaa !22
  %27 = getelementptr inbounds %struct.mln_rbtree_attr, ptr %4, i32 0, i32 3
  store ptr @mln_pg_token_rbtree_cmp, ptr %27, align 8, !tbaa !23
  %28 = getelementptr inbounds %struct.mln_rbtree_attr, ptr %4, i32 0, i32 4
  store ptr null, ptr %28, align 8, !tbaa !24
  %29 = call ptr @mln_rbtree_new(ptr noundef %4)
  %30 = load ptr, ptr %2, align 8, !tbaa !5
  %31 = getelementptr inbounds %struct.mln_pg_item_s, ptr %30, i32 0, i32 2
  store ptr %29, ptr %31, align 8, !tbaa !14
  %32 = load ptr, ptr %2, align 8, !tbaa !5
  %33 = getelementptr inbounds %struct.mln_pg_item_s, ptr %32, i32 0, i32 2
  %34 = load ptr, ptr %33, align 8, !tbaa !14
  %35 = icmp eq ptr %34, null
  br i1 %35, label %36, label %38

36:                                               ; preds = %9
  %37 = load ptr, ptr %2, align 8, !tbaa !5
  call void @mln_pg_item_free(ptr noundef %37)
  store ptr null, ptr %1, align 8
  store i32 1, ptr %3, align 4
  br label %40

38:                                               ; preds = %9
  %39 = load ptr, ptr %2, align 8, !tbaa !5
  store ptr %39, ptr %1, align 8
  store i32 1, ptr %3, align 4
  br label %40

40:                                               ; preds = %38, %36
  call void @llvm.lifetime.end.p0(i64 40, ptr %4) #4
  br label %41

41:                                               ; preds = %40, %8
  call void @llvm.lifetime.end.p0(i64 8, ptr %2) #4
  %42 = load ptr, ptr %1, align 8
  ret ptr %42
}

; Function Attrs: nounwind uwtable
declare dso_local void @mln_pg_item_free(ptr 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 = { 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 = { "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 }
attributes #5 = { 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 0}
!10 = !{!"mln_pg_item_s", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !11, i64 32, !6, i64 40, !12, i64 48}
!11 = !{!"long", !7, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = !{!10, !6, i64 8}
!14 = !{!10, !6, i64 16}
!15 = !{!10, !6, i64 24}
!16 = !{!10, !11, i64 32}
!17 = !{!10, !6, i64 40}
!18 = !{!10, !12, i64 48}
!19 = !{!20, !6, i64 0}
!20 = !{!"mln_rbtree_attr", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32}
!21 = !{!20, !6, i64 8}
!22 = !{!20, !6, i64 16}
!23 = !{!20, !6, i64 24}
!24 = !{!20, !6, i64 32}


; 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.mln_rbtree_attr = type { ptr, ptr, ptr, ptr, ptr }

; 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 nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite)
declare noalias noundef ptr @malloc(i64 noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
declare dso_local i32 @mln_pg_token_rbtree_cmp(ptr noundef, ptr noundef) #2

declare ptr @mln_rbtree_new(ptr noundef) local_unnamed_addr #3

; 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
define dso_local noundef ptr @mln_pg_item_new() local_unnamed_addr #2 {
  %1 = alloca %struct.mln_rbtree_attr, align 8
  %2 = tail call noalias dereferenceable_or_null(56) ptr @malloc(i64 noundef 56) #5
  %3 = icmp eq ptr %2, null
  br i1 %3, label %15, label %4

4:                                                ; preds = %0
  %5 = getelementptr inbounds i8, ptr %2, i64 16
  %6 = getelementptr inbounds i8, ptr %2, i64 32
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(32) %2, i8 0, i64 32, i1 false)
  store i64 -1, ptr %6, align 8, !tbaa !5
  %7 = getelementptr inbounds i8, ptr %2, i64 40
  store ptr null, ptr %7, align 8, !tbaa !12
  %8 = getelementptr inbounds i8, ptr %2, i64 48
  store i32 0, ptr %8, align 8, !tbaa !13
  call void @llvm.lifetime.start.p0(i64 40, ptr nonnull %1) #6
  %9 = getelementptr inbounds i8, ptr %1, i64 24
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(24) %1, i8 0, i64 24, i1 false)
  store ptr @mln_pg_token_rbtree_cmp, ptr %9, align 8, !tbaa !14
  %10 = getelementptr inbounds i8, ptr %1, i64 32
  store ptr null, ptr %10, align 8, !tbaa !16
  %11 = call ptr @mln_rbtree_new(ptr noundef nonnull %1) #6
  store ptr %11, ptr %5, align 8, !tbaa !17
  %12 = icmp eq ptr %11, null
  br i1 %12, label %13, label %14

13:                                               ; preds = %4
  call void @mln_pg_item_free(ptr noundef nonnull %2)
  br label %14

14:                                               ; preds = %4, %13
  %.0 = phi ptr [ null, %13 ], [ %2, %4 ]
  call void @llvm.lifetime.end.p0(i64 40, ptr nonnull %1) #6
  br label %15

15:                                               ; preds = %0, %14
  %.1 = phi ptr [ %.0, %14 ], [ null, %0 ]
  ret ptr %.1
}

; Function Attrs: nounwind uwtable
declare dso_local void @mln_pg_item_free(ptr noundef) local_unnamed_addr #2

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #4

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 = { 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 = { "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: write) }
attributes #5 = { nounwind allocsize(0) }
attributes #6 = { 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 32}
!6 = !{!"mln_pg_item_s", !7, i64 0, !7, i64 8, !7, i64 16, !7, i64 24, !10, i64 32, !7, i64 40, !11, i64 48}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"long", !8, i64 0}
!11 = !{!"int", !8, i64 0}
!12 = !{!6, !7, i64 40}
!13 = !{!6, !11, i64 48}
!14 = !{!15, !7, i64 24}
!15 = !{!"mln_rbtree_attr", !7, i64 0, !7, i64 8, !7, i64 16, !7, i64 24, !7, i64 32}
!16 = !{!15, !7, i64 32}
!17 = !{!6, !7, i64 16}


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