; LLVM IR from lichen-community-systems/signaletic :: libsignaletic/vendor/tlsf (tlsf)

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

@.str.2 = external hidden unnamed_addr constant [102 x i8], align 1
@.str.27 = external hidden unnamed_addr constant [43 x i8], align 1
@__PRETTY_FUNCTION__.tlsf_memalign = external hidden unnamed_addr constant [44 x i8], align 1

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

; Function Attrs: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) #1

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

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

; Function Attrs: nounwind uwtable
declare hidden i64 @adjust_request_size(i64 noundef, i64 noundef) #2

; Function Attrs: nounwind uwtable
declare hidden ptr @block_locate_free(ptr noundef, i64 noundef) #2

; Function Attrs: nounwind uwtable
declare hidden ptr @block_prepare_used(ptr noundef, ptr noundef, i64 noundef) #2

; Function Attrs: nounwind uwtable
define dso_local ptr @tlsf_memalign(ptr noundef %0, i64 noundef %1, i64 noundef %2) #2 {
  %4 = alloca ptr, align 8
  %5 = alloca i64, align 8
  %6 = alloca i64, align 8
  %7 = alloca ptr, align 8
  %8 = alloca i64, align 8
  %9 = alloca i64, align 8
  %10 = alloca i64, align 8
  %11 = alloca i64, align 8
  %12 = alloca ptr, align 8
  %13 = alloca ptr, align 8
  %14 = alloca ptr, align 8
  %15 = alloca i64, align 8
  %16 = alloca i64, align 8
  %17 = alloca i64, align 8
  %18 = alloca ptr, align 8
  store ptr %0, ptr %4, align 8, !tbaa !5
  store i64 %1, ptr %5, align 8, !tbaa !9
  store i64 %2, ptr %6, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #3
  %19 = load ptr, ptr %4, align 8, !tbaa !5
  store ptr %19, ptr %7, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #3
  %20 = load i64, ptr %6, align 8, !tbaa !9
  %21 = call i64 @adjust_request_size(i64 noundef %20, i64 noundef 8)
  store i64 %21, ptr %8, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #3
  store i64 32, ptr %9, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #3
  %22 = load i64, ptr %8, align 8, !tbaa !9
  %23 = load i64, ptr %5, align 8, !tbaa !9
  %24 = add i64 %22, %23
  %25 = add i64 %24, 32
  %26 = load i64, ptr %5, align 8, !tbaa !9
  %27 = call i64 @adjust_request_size(i64 noundef %25, i64 noundef %26)
  store i64 %27, ptr %10, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #3
  %28 = load i64, ptr %8, align 8, !tbaa !9
  %29 = icmp ne i64 %28, 0
  br i1 %29, label %30, label %35

30:                                               ; preds = %3
  %31 = load i64, ptr %5, align 8, !tbaa !9
  %32 = icmp ugt i64 %31, 8
  br i1 %32, label %33, label %35

33:                                               ; preds = %30
  %34 = load i64, ptr %10, align 8, !tbaa !9
  br label %37

35:                                               ; preds = %30, %3
  %36 = load i64, ptr %8, align 8, !tbaa !9
  br label %37

37:                                               ; preds = %35, %33
  %38 = phi i64 [ %34, %33 ], [ %36, %35 ]
  store i64 %38, ptr %11, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #3
  %39 = load ptr, ptr %7, align 8, !tbaa !5
  %40 = load i64, ptr %11, align 8, !tbaa !9
  %41 = call ptr @block_locate_free(ptr noundef %39, i64 noundef %40)
  store ptr %41, ptr %12, align 8, !tbaa !5
  %42 = load ptr, ptr %12, align 8, !tbaa !5
  %43 = icmp ne ptr %42, null
  br i1 %43, label %44, label %100

44:                                               ; preds = %37
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #3
  %45 = load ptr, ptr %12, align 8, !tbaa !5
  %46 = call ptr @block_to_ptr(ptr noundef %45)
  store ptr %46, ptr %13, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #3
  %47 = load ptr, ptr %13, align 8, !tbaa !5
  %48 = load i64, ptr %5, align 8, !tbaa !9
  %49 = call ptr @align_ptr(ptr noundef %47, i64 noundef %48)
  store ptr %49, ptr %14, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %15) #3
  %50 = load ptr, ptr %14, align 8, !tbaa !5
  %51 = ptrtoint ptr %50 to i64
  %52 = load ptr, ptr %13, align 8, !tbaa !5
  %53 = ptrtoint ptr %52 to i64
  %54 = sub nsw i64 %51, %53
  store i64 %54, ptr %15, align 8, !tbaa !9
  %55 = load i64, ptr %15, align 8, !tbaa !9
  %56 = icmp ne i64 %55, 0
  br i1 %56, label %57, label %85

