; LLVM IR from libxsmm/libxsmm :: src (libxsmm_malloc)

; 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.libxsmm_scratch_info = type { i64, i64, i64, i64, i64, i32 }
%union.internal_malloc_pool_type = type { %struct.anon, [8 x i8] }
%struct.anon = type { i64, i64, i64, ptr, ptr, ptr, i32 }
%struct.internal_malloc_info_type = type { %union.libxsmm_free_function, ptr, ptr, ptr, i64, i32 }
%union.libxsmm_free_function = type { ptr }

@.str.1 = external hidden unnamed_addr constant [70 x i8], align 1
@libxsmm_verbosity = external global i32, align 4
@stderr = external global ptr, align 8
@libxsmm_scratch_pools = external global i32, align 4
@internal_malloc_pool_buffer = external dso_local global [65599 x i8], align 64
@internal_malloc_kind = external dso_local global i32, align 64
@internal_malloc_local_cur = external dso_local global i64, align 64
@internal_malloc_local_max = external dso_local global i64, align 64
@internal_malloc_scratch_nmallocs = external dso_local global i64, align 64
@internal_malloc_public_cur = external dso_local global i64, align 64
@.str.22 = external hidden unnamed_addr constant [39 x i8], align 1
@.str.23 = external hidden unnamed_addr constant [44 x i8], align 1
@.str.25 = external hidden unnamed_addr constant [44 x i8], align 1
@.str.38 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.39 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.49 = external hidden unnamed_addr constant [1 x i8], align 1
@internal_malloc_public_max = external dso_local global i64, align 64
@.str.80 = external hidden unnamed_addr constant [30 x i8], align 1
@__PRETTY_FUNCTION__.libxsmm_xrelease_scratch = external hidden unnamed_addr constant [46 x i8], align 1
@.str.81 = external hidden unnamed_addr constant [45 x i8], align 1
@.str.82 = external hidden unnamed_addr constant [67 x i8], align 1
@.str.83 = external hidden unnamed_addr constant [2 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: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.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: inlinehint nounwind uwtable
declare hidden ptr @internal_malloc_info(ptr noundef, i32 noundef) #2

; Function Attrs: nounwind uwtable
declare dso_local i32 @internal_xfree(ptr noundef, ptr noundef) #3

; Function Attrs: nounwind
declare i32 @fprintf(ptr noundef, ptr noundef, ...) #4

; Function Attrs: nounwind
declare void @llvm.x86.sse2.pause() #5

; Function Attrs: nounwind
declare i32 @sched_yield() #4

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #6

declare i64 @libxsmm_format_value(ptr noundef, i32 noundef, i64 noundef, ptr noundef, ptr noundef, i32 noundef) #7

; Function Attrs: nounwind uwtable
define dso_local void @libxsmm_xrelease_scratch(ptr noundef %0) #3 {
  %2 = alloca ptr, align 8
  %3 = alloca ptr, align 8
  %4 = alloca %struct.libxsmm_scratch_info, align 8
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca ptr, align 8
  %9 = alloca [32 x i8], align 16
  store ptr %0, ptr %2, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #5
  store ptr null, ptr %3, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 48, ptr %4) #5
  %10 = load i32, ptr @libxsmm_scratch_pools, align 4, !tbaa !9
  %11 = icmp ule i32 %10, 1024
  br i1 %11, label %12, label %13

12:                                               ; preds = %1
  br label %14

13:                                               ; preds = %1
  call void @__assert_fail(ptr noundef @.str.80, ptr noundef @.str.1, i32 noundef 2485, ptr noundef @__PRETTY_FUNCTION__.libxsmm_xrelease_scratch) #8
  unreachable

14:                                               ; preds = %12
  %15 = load ptr, ptr %2, align 8, !tbaa !5
  %16 = icmp ne ptr null, %15
  br i1 %16, label %17, label %65

17:                                               ; preds = %14
  %18 = load ptr, ptr %2, align 8, !tbaa !5
  %19 = ptrtoint ptr %18 to i64
  %20 = and i64 %19, 3
  %21 = icmp eq i64 0, %20
  br i1 %21, label %22, label %23

22:                                               ; preds = %17
  br label %24

