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

@.str.1 = external hidden unnamed_addr constant [70 x i8], align 1
@.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
@internal_pmallocs = external dso_local global [16 x i32], align 64
@.str.89 = external hidden unnamed_addr constant [63 x i8], align 1
@__PRETTY_FUNCTION__.libxsmm_pfree = external hidden unnamed_addr constant [46 x i8], align 1
@.str.90 = external hidden unnamed_addr constant [17 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: nounwind
declare void @llvm.x86.sse2.pause() #2

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

declare i32 @libxsmm_crc32_u64(i32 noundef, ptr noundef, ...) #4

; Function Attrs: nounwind uwtable
define dso_local void @libxsmm_pfree(ptr noundef %0, ptr noundef %1, ptr noundef %2) #5 {
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca i32, align 4
  %8 = alloca ptr, align 8
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  store ptr %2, ptr %6, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #2
  %11 = call i32 (i32, ptr, ...) @libxsmm_crc32_u64(i32 noundef 1051981, ptr noundef %5)
  store i32 %11, ptr %7, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #2
  %12 = load i32, ptr %7, align 4, !tbaa !9
  %13 = and i32 %12, 15
  %14 = zext i32 %13 to i64
  %15 = getelementptr inbounds i32, ptr @internal_pmallocs, i64 %14
  store ptr %15, ptr %8, align 8, !tbaa !5
  %16 = load ptr, ptr %4, align 8, !tbaa !5
  %17 = icmp ne ptr null, %16
  br i1 %17, label %18, label %25

18:                                               ; preds = %3
  %19 = load ptr, ptr %5, align 8, !tbaa !5
  %20 = icmp ne ptr null, %19
  br i1 %20, label %21, label %25

21:                                               ; preds = %18
  %22 = load ptr, ptr %6, align 8, !tbaa !5
  %23 = icmp ne ptr null, %22
  br i1 %23, label %24, label %25

24:                                               ; preds = %21
  br label %26

25:                                               ; preds = %21, %18, %3
  call void @__assert_fail(ptr noundef @.str.89, ptr noundef @.str.1, i32 noundef 2708, ptr noundef @__PRETTY_FUNCTION__.libxsmm_pfree) #6
  unreachable

26:                                               ; preds = %24
  %27 = load ptr, ptr %8, align 8, !tbaa !5
  %28 = ptrtoint ptr %27 to i64
  %29 = and i64 %28, 3
  %30 = icmp eq i64 0, %29
  br i1 %30, label %31, label %32

31:                                               ; preds = %26
  br label %33

32:                                               ; preds = %26
  call void @__assert_fail(ptr noundef @.str.22, ptr noundef @.str.1, i32 noundef 2709, ptr noundef @__PRETTY_FUNCTION__.libxsmm_pfree) #6
  unreachable

33:                                               ; preds = %31
  br label %34

34:                                               ; preds = %66, %33
  %35 = load ptr, ptr %8, align 8, !tbaa !5
  %36 = atomicrmw or ptr %35, i32 1 seq_cst, align 4
  %37 = icmp eq i32 0, %36
  %38 = xor i1 %37, true
  br i1 %38, label %39, label %67

39:                                               ; preds = %34
  br label %40

40:                                               ; preds = %39
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #2
  store i32 1, ptr %9, align 4, !tbaa !9
  br label %41

41:                                               ; preds = %59, %40
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #2
  store i32 0, ptr %10, align 4, !tbaa !9
  br label %42

42:                                               ; preds = %47, %41
  %43 = load i32, ptr %10, align 4, !tbaa !9
  %44 = load i32, ptr %9, align 4, !tbaa !9
  %45 = icmp slt i32 %43, %44
  br i1 %45, label %46, label %50

46:                                               ; preds = %42
  call void @llvm.x86.sse2.pause()
  br label %47

47:                                               ; preds = %46
  %48 = load i32, ptr %10, align 4, !tbaa !9
  %49 = add nsw i32 %48, 1
  store i32 %49, ptr %10, align 4, !tbaa !9
  br label %42, !llvm.loop !11

50:                                               ; preds = %42
  %51 = load i32, ptr %9, align 4, !tbaa !9
  %52 = icmp slt i32 %51, 4096
  br i1 %52, label %53, label %56

53:                                               ; preds = %50
  %54 = load i32, ptr %9, align 4, !tbaa !9
  %55 = mul nsw i32 %54, 2
  store i32 %55, ptr %9, align 4, !tbaa !9
  br label %58

56:                                               ; preds = %50
  store i32 4096, ptr %9, align 4, !tbaa !9
  %57 = call i32 @sched_yield() #2
  br label %58

58:                                               ; preds = %56, %53
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #2
  br label %59

59:                                               ; preds = %58
  %60 = load ptr, ptr %8, align 8, !tbaa !5
  %61 = load volatile i32, ptr %60, align 4, !tbaa !9
  %62 = and i32 %61, 1
  %63 = icmp ne i32 0, %62
  br i1 %63, label %41, label %64, !llvm.loop !13

64:                                               ; preds = %59
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #2
  br label %65

65:                                               ; preds = %64
  br label %66

66:                                               ; preds = %65
  br label %34, !llvm.loop !14

67:                                               ; preds = %34
  %68 = load ptr, ptr %8, align 8, !tbaa !5
  %69 = load volatile i32, ptr %68, align 4, !tbaa !9
  %70 = icmp ne i32 0, %69
  br i1 %70, label %71, label %72

71:                                               ; preds = %67
  br label %73

72:                                               ; preds = %67
  call void @__assert_fail(ptr noundef @.str.23, ptr noundef @.str.1, i32 noundef 2709, ptr noundef @__PRETTY_FUNCTION__.libxsmm_pfree) #6
  unreachable

73:                                               ; preds = %71
  %74 = load ptr, ptr %5, align 8, !tbaa !5
  %75 = load ptr, ptr %6, align 8, !tbaa !5
  %76 = load i64, ptr %75, align 8, !tbaa !15
  %77 = getelementptr inbounds ptr, ptr %74, i64 %76
  %78 = load ptr, ptr %77, align 8, !tbaa !5
  %79 = icmp eq ptr null, %78
  br i1 %79, label %80, label %81

80:                                               ; preds = %73
  br label %82

81:                                               ; preds = %73
  call void @__assert_fail(ptr noundef @.str.90, ptr noundef @.str.1, i32 noundef 2710, ptr noundef @__PRETTY_FUNCTION__.libxsmm_pfree) #6
  unreachable

82:                                               ; preds = %80
  %83 = load ptr, ptr %4, align 8, !tbaa !5
  %84 = load ptr, ptr %5, align 8, !tbaa !5
  %85 = load ptr, ptr %6, align 8, !tbaa !5
  %86 = load i64, ptr %85, align 8, !tbaa !15
  %87 = add i64 %86, 1
  store i64 %87, ptr %85, align 8, !tbaa !15
  %88 = getelementptr inbounds ptr, ptr %84, i64 %86
  store ptr %83, ptr %88, align 8, !tbaa !5
  %89 = load ptr, ptr %8, align 8, !tbaa !5
  %90 = load volatile i32, ptr %89, align 4, !tbaa !9
  %91 = icmp ne i32 0, %90
  br i1 %91, label %92, label %93

92:                                               ; preds = %82
  br label %94

93:                                               ; preds = %82
  call void @__assert_fail(ptr noundef @.str.25, ptr noundef @.str.1, i32 noundef 2712, ptr noundef @__PRETTY_FUNCTION__.libxsmm_pfree) #6
  unreachable

94:                                               ; preds = %92
  %95 = load ptr, ptr %8, align 8, !tbaa !5
  store atomic i32 0, ptr %95 release, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #2
  ret void
}

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 }
attributes #3 = { 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 #4 = { "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 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 #6 = { 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 = !{!16, !16, i64 0}
!16 = !{!"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.1 = external hidden unnamed_addr constant [70 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
@internal_pmallocs = external dso_local global [16 x i32], align 64
@.str.89 = external hidden unnamed_addr constant [63 x i8], align 1
@__PRETTY_FUNCTION__.libxsmm_pfree = external hidden unnamed_addr constant [46 x i8], align 1
@.str.90 = external hidden unnamed_addr constant [17 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
declare void @llvm.x86.sse2.pause() #1

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

declare i32 @libxsmm_crc32_u64(i32 noundef, ptr noundef, ...) local_unnamed_addr #3

; Function Attrs: nounwind uwtable
define dso_local void @libxsmm_pfree(ptr noundef %0, ptr noundef %1, ptr noundef %2) local_unnamed_addr #4 {
  %4 = alloca ptr, align 8
  store ptr %1, ptr %4, align 8, !tbaa !5
  %5 = call i32 (i32, ptr, ...) @libxsmm_crc32_u64(i32 noundef 1051981, ptr noundef nonnull %4) #1
  %6 = and i32 %5, 15
  %7 = zext nneg i32 %6 to i64
  %8 = getelementptr inbounds i32, ptr @internal_pmallocs, i64 %7
  %9 = icmp ne ptr %0, null
  %10 = load ptr, ptr %4, align 8
  %11 = icmp ne ptr %10, null
  %or.cond = select i1 %9, i1 %11, i1 false
  %12 = icmp ne ptr %2, null
  %or.cond3 = and i1 %12, %or.cond
  br i1 %or.cond3, label %.preheader25, label %14

.preheader25:                                     ; preds = %3
  %13 = atomicrmw or ptr %8, i32 1 seq_cst, align 4
  %.not27 = icmp eq i32 %13, 0
  br i1 %.not27, label %._crit_edge28, label %.preheader

14:                                               ; preds = %3
  call void @__assert_fail(ptr noundef nonnull @.str.89, ptr noundef nonnull @.str.1, i32 noundef 2708, ptr noundef nonnull @__PRETTY_FUNCTION__.libxsmm_pfree) #5
  unreachable

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

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

.lr.ph.preheader.new:                             ; preds = %.lr.ph.preheader
  %unroll_iter = and i32 %.019, 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 ]
  call void @llvm.x86.sse2.pause()
  call void @llvm.x86.sse2.pause()
  call void @llvm.x86.sse2.pause()
  call void @llvm.x86.sse2.pause()
  call void @llvm.x86.sse2.pause()
  call void @llvm.x86.sse2.pause()
  call void @llvm.x86.sse2.pause()
  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 ]
  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
  %17 = icmp slt i32 %.019, 4096
  br i1 %17, label %._crit_edge.thread, label %19