57:                                               ; preds = %44
  %58 = load i64, ptr %15, align 8, !tbaa !9
  %59 = icmp ult i64 %58, 32
  br i1 %59, label %60, label %85

60:                                               ; preds = %57
  call void @llvm.lifetime.start.p0(i64 8, ptr %16) #3
  %61 = load i64, ptr %15, align 8, !tbaa !9
  %62 = sub i64 32, %61
  store i64 %62, ptr %16, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %17) #3
  %63 = load i64, ptr %16, align 8, !tbaa !9
  %64 = load i64, ptr %5, align 8, !tbaa !9
  %65 = icmp ugt i64 %63, %64
  br i1 %65, label %66, label %68

66:                                               ; preds = %60
  %67 = load i64, ptr %16, align 8, !tbaa !9
  br label %70

68:                                               ; preds = %60
  %69 = load i64, ptr %5, align 8, !tbaa !9
  br label %70

70:                                               ; preds = %68, %66
  %71 = phi i64 [ %67, %66 ], [ %69, %68 ]
  store i64 %71, ptr %17, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %18) #3
  %72 = load ptr, ptr %14, align 8, !tbaa !5
  %73 = ptrtoint ptr %72 to i64
  %74 = load i64, ptr %17, align 8, !tbaa !9
  %75 = add i64 %73, %74
  %76 = inttoptr i64 %75 to ptr
  store ptr %76, ptr %18, align 8, !tbaa !5
  %77 = load ptr, ptr %18, align 8, !tbaa !5
  %78 = load i64, ptr %5, align 8, !tbaa !9
  %79 = call ptr @align_ptr(ptr noundef %77, i64 noundef %78)
  store ptr %79, ptr %14, align 8, !tbaa !5
  %80 = load ptr, ptr %14, align 8, !tbaa !5
  %81 = ptrtoint ptr %80 to i64
  %82 = load ptr, ptr %13, align 8, !tbaa !5
  %83 = ptrtoint ptr %82 to i64
  %84 = sub nsw i64 %81, %83
  store i64 %84, ptr %15, align 8, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 8, ptr %18) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %17) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %16) #3
  br label %85

85:                                               ; preds = %70, %57, %44
  %86 = load i64, ptr %15, align 8, !tbaa !9
  %87 = icmp ne i64 %86, 0
  br i1 %87, label %88, label %99

88:                                               ; preds = %85
  %89 = load i64, ptr %15, align 8, !tbaa !9
  %90 = icmp uge i64 %89, 32
  br i1 %90, label %91, label %93

91:                                               ; preds = %88
  br i1 true, label %92, label %93

92:                                               ; preds = %91
  br label %94

93:                                               ; preds = %91, %88
  call void @__assert_fail(ptr noundef @.str.27, ptr noundef @.str.2, i32 noundef 1172, ptr noundef @__PRETTY_FUNCTION__.tlsf_memalign) #4
  unreachable

94:                                               ; preds = %92
  %95 = load ptr, ptr %7, align 8, !tbaa !5
  %96 = load ptr, ptr %12, align 8, !tbaa !5
  %97 = load i64, ptr %15, align 8, !tbaa !9
  %98 = call ptr @block_trim_free_leading(ptr noundef %95, ptr noundef %96, i64 noundef %97)
  store ptr %98, ptr %12, align 8, !tbaa !5
  br label %99

99:                                               ; preds = %94, %85
  call void @llvm.lifetime.end.p0(i64 8, ptr %15) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #3
  br label %100

100:                                              ; preds = %99, %37
  %101 = load ptr, ptr %7, align 8, !tbaa !5
  %102 = load ptr, ptr %12, align 8, !tbaa !5
  %103 = load i64, ptr %8, align 8, !tbaa !9
  %104 = call ptr @block_prepare_used(ptr noundef %101, ptr noundef %102, i64 noundef %103)
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #3
  ret ptr %104
}