23:                                               ; preds = %17
  call void @__assert_fail(ptr noundef @.str.22, ptr noundef @.str.1, i32 noundef 2487, ptr noundef @__PRETTY_FUNCTION__.libxsmm_xrelease_scratch) #8
  unreachable

24:                                               ; preds = %22
  br label %25

25:                                               ; preds = %57, %24
  %26 = load ptr, ptr %2, align 8, !tbaa !5
  %27 = atomicrmw or ptr %26, i32 1 seq_cst, align 4
  %28 = icmp eq i32 0, %27
  %29 = xor i1 %28, true
  br i1 %29, label %30, label %58

30:                                               ; preds = %25
  br label %31

31:                                               ; preds = %30
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #5
  store i32 1, ptr %5, align 4, !tbaa !9
  br label %32

32:                                               ; preds = %50, %31
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #5
  store i32 0, ptr %6, align 4, !tbaa !9
  br label %33

33:                                               ; preds = %38, %32
  %34 = load i32, ptr %6, align 4, !tbaa !9
  %35 = load i32, ptr %5, align 4, !tbaa !9
  %36 = icmp slt i32 %34, %35
  br i1 %36, label %37, label %41

37:                                               ; preds = %33
  call void @llvm.x86.sse2.pause()
  br label %38

38:                                               ; preds = %37
  %39 = load i32, ptr %6, align 4, !tbaa !9
  %40 = add nsw i32 %39, 1
  store i32 %40, ptr %6, align 4, !tbaa !9
  br label %33, !llvm.loop !11

41:                                               ; preds = %33
  %42 = load i32, ptr %5, align 4, !tbaa !9
  %43 = icmp slt i32 %42, 4096
  br i1 %43, label %44, label %47

44:                                               ; preds = %41
  %45 = load i32, ptr %5, align 4, !tbaa !9
  %46 = mul nsw i32 %45, 2
  store i32 %46, ptr %5, align 4, !tbaa !9
  br label %49

47:                                               ; preds = %41
  store i32 4096, ptr %5, align 4, !tbaa !9
  %48 = call i32 @sched_yield() #5
  br label %49

49:                                               ; preds = %47, %44
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #5
  br label %50

50:                                               ; preds = %49
  %51 = load ptr, ptr %2, align 8, !tbaa !5
  %52 = load volatile i32, ptr %51, align 4, !tbaa !9
  %53 = and i32 %52, 1
  %54 = icmp ne i32 0, %53
  br i1 %54, label %32, label %55, !llvm.loop !13

55:                                               ; preds = %50
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #5
  br label %56

56:                                               ; preds = %55
  br label %57

57:                                               ; preds = %56
  br label %25, !llvm.loop !14

58:                                               ; preds = %25
  %59 = load ptr, ptr %2, align 8, !tbaa !5
  %60 = load volatile i32, ptr %59, align 4, !tbaa !9
  %61 = icmp ne i32 0, %60
  br i1 %61, label %62, label %63

62:                                               ; preds = %58
  br label %64

63:                                               ; preds = %58
  call void @__assert_fail(ptr noundef @.str.23, ptr noundef @.str.1, i32 noundef 2487, ptr noundef @__PRETTY_FUNCTION__.libxsmm_xrelease_scratch) #8
  unreachable

64:                                               ; preds = %62
  br label %65

65:                                               ; preds = %64, %14
  %66 = load i32, ptr @internal_malloc_kind, align 64, !tbaa !9
  %67 = and i32 %66, 1
  %68 = icmp eq i32 0, %67
  br i1 %68, label %72, label %69

69:                                               ; preds = %65
  %70 = load i32, ptr @internal_malloc_kind, align 64, !tbaa !9
  %71 = icmp sge i32 0, %70
  br i1 %71, label %72, label %119

72:                                               ; preds = %69, %65
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #5
  %73 = and i64 add (i64 ptrtoint (ptr @internal_malloc_pool_buffer to i64), i64 63), -64
  %74 = inttoptr i64 %73 to ptr
  store ptr %74, ptr %3, align 8, !tbaa !5
  store i32 0, ptr %7, align 4, !tbaa !9
  br label %75