._crit_edge.thread:                               ; preds = %.preheader, %._crit_edge
  %18 = shl i32 %.019, 1
  br label %21

19:                                               ; preds = %._crit_edge
  %20 = call i32 @sched_yield() #1
  br label %21

21:                                               ; preds = %19, %._crit_edge.thread
  %.1 = phi i32 [ %18, %._crit_edge.thread ], [ 4096, %19 ]
  %22 = load volatile i32, ptr %8, align 4, !tbaa !13
  %23 = and i32 %22, 1
  %.not24 = icmp eq i32 %23, 0
  br i1 %.not24, label %24, label %.preheader.backedge

.preheader.backedge:                              ; preds = %21, %24
  %.019.be = phi i32 [ %.1, %21 ], [ 1, %24 ]
  br label %.preheader, !llvm.loop !15

24:                                               ; preds = %21
  %25 = atomicrmw or ptr %8, i32 1 seq_cst, align 4
  %.not = icmp eq i32 %25, 0
  br i1 %.not, label %._crit_edge28, label %.preheader.backedge

._crit_edge28:                                    ; preds = %24, %.preheader25
  %26 = load volatile i32, ptr %8, align 4, !tbaa !13
  %.not22 = icmp eq i32 %26, 0
  br i1 %.not22, label %27, label %28