; Function Attrs: nounwind uwtable
declare hidden ptr @align_ptr(ptr noundef, i64 noundef) #2

; Function Attrs: nounwind uwtable
declare hidden ptr @block_trim_free_leading(ptr noundef, ptr noundef, i64 noundef) #2

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { noreturn 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 #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 }
attributes #4 = { noreturn 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, !10, i64 0}
!10 = !{!"long", !7, i64 0}


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

@.str.2 = external hidden unnamed_addr constant [102 x i8], align 1
@.str.27 = external hidden unnamed_addr constant [43 x i8], align 1
@__PRETTY_FUNCTION__.tlsf_memalign = external hidden unnamed_addr constant [44 x i8], align 1

; Function Attrs: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare hidden ptr @block_to_ptr(ptr noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
declare hidden i64 @adjust_request_size(i64 noundef, i64 noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
declare hidden ptr @block_locate_free(ptr noundef, i64 noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
declare hidden ptr @block_prepare_used(ptr noundef, ptr noundef, i64 noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
define dso_local ptr @tlsf_memalign(ptr noundef %0, i64 noundef %1, i64 noundef %2) local_unnamed_addr #1 {
  %4 = tail call i64 @adjust_request_size(i64 noundef %2, i64 noundef 8)
  %5 = add i64 %1, 32
  %6 = add i64 %5, %4
  %7 = tail call i64 @adjust_request_size(i64 noundef %6, i64 noundef %1)
  %8 = icmp ne i64 %4, 0
  %9 = icmp ugt i64 %1, 8
  %or.cond = and i1 %9, %8
  %10 = select i1 %or.cond, i64 %7, i64 %4
  %11 = tail call ptr @block_locate_free(ptr noundef %0, i64 noundef %10)
  %.not = icmp eq ptr %11, null
  br i1 %.not, label %33, label %12

12:                                               ; preds = %3
  %13 = tail call ptr @block_to_ptr(ptr noundef nonnull %11)
  %14 = tail call ptr @align_ptr(ptr noundef %13, i64 noundef %1)
  %15 = ptrtoint ptr %14 to i64
  %16 = ptrtoint ptr %13 to i64
  %17 = sub nsw i64 %15, %16
  %18 = add i64 %17, -1
  %or.cond3 = icmp ult i64 %18, 31
  br i1 %or.cond3, label %19, label %27

19:                                               ; preds = %12
  %20 = sub nuw nsw i64 32, %17
  %21 = tail call i64 @llvm.umax.i64(i64 %20, i64 %1)
  %22 = add i64 %21, %15
  %23 = inttoptr i64 %22 to ptr
  %24 = tail call ptr @align_ptr(ptr noundef %23, i64 noundef %1)
  %25 = ptrtoint ptr %24 to i64
  %26 = sub nsw i64 %25, %16
  br label %27

27:                                               ; preds = %19, %12
  %.040 = phi i64 [ %26, %19 ], [ %17, %12 ]
  %.not44 = icmp eq i64 %.040, 0
  br i1 %.not44, label %33, label %28

28:                                               ; preds = %27
  %29 = icmp ugt i64 %.040, 31
  br i1 %29, label %31, label %30

30:                                               ; preds = %28
  tail call void @__assert_fail(ptr noundef nonnull @.str.27, ptr noundef nonnull @.str.2, i32 noundef 1172, ptr noundef nonnull @__PRETTY_FUNCTION__.tlsf_memalign) #3
  unreachable

31:                                               ; preds = %28
  %32 = tail call ptr @block_trim_free_leading(ptr noundef %0, ptr noundef nonnull %11, i64 noundef %.040)
  br label %33

33:                                               ; preds = %27, %31, %3
  %.1 = phi ptr [ null, %3 ], [ %32, %31 ], [ %11, %27 ]
  %34 = tail call ptr @block_prepare_used(ptr noundef %0, ptr noundef %.1, i64 noundef %4)
  ret ptr %34
}

; Function Attrs: nounwind uwtable
declare hidden ptr @align_ptr(ptr noundef, i64 noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
declare hidden ptr @block_trim_free_leading(ptr noundef, ptr noundef, i64 noundef) local_unnamed_addr #1

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i64 @llvm.umax.i64(i64, i64) #2

attributes #0 = { noreturn 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 #1 = { 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 #2 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #3 = { noreturn 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)"}


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