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

; 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_string_t = type { ptr, i64, i32 }
%struct.mln_lang_ctx_s = type { ptr, ptr, ptr, ptr, ptr, [1025 x %struct.mln_lang_stack_node_s], ptr, [1025 x %struct.mln_lang_scope_s], ptr, i64, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, i64, ptr, i32 }
%struct.mln_lang_stack_node_s = type { ptr, i32, i32, %union.anon, ptr, ptr, ptr }
%union.anon = type { ptr }
%struct.mln_lang_scope_s = type { i32, ptr, ptr, ptr, ptr, i64, ptr, ptr }
%struct.mln_lang_resource_s = type { ptr, ptr, ptr }

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

declare ptr @mln_alloc_m(ptr noundef, i64 noundef) #1

declare void @mln_alloc_free(ptr noundef) #1

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

declare ptr @mln_string_pool_dup(ptr noundef, ptr noundef) #1

declare ptr @mln_rbtree_node_new(ptr noundef, ptr noundef) #1

declare void @mln_rbtree_insert(ptr noundef, ptr noundef) #1

; Function Attrs: nounwind uwtable
define dso_local i32 @mln_lang_ctx_resource_register(ptr noundef nonnull %0, ptr noundef nonnull %1, ptr noundef %2, ptr noundef %3) #2 {
  %5 = alloca i32, align 4
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  %10 = alloca ptr, align 8
  %11 = alloca %struct.mln_string_t, align 8
  %12 = alloca ptr, align 8
  %13 = alloca i32, align 4
  %14 = alloca ptr, align 8
  store ptr %0, ptr %6, align 8, !tbaa !5
  store ptr %1, ptr %7, align 8, !tbaa !5
  store ptr %2, ptr %8, align 8, !tbaa !5
  store ptr %3, ptr %9, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #4
  call void @llvm.lifetime.start.p0(i64 24, ptr %11) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #4
  %15 = load ptr, ptr %6, align 8, !tbaa !5
  %16 = getelementptr inbounds %struct.mln_lang_ctx_s, ptr %15, i32 0, i32 1
  %17 = load ptr, ptr %16, align 8, !tbaa !9
  %18 = call ptr @mln_alloc_m(ptr noundef %17, i64 noundef 24)
  store ptr %18, ptr %12, align 8, !tbaa !5
  %19 = load ptr, ptr %12, align 8, !tbaa !5
  %20 = icmp eq ptr %19, null
  br i1 %20, label %21, label %22

21:                                               ; preds = %4
  store i32 -1, ptr %5, align 4
  store i32 1, ptr %13, align 4
  br label %70

22:                                               ; preds = %4
  %23 = load ptr, ptr %7, align 8, !tbaa !5
  %24 = getelementptr inbounds %struct.mln_string_t, ptr %11, i32 0, i32 0
  store ptr %23, ptr %24, align 8, !tbaa !13
  %25 = load ptr, ptr %7, align 8, !tbaa !5
  %26 = call i64 @strlen(ptr noundef %25) #5
  %27 = getelementptr inbounds %struct.mln_string_t, ptr %11, i32 0, i32 1
  store i64 %26, ptr %27, align 8, !tbaa !15
  %28 = getelementptr inbounds %struct.mln_string_t, ptr %11, i32 0, i32 2
  %29 = load i32, ptr %28, align 8
  %30 = and i32 %29, -2
  %31 = or i32 %30, 1
  store i32 %31, ptr %28, align 8
  %32 = getelementptr inbounds %struct.mln_string_t, ptr %11, i32 0, i32 2
  %33 = load i32, ptr %32, align 8
  %34 = and i32 %33, -3
  %35 = or i32 %34, 0
  store i32 %35, ptr %32, align 8
  %36 = getelementptr inbounds %struct.mln_string_t, ptr %11, i32 0, i32 2
  %37 = load i32, ptr %36, align 8
  %38 = and i32 %37, 3
  %39 = or i32 %38, 4
  store i32 %39, ptr %36, align 8
  store ptr %11, ptr %14, align 8, !tbaa !5
  %40 = load ptr, ptr %14, align 8, !tbaa !5
  %41 = load ptr, ptr %6, align 8, !tbaa !5
  %42 = getelementptr inbounds %struct.mln_lang_ctx_s, ptr %41, i32 0, i32 1
  %43 = load ptr, ptr %42, align 8, !tbaa !9
  %44 = call ptr @mln_string_pool_dup(ptr noundef %43, ptr noundef %11)
  %45 = load ptr, ptr %12, align 8, !tbaa !5
  %46 = getelementptr inbounds %struct.mln_lang_resource_s, ptr %45, i32 0, i32 0
  store ptr %44, ptr %46, align 8, !tbaa !16
  %47 = icmp eq ptr %44, null
  br i1 %47, label %48, label %50

