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

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

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 void @mln_rbtree_free(ptr noundef) #1

; Function Attrs: nounwind
declare void @free(ptr noundef) #2

; Function Attrs: nounwind uwtable
define dso_local void @mln_lang_set_detail_free(ptr noundef %0) #3 {
  %2 = alloca ptr, align 8
  %3 = alloca ptr, align 8
  store ptr %0, ptr %2, align 8, !tbaa !5
  %4 = load ptr, ptr %2, align 8, !tbaa !5
  %5 = icmp eq ptr %4, null
  br i1 %5, label %6, label %7

6:                                                ; preds = %1
  br label %95

7:                                                ; preds = %1
  %8 = load ptr, ptr %2, align 8, !tbaa !5
  %9 = getelementptr inbounds %struct.mln_lang_set_detail_s, ptr %8, i32 0, i32 2
  %10 = load i64, ptr %9, align 8, !tbaa !9
  %11 = add i64 %10, -1
  store i64 %11, ptr %9, align 8, !tbaa !9
  %12 = icmp ugt i64 %10, 1
  br i1 %12, label %13, label %14

13:                                               ; preds = %7
  br label %95

14:                                               ; preds = %7
  %15 = load ptr, ptr %2, align 8, !tbaa !5
  %16 = getelementptr inbounds %struct.mln_lang_set_detail_s, ptr %15, i32 0, i32 0
  %17 = load ptr, ptr %16, align 8, !tbaa !12
  %18 = icmp ne ptr %17, null
  br i1 %18, label %19, label %84

19:                                               ; preds = %14
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #4
  %20 = load ptr, ptr %2, align 8, !tbaa !5
  %21 = getelementptr inbounds %struct.mln_lang_set_detail_s, ptr %20, i32 0, i32 0
  %22 = load ptr, ptr %21, align 8, !tbaa !12
  store ptr %22, ptr %3, align 8, !tbaa !5
  %23 = load ptr, ptr %3, align 8, !tbaa !5
  %24 = icmp ne ptr %23, null
  br i1 %24, label %25, label %83

25:                                               ; preds = %19
  %26 = load ptr, ptr %3, align 8, !tbaa !5
  %27 = getelementptr inbounds %struct.mln_string_t, ptr %26, i32 0, i32 2
  %28 = load i32, ptr %27, align 8
  %29 = lshr i32 %28, 2
  %30 = zext i32 %29 to i64
  %31 = add i64 %30, -1
  %32 = trunc i64 %31 to i32
  %33 = load i32, ptr %27, align 8
  %34 = and i32 %32, 1073741823
  %35 = shl i32 %34, 2
  %36 = and i32 %33, 3
  %37 = or i32 %36, %35
  store i32 %37, ptr %27, align 8
  %38 = zext i32 %34 to i64
  %39 = icmp ule i64 %30, 1
  br i1 %39, label %40, label %82

40:                                               ; preds = %25
  %41 = load ptr, ptr %3, align 8, !tbaa !5
  %42 = getelementptr inbounds %struct.mln_string_t, ptr %41, i32 0, i32 2
  %43 = load i32, ptr %42, align 8
  %44 = and i32 %43, 1
  %45 = zext i32 %44 to i64
  %46 = icmp ne i64 %45, 0
  br i1 %46, label %69, label %47

47:                                               ; preds = %40
  %48 = load ptr, ptr %3, align 8, !tbaa !5
  %49 = getelementptr inbounds %struct.mln_string_t, ptr %48, i32 0, i32 0
  %50 = load ptr, ptr %49, align 8, !tbaa !13
  %51 = icmp ne ptr %50, null
  br i1 %51, label %52, label %69

52:                                               ; preds = %47
  %53 = load ptr, ptr %3, align 8, !tbaa !5
  %54 = getelementptr inbounds %struct.mln_string_t, ptr %53, i32 0, i32 2
  %55 = load i32, ptr %54, align 8
  %56 = lshr i32 %55, 1
  %57 = and i32 %56, 1
  %58 = zext i32 %57 to i64
  %59 = icmp ne i64 %58, 0
  br i1 %59, label %60, label %64

60:                                               ; preds = %52
  %61 = load ptr, ptr %3, align 8, !tbaa !5
  %62 = getelementptr inbounds %struct.mln_string_t, ptr %61, i32 0, i32 0
  %63 = load ptr, ptr %62, align 8, !tbaa !13
  call void @mln_alloc_free(ptr noundef %63)
  br label %68

64:                                               ; preds = %52
  %65 = load ptr, ptr %3, align 8, !tbaa !5
  %66 = getelementptr inbounds %struct.mln_string_t, ptr %65, i32 0, i32 0
  %67 = load ptr, ptr %66, align 8, !tbaa !13
  call void @free(ptr noundef %67) #4
  br label %68

68:                                               ; preds = %64, %60
  br label %69

69:                                               ; preds = %68, %47, %40
  %70 = load ptr, ptr %3, align 8, !tbaa !5
  %71 = getelementptr inbounds %struct.mln_string_t, ptr %70, i32 0, i32 2
  %72 = load i32, ptr %71, align 8
  %73 = lshr i32 %72, 1
  %74 = and i32 %73, 1
  %75 = zext i32 %74 to i64
  %76 = icmp ne i64 %75, 0
  br i1 %76, label %77, label %79

77:                                               ; preds = %69
  %78 = load ptr, ptr %3, align 8, !tbaa !5
  call void @mln_alloc_free(ptr noundef %78)
  br label %81

79:                                               ; preds = %69
  %80 = load ptr, ptr %3, align 8, !tbaa !5
  call void @free(ptr noundef %80) #4
  br label %81

81:                                               ; preds = %79, %77
  br label %82

82:                                               ; preds = %81, %25
  br label %83

83:                                               ; preds = %82, %19
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #4
  br label %84

84:                                               ; preds = %83, %14
  %85 = load ptr, ptr %2, align 8, !tbaa !5
  %86 = getelementptr inbounds %struct.mln_lang_set_detail_s, ptr %85, i32 0, i32 1
  %87 = load ptr, ptr %86, align 8, !tbaa !15
  %88 = icmp ne ptr %87, null
  br i1 %88, label %89, label %93

89:                                               ; preds = %84
  %90 = load ptr, ptr %2, align 8, !tbaa !5
  %91 = getelementptr inbounds %struct.mln_lang_set_detail_s, ptr %90, i32 0, i32 1
  %92 = load ptr, ptr %91, align 8, !tbaa !15
  call void @mln_rbtree_free(ptr noundef %92)
  br label %93

93:                                               ; preds = %89, %84
  %94 = load ptr, ptr %2, align 8, !tbaa !5
  call void @mln_alloc_free(ptr noundef %94)
  br label %95

95:                                               ; preds = %93, %13, %6
  ret void
}

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

!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, !11, i64 16}
!10 = !{!"mln_lang_set_detail_s", !6, i64 0, !6, i64 8, !11, i64 16}
!11 = !{!"long", !7, i64 0}
!12 = !{!10, !6, i64 0}
!13 = !{!14, !6, i64 0}
!14 = !{!"", !6, i64 0, !11, i64 8, !11, i64 16, !11, i64 16, !11, i64 16}
!15 = !{!10, !6, i64 8}


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

declare void @mln_alloc_free(ptr noundef) local_unnamed_addr #0

declare void @mln_rbtree_free(ptr noundef) local_unnamed_addr #0

; Function Attrs: mustprogress nounwind willreturn allockind("free") memory(argmem: readwrite, inaccessiblemem: readwrite)
declare void @free(ptr allocptr nocapture noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
define dso_local void @mln_lang_set_detail_free(ptr noundef %0) local_unnamed_addr #2 {
  %2 = icmp eq ptr %0, null
  br i1 %2, label %36, label %3

3:                                                ; preds = %1
  %4 = getelementptr inbounds i8, ptr %0, i64 16
  %5 = load i64, ptr %4, align 8, !tbaa !5
  %6 = add i64 %5, -1
  store i64 %6, ptr %4, align 8, !tbaa !5
  %7 = icmp ugt i64 %5, 1
  br i1 %7, label %36, label %8

8:                                                ; preds = %3
  %9 = load ptr, ptr %0, align 8, !tbaa !11
  %.not = icmp eq ptr %9, null
  br i1 %.not, label %31, label %10

10:                                               ; preds = %8
  %11 = getelementptr inbounds i8, ptr %9, i64 16
  %12 = load i32, ptr %11, align 8
  %13 = and i32 %12, -4
  %14 = add i32 %13, -4
  %15 = and i32 %12, 3
  %16 = or disjoint i32 %14, %15
  store i32 %16, ptr %11, align 8
  %17 = icmp ult i32 %12, 8
  br i1 %17, label %18, label %31

18:                                               ; preds = %10
  %19 = and i32 %12, 1
  %.not20 = icmp eq i32 %19, 0
  br i1 %.not20, label %20, label %26

20:                                               ; preds = %18
  %21 = load ptr, ptr %9, align 8, !tbaa !12
  %.not21 = icmp eq ptr %21, null
  br i1 %.not21, label %26, label %22

22:                                               ; preds = %20
  %23 = and i32 %12, 2
  %.not22 = icmp eq i32 %23, 0
  br i1 %.not22, label %25, label %24

24:                                               ; preds = %22
  tail call void @mln_alloc_free(ptr noundef nonnull %21) #3
  br label %26

25:                                               ; preds = %22
  tail call void @free(ptr noundef nonnull %21) #3
  br label %26

26:                                               ; preds = %24, %25, %20, %18
  %27 = load i32, ptr %11, align 8
  %28 = and i32 %27, 2
  %.not23 = icmp eq i32 %28, 0
  br i1 %.not23, label %30, label %29

29:                                               ; preds = %26
  tail call void @mln_alloc_free(ptr noundef nonnull %9) #3
  br label %31

30:                                               ; preds = %26
  tail call void @free(ptr noundef nonnull %9) #3
  br label %31

31:                                               ; preds = %29, %30, %10, %8
  %32 = getelementptr inbounds i8, ptr %0, i64 8
  %33 = load ptr, ptr %32, align 8, !tbaa !14
  %.not24 = icmp eq ptr %33, null
  br i1 %.not24, label %35, label %34

34:                                               ; preds = %31
  tail call void @mln_rbtree_free(ptr noundef nonnull %33) #3
  br label %35

35:                                               ; preds = %34, %31
  tail call void @mln_alloc_free(ptr noundef nonnull %0) #3
  br label %36

36:                                               ; preds = %3, %1, %35
  ret void
}

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 = { mustprogress nounwind willreturn allockind("free") memory(argmem: readwrite, 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 = { 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 16}
!6 = !{!"mln_lang_set_detail_s", !7, i64 0, !7, i64 8, !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, !7, i64 0}
!12 = !{!13, !7, i64 0}
!13 = !{!"", !7, i64 0, !10, i64 8, !10, i64 16, !10, i64 16, !10, i64 16}
!14 = !{!6, !7, i64 8}


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