75:                                               ; preds = %115, %72
  %76 = load i32, ptr %7, align 4, !tbaa !9
  %77 = load i32, ptr @libxsmm_scratch_pools, align 4, !tbaa !9
  %78 = icmp ult i32 %76, %77
  br i1 %78, label %79, label %118

79:                                               ; preds = %75
  %80 = load ptr, ptr %3, align 8, !tbaa !5
  %81 = load i32, ptr %7, align 4, !tbaa !9
  %82 = zext i32 %81 to i64
  %83 = getelementptr inbounds %union.internal_malloc_pool_type, ptr %80, i64 %82
  %84 = getelementptr inbounds %struct.anon, ptr %83, i32 0, i32 0
  %85 = load i64, ptr %84, align 8, !tbaa !15
  %86 = icmp ne i64 0, %85
  br i1 %86, label %87, label %113

87:                                               ; preds = %79
  %88 = load ptr, ptr %3, align 8, !tbaa !5
  %89 = load i32, ptr %7, align 4, !tbaa !9
  %90 = zext i32 %89 to i64
  %91 = getelementptr inbounds %union.internal_malloc_pool_type, ptr %88, i64 %90
  %92 = getelementptr inbounds %struct.anon, ptr %91, i32 0, i32 3
  %93 = load ptr, ptr %92, align 8, !tbaa !15
  %94 = icmp ne ptr null, %93
  br i1 %94, label %95, label %112

95:                                               ; preds = %87
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #5
  %96 = load ptr, ptr %3, align 8, !tbaa !5
  %97 = load i32, ptr %7, align 4, !tbaa !9
  %98 = zext i32 %97 to i64
  %99 = getelementptr inbounds %union.internal_malloc_pool_type, ptr %96, i64 %98
  %100 = getelementptr inbounds %struct.anon, ptr %99, i32 0, i32 3
  %101 = load ptr, ptr %100, align 8, !tbaa !15
  %102 = call ptr @internal_malloc_info(ptr noundef %101, i32 noundef 2)
  store ptr %102, ptr %8, align 8, !tbaa !5
  %103 = load ptr, ptr %8, align 8, !tbaa !5
  %104 = icmp ne ptr null, %103
  br i1 %104, label %105, label %111

105:                                              ; preds = %95
  %106 = load ptr, ptr %8, align 8, !tbaa !5
  %107 = getelementptr inbounds %struct.internal_malloc_info_type, ptr %106, i32 0, i32 1
  %108 = load ptr, ptr %107, align 8, !tbaa !16
  %109 = load ptr, ptr %8, align 8, !tbaa !5
  %110 = call i32 @internal_xfree(ptr noundef %108, ptr noundef %109)
  br label %111

111:                                              ; preds = %105, %95
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #5
  br label %112

112:                                              ; preds = %111, %87
  br label %114

113:                                              ; preds = %79
  br label %118

114:                                              ; preds = %112
  br label %115

115:                                              ; preds = %114
  %116 = load i32, ptr %7, align 4, !tbaa !9
  %117 = add i32 %116, 1
  store i32 %117, ptr %7, align 4, !tbaa !9
  br label %75, !llvm.loop !19

118:                                              ; preds = %113, %75
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #5
  br label %119

119:                                              ; preds = %118, %69
  %120 = call i32 @libxsmm_get_scratch_info(ptr noundef %4)
  %121 = icmp eq i32 0, %120
  br i1 %121, label %122, label %123

122:                                              ; preds = %119
  br label %124

123:                                              ; preds = %119
  call void @__assert_fail(ptr noundef @.str.81, ptr noundef @.str.1, i32 noundef 2511, ptr noundef @__PRETTY_FUNCTION__.libxsmm_xrelease_scratch) #8
  unreachable

124:                                              ; preds = %122
  %125 = getelementptr inbounds %struct.libxsmm_scratch_info, ptr %4, i32 0, i32 3
  %126 = load i64, ptr %125, align 8, !tbaa !20
  %127 = icmp ne i64 0, %126
  br i1 %127, label %128, label %150

128:                                              ; preds = %124
  %129 = load i32, ptr @libxsmm_verbosity, align 4, !tbaa !9
  %130 = icmp sle i32 2, %129
  br i1 %130, label %134, label %131

