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

; 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_meltw_descriptor = type <{ i32, i32, i32, i32, i32, i32, i8, i8, i8, i16, i16, i8 }>

; 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: nounwind uwtable
define dso_local i32 @libxsmm_is_reduce_op(ptr noundef %0) #1 {
  %2 = alloca ptr, align 8
  %3 = alloca i32, align 4
  store ptr %0, ptr %2, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #2
  store i32 0, ptr %3, align 4, !tbaa !9
  %4 = load ptr, ptr %2, align 8, !tbaa !5
  %5 = getelementptr inbounds %struct.libxsmm_meltw_descriptor, ptr %4, i32 0, i32 10
  %6 = load i16, ptr %5, align 1, !tbaa !11
  %7 = zext i16 %6 to i32
  %8 = icmp eq i32 %7, 20
  br i1 %8, label %57, label %9

9:                                                ; preds = %1
  %10 = load ptr, ptr %2, align 8, !tbaa !5
  %11 = getelementptr inbounds %struct.libxsmm_meltw_descriptor, ptr %10, i32 0, i32 10
  %12 = load i16, ptr %11, align 1, !tbaa !11
  %13 = zext i16 %12 to i32
  %14 = icmp eq i32 %13, 18
  br i1 %14, label %57, label %15

15:                                               ; preds = %9
  %16 = load ptr, ptr %2, align 8, !tbaa !5
  %17 = getelementptr inbounds %struct.libxsmm_meltw_descriptor, ptr %16, i32 0, i32 10
  %18 = load i16, ptr %17, align 1, !tbaa !11
  %19 = zext i16 %18 to i32
  %20 = icmp eq i32 %19, 19
  br i1 %20, label %57, label %21

21:                                               ; preds = %15
  %22 = load ptr, ptr %2, align 8, !tbaa !5
  %23 = getelementptr inbounds %struct.libxsmm_meltw_descriptor, ptr %22, i32 0, i32 10
  %24 = load i16, ptr %23, align 1, !tbaa !11
  %25 = zext i16 %24 to i32
  %26 = icmp eq i32 %25, 21
  br i1 %26, label %57, label %27

27:                                               ; preds = %21
  %28 = load ptr, ptr %2, align 8, !tbaa !5
  %29 = getelementptr inbounds %struct.libxsmm_meltw_descriptor, ptr %28, i32 0, i32 10
  %30 = load i16, ptr %29, align 1, !tbaa !11
  %31 = zext i16 %30 to i32
  %32 = icmp eq i32 %31, 69
  br i1 %32, label %57, label %33

33:                                               ; preds = %27
  %34 = load ptr, ptr %2, align 8, !tbaa !5
  %35 = getelementptr inbounds %struct.libxsmm_meltw_descriptor, ptr %34, i32 0, i32 10
  %36 = load i16, ptr %35, align 1, !tbaa !11
  %37 = zext i16 %36 to i32
  %38 = icmp eq i32 %37, 44
  br i1 %38, label %57, label %39

39:                                               ; preds = %33
  %40 = load ptr, ptr %2, align 8, !tbaa !5
  %41 = getelementptr inbounds %struct.libxsmm_meltw_descriptor, ptr %40, i32 0, i32 10
  %42 = load i16, ptr %41, align 1, !tbaa !11
  %43 = zext i16 %42 to i32
  %44 = icmp eq i32 %43, 53
  br i1 %44, label %57, label %45

45:                                               ; preds = %39
  %46 = load ptr, ptr %2, align 8, !tbaa !5
  %47 = getelementptr inbounds %struct.libxsmm_meltw_descriptor, ptr %46, i32 0, i32 10
  %48 = load i16, ptr %47, align 1, !tbaa !11
  %49 = zext i16 %48 to i32
  %50 = icmp eq i32 %49, 68
  br i1 %50, label %57, label %51

51:                                               ; preds = %45
  %52 = load ptr, ptr %2, align 8, !tbaa !5
  %53 = getelementptr inbounds %struct.libxsmm_meltw_descriptor, ptr %52, i32 0, i32 10
  %54 = load i16, ptr %53, align 1, !tbaa !11
  %55 = zext i16 %54 to i32
  %56 = icmp eq i32 %55, 70
  br i1 %56, label %57, label %58

57:                                               ; preds = %51, %45, %39, %33, %27, %21, %15, %9, %1
  store i32 1, ptr %3, align 4, !tbaa !9
  br label %58

58:                                               ; preds = %57, %51
  %59 = load i32, ptr %3, align 4, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #2
  ret i32 %59
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { 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 = !{!12, !13, i64 29}
!12 = !{!"libxsmm_meltw_descriptor", !10, i64 0, !10, i64 4, !10, i64 8, !10, i64 12, !10, i64 16, !10, i64 20, !7, i64 24, !7, i64 25, !7, i64 26, !13, i64 27, !13, i64 29, !7, i64 31}
!13 = !{!"short", !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"

; Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: read) uwtable
define dso_local range(i32 0, 2) i32 @libxsmm_is_reduce_op(ptr nocapture noundef readonly %0) local_unnamed_addr #0 {
  %2 = getelementptr inbounds i8, ptr %0, i64 29
  %3 = load i16, ptr %2, align 1, !tbaa !5
  switch i16 %3, label %5 [
    i16 20, label %4
    i16 18, label %4
    i16 19, label %4
    i16 21, label %4
    i16 69, label %4
    i16 44, label %4
    i16 53, label %4
    i16 68, label %4
    i16 70, label %4
  ]

4:                                                ; preds = %1, %1, %1, %1, %1, %1, %1, %1, %1
  br label %5

5:                                                ; preds = %1, %4
  %.0 = phi i32 [ 1, %4 ], [ 0, %1 ]
  ret i32 %.0
}

attributes #0 = { mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: read) 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" }

!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, !10, i64 29}
!6 = !{!"libxsmm_meltw_descriptor", !7, i64 0, !7, i64 4, !7, i64 8, !7, i64 12, !7, i64 16, !7, i64 20, !8, i64 24, !8, i64 25, !8, i64 26, !10, i64 27, !10, i64 29, !8, i64 31}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"short", !8, i64 0}


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