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

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

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

; Function Attrs: nounwind uwtable
define dso_local i32 @libxsmm_generator_mateltwise_rv64_valid_arch_precision(ptr noundef %0, ptr noundef %1) #1 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  %12 = alloca i32, align 4
  %13 = alloca i32, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  store ptr %1, ptr %4, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #3
  store i32 0, ptr %5, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #3
  %14 = load ptr, ptr %4, align 8, !tbaa !5
  %15 = getelementptr inbounds %struct.libxsmm_meltw_descriptor, ptr %14, i32 0, i32 10
  %16 = load i16, ptr %15, align 1, !tbaa !11
  %17 = zext i16 %16 to i32
  %18 = icmp eq i32 %17, 29
  %19 = zext i1 %18 to i32
  store i32 %19, ptr %6, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #3
  %20 = load ptr, ptr %4, align 8, !tbaa !5
  %21 = getelementptr inbounds %struct.libxsmm_meltw_descriptor, ptr %20, i32 0, i32 11
  %22 = load i8, ptr %21, align 1, !tbaa !14
  %23 = zext i8 %22 to i32
  %24 = icmp eq i32 %23, 1
  br i1 %24, label %25, label %45

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

31:                                               ; preds = %25
  %32 = load ptr, ptr %4, align 8, !tbaa !5
  %33 = getelementptr inbounds %struct.libxsmm_meltw_descriptor, ptr %32, i32 0, i32 10
  %34 = load i16, ptr %33, align 1, !tbaa !11
  %35 = zext i16 %34 to i32
  %36 = icmp eq i32 %35, 2
  br i1 %36, label %43, label %37

37:                                               ; preds = %31
  %38 = load ptr, ptr %4, align 8, !tbaa !5
  %39 = getelementptr inbounds %struct.libxsmm_meltw_descriptor, ptr %38, i32 0, i32 10
  %40 = load i16, ptr %39, align 1, !tbaa !11
  %41 = zext i16 %40 to i32
  %42 = icmp eq i32 %41, 3
  br label %43

43:                                               ; preds = %37, %31, %25
  %44 = phi i1 [ true, %31 ], [ true, %25 ], [ %42, %37 ]
  br label %45

45:                                               ; preds = %43, %2
  %46 = phi i1 [ false, %2 ], [ %44, %43 ]
  %47 = zext i1 %46 to i64
  %48 = select i1 %46, i32 1, i32 0
  store i32 %48, ptr %7, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #3
  %49 = load ptr, ptr %4, align 8, !tbaa !5
  %50 = getelementptr inbounds %struct.libxsmm_meltw_descriptor, ptr %49, i32 0, i32 11
  %51 = load i8, ptr %50, align 1, !tbaa !14
  %52 = zext i8 %51 to i32
  %53 = icmp eq i32 %52, 2
  br i1 %53, label %54, label %60

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

60:                                               ; preds = %54, %45
  %61 = phi i1 [ false, %45 ], [ %59, %54 ]
  %62 = zext i1 %61 to i64
  %63 = select i1 %61, i32 1, i32 0
  store i32 %63, ptr %8, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #3
  %64 = load ptr, ptr %4, align 8, !tbaa !5
  %65 = call i32 @libxsmm_meltw_getenum_precision(ptr noundef %64, i32 noundef 0)
  store i32 %65, ptr %9, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #3
  %66 = load ptr, ptr %4, align 8, !tbaa !5
  %67 = call i32 @libxsmm_meltw_getenum_precision(ptr noundef %66, i32 noundef 3)
  store i32 %67, ptr %10, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #3
  store i32 1, ptr %11, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #3
  %68 = load ptr, ptr %4, align 8, !tbaa !5
  %69 = call i32 @libxsmm_meltw_getenum_precision(ptr noundef %68, i32 noundef 4)
  store i32 %69, ptr %12, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #3
  store i32 0, ptr %13, align 4, !tbaa !9
  %70 = load i32, ptr %8, align 4, !tbaa !9
  %71 = icmp ne i32 %70, 0
  br i1 %71, label %72, label %75

72:                                               ; preds = %60
  %73 = load ptr, ptr %4, align 8, !tbaa !5
  %74 = call i32 @libxsmm_meltw_getenum_precision(ptr noundef %73, i32 noundef 1)
  store i32 %74, ptr %11, align 4, !tbaa !9
  br label %75

75:                                               ; preds = %72, %60
  %76 = load i32, ptr %9, align 4, !tbaa !9
  %77 = icmp eq i32 1, %76
  br i1 %77, label %78, label %87