131:                                              ; preds = %128
  %132 = load i32, ptr @libxsmm_verbosity, align 4, !tbaa !9
  %133 = icmp sgt i32 0, %132
  br i1 %133, label %134, label %150

134:                                              ; preds = %131, %128
  call void @llvm.lifetime.start.p0(i64 32, ptr %9) #5
  %135 = getelementptr inbounds [32 x i8], ptr %9, i64 0, i64 0
  %136 = load i64, ptr @internal_malloc_public_cur, align 64, !tbaa !22
  %137 = load i64, ptr @internal_malloc_local_cur, align 64, !tbaa !22
  %138 = add i64 %136, %137
  %139 = call i64 @libxsmm_format_value(ptr noundef %135, i32 noundef 32, i64 noundef %138, ptr noundef @.str.38, ptr noundef @.str.39, i32 noundef 10)
  %140 = load ptr, ptr @stderr, align 8, !tbaa !5
  %141 = getelementptr inbounds [32 x i8], ptr %9, i64 0, i64 0
  %142 = getelementptr inbounds %struct.libxsmm_scratch_info, ptr %4, i32 0, i32 3
  %143 = load i64, ptr %142, align 8, !tbaa !20
  %144 = getelementptr inbounds %struct.libxsmm_scratch_info, ptr %4, i32 0, i32 3
  %145 = load i64, ptr %144, align 8, !tbaa !20
  %146 = icmp ult i64 1, %145
  %147 = zext i1 %146 to i64
  %148 = select i1 %146, ptr @.str.83, ptr @.str.49
  %149 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %140, ptr noundef @.str.82, ptr noundef %141, i64 noundef %143, ptr noundef %148) #5
  call void @llvm.lifetime.end.p0(i64 32, ptr %9) #5
  br label %150

150:                                              ; preds = %134, %131, %124
  %151 = load ptr, ptr %3, align 8, !tbaa !5
  %152 = icmp ne ptr null, %151
  br i1 %152, label %153, label %155

153:                                              ; preds = %150
  %154 = load ptr, ptr %3, align 8, !tbaa !5
  call void @llvm.memset.p0.i64(ptr align 8 %154, i8 0, i64 65536, i1 false)
  store i64 0, ptr @internal_malloc_public_cur, align 64, !tbaa !22
  store i64 0, ptr @internal_malloc_public_max, align 64, !tbaa !22
  store i64 0, ptr @internal_malloc_local_cur, align 64, !tbaa !22
  store i64 0, ptr @internal_malloc_local_max, align 64, !tbaa !22
  store i64 0, ptr @internal_malloc_scratch_nmallocs, align 64, !tbaa !22
  br label %155

155:                                              ; preds = %153, %150
  %156 = load ptr, ptr %2, align 8, !tbaa !5
  %157 = icmp ne ptr null, %156
  br i1 %157, label %158, label %166

158:                                              ; preds = %155
  %159 = load ptr, ptr %2, align 8, !tbaa !5
  %160 = load volatile i32, ptr %159, align 4, !tbaa !9
  %161 = icmp ne i32 0, %160
  br i1 %161, label %162, label %163

162:                                              ; preds = %158
  br label %164

163:                                              ; preds = %158
  call void @__assert_fail(ptr noundef @.str.25, ptr noundef @.str.1, i32 noundef 2529, ptr noundef @__PRETTY_FUNCTION__.libxsmm_xrelease_scratch) #8
  unreachable

164:                                              ; preds = %162
  %165 = load ptr, ptr %2, align 8, !tbaa !5
  store atomic i32 0, ptr %165 release, align 4
  br label %166

166:                                              ; preds = %164, %155
  call void @llvm.lifetime.end.p0(i64 48, ptr %4) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #5
  ret void
}