48:                                               ; preds = %22
  %49 = load ptr, ptr %12, align 8, !tbaa !5
  call void @mln_alloc_free(ptr noundef %49)
  store i32 -1, ptr %5, align 4
  store i32 1, ptr %13, align 4
  br label %70

50:                                               ; preds = %22
  %51 = load ptr, ptr %8, align 8, !tbaa !5
  %52 = load ptr, ptr %12, align 8, !tbaa !5
  %53 = getelementptr inbounds %struct.mln_lang_resource_s, ptr %52, i32 0, i32 1
  store ptr %51, ptr %53, align 8, !tbaa !18
  %54 = load ptr, ptr %9, align 8, !tbaa !5
  %55 = load ptr, ptr %12, align 8, !tbaa !5
  %56 = getelementptr inbounds %struct.mln_lang_resource_s, ptr %55, i32 0, i32 2
  store ptr %54, ptr %56, align 8, !tbaa !19
  %57 = load ptr, ptr %6, align 8, !tbaa !5
  %58 = getelementptr inbounds %struct.mln_lang_ctx_s, ptr %57, i32 0, i32 11
  %59 = load ptr, ptr %58, align 8, !tbaa !20
  %60 = load ptr, ptr %12, align 8, !tbaa !5
  %61 = call ptr @mln_rbtree_node_new(ptr noundef %59, ptr noundef %60)
  store ptr %61, ptr %10, align 8, !tbaa !5
  %62 = icmp eq ptr %61, null
  br i1 %62, label %63, label %65

63:                                               ; preds = %50
  %64 = load ptr, ptr %12, align 8, !tbaa !5
  call void @mln_lang_ctx_resource_free_handler(ptr noundef %64)
  store i32 -1, ptr %5, align 4
  store i32 1, ptr %13, align 4
  br label %70

65:                                               ; preds = %50
  %66 = load ptr, ptr %6, align 8, !tbaa !5
  %67 = getelementptr inbounds %struct.mln_lang_ctx_s, ptr %66, i32 0, i32 11
  %68 = load ptr, ptr %67, align 8, !tbaa !20
  %69 = load ptr, ptr %10, align 8, !tbaa !5
  call void @mln_rbtree_insert(ptr noundef %68, ptr noundef %69)
  store i32 0, ptr %5, align 4
  store i32 1, ptr %13, align 4
  br label %70

70:                                               ; preds = %65, %63, %48, %21
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #4
  call void @llvm.lifetime.end.p0(i64 24, ptr %11) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #4
  %71 = load i32, ptr %5, align 4
  ret i32 %71
}

; Function Attrs: nounwind willreturn memory(read)
declare i64 @strlen(ptr noundef) #3

; Function Attrs: nounwind uwtable
declare hidden void @mln_lang_ctx_resource_free_handler(ptr noundef) #2

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

