; 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_lang_resource_s = type { ptr, ptr, ptr }
%struct.mln_string_t = type { ptr, i64, i32 }
%struct.mln_lang_s = type { ptr, ptr, ptr, ptr, ptr, ptr, ptr, i64, ptr, ptr, ptr, ptr, ptr, ptr, ptr, %union.pthread_mutex_t }
%union.pthread_mutex_t = type { %struct.__pthread_mutex_s }
%struct.__pthread_mutex_s = type { i32, i32, i32, i32, i32, i16, i16, %struct.__pthread_internal_list }
%struct.__pthread_internal_list = type { ptr, ptr }
%struct.rbtree_s = type { ptr, ptr, ptr, ptr, ptr, %struct.mln_rbtree_node_s, ptr, ptr, ptr, ptr, ptr, i64, i8 }
%struct.mln_rbtree_node_s = type { ptr, ptr, ptr, ptr, ptr, 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: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #0

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

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

; Function Attrs: nounwind uwtable
define dso_local void @mln_lang_resource_cancel(ptr noundef nonnull %0, ptr noundef nonnull %1) #3 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca %struct.mln_lang_resource_s, align 8
  %7 = alloca %struct.mln_string_t, align 8
  %8 = alloca ptr, align 8
  %9 = alloca i32, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  store ptr %1, ptr %4, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #4
  call void @llvm.lifetime.start.p0(i64 24, ptr %6) #4
  call void @llvm.lifetime.start.p0(i64 24, ptr %7) #4
  %10 = load ptr, ptr %4, align 8, !tbaa !5
  %11 = getelementptr inbounds %struct.mln_string_t, ptr %7, i32 0, i32 0
  store ptr %10, ptr %11, align 8, !tbaa !9
  %12 = load ptr, ptr %4, align 8, !tbaa !5
  %13 = call i64 @strlen(ptr noundef %12) #5
  %14 = getelementptr inbounds %struct.mln_string_t, ptr %7, i32 0, i32 1
  store i64 %13, ptr %14, align 8, !tbaa !12
  %15 = getelementptr inbounds %struct.mln_string_t, ptr %7, i32 0, i32 2
  %16 = load i32, ptr %15, align 8
  %17 = and i32 %16, -2
  %18 = or i32 %17, 1
  store i32 %18, ptr %15, align 8
  %19 = getelementptr inbounds %struct.mln_string_t, ptr %7, i32 0, i32 2
  %20 = load i32, ptr %19, align 8
  %21 = and i32 %20, -3
  %22 = or i32 %21, 0
  store i32 %22, ptr %19, align 8
  %23 = getelementptr inbounds %struct.mln_string_t, ptr %7, i32 0, i32 2
  %24 = load i32, ptr %23, align 8
  %25 = and i32 %24, 3
  %26 = or i32 %25, 4
  store i32 %26, ptr %23, align 8
  store ptr %7, ptr %8, align 8, !tbaa !5
  %27 = load ptr, ptr %8, align 8, !tbaa !5
  %28 = getelementptr inbounds %struct.mln_lang_resource_s, ptr %6, i32 0, i32 0
  store ptr %7, ptr %28, align 8, !tbaa !13
  %29 = load ptr, ptr %3, align 8, !tbaa !5
  %30 = getelementptr inbounds %struct.mln_lang_s, ptr %29, i32 0, i32 6
  %31 = load ptr, ptr %30, align 8, !tbaa !15
  %32 = call ptr @mln_rbtree_search(ptr noundef %31, ptr noundef %6)
  store ptr %32, ptr %5, align 8, !tbaa !5
  %33 = load ptr, ptr %5, align 8, !tbaa !5
  %34 = load ptr, ptr %3, align 8, !tbaa !5
  %35 = getelementptr inbounds %struct.mln_lang_s, ptr %34, i32 0, i32 6
  %36 = load ptr, ptr %35, align 8, !tbaa !15
  %37 = getelementptr inbounds %struct.rbtree_s, ptr %36, i32 0, i32 5
  %38 = icmp eq ptr %33, %37
  br i1 %38, label %39, label %40

39:                                               ; preds = %2
  store i32 1, ptr %9, align 4
  br label %49

40:                                               ; preds = %2
  %41 = load ptr, ptr %3, align 8, !tbaa !5
  %42 = getelementptr inbounds %struct.mln_lang_s, ptr %41, i32 0, i32 6
  %43 = load ptr, ptr %42, align 8, !tbaa !15
  %44 = load ptr, ptr %5, align 8, !tbaa !5
  call void @mln_rbtree_delete(ptr noundef %43, ptr noundef %44)
  %45 = load ptr, ptr %3, align 8, !tbaa !5
  %46 = getelementptr inbounds %struct.mln_lang_s, ptr %45, i32 0, i32 6
  %47 = load ptr, ptr %46, align 8, !tbaa !15
  %48 = load ptr, ptr %5, align 8, !tbaa !5
  call void @mln_rbtree_node_free(ptr noundef %47, ptr noundef %48)
  store i32 0, ptr %9, align 4
  br label %49

49:                                               ; preds = %40, %39
  call void @llvm.lifetime.end.p0(i64 24, ptr %7) #4
  call void @llvm.lifetime.end.p0(i64 24, ptr %6) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #4
  %50 = load i32, ptr %9, align 4
  switch i32 %50, label %52 [
    i32 0, label %51
    i32 1, label %51
  ]

51:                                               ; preds = %49, %49
  ret void

52:                                               ; preds = %49
  unreachable
}

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

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

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 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 #3 = { 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 #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 0}
!10 = !{!"", !6, i64 0, !11, i64 8, !11, i64 16, !11, i64 16, !11, i64 16}
!11 = !{!"long", !7, i64 0}
!12 = !{!10, !11, i64 8}
!13 = !{!14, !6, i64 0}
!14 = !{!"mln_lang_resource_s", !6, i64 0, !6, i64 8, !6, i64 16}
!15 = !{!16, !6, i64 48}
!16 = !{!"mln_lang_s", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !6, i64 40, !6, i64 48, !11, i64 56, !11, i64 63, !11, i64 63, !6, i64 64, !6, i64 72, !6, i64 80, !6, i64 88, !6, i64 96, !6, i64 104, !6, i64 112, !7, i64 120}