; Function Attrs: nounwind uwtable
declare dso_local i32 @libxsmm_get_scratch_info(ptr noundef) #3

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 = { inlinehint 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 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 "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 #5 = { nounwind }
attributes #6 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #7 = { "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 #8 = { 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 = !{!"int", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = distinct !{!13, !12}
!14 = distinct !{!14, !12}
!15 = !{!7, !7, i64 0}
!16 = !{!17, !6, i64 8}
!17 = !{!"internal_malloc_info_type", !7, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !18, i64 32, !10, i64 40}
!18 = !{!"long", !7, i64 0}
!19 = distinct !{!19, !12}
!20 = !{!21, !18, i64 24}
!21 = !{!"libxsmm_scratch_info", !18, i64 0, !18, i64 8, !18, i64 16, !18, i64 24, !18, i64 32, !10, i64 40}
!22 = !{!18, !18, 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"

%struct.libxsmm_scratch_info = type { i64, i64, i64, i64, i64, i32 }
%union.internal_malloc_pool_type = type { %struct.anon, [8 x i8] }
%struct.anon = type { i64, i64, i64, ptr, ptr, ptr, i32 }

@.str.1 = external hidden unnamed_addr constant [70 x i8], align 1
@libxsmm_verbosity = external local_unnamed_addr global i32, align 4
@stderr = external local_unnamed_addr global ptr, align 8
@libxsmm_scratch_pools = external local_unnamed_addr global i32, align 4
@internal_malloc_pool_buffer = external dso_local global [65599 x i8], align 64
@internal_malloc_kind = external dso_local local_unnamed_addr global i32, align 64
@internal_malloc_local_cur = external dso_local local_unnamed_addr global i64, align 64
@internal_malloc_local_max = external dso_local local_unnamed_addr global i64, align 64
@internal_malloc_scratch_nmallocs = external dso_local local_unnamed_addr global i64, align 64
@internal_malloc_public_cur = external dso_local local_unnamed_addr global i64, align 64
@.str.22 = external hidden unnamed_addr constant [39 x i8], align 1
@.str.23 = external hidden unnamed_addr constant [44 x i8], align 1
@.str.25 = external hidden unnamed_addr constant [44 x i8], align 1
@.str.38 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.39 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.49 = external hidden unnamed_addr constant [1 x i8], align 1
@internal_malloc_public_max = external dso_local local_unnamed_addr global i64, align 64
@.str.80 = external hidden unnamed_addr constant [30 x i8], align 1
@__PRETTY_FUNCTION__.libxsmm_xrelease_scratch = external hidden unnamed_addr constant [46 x i8], align 1
@.str.81 = external hidden unnamed_addr constant [45 x i8], align 1
@.str.82 = external hidden unnamed_addr constant [67 x i8], align 1
@.str.83 = external hidden unnamed_addr constant [2 x i8], align 1

; 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

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

; Function Attrs: inlinehint nounwind uwtable
declare hidden ptr @internal_malloc_info(ptr noundef, i32 noundef) local_unnamed_addr #2

; Function Attrs: nounwind uwtable
declare dso_local i32 @internal_xfree(ptr noundef, ptr noundef) local_unnamed_addr #3

; Function Attrs: nofree nounwind
declare noundef i32 @fprintf(ptr nocapture noundef, ptr nocapture noundef readonly, ...) local_unnamed_addr #4

; Function Attrs: nounwind
declare void @llvm.x86.sse2.pause() #5

; Function Attrs: nounwind
declare i32 @sched_yield() local_unnamed_addr #6

; Function Attrs: mustprogress nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #7

declare i64 @libxsmm_format_value(ptr noundef, i32 noundef, i64 noundef, ptr noundef, ptr noundef, i32 noundef) local_unnamed_addr #8

; Function Attrs: nounwind uwtable
define dso_local void @libxsmm_xrelease_scratch(ptr noundef %0) local_unnamed_addr #3 {
  %2 = alloca %struct.libxsmm_scratch_info, align 8
  %3 = alloca [32 x i8], align 16
  call void @llvm.lifetime.start.p0(i64 48, ptr nonnull %2) #5
  %4 = load i32, ptr @libxsmm_scratch_pools, align 4, !tbaa !5
  %5 = icmp ult i32 %4, 1025
  br i1 %5, label %7, label %6

6:                                                ; preds = %1
  tail call void @__assert_fail(ptr noundef nonnull @.str.80, ptr noundef nonnull @.str.1, i32 noundef 2485, ptr noundef nonnull @__PRETTY_FUNCTION__.libxsmm_xrelease_scratch) #9
  unreachable

7:                                                ; preds = %1
  %.not = icmp eq ptr %0, null
  br i1 %.not, label %27, label %8

8:                                                ; preds = %7
  %9 = ptrtoint ptr %0 to i64
  %10 = and i64 %9, 3
  %11 = icmp eq i64 %10, 0
  br i1 %11, label %.preheader45, label %13

.preheader45:                                     ; preds = %8
  %12 = atomicrmw or ptr %0, i32 1 seq_cst, align 4
  %.not3547 = icmp eq i32 %12, 0
  br i1 %.not3547, label %._crit_edge48, label %.preheader

13:                                               ; preds = %8
  tail call void @__assert_fail(ptr noundef nonnull @.str.22, ptr noundef nonnull @.str.1, i32 noundef 2487, ptr noundef nonnull @__PRETTY_FUNCTION__.libxsmm_xrelease_scratch) #9
  unreachable

.preheader:                                       ; preds = %.preheader45, %.preheader.backedge
  %.030 = phi i32 [ %.030.be, %.preheader.backedge ], [ 1, %.preheader45 ]
  %14 = icmp sgt i32 %.030, 0
  br i1 %14, label %.lr.ph.preheader, label %._crit_edge.thread

.lr.ph.preheader:                                 ; preds = %.preheader
  %xtraiter = and i32 %.030, 7
  %15 = icmp ult i32 %.030, 8
  br i1 %15, label %._crit_edge.unr-lcssa, label %.lr.ph.preheader.new

.lr.ph.preheader.new:                             ; preds = %.lr.ph.preheader
  %unroll_iter = and i32 %.030, 2147483640
  br label %.lr.ph

.lr.ph:                                           ; preds = %.lr.ph, %.lr.ph.preheader.new
  %niter = phi i32 [ 0, %.lr.ph.preheader.new ], [ %niter.next.7, %.lr.ph ]
  tail call void @llvm.x86.sse2.pause()
  tail call void @llvm.x86.sse2.pause()
  tail call void @llvm.x86.sse2.pause()
  tail call void @llvm.x86.sse2.pause()
  tail call void @llvm.x86.sse2.pause()
  tail call void @llvm.x86.sse2.pause()
  tail call void @llvm.x86.sse2.pause()
  tail call void @llvm.x86.sse2.pause()
  %niter.next.7 = add i32 %niter, 8
  %niter.ncmp.7 = icmp eq i32 %niter.next.7, %unroll_iter
  br i1 %niter.ncmp.7, label %._crit_edge.unr-lcssa, label %.lr.ph, !llvm.loop !9

._crit_edge.unr-lcssa:                            ; preds = %.lr.ph, %.lr.ph.preheader
  %lcmp.mod.not = icmp eq i32 %xtraiter, 0
  br i1 %lcmp.mod.not, label %._crit_edge, label %.lr.ph.epil

.lr.ph.epil:                                      ; preds = %._crit_edge.unr-lcssa, %.lr.ph.epil
  %epil.iter = phi i32 [ %epil.iter.next, %.lr.ph.epil ], [ 0, %._crit_edge.unr-lcssa ]
  tail call void @llvm.x86.sse2.pause()
  %epil.iter.next = add i32 %epil.iter, 1
  %epil.iter.cmp.not = icmp eq i32 %epil.iter.next, %xtraiter
  br i1 %epil.iter.cmp.not, label %._crit_edge, label %.lr.ph.epil, !llvm.loop !11

._crit_edge:                                      ; preds = %.lr.ph.epil, %._crit_edge.unr-lcssa
  %16 = icmp slt i32 %.030, 4096
  br i1 %16, label %._crit_edge.thread, label %18

._crit_edge.thread:                               ; preds = %.preheader, %._crit_edge
  %17 = shl i32 %.030, 1
  br label %20

18:                                               ; preds = %._crit_edge
  %19 = tail call i32 @sched_yield() #5
  br label %20

20:                                               ; preds = %18, %._crit_edge.thread
  %.1 = phi i32 [ %17, %._crit_edge.thread ], [ 4096, %18 ]
  %21 = load volatile i32, ptr %0, align 4, !tbaa !5
  %22 = and i32 %21, 1
  %.not43 = icmp eq i32 %22, 0
  br i1 %.not43, label %23, label %.preheader.backedge

.preheader.backedge:                              ; preds = %20, %23
  %.030.be = phi i32 [ %.1, %20 ], [ 1, %23 ]
  br label %.preheader, !llvm.loop !13

23:                                               ; preds = %20
  %24 = atomicrmw or ptr %0, i32 1 seq_cst, align 4
  %.not35 = icmp eq i32 %24, 0
  br i1 %.not35, label %._crit_edge48, label %.preheader.backedge

._crit_edge48:                                    ; preds = %23, %.preheader45
  %25 = load volatile i32, ptr %0, align 4, !tbaa !5
  %.not36 = icmp eq i32 %25, 0
  br i1 %.not36, label %26, label %27

26:                                               ; preds = %._crit_edge48
  tail call void @__assert_fail(ptr noundef nonnull @.str.23, ptr noundef nonnull @.str.1, i32 noundef 2487, ptr noundef nonnull @__PRETTY_FUNCTION__.libxsmm_xrelease_scratch) #9
  unreachable

27:                                               ; preds = %._crit_edge48, %7
  %28 = load i32, ptr @internal_malloc_kind, align 64
  %29 = and i32 %28, 1
  %30 = icmp eq i32 %29, 0
  %31 = icmp slt i32 %28, 1
  %or.cond = or i1 %31, %30
  br i1 %or.cond, label %32, label %.loopexit

32:                                               ; preds = %27
  %33 = and i64 add (i64 ptrtoint (ptr @internal_malloc_pool_buffer to i64), i64 63), -64
  %34 = inttoptr i64 %33 to ptr
  %35 = load i32, ptr @libxsmm_scratch_pools, align 4, !tbaa !5
  %.not53 = icmp eq i32 %35, 0
  br i1 %.not53, label %.loopexit, label %.lr.ph51

.lr.ph51:                                         ; preds = %32, %47
  %indvars.iv = phi i64 [ %indvars.iv.next, %47 ], [ 0, %32 ]
  %36 = getelementptr inbounds %union.internal_malloc_pool_type, ptr %34, i64 %indvars.iv
  %37 = load i64, ptr %36, align 64, !tbaa !14
  %.not37 = icmp eq i64 %37, 0
  br i1 %.not37, label %.loopexit, label %38

38:                                               ; preds = %.lr.ph51
  %39 = getelementptr inbounds i8, ptr %36, i64 24
  %40 = load ptr, ptr %39, align 8, !tbaa !14
  %.not41 = icmp eq ptr %40, null
  br i1 %.not41, label %47, label %41

41:                                               ; preds = %38
  %42 = tail call ptr @internal_malloc_info(ptr noundef nonnull %40, i32 noundef 2)
  %.not42 = icmp eq ptr %42, null
  br i1 %.not42, label %47, label %43

43:                                               ; preds = %41
  %44 = getelementptr inbounds i8, ptr %42, i64 8
  %45 = load ptr, ptr %44, align 8, !tbaa !15
  %46 = tail call i32 @internal_xfree(ptr noundef %45, ptr noundef nonnull %42)
  br label %47

47:                                               ; preds = %41, %43, %38
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %48 = load i32, ptr @libxsmm_scratch_pools, align 4, !tbaa !5
  %49 = zext i32 %48 to i64
  %50 = icmp ult i64 %indvars.iv.next, %49
  br i1 %50, label %.lr.ph51, label %.loopexit, !llvm.loop !19

.loopexit:                                        ; preds = %.lr.ph51, %47, %32, %27
  %.0 = phi ptr [ null, %27 ], [ %34, %32 ], [ %34, %47 ], [ %34, %.lr.ph51 ]
  %51 = call i32 @libxsmm_get_scratch_info(ptr noundef nonnull %2)
  %52 = icmp eq i32 %51, 0
  br i1 %52, label %54, label %53

53:                                               ; preds = %.loopexit
  call void @__assert_fail(ptr noundef nonnull @.str.81, ptr noundef nonnull @.str.1, i32 noundef 2511, ptr noundef nonnull @__PRETTY_FUNCTION__.libxsmm_xrelease_scratch) #9
  unreachable

54:                                               ; preds = %.loopexit
  %55 = getelementptr inbounds i8, ptr %2, i64 24
  %56 = load i64, ptr %55, align 8, !tbaa !20
  %.not38 = icmp ne i64 %56, 0
  %57 = load i32, ptr @libxsmm_verbosity, align 4
  %or.cond3 = icmp ugt i32 %57, 1
  %or.cond44 = select i1 %.not38, i1 %or.cond3, i1 false
  br i1 %or.cond44, label %58, label %68

58:                                               ; preds = %54
  call void @llvm.lifetime.start.p0(i64 32, ptr nonnull %3) #5
  %59 = load i64, ptr @internal_malloc_public_cur, align 64, !tbaa !22
  %60 = load i64, ptr @internal_malloc_local_cur, align 64, !tbaa !22
  %61 = add i64 %60, %59
  %62 = call i64 @libxsmm_format_value(ptr noundef nonnull %3, i32 noundef 32, i64 noundef %61, ptr noundef nonnull @.str.38, ptr noundef nonnull @.str.39, i32 noundef 10) #5
  %63 = load ptr, ptr @stderr, align 8, !tbaa !23
  %64 = load i64, ptr %55, align 8, !tbaa !20
  %65 = icmp ugt i64 %64, 1
  %66 = select i1 %65, ptr @.str.83, ptr @.str.49
  %67 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %63, ptr noundef nonnull @.str.82, ptr noundef nonnull %3, i64 noundef %64, ptr noundef nonnull %66) #10
  call void @llvm.lifetime.end.p0(i64 32, ptr nonnull %3) #5
  br label %68

68:                                               ; preds = %58, %54
  %.not39 = icmp eq ptr %.0, null
  br i1 %.not39, label %70, label %69

69:                                               ; preds = %68
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(65536) %.0, i8 0, i64 65536, i1 false)
  store i64 0, ptr @internal_malloc_public_cur, align 64, !tbaa !22
  store i64 0, ptr @internal_malloc_public_max, align 64, !tbaa !22
  store i64 0, ptr @internal_malloc_local_cur, align 64, !tbaa !22
  store i64 0, ptr @internal_malloc_local_max, align 64, !tbaa !22
  store i64 0, ptr @internal_malloc_scratch_nmallocs, align 64, !tbaa !22
  br label %70