!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 8}
!10 = !{!"mln_lang_ctx_s", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !7, i64 40, !6, i64 49240, !7, i64 49248, !6, i64 114848, !11, i64 114856, !6, i64 114864, !6, i64 114872, !6, i64 114880, !6, i64 114888, !6, i64 114896, !6, i64 114904, !6, i64 114912, !6, i64 114920, !6, i64 114928, !6, i64 114936, !6, i64 114944, !11, i64 114952, !6, i64 114960, !12, i64 114968, !12, i64 114970, !12, i64 114970, !12, i64 114970, !12, i64 114970, !12, i64 114970, !12, i64 114970, !12, i64 114970, !12, i64 114970, !12, i64 114971, !12, i64 114971, !12, i64 114971}
!11 = !{!"long", !7, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = !{!14, !6, i64 0}
!14 = !{!"", !6, i64 0, !11, i64 8, !11, i64 16, !11, i64 16, !11, i64 16}
!15 = !{!14, !11, i64 8}
!16 = !{!17, !6, i64 0}
!17 = !{!"mln_lang_resource_s", !6, i64 0, !6, i64 8, !6, i64 16}
!18 = !{!17, !6, i64 8}
!19 = !{!17, !6, i64 16}
!20 = !{!10, !6, i64 114872}


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

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

declare ptr @mln_alloc_m(ptr noundef, i64 noundef) local_unnamed_addr #1

declare void @mln_alloc_free(ptr noundef) local_unnamed_addr #1

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

declare ptr @mln_string_pool_dup(ptr noundef, ptr noundef) local_unnamed_addr #1

declare ptr @mln_rbtree_node_new(ptr noundef, ptr noundef) local_unnamed_addr #1

declare void @mln_rbtree_insert(ptr noundef, ptr noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
define dso_local range(i32 -1, 1) i32 @mln_lang_ctx_resource_register(ptr nocapture noundef nonnull readonly %0, ptr noundef nonnull %1, ptr noundef %2, ptr noundef %3) local_unnamed_addr #2 {
  %5 = alloca %struct.mln_string_t, align 8
  call void @llvm.lifetime.start.p0(i64 24, ptr nonnull %5) #4
  %6 = getelementptr inbounds i8, ptr %0, i64 8
  %7 = load ptr, ptr %6, align 8, !tbaa !5
  %8 = tail call ptr @mln_alloc_m(ptr noundef %7, i64 noundef 24) #4
  %9 = icmp eq ptr %8, null
  br i1 %9, label %28, label %10

10:                                               ; preds = %4
  store ptr %1, ptr %5, align 8, !tbaa !12
  %11 = tail call i64 @strlen(ptr noundef nonnull dereferenceable(1) %1) #5
  %12 = getelementptr inbounds i8, ptr %5, i64 8
  store i64 %11, ptr %12, align 8, !tbaa !14
  %13 = getelementptr inbounds i8, ptr %5, i64 16
  store i32 5, ptr %13, align 8
  %14 = load ptr, ptr %6, align 8, !tbaa !5
  %15 = call ptr @mln_string_pool_dup(ptr noundef %14, ptr noundef nonnull %5) #4
  store ptr %15, ptr %8, align 8, !tbaa !15
  %16 = icmp eq ptr %15, null
  br i1 %16, label %17, label %18

17:                                               ; preds = %10
  call void @mln_alloc_free(ptr noundef nonnull %8) #4
  br label %28

18:                                               ; preds = %10
  %19 = getelementptr inbounds i8, ptr %8, i64 8
  store ptr %2, ptr %19, align 8, !tbaa !17
  %20 = getelementptr inbounds i8, ptr %8, i64 16
  store ptr %3, ptr %20, align 8, !tbaa !18
  %21 = getelementptr inbounds i8, ptr %0, i64 114872
  %22 = load ptr, ptr %21, align 8, !tbaa !19
  %23 = call ptr @mln_rbtree_node_new(ptr noundef %22, ptr noundef nonnull %8) #4
  %24 = icmp eq ptr %23, null
  br i1 %24, label %25, label %26

25:                                               ; preds = %18
  call void @mln_lang_ctx_resource_free_handler(ptr noundef nonnull %8)
  br label %28

26:                                               ; preds = %18
  %27 = load ptr, ptr %21, align 8, !tbaa !19
  call void @mln_rbtree_insert(ptr noundef %27, ptr noundef nonnull %23) #4
  br label %28

28:                                               ; preds = %4, %26, %25, %17
  %.0 = phi i32 [ -1, %17 ], [ -1, %25 ], [ 0, %26 ], [ -1, %4 ]
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %5) #4
  ret i32 %.0
}

; Function Attrs: mustprogress nofree nounwind willreturn memory(argmem: read)
declare i64 @strlen(ptr nocapture noundef) local_unnamed_addr #3

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

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

!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, !7, i64 8}
!6 = !{!"mln_lang_ctx_s", !7, i64 0, !7, i64 8, !7, i64 16, !7, i64 24, !7, i64 32, !8, i64 40, !7, i64 49240, !8, i64 49248, !7, i64 114848, !10, i64 114856, !7, i64 114864, !7, i64 114872, !7, i64 114880, !7, i64 114888, !7, i64 114896, !7, i64 114904, !7, i64 114912, !7, i64 114920, !7, i64 114928, !7, i64 114936, !7, i64 114944, !10, i64 114952, !7, i64 114960, !11, i64 114968, !11, i64 114970, !11, i64 114970, !11, i64 114970, !11, i64 114970, !11, i64 114970, !11, i64 114970, !11, i64 114970, !11, i64 114970, !11, i64 114971, !11, i64 114971, !11, i64 114971}
!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 = !{!13, !7, i64 0}
!13 = !{!"", !7, i64 0, !10, i64 8, !10, i64 16, !10, i64 16, !10, i64 16}
!14 = !{!13, !10, i64 8}
!15 = !{!16, !7, i64 0}
!16 = !{!"mln_lang_resource_s", !7, i64 0, !7, i64 8, !7, i64 16}
!17 = !{!16, !7, i64 8}
!18 = !{!16, !7, i64 16}
!19 = !{!6, !7, i64 114872}


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