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

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

11:                                               ; preds = %2
  %12 = load i32, ptr %4, align 4, !tbaa !9
  %13 = load ptr, ptr %3, align 8, !tbaa !5
  %14 = call i32 @libxsmm_meltw_getenum_precision(ptr noundef %13, i32 noundef 0)
  %15 = icmp eq i32 %12, %14
  br i1 %15, label %16, label %27

16:                                               ; preds = %11
  %17 = load i32, ptr %4, align 4, !tbaa !9
  %18 = load ptr, ptr %3, align 8, !tbaa !5
  %19 = call i32 @libxsmm_meltw_getenum_precision(ptr noundef %18, i32 noundef 4)
  %20 = icmp eq i32 %17, %19
  br i1 %20, label %21, label %27

21:                                               ; preds = %16
  %22 = load i32, ptr %4, align 4, !tbaa !9
  %23 = load ptr, ptr %3, align 8, !tbaa !5
  %24 = call i32 @libxsmm_meltw_getenum_precision(ptr noundef %23, i32 noundef 3)
  %25 = icmp eq i32 %22, %24
  br i1 %25, label %26, label %27

26:                                               ; preds = %21
  store i32 1, ptr %5, align 4, !tbaa !9
  br label %27

27:                                               ; preds = %26, %21, %16, %11
  br label %92

28:                                               ; preds = %2
  %29 = load ptr, ptr %3, align 8, !tbaa !5
  %30 = getelementptr inbounds %struct.libxsmm_meltw_descriptor, ptr %29, i32 0, i32 11
  %31 = load i8, ptr %30, align 1, !tbaa !11
  %32 = zext i8 %31 to i32
  %33 = icmp eq i32 %32, 2
  br i1 %33, label %34, label %56

34:                                               ; preds = %28
  %35 = load i32, ptr %4, align 4, !tbaa !9
  %36 = load ptr, ptr %3, align 8, !tbaa !5
  %37 = call i32 @libxsmm_meltw_getenum_precision(ptr noundef %36, i32 noundef 0)
  %38 = icmp eq i32 %35, %37
  br i1 %38, label %39, label %55

39:                                               ; preds = %34
  %40 = load i32, ptr %4, align 4, !tbaa !9
  %41 = load ptr, ptr %3, align 8, !tbaa !5
  %42 = call i32 @libxsmm_meltw_getenum_precision(ptr noundef %41, i32 noundef 1)
  %43 = icmp eq i32 %40, %42
  br i1 %43, label %44, label %55

44:                                               ; preds = %39
  %45 = load i32, ptr %4, align 4, !tbaa !9
  %46 = load ptr, ptr %3, align 8, !tbaa !5
  %47 = call i32 @libxsmm_meltw_getenum_precision(ptr noundef %46, i32 noundef 4)
  %48 = icmp eq i32 %45, %47
  br i1 %48, label %49, label %55

49:                                               ; preds = %44
  %50 = load i32, ptr %4, align 4, !tbaa !9
  %51 = load ptr, ptr %3, align 8, !tbaa !5
  %52 = call i32 @libxsmm_meltw_getenum_precision(ptr noundef %51, i32 noundef 3)
  %53 = icmp eq i32 %50, %52
  br i1 %53, label %54, label %55

54:                                               ; preds = %49
  store i32 1, ptr %5, align 4, !tbaa !9
  br label %55

55:                                               ; preds = %54, %49, %44, %39, %34
  br label %91

56:                                               ; preds = %28
  %57 = load ptr, ptr %3, align 8, !tbaa !5
  %58 = getelementptr inbounds %struct.libxsmm_meltw_descriptor, ptr %57, i32 0, i32 11
  %59 = load i8, ptr %58, align 1, !tbaa !11
  %60 = zext i8 %59 to i32
  %61 = icmp eq i32 %60, 3
  br i1 %61, label %62, label %89

62:                                               ; preds = %56
  %63 = load i32, ptr %4, align 4, !tbaa !9
  %64 = load ptr, ptr %3, align 8, !tbaa !5
  %65 = call i32 @libxsmm_meltw_getenum_precision(ptr noundef %64, i32 noundef 0)
  %66 = icmp eq i32 %63, %65
  br i1 %66, label %67, label %88

67:                                               ; preds = %62
  %68 = load i32, ptr %4, align 4, !tbaa !9
  %69 = load ptr, ptr %3, align 8, !tbaa !5
  %70 = call i32 @libxsmm_meltw_getenum_precision(ptr noundef %69, i32 noundef 1)
  %71 = icmp eq i32 %68, %70
  br i1 %71, label %72, label %88

72:                                               ; preds = %67
  %73 = load i32, ptr %4, align 4, !tbaa !9
  %74 = load ptr, ptr %3, align 8, !tbaa !5
  %75 = call i32 @libxsmm_meltw_getenum_precision(ptr noundef %74, i32 noundef 2)
  %76 = icmp eq i32 %73, %75
  br i1 %76, label %77, label %88

77:                                               ; preds = %72
  %78 = load i32, ptr %4, align 4, !tbaa !9
  %79 = load ptr, ptr %3, align 8, !tbaa !5
  %80 = call i32 @libxsmm_meltw_getenum_precision(ptr noundef %79, i32 noundef 4)
  %81 = icmp eq i32 %78, %80
  br i1 %81, label %82, label %88