78:                                               ; preds = %75
  %79 = load i32, ptr %11, align 4, !tbaa !9
  %80 = icmp eq i32 1, %79
  br i1 %80, label %81, label %87

81:                                               ; preds = %78
  %82 = load i32, ptr %10, align 4, !tbaa !9
  %83 = icmp eq i32 1, %82
  br i1 %83, label %84, label %87

84:                                               ; preds = %81
  %85 = load i32, ptr %12, align 4, !tbaa !9
  %86 = icmp eq i32 1, %85
  br label %87

87:                                               ; preds = %84, %81, %78, %75
  %88 = phi i1 [ false, %81 ], [ false, %78 ], [ false, %75 ], [ %86, %84 ]
  %89 = zext i1 %88 to i64
  %90 = select i1 %88, i32 1, i32 0
  store i32 %90, ptr %13, align 4, !tbaa !9
  %91 = load i32, ptr %7, align 4, !tbaa !9
  %92 = icmp ne i32 %91, 0
  br i1 %92, label %99, label %93

93:                                               ; preds = %87
  %94 = load i32, ptr %8, align 4, !tbaa !9
  %95 = icmp ne i32 %94, 0
  br i1 %95, label %99, label %96

96:                                               ; preds = %93
  %97 = load i32, ptr %6, align 4, !tbaa !9
  %98 = icmp ne i32 %97, 0
  br i1 %98, label %99, label %102

99:                                               ; preds = %96, %93, %87
  %100 = load i32, ptr %13, align 4, !tbaa !9
  %101 = icmp ne i32 %100, 0
  br label %102

102:                                              ; preds = %99, %96
  %103 = phi i1 [ false, %96 ], [ %101, %99 ]
  %104 = zext i1 %103 to i32
  store i32 %104, ptr %5, align 4, !tbaa !9
  %105 = load i32, ptr %5, align 4, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #3
  ret i32 %105
}

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

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

attributes #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 = { 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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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, !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}
!14 = !{!12, !7, i64 31}


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

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

; Function Attrs: nounwind uwtable
define dso_local range(i32 0, 2) i32 @libxsmm_generator_mateltwise_rv64_valid_arch_precision(ptr nocapture noundef readnone %0, ptr noundef %1) local_unnamed_addr #1 {
  %3 = getelementptr inbounds i8, ptr %1, i64 29
  %4 = load i16, ptr %3, align 1, !tbaa !5
  %5 = getelementptr inbounds i8, ptr %1, i64 31
  %6 = load i8, ptr %5, align 1, !tbaa !11
  switch i8 %6, label %9 [
    i8 1, label %switch.edge.thread
    i8 2, label %7
  ]

switch.edge.thread:                               ; preds = %2
  %.off = add i16 %4, -1
  %switch = icmp ult i16 %.off, 3
  br label %9

7:                                                ; preds = %2
  %8 = icmp eq i16 %4, 1
  br label %9

9:                                                ; preds = %2, %switch.edge.thread, %7
  %or.cond5 = phi i1 [ %8, %7 ], [ %switch, %switch.edge.thread ], [ false, %2 ]
  %10 = phi i1 [ %8, %7 ], [ false, %switch.edge.thread ], [ false, %2 ]
  %11 = tail call i32 @libxsmm_meltw_getenum_precision(ptr noundef nonnull %1, i32 noundef 0) #2
  %12 = tail call i32 @libxsmm_meltw_getenum_precision(ptr noundef nonnull %1, i32 noundef 3) #2
  %13 = tail call i32 @libxsmm_meltw_getenum_precision(ptr noundef nonnull %1, i32 noundef 4) #2
  br i1 %10, label %14, label %17

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

17:                                               ; preds = %14, %9
  %.0 = phi i1 [ %16, %14 ], [ true, %9 ]
  %18 = icmp eq i16 %4, 29
  %19 = icmp eq i32 %11, 1
  %20 = icmp eq i32 %12, 1
  %21 = icmp eq i32 %13, 1
  %or.cond7 = select i1 %or.cond5, i1 true, i1 %18
  %22 = select i1 %or.cond7, i1 %19, i1 false
  %23 = select i1 %22, i1 %.0, i1 false
  %24 = select i1 %23, i1 %20, i1 false
  %narrow28 = select i1 %24, i1 %21, i1 false
  %25 = zext i1 %narrow28 to i32
  ret i32 %25
}

attributes #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 = { 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, !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}
!11 = !{!6, !8, i64 31}


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