; 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_token_s = type { ptr, ptr, ptr, ptr, ptr, i32, i8 }

; Function Attrs: nounwind uwtable
define dso_local ptr @mln_pg_token_new(ptr noundef %0, i32 noundef %1) #0 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca i32, align 4
  %6 = alloca ptr, align 8
  %7 = alloca i32, align 4
  %8 = alloca %struct.mln_rbtree_attr, align 8
  store ptr %0, ptr %4, align 8, !tbaa !5
  store i32 %1, ptr %5, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #5
  %9 = call noalias ptr @malloc(i64 noundef 48) #6
  store ptr %9, ptr %6, align 8, !tbaa !5
  %10 = load ptr, ptr %6, align 8, !tbaa !5
  %11 = icmp eq ptr %10, null
  br i1 %11, label %12, label %13

12:                                               ; preds = %2
  store ptr null, ptr %3, align 8
  store i32 1, ptr %7, align 4
  br label %98

13:                                               ; preds = %2
  %14 = load ptr, ptr %6, align 8, !tbaa !5
  %15 = getelementptr inbounds %struct.mln_pg_token_s, ptr %14, i32 0, i32 0
  store ptr null, ptr %15, align 8, !tbaa !11
  %16 = load ptr, ptr %6, align 8, !tbaa !5
  %17 = getelementptr inbounds %struct.mln_pg_token_s, ptr %16, i32 0, i32 1
  store ptr null, ptr %17, align 8, !tbaa !13
  %18 = load ptr, ptr %6, align 8, !tbaa !5
  %19 = getelementptr inbounds %struct.mln_pg_token_s, ptr %18, i32 0, i32 2
  store ptr null, ptr %19, align 8, !tbaa !14
  %20 = load ptr, ptr %6, align 8, !tbaa !5
  %21 = getelementptr inbounds %struct.mln_pg_token_s, ptr %20, i32 0, i32 3
  store ptr null, ptr %21, align 8, !tbaa !15
  %22 = load ptr, ptr %6, align 8, !tbaa !5
  %23 = getelementptr inbounds %struct.mln_pg_token_s, ptr %22, i32 0, i32 4
  store ptr null, ptr %23, align 8, !tbaa !16
  %24 = load ptr, ptr %6, align 8, !tbaa !5
  %25 = getelementptr inbounds %struct.mln_pg_token_s, ptr %24, i32 0, i32 5
  store i32 -1, ptr %25, align 8, !tbaa !17
  %26 = load ptr, ptr %6, align 8, !tbaa !5
  %27 = getelementptr inbounds %struct.mln_pg_token_s, ptr %26, i32 0, i32 6
  %28 = load i8, ptr %27, align 4
  %29 = and i8 %28, -2
  %30 = or i8 %29, 0
  store i8 %30, ptr %27, align 4
  %31 = load ptr, ptr %6, align 8, !tbaa !5
  %32 = getelementptr inbounds %struct.mln_pg_token_s, ptr %31, i32 0, i32 6
  %33 = load i8, ptr %32, align 4
  %34 = and i8 %33, -3
  %35 = or i8 %34, 0
  store i8 %35, ptr %32, align 4
  %36 = load ptr, ptr %4, align 8, !tbaa !5
  %37 = call ptr @mln_string_dup(ptr noundef %36)
  %38 = load ptr, ptr %6, align 8, !tbaa !5
  %39 = getelementptr inbounds %struct.mln_pg_token_s, ptr %38, i32 0, i32 0
  store ptr %37, ptr %39, align 8, !tbaa !11
  %40 = load ptr, ptr %6, align 8, !tbaa !5
  %41 = getelementptr inbounds %struct.mln_pg_token_s, ptr %40, i32 0, i32 0
  %42 = load ptr, ptr %41, align 8, !tbaa !11
  %43 = icmp eq ptr %42, null
  br i1 %43, label %44, label %46

44:                                               ; preds = %13
  %45 = load ptr, ptr %6, align 8, !tbaa !5
  call void @mln_pg_token_free(ptr noundef %45)
  store ptr null, ptr %3, align 8
  store i32 1, ptr %7, align 4
  br label %98