; 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_lang_resource_s = type { ptr, ptr, ptr }
%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

; 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_rbtree_search(ptr noundef, ptr noundef) local_unnamed_addr #1

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

; Function Attrs: nounwind uwtable
define dso_local void @mln_lang_resource_cancel(ptr nocapture noundef nonnull readonly %0, ptr noundef nonnull %1) local_unnamed_addr #3 {
  %3 = alloca %struct.mln_lang_resource_s, align 8
  %4 = alloca %struct.mln_string_t, align 8
  call void @llvm.lifetime.start.p0(i64 24, ptr nonnull %3) #4
  call void @llvm.lifetime.start.p0(i64 24, ptr nonnull %4) #4
  store ptr %1, ptr %4, align 8, !tbaa !5
  %5 = tail call i64 @strlen(ptr noundef nonnull dereferenceable(1) %1) #5
  %6 = getelementptr inbounds i8, ptr %4, i64 8
  store i64 %5, ptr %6, align 8, !tbaa !11
  %7 = getelementptr inbounds i8, ptr %4, i64 16
  store i32 5, ptr %7, align 8
  store ptr %4, ptr %3, align 8, !tbaa !12
  %8 = getelementptr inbounds i8, ptr %0, i64 48
  %9 = load ptr, ptr %8, align 8, !tbaa !14
  %10 = call ptr @mln_rbtree_search(ptr noundef %9, ptr noundef nonnull %3) #4
  %11 = load ptr, ptr %8, align 8, !tbaa !14
  %12 = getelementptr inbounds i8, ptr %11, i64 40
  %13 = icmp eq ptr %10, %12
  br i1 %13, label %16, label %14

14:                                               ; preds = %2
  call void @mln_rbtree_delete(ptr noundef %11, ptr noundef %10) #4
  %15 = load ptr, ptr %8, align 8, !tbaa !14
  call void @mln_rbtree_node_free(ptr noundef %15, ptr noundef %10) #4
  br label %16

16:                                               ; preds = %2, %14
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %4) #4
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %3) #4
  ret void
}

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

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

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 = { 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 #3 = { 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 #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 0}
!6 = !{!"", !7, i64 0, !10, i64 8, !10, i64 16, !10, i64 16, !10, i64 16}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"long", !8, i64 0}
!11 = !{!6, !10, i64 8}
!12 = !{!13, !7, i64 0}
!13 = !{!"mln_lang_resource_s", !7, i64 0, !7, i64 8, !7, i64 16}
!14 = !{!15, !7, i64 48}
!15 = !{!"mln_lang_s", !7, i64 0, !7, i64 8, !7, i64 16, !7, i64 24, !7, i64 32, !7, i64 40, !7, i64 48, !10, i64 56, !10, i64 63, !10, i64 63, !7, i64 64, !7, i64 72, !7, i64 80, !7, i64 88, !7, i64 96, !7, i64 104, !7, i64 112, !8, i64 120}


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