70:                                               ; preds = %69, %68
  br i1 %.not, label %75, label %71

71:                                               ; preds = %70
  %72 = load volatile i32, ptr %0, align 4, !tbaa !5
  %.not40 = icmp eq i32 %72, 0
  br i1 %.not40, label %73, label %74

73:                                               ; preds = %71
  call void @__assert_fail(ptr noundef nonnull @.str.25, ptr noundef nonnull @.str.1, i32 noundef 2529, ptr noundef nonnull @__PRETTY_FUNCTION__.libxsmm_xrelease_scratch) #9
  unreachable

74:                                               ; preds = %71
  store atomic i32 0, ptr %0 release, align 4
  br label %75

75:                                               ; preds = %74, %70
  call void @llvm.lifetime.end.p0(i64 48, ptr nonnull %2) #5
  ret void
}

; Function Attrs: nounwind uwtable
declare dso_local i32 @libxsmm_get_scratch_info(ptr noundef) local_unnamed_addr #3

attributes #0 = { mustprogress 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 = { inlinehint 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 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 = { nofree 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 #5 = { nounwind }
attributes #6 = { 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 #7 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #8 = { "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 #9 = { noreturn nounwind }
attributes #10 = { cold 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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.unroll.disable"}
!13 = distinct !{!13, !10}
!14 = !{!7, !7, i64 0}
!15 = !{!16, !17, i64 8}
!16 = !{!"internal_malloc_info_type", !7, i64 0, !17, i64 8, !17, i64 16, !17, i64 24, !18, i64 32, !6, i64 40}
!17 = !{!"any pointer", !7, i64 0}
!18 = !{!"long", !7, i64 0}
!19 = distinct !{!19, !10}
!20 = !{!21, !18, i64 24}
!21 = !{!"libxsmm_scratch_info", !18, i64 0, !18, i64 8, !18, i64 16, !18, i64 24, !18, i64 32, !6, i64 40}
!22 = !{!18, !18, i64 0}
!23 = !{!17, !17, i64 0}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GlobalOptPass,IndVarSimplifyPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass