; 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_self_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 %97

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 1
  %10 = load ptr, ptr %9, align 8, !tbaa !9
  %11 = icmp ne ptr %10, null
  br i1 %11, label %12, label %18

12:                                               ; preds = %7
  %13 = load ptr, ptr %2, align 8, !tbaa !5
  %14 = getelementptr inbounds %struct.mln_lang_set_detail_s, ptr %13, i32 0, i32 1
  %15 = load ptr, ptr %14, align 8, !tbaa !9
  call void @mln_rbtree_free(ptr noundef %15)
  %16 = load ptr, ptr %2, align 8, !tbaa !5
  %17 = getelementptr inbounds %struct.mln_lang_set_detail_s, ptr %16, i32 0, i32 1
  store ptr null, ptr %17, align 8, !tbaa !9
  br label %18

18:                                               ; preds = %12, %7
  %19 = load ptr, ptr %2, align 8, !tbaa !5
  %20 = getelementptr inbounds %struct.mln_lang_set_detail_s, ptr %19, i32 0, i32 2
  %21 = load i64, ptr %20, align 8, !tbaa !12
  %22 = add i64 %21, -1
  store i64 %22, ptr %20, align 8, !tbaa !12
  %23 = icmp ugt i64 %21, 1
  br i1 %23, label %24, label %25

24:                                               ; preds = %18
  br label %97

25:                                               ; preds = %18
  %26 = load ptr, ptr %2, align 8, !tbaa !5
  %27 = getelementptr inbounds %struct.mln_lang_set_detail_s, ptr %26, i32 0, i32 0
  %28 = load ptr, ptr %27, align 8, !tbaa !13
  %29 = icmp ne ptr %28, null
  br i1 %29, label %30, label %95

30:                                               ; preds = %25
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #4
  %31 = load ptr, ptr %2, align 8, !tbaa !5
  %32 = getelementptr inbounds %struct.mln_lang_set_detail_s, ptr %31, i32 0, i32 0
  %33 = load ptr, ptr %32, align 8, !tbaa !13
  store ptr %33, ptr %3, align 8, !tbaa !5
  %34 = load ptr, ptr %3, align 8, !tbaa !5
  %35 = icmp ne ptr %34, null
  br i1 %35, label %36, label %94

36:                                               ; preds = %30
  %37 = load ptr, ptr %3, align 8, !tbaa !5
  %38 = getelementptr inbounds %struct.mln_string_t, ptr %37, i32 0, i32 2
  %39 = load i32, ptr %38, align 8
  %40 = lshr i32 %39, 2
  %41 = zext i32 %40 to i64
  %42 = add i64 %41, -1
  %43 = trunc i64 %42 to i32
  %44 = load i32, ptr %38, align 8
  %45 = and i32 %43, 1073741823
  %46 = shl i32 %45, 2
  %47 = and i32 %44, 3
  %48 = or i32 %47, %46
  store i32 %48, ptr %38, align 8
  %49 = zext i32 %45 to i64
  %50 = icmp ule i64 %41, 1
  br i1 %50, label %51, label %93

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

58:                                               ; preds = %51
  %59 = load ptr, ptr %3, align 8, !tbaa !5
  %60 = getelementptr inbounds %struct.mln_string_t, ptr %59, i32 0, i32 0
  %61 = load ptr, ptr %60, align 8, !tbaa !14
  %62 = icmp ne ptr %61, null
  br i1 %62, label %63, label %80

63:                                               ; preds = %58
  %64 = load ptr, ptr %3, align 8, !tbaa !5
  %65 = getelementptr inbounds %struct.mln_string_t, ptr %64, i32 0, i32 2
  %66 = load i32, ptr %65, align 8
  %67 = lshr i32 %66, 1
  %68 = and i32 %67, 1
  %69 = zext i32 %68 to i64
  %70 = icmp ne i64 %69, 0
  br i1 %70, label %71, label %75

71:                                               ; preds = %63
  %72 = load ptr, ptr %3, align 8, !tbaa !5
  %73 = getelementptr inbounds %struct.mln_string_t, ptr %72, i32 0, i32 0
  %74 = load ptr, ptr %73, align 8, !tbaa !14
  call void @mln_alloc_free(ptr noundef %74)
  br label %79

75:                                               ; preds = %63
  %76 = load ptr, ptr %3, align 8, !tbaa !5
  %77 = getelementptr inbounds %struct.mln_string_t, ptr %76, i32 0, i32 0
  %78 = load ptr, ptr %77, align 8, !tbaa !14
  call void @free(ptr noundef %78) #4
  br label %79

79:                                               ; preds = %75, %71
  br label %80

80:                                               ; preds = %79, %58, %51
  %81 = load ptr, ptr %3, align 8, !tbaa !5
  %82 = getelementptr inbounds %struct.mln_string_t, ptr %81, i32 0, i32 2
  %83 = load i32, ptr %82, align 8
  %84 = lshr i32 %83, 1
  %85 = and i32 %84, 1
  %86 = zext i32 %85 to i64
  %87 = icmp ne i64 %86, 0
  br i1 %87, label %88, label %90

88:                                               ; preds = %80
  %89 = load ptr, ptr %3, align 8, !tbaa !5
  call void @mln_alloc_free(ptr noundef %89)
  br label %92

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

92:                                               ; preds = %90, %88
  br label %93

93:                                               ; preds = %92, %36
  br label %94

94:                                               ; preds = %93, %30
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #4
  br label %95

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

97:                                               ; preds = %95, %24, %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, !6, i64 8}
!10 = !{!"mln_lang_set_detail_s", !6, i64 0, !6, i64 8, !11, i64 16}
!11 = !{!"long", !7, i64 0}
!12 = !{!10, !11, i64 16}
!13 = !{!10, !6, i64 0}
!14 = !{!15, !6, i64 0}
!15 = !{!"", !6, i64 0, !11, i64 8, !11, i64 16, !11, i64 16, !11, i64 16}


; 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_self_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 8
  %5 = load ptr, ptr %4, align 8, !tbaa !5
  %.not = icmp eq ptr %5, null
  br i1 %.not, label %7, label %6

6:                                                ; preds = %3
  tail call void @mln_rbtree_free(ptr noundef nonnull %5) #3
  store ptr null, ptr %4, align 8, !tbaa !5
  br label %7

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

12:                                               ; preds = %7
  %13 = load ptr, ptr %0, align 8, !tbaa !12
  %.not21 = icmp eq ptr %13, null
  br i1 %.not21, label %35, label %14

14:                                               ; preds = %12
  %15 = getelementptr inbounds i8, ptr %13, i64 16
  %16 = load i32, ptr %15, align 8
  %17 = and i32 %16, -4
  %18 = add i32 %17, -4
  %19 = and i32 %16, 3
  %20 = or disjoint i32 %18, %19
  store i32 %20, ptr %15, align 8
  %21 = icmp ult i32 %16, 8
  br i1 %21, label %22, label %35

22:                                               ; preds = %14
  %23 = and i32 %16, 1
  %.not22 = icmp eq i32 %23, 0
  br i1 %.not22, label %24, label %30

24:                                               ; preds = %22
  %25 = load ptr, ptr %13, align 8, !tbaa !13
  %.not23 = icmp eq ptr %25, null
  br i1 %.not23, label %30, label %26

26:                                               ; preds = %24
  %27 = and i32 %16, 2
  %.not24 = icmp eq i32 %27, 0
  br i1 %.not24, label %29, label %28

28:                                               ; preds = %26
  tail call void @mln_alloc_free(ptr noundef nonnull %25) #3
  br label %30

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

30:                                               ; preds = %28, %29, %24, %22
  %31 = load i32, ptr %15, align 8
  %32 = and i32 %31, 2
  %.not25 = icmp eq i32 %32, 0
  br i1 %.not25, label %34, label %33

33:                                               ; preds = %30
  tail call void @mln_alloc_free(ptr noundef nonnull %13) #3
  br label %35

34:                                               ; preds = %30
  tail call void @free(ptr noundef nonnull %13) #3
  br label %35

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

36:                                               ; preds = %7, %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, !7, i64 8}
!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, !10, i64 16}
!12 = !{!6, !7, i64 0}
!13 = !{!14, !7, i64 0}
!14 = !{!"", !7, i64 0, !10, i64 8, !10, i64 16, !10, i64 16, !10, i64 16}


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