46:                                               ; preds = %13
  call void @llvm.lifetime.start.p0(i64 40, ptr %8) #5
  %47 = getelementptr inbounds %struct.mln_rbtree_attr, ptr %8, i32 0, i32 0
  store ptr null, ptr %47, align 8, !tbaa !18
  %48 = getelementptr inbounds %struct.mln_rbtree_attr, ptr %8, i32 0, i32 1
  store ptr null, ptr %48, align 8, !tbaa !20
  %49 = getelementptr inbounds %struct.mln_rbtree_attr, ptr %8, i32 0, i32 2
  store ptr null, ptr %49, align 8, !tbaa !21
  %50 = getelementptr inbounds %struct.mln_rbtree_attr, ptr %8, i32 0, i32 3
  store ptr @mln_pg_token_rbtree_cmp, ptr %50, align 8, !tbaa !22
  %51 = getelementptr inbounds %struct.mln_rbtree_attr, ptr %8, i32 0, i32 4
  store ptr null, ptr %51, align 8, !tbaa !23
  %52 = call ptr @mln_rbtree_new(ptr noundef %8)
  %53 = load ptr, ptr %6, align 8, !tbaa !5
  %54 = getelementptr inbounds %struct.mln_pg_token_s, ptr %53, i32 0, i32 1
  store ptr %52, ptr %54, align 8, !tbaa !13
  %55 = load ptr, ptr %6, align 8, !tbaa !5
  %56 = getelementptr inbounds %struct.mln_pg_token_s, ptr %55, i32 0, i32 1
  %57 = load ptr, ptr %56, align 8, !tbaa !13
  %58 = icmp eq ptr %57, null
  br i1 %58, label %59, label %61

59:                                               ; preds = %46
  %60 = load ptr, ptr %6, align 8, !tbaa !5
  call void @mln_pg_token_free(ptr noundef %60)
  store ptr null, ptr %3, align 8
  store i32 1, ptr %7, align 4
  br label %97

61:                                               ; preds = %46
  %62 = call ptr @mln_rbtree_new(ptr noundef %8)
  %63 = load ptr, ptr %6, align 8, !tbaa !5
  %64 = getelementptr inbounds %struct.mln_pg_token_s, ptr %63, i32 0, i32 2
  store ptr %62, ptr %64, align 8, !tbaa !14
  %65 = load ptr, ptr %6, align 8, !tbaa !5
  %66 = getelementptr inbounds %struct.mln_pg_token_s, ptr %65, i32 0, i32 2
  %67 = load ptr, ptr %66, align 8, !tbaa !14
  %68 = icmp eq ptr %67, null
  br i1 %68, label %69, label %71

69:                                               ; preds = %61
  %70 = load ptr, ptr %6, align 8, !tbaa !5
  call void @mln_pg_token_free(ptr noundef %70)
  store ptr null, ptr %3, align 8
  store i32 1, ptr %7, align 4
  br label %97

71:                                               ; preds = %61
  %72 = load i32, ptr %5, align 4, !tbaa !9
  %73 = zext i32 %72 to i64
  %74 = call noalias ptr @calloc(i64 noundef %73, i64 noundef 4) #7
  %75 = load ptr, ptr %6, align 8, !tbaa !5
  %76 = getelementptr inbounds %struct.mln_pg_token_s, ptr %75, i32 0, i32 3
  store ptr %74, ptr %76, align 8, !tbaa !15
  %77 = load ptr, ptr %6, align 8, !tbaa !5
  %78 = getelementptr inbounds %struct.mln_pg_token_s, ptr %77, i32 0, i32 3
  %79 = load ptr, ptr %78, align 8, !tbaa !15
  %80 = icmp eq ptr %79, null
  br i1 %80, label %81, label %83

81:                                               ; preds = %71
  %82 = load ptr, ptr %6, align 8, !tbaa !5
  call void @mln_pg_token_free(ptr noundef %82)
  store ptr null, ptr %3, align 8
  store i32 1, ptr %7, align 4
  br label %97

83:                                               ; preds = %71
  %84 = load i32, ptr %5, align 4, !tbaa !9
  %85 = zext i32 %84 to i64
  %86 = call noalias ptr @calloc(i64 noundef %85, i64 noundef 4) #7
  %87 = load ptr, ptr %6, align 8, !tbaa !5
  %88 = getelementptr inbounds %struct.mln_pg_token_s, ptr %87, i32 0, i32 4
  store ptr %86, ptr %88, align 8, !tbaa !16
  %89 = load ptr, ptr %6, align 8, !tbaa !5
  %90 = getelementptr inbounds %struct.mln_pg_token_s, ptr %89, i32 0, i32 4
  %91 = load ptr, ptr %90, align 8, !tbaa !16
  %92 = icmp eq ptr %91, null
  br i1 %92, label %93, label %95

93:                                               ; preds = %83
  %94 = load ptr, ptr %6, align 8, !tbaa !5
  call void @mln_pg_token_free(ptr noundef %94)
  store ptr null, ptr %3, align 8
  store i32 1, ptr %7, align 4
  br label %97

95:                                               ; preds = %83
  %96 = load ptr, ptr %6, align 8, !tbaa !5
  store ptr %96, ptr %3, align 8
  store i32 1, ptr %7, align 4
  br label %97

97:                                               ; preds = %95, %93, %81, %69, %59
  call void @llvm.lifetime.end.p0(i64 40, ptr %8) #5
  br label %98

98:                                               ; preds = %97, %44, %12
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #5
  %99 = load ptr, ptr %3, align 8
  ret ptr %99
}

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

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