27:                                               ; preds = %._crit_edge28
  call void @__assert_fail(ptr noundef nonnull @.str.23, ptr noundef nonnull @.str.1, i32 noundef 2709, ptr noundef nonnull @__PRETTY_FUNCTION__.libxsmm_pfree) #5
  unreachable

28:                                               ; preds = %._crit_edge28
  %29 = load ptr, ptr %4, align 8, !tbaa !5
  %30 = load i64, ptr %2, align 8, !tbaa !16
  %31 = getelementptr inbounds ptr, ptr %29, i64 %30
  %32 = load ptr, ptr %31, align 8, !tbaa !5
  %33 = icmp eq ptr %32, null
  br i1 %33, label %35, label %34

34:                                               ; preds = %28
  call void @__assert_fail(ptr noundef nonnull @.str.90, ptr noundef nonnull @.str.1, i32 noundef 2710, ptr noundef nonnull @__PRETTY_FUNCTION__.libxsmm_pfree) #5
  unreachable

35:                                               ; preds = %28
  %36 = add i64 %30, 1
  store i64 %36, ptr %2, align 8, !tbaa !16
  store ptr %0, ptr %31, align 8, !tbaa !5
  %37 = load volatile i32, ptr %8, align 4, !tbaa !13
  %.not23 = icmp eq i32 %37, 0
  br i1 %.not23, label %38, label %39

38:                                               ; preds = %35
  call void @__assert_fail(ptr noundef nonnull @.str.25, ptr noundef nonnull @.str.1, i32 noundef 2712, ptr noundef nonnull @__PRETTY_FUNCTION__.libxsmm_pfree) #5
  unreachable

39:                                               ; preds = %35
  store atomic i32 0, ptr %8 release, align 4
  ret void
}

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 }
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 = { "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 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 #5 = { 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 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.unroll.disable"}
!13 = !{!14, !14, i64 0}
!14 = !{!"int", !7, i64 0}
!15 = distinct !{!15, !10}
!16 = !{!17, !17, i64 0}
!17 = !{!"long", !7, i64 0}


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