82:                                               ; preds = %77
  %83 = load i32, ptr %4, align 4, !tbaa !9
  %84 = load ptr, ptr %3, align 8, !tbaa !5
  %85 = call i32 @libxsmm_meltw_getenum_precision(ptr noundef %84, i32 noundef 3)
  %86 = icmp eq i32 %83, %85
  br i1 %86, label %87, label %88

87:                                               ; preds = %82
  store i32 1, ptr %5, align 4, !tbaa !9
  br label %88

88:                                               ; preds = %87, %82, %77, %72, %67, %62
  br label %90

89:                                               ; preds = %56
  br label %90

90:                                               ; preds = %89, %88
  br label %91

91:                                               ; preds = %90, %55
  br label %92

92:                                               ; preds = %91, %27
  %93 = load i32, ptr %5, align 4, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #3
  ret i32 %93
}

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

declare i32 @libxsmm_meltw_getenum_precision(ptr noundef, i32 noundef) #2

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

attributes #0 = { 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 #1 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { "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 }

!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, !7, i64 31}
!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: nounwind uwtable
define dso_local range(i32 0, 2) i32 @libxsmm_generator_mateltwise_all_inp_comp_out_prec(ptr noundef %0, i32 noundef %1) local_unnamed_addr #0 {
  %3 = getelementptr inbounds i8, ptr %0, i64 31
  %4 = load i8, ptr %3, align 1, !tbaa !5
  switch i8 %4, label %35 [
    i8 1, label %5
    i8 2, label %11
    i8 3, label %20
  ]

5:                                                ; preds = %2
  %6 = tail call i32 @libxsmm_meltw_getenum_precision(ptr noundef nonnull %0, i32 noundef 0) #2
  %7 = icmp eq i32 %6, %1
  br i1 %7, label %8, label %35

8:                                                ; preds = %5
  %9 = tail call i32 @libxsmm_meltw_getenum_precision(ptr noundef nonnull %0, i32 noundef 4) #2
  %10 = icmp eq i32 %9, %1
  br i1 %10, label %.sink.split, label %35

11:                                               ; preds = %2
  %12 = tail call i32 @libxsmm_meltw_getenum_precision(ptr noundef nonnull %0, i32 noundef 0) #2
  %13 = icmp eq i32 %12, %1
  br i1 %13, label %14, label %35

14:                                               ; preds = %11
  %15 = tail call i32 @libxsmm_meltw_getenum_precision(ptr noundef nonnull %0, i32 noundef 1) #2
  %16 = icmp eq i32 %15, %1
  br i1 %16, label %17, label %35

17:                                               ; preds = %14
  %18 = tail call i32 @libxsmm_meltw_getenum_precision(ptr noundef nonnull %0, i32 noundef 4) #2
  %19 = icmp eq i32 %18, %1
  br i1 %19, label %.sink.split, label %35

20:                                               ; preds = %2
  %21 = tail call i32 @libxsmm_meltw_getenum_precision(ptr noundef nonnull %0, i32 noundef 0) #2
  %22 = icmp eq i32 %21, %1
  br i1 %22, label %23, label %35

23:                                               ; preds = %20
  %24 = tail call i32 @libxsmm_meltw_getenum_precision(ptr noundef nonnull %0, i32 noundef 1) #2
  %25 = icmp eq i32 %24, %1
  br i1 %25, label %26, label %35

26:                                               ; preds = %23
  %27 = tail call i32 @libxsmm_meltw_getenum_precision(ptr noundef nonnull %0, i32 noundef 2) #2
  %28 = icmp eq i32 %27, %1
  br i1 %28, label %29, label %35

29:                                               ; preds = %26
  %30 = tail call i32 @libxsmm_meltw_getenum_precision(ptr noundef nonnull %0, i32 noundef 4) #2
  %31 = icmp eq i32 %30, %1
  br i1 %31, label %.sink.split, label %35

.sink.split:                                      ; preds = %29, %17, %8
  %32 = tail call i32 @libxsmm_meltw_getenum_precision(ptr noundef nonnull %0, i32 noundef 3) #2
  %33 = icmp eq i32 %32, %1
  %34 = zext i1 %33 to i32
  br label %35

35:                                               ; preds = %.sink.split, %2, %17, %14, %11, %20, %23, %26, %29, %5, %8
  %.0.shrunk = phi i32 [ 0, %8 ], [ 0, %5 ], [ 0, %17 ], [ 0, %14 ], [ 0, %11 ], [ 0, %29 ], [ 0, %26 ], [ 0, %23 ], [ 0, %20 ], [ 0, %2 ], [ %34, %.sink.split ]
  ret i32 %.0.shrunk
}

declare i32 @libxsmm_meltw_getenum_precision(ptr noundef, i32 noundef) local_unnamed_addr #1

attributes #0 = { 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 #1 = { "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, !8, i64 31}
!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: CorrelatedValuePropagationPass,EarlyCSEPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,SROAPass,SimplifyCFGPass,TailCallElimPass