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

; 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 [73 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [16 x i8], align 1
@__PRETTY_FUNCTION__.libxsmm_product_limit = external hidden unnamed_addr constant [68 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [35 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
define dso_local i32 @libxsmm_product_limit(i32 noundef %0, i32 noundef %1, i32 noundef %2) #2 {
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  store i32 %0, ptr %4, align 4, !tbaa !5
  store i32 %1, ptr %5, align 4, !tbaa !5
  store i32 %2, ptr %6, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #4
  %8 = load i32, ptr %5, align 4, !tbaa !5
  %9 = icmp ult i32 1, %8
  br i1 %9, label %10, label %14

10:                                               ; preds = %3
  %11 = load i32, ptr %4, align 4, !tbaa !5
  %12 = load i32, ptr %5, align 4, !tbaa !5
  %13 = call i32 @internal_product_limit(i32 noundef %11, i32 noundef %12)
  store i32 %13, ptr %7, align 4, !tbaa !5
  br label %16

14:                                               ; preds = %3
  %15 = load i32, ptr %5, align 4, !tbaa !5
  store i32 %15, ptr %7, align 4, !tbaa !5
  br label %16

16:                                               ; preds = %14, %10
  %17 = load i32, ptr %6, align 4, !tbaa !5
  %18 = icmp ne i32 0, %17
  br i1 %18, label %19, label %61

19:                                               ; preds = %16
  %20 = load i32, ptr %5, align 4, !tbaa !5
  %21 = load i32, ptr %4, align 4, !tbaa !5
  %22 = icmp ult i32 %20, %21
  br i1 %22, label %23, label %46

23:                                               ; preds = %19
  %24 = load i32, ptr %7, align 4, !tbaa !5
  %25 = load i32, ptr %5, align 4, !tbaa !5
  %26 = icmp ult i32 %24, %25
  br i1 %26, label %27, label %33

27:                                               ; preds = %23
  %28 = load i32, ptr %4, align 4, !tbaa !5
  %29 = load i32, ptr %5, align 4, !tbaa !5
  %30 = mul i32 2, %29
  %31 = sub i32 %30, 1
  %32 = call i32 @internal_product_limit(i32 noundef %28, i32 noundef %31)
  store i32 %32, ptr %7, align 4, !tbaa !5
  br label %33

33:                                               ; preds = %27, %23
  %34 = load i32, ptr %7, align 4, !tbaa !5
  %35 = load i32, ptr %5, align 4, !tbaa !5
  %36 = icmp ult i32 %34, %35
  br i1 %36, label %37, label %39

37:                                               ; preds = %33
  %38 = load i32, ptr %4, align 4, !tbaa !5
  store i32 %38, ptr %7, align 4, !tbaa !5
  br label %39

39:                                               ; preds = %37, %33
  %40 = load i32, ptr %5, align 4, !tbaa !5
  %41 = load i32, ptr %7, align 4, !tbaa !5
  %42 = icmp ule i32 %40, %41
  br i1 %42, label %43, label %44

43:                                               ; preds = %39
  br label %45

44:                                               ; preds = %39
  call void @__assert_fail(ptr noundef @.str.7, ptr noundef @.str.1, i32 noundef 590, ptr noundef @__PRETTY_FUNCTION__.libxsmm_product_limit) #5
  unreachable

45:                                               ; preds = %43
  br label %60

46:                                               ; preds = %19
  %47 = load i32, ptr %4, align 4, !tbaa !5
  %48 = icmp ne i32 0, %47
  br i1 %48, label %49, label %58

49:                                               ; preds = %46
  %50 = load i32, ptr %5, align 4, !tbaa !5
  %51 = load i32, ptr %4, align 4, !tbaa !5
  %52 = sub i32 %51, 1
  %53 = add i32 %50, %52
  %54 = load i32, ptr %4, align 4, !tbaa !5
  %55 = udiv i32 %53, %54
  %56 = load i32, ptr %4, align 4, !tbaa !5
  %57 = mul i32 %55, %56
  store i32 %57, ptr %7, align 4, !tbaa !5
  br label %59

58:                                               ; preds = %46
  store i32 0, ptr %7, align 4, !tbaa !5
  br label %59

59:                                               ; preds = %58, %49
  br label %60

60:                                               ; preds = %59, %45
  br label %68

61:                                               ; preds = %16
  %62 = load i32, ptr %4, align 4, !tbaa !5
  %63 = load i32, ptr %7, align 4, !tbaa !5
  %64 = icmp ult i32 %62, %63
  br i1 %64, label %65, label %67

65:                                               ; preds = %61
  %66 = load i32, ptr %4, align 4, !tbaa !5
  store i32 %66, ptr %7, align 4, !tbaa !5
  br label %67

67:                                               ; preds = %65, %61
  br label %68

68:                                               ; preds = %67, %60
  %69 = load i32, ptr %6, align 4, !tbaa !5
  %70 = icmp ne i32 0, %69
  br i1 %70, label %75, label %71

71:                                               ; preds = %68
  %72 = load i32, ptr %7, align 4, !tbaa !5
  %73 = load i32, ptr %4, align 4, !tbaa !5
  %74 = icmp ule i32 %72, %73
  br i1 %74, label %75, label %76

75:                                               ; preds = %71, %68
  br label %77

76:                                               ; preds = %71
  call void @__assert_fail(ptr noundef @.str.8, ptr noundef @.str.1, i32 noundef 600, ptr noundef @__PRETTY_FUNCTION__.libxsmm_product_limit) #5
  unreachable

77:                                               ; preds = %75
  %78 = load i32, ptr %7, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #4
  ret i32 %78
}

; Function Attrs: inlinehint nounwind uwtable
declare hidden i32 @internal_product_limit(i32 noundef, i32 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 = { 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 = { 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 #4 = { nounwind }
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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}


; 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 [73 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [16 x i8], align 1
@__PRETTY_FUNCTION__.libxsmm_product_limit = external hidden unnamed_addr constant [68 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
define dso_local i32 @libxsmm_product_limit(i32 noundef %0, i32 noundef %1, i32 noundef %2) local_unnamed_addr #1 {
  %4 = icmp ugt i32 %1, 1
  br i1 %4, label %5, label %7

5:                                                ; preds = %3
  %6 = tail call i32 @internal_product_limit(i32 noundef %0, i32 noundef %1)
  br label %7

7:                                                ; preds = %3, %5
  %.0 = phi i32 [ %6, %5 ], [ %1, %3 ]
  %.not = icmp eq i32 %2, 0
  br i1 %.not, label %25, label %8

8:                                                ; preds = %7
  %9 = icmp ult i32 %1, %0
  br i1 %9, label %10, label %19

10:                                               ; preds = %8
  %11 = icmp ult i32 %.0, %1
  br i1 %11, label %12, label %16

12:                                               ; preds = %10
  %13 = shl i32 %1, 1
  %14 = add i32 %13, -1
  %15 = tail call i32 @internal_product_limit(i32 noundef %0, i32 noundef %14)
  br label %16

16:                                               ; preds = %12, %10
  %.1 = phi i32 [ %15, %12 ], [ %.0, %10 ]
  %17 = icmp ult i32 %.1, %1
  %spec.select = select i1 %17, i32 %0, i32 %.1
  %.not35 = icmp ult i32 %spec.select, %1
  br i1 %.not35, label %18, label %26

18:                                               ; preds = %16
  tail call void @__assert_fail(ptr noundef nonnull @.str.7, ptr noundef nonnull @.str.1, i32 noundef 590, ptr noundef nonnull @__PRETTY_FUNCTION__.libxsmm_product_limit) #4
  unreachable

19:                                               ; preds = %8
  %.not34 = icmp eq i32 %0, 0
  br i1 %.not34, label %26, label %20

20:                                               ; preds = %19
  %21 = add i32 %0, -1
  %22 = add i32 %21, %1
  %23 = urem i32 %22, %0
  %24 = sub nuw i32 %22, %23
  br label %26

25:                                               ; preds = %7
  %spec.select37 = tail call i32 @llvm.umin.i32(i32 %.0, i32 %0)
  br label %26

26:                                               ; preds = %20, %16, %19, %25
  %.3 = phi i32 [ %spec.select, %16 ], [ %24, %20 ], [ 0, %19 ], [ %spec.select37, %25 ]
  ret i32 %.3
}

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

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i32 @llvm.umin.i32(i32, i32) #3

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 = { 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 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
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)"}


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