declare ptr @mln_string_dup(ptr noundef) #3

; Function Attrs: nounwind uwtable
declare dso_local void @mln_pg_token_free(ptr noundef) #0

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

declare ptr @mln_rbtree_new(ptr noundef) #3

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

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

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

!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, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!12, !6, i64 0}
!12 = !{!"mln_pg_token_s", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !10, i64 40, !10, i64 44, !10, i64 44}
!13 = !{!12, !6, i64 8}
!14 = !{!12, !6, i64 16}
!15 = !{!12, !6, i64 24}
!16 = !{!12, !6, i64 32}
!17 = !{!12, !10, i64 40}
!18 = !{!19, !6, i64 0}
!19 = !{!"mln_rbtree_attr", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32}
!20 = !{!19, !6, i64 8}
!21 = !{!19, !6, i64 16}
!22 = !{!19, !6, i64 24}
!23 = !{!19, !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: nounwind uwtable
define dso_local noundef ptr @mln_pg_token_new(ptr noundef %0, i32 noundef %1) local_unnamed_addr #0 {
  %3 = alloca %struct.mln_rbtree_attr, align 8
  %4 = tail call noalias dereferenceable_or_null(48) ptr @malloc(i64 noundef 48) #6
  %5 = icmp eq ptr %4, null
  br i1 %5, label %33, label %6

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

15:                                               ; preds = %6
  tail call void @mln_pg_token_free(ptr noundef nonnull %4)
  br label %33

16:                                               ; preds = %6
  %17 = getelementptr inbounds i8, ptr %4, i64 8
  call void @llvm.lifetime.start.p0(i64 40, ptr nonnull %3) #7
  %18 = getelementptr inbounds i8, ptr %3, i64 24
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(24) %3, i8 0, i64 24, i1 false)
  store ptr @mln_pg_token_rbtree_cmp, ptr %18, align 8, !tbaa !12
  %19 = getelementptr inbounds i8, ptr %3, i64 32
  store ptr null, ptr %19, align 8, !tbaa !14
  %20 = call ptr @mln_rbtree_new(ptr noundef nonnull %3) #7
  store ptr %20, ptr %17, align 8, !tbaa !15
  %21 = icmp eq ptr %20, null
  br i1 %21, label %.sink.split, label %22

22:                                               ; preds = %16
  %23 = call ptr @mln_rbtree_new(ptr noundef nonnull %3) #7
  store ptr %23, ptr %7, align 8, !tbaa !16
  %24 = icmp eq ptr %23, null
  br i1 %24, label %.sink.split, label %25

25:                                               ; preds = %22
  %26 = zext i32 %1 to i64
  %27 = call noalias ptr @calloc(i64 noundef %26, i64 noundef 4) #8
  store ptr %27, ptr %8, align 8, !tbaa !17
  %28 = icmp eq ptr %27, null
  br i1 %28, label %.sink.split, label %29

29:                                               ; preds = %25
  %30 = call noalias ptr @calloc(i64 noundef %26, i64 noundef 4) #8
  store ptr %30, ptr %9, align 8, !tbaa !18
  %31 = icmp eq ptr %30, null
  br i1 %31, label %.sink.split, label %32

.sink.split:                                      ; preds = %29, %25, %22, %16
  call void @mln_pg_token_free(ptr noundef nonnull %4)
  br label %32

32:                                               ; preds = %.sink.split, %29
  %.0 = phi ptr [ %4, %29 ], [ null, %.sink.split ]
  call void @llvm.lifetime.end.p0(i64 40, ptr nonnull %3) #7
  br label %33

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

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

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

declare ptr @mln_string_dup(ptr noundef) local_unnamed_addr #3

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

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

declare ptr @mln_rbtree_new(ptr noundef) local_unnamed_addr #3

; Function Attrs: mustprogress nofree nounwind willreturn allockind("alloc,zeroed") allocsize(0,1) memory(inaccessiblemem: readwrite)
declare noalias noundef ptr @calloc(i64 noundef, i64 noundef) local_unnamed_addr #4

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

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

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

!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 40}
!6 = !{!"mln_pg_token_s", !7, i64 0, !7, i64 8, !7, i64 16, !7, i64 24, !7, i64 32, !10, i64 40, !10, i64 44, !10, i64 44}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"int", !8, i64 0}
!11 = !{!6, !7, i64 0}
!12 = !{!13, !7, i64 24}
!13 = !{!"mln_rbtree_attr", !7, i64 0, !7, i64 8, !7, i64 16, !7, i64 24, !7, i64 32}
!14 = !{!13, !7, i64 32}
!15 = !{!6, !7, i64 8}
!16 = !{!6, !7, i64 16}
!17 = !{!6, !7, i64 24}
!18 = !{!6, !7, i64 32}


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