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

; 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_generated_code = type { ptr, i32, i32, i32, i32, i32, i32 }

@.str = external hidden unnamed_addr constant [93 x i8], align 1
@libxsmm_ninit = external global i32, align 4
@libxsmm_verbosity = external global i32, align 4
@__func__.libxsmm_generator_transform_Xway_half_load_blend_avx512 = external hidden unnamed_addr constant [56 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

declare void @libxsmm_handle_error(ptr noundef, i32 noundef, ptr noundef, ptr noundef, i32 noundef, i32 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 void @libxsmm_generator_transform_Xway_half_load_blend_avx512(ptr noundef %0, i8 noundef signext %1, i32 noundef %2, i32 noundef %3, i32 noundef %4, ptr noundef %5, i32 noundef %6, i32 noundef %7, i32 noundef %8, ptr noundef %9, i32 noundef %10) #2 {
  %12 = alloca ptr, align 8
  %13 = alloca i8, align 1
  %14 = alloca i32, align 4
  %15 = alloca i32, align 4
  %16 = alloca i32, align 4
  %17 = alloca ptr, align 8
  %18 = alloca i32, align 4
  %19 = alloca i32, align 4
  %20 = alloca i32, align 4
  %21 = alloca ptr, align 8
  %22 = alloca i32, align 4
  %23 = alloca i32, align 4
  %24 = alloca i32, align 4
  %25 = alloca i32, align 4
  %26 = alloca i32, align 4
  %27 = alloca i32, align 4
  %28 = alloca i32, align 4
  %29 = alloca i32, align 4
  store ptr %0, ptr %12, align 8, !tbaa !5
  store i8 %1, ptr %13, align 1, !tbaa !9
  store i32 %2, ptr %14, align 4, !tbaa !10
  store i32 %3, ptr %15, align 4, !tbaa !10
  store i32 %4, ptr %16, align 4, !tbaa !10
  store ptr %5, ptr %17, align 8, !tbaa !5
  store i32 %6, ptr %18, align 4, !tbaa !10
  store i32 %7, ptr %19, align 4, !tbaa !10
  store i32 %8, ptr %20, align 4, !tbaa !10
  store ptr %9, ptr %21, align 8, !tbaa !5
  store i32 %10, ptr %22, align 4, !tbaa !10
  call void @llvm.lifetime.start.p0(i64 4, ptr %23) #3
  store i32 0, ptr %23, align 4, !tbaa !10
  call void @llvm.lifetime.start.p0(i64 4, ptr %24) #3
  store i32 0, ptr %24, align 4, !tbaa !10
  call void @llvm.lifetime.start.p0(i64 4, ptr %25) #3
  %30 = load i32, ptr %18, align 4, !tbaa !10
  %31 = load i32, ptr %16, align 4, !tbaa !10
  %32 = mul i32 %30, %31
  store i32 %32, ptr %25, align 4, !tbaa !10
  %33 = load i32, ptr %20, align 4, !tbaa !10
  %34 = icmp ugt i32 %33, 32
  br i1 %34, label %35, label %44

35:                                               ; preds = %11
  %36 = load ptr, ptr %12, align 8, !tbaa !5
  %37 = load i32, ptr @libxsmm_ninit, align 4, !tbaa !10
  %38 = icmp ult i32 1, %37
  br i1 %38, label %39, label %41

39:                                               ; preds = %35
  %40 = load i32, ptr @libxsmm_verbosity, align 4, !tbaa !10
  br label %42

41:                                               ; preds = %35
  br label %42

42:                                               ; preds = %41, %39
  %43 = phi i32 [ %40, %39 ], [ 1, %41 ]
  call void @libxsmm_handle_error(ptr noundef %36, i32 noundef 90000, ptr noundef @__func__.libxsmm_generator_transform_Xway_half_load_blend_avx512, ptr noundef @.str, i32 noundef 253, i32 noundef %43)
  store i32 1, ptr %26, align 4
  br label %127

44:                                               ; preds = %11
  %45 = load i32, ptr %22, align 4, !tbaa !10
  %46 = load i32, ptr %20, align 4, !tbaa !10
  %47 = mul i32 %46, 2
  %48 = icmp ugt i32 %45, %47
  br i1 %48, label %49, label %58

49:                                               ; preds = %44
  %50 = load ptr, ptr %12, align 8, !tbaa !5
  %51 = load i32, ptr @libxsmm_ninit, align 4, !tbaa !10
  %52 = icmp ult i32 1, %51
  br i1 %52, label %53, label %55

53:                                               ; preds = %49
  %54 = load i32, ptr @libxsmm_verbosity, align 4, !tbaa !10
  br label %56

55:                                               ; preds = %49
  br label %56

56:                                               ; preds = %55, %53
  %57 = phi i32 [ %54, %53 ], [ 1, %55 ]
  call void @libxsmm_handle_error(ptr noundef %50, i32 noundef 90000, ptr noundef @__func__.libxsmm_generator_transform_Xway_half_load_blend_avx512, ptr noundef @.str, i32 noundef 258, i32 noundef %57)
  store i32 1, ptr %26, align 4
  br label %127

58:                                               ; preds = %44
  store i32 0, ptr %23, align 4, !tbaa !10
  br label %59

59:                                               ; preds = %123, %58
  %60 = load i32, ptr %23, align 4, !tbaa !10
  %61 = load i32, ptr %20, align 4, !tbaa !10
  %62 = icmp ult i32 %60, %61
  br i1 %62, label %63, label %126

63:                                               ; preds = %59
  call void @llvm.lifetime.start.p0(i64 4, ptr %27) #3
  %64 = load i32, ptr %23, align 4, !tbaa !10
  %65 = load i32, ptr %15, align 4, !tbaa !10
  %66 = add i32 %64, %65
  store i32 %66, ptr %27, align 4, !tbaa !10
  call void @llvm.lifetime.start.p0(i64 4, ptr %28) #3
  %67 = load i32, ptr %16, align 4, !tbaa !10
  %68 = load ptr, ptr %17, align 8, !tbaa !5
  %69 = load i32, ptr %23, align 4, !tbaa !10
  %70 = zext i32 %69 to i64
  %71 = getelementptr inbounds i32, ptr %68, i64 %70
  %72 = load i32, ptr %71, align 4, !tbaa !10
  %73 = udiv i32 %72, 2
  %74 = mul i32 %67, %73
  %75 = load ptr, ptr %17, align 8, !tbaa !5
  %76 = load i32, ptr %23, align 4, !tbaa !10
  %77 = zext i32 %76 to i64
  %78 = getelementptr inbounds i32, ptr %75, i64 %77
  %79 = load i32, ptr %78, align 4, !tbaa !10
  %80 = urem i32 %79, 2
  %81 = mul i32 32, %80
  %82 = add i32 %74, %81
  store i32 %82, ptr %28, align 4, !tbaa !10
  call void @llvm.lifetime.start.p0(i64 4, ptr %29) #3
  %83 = load i32, ptr %22, align 4, !tbaa !10
  %84 = load i32, ptr %20, align 4, !tbaa !10
  %85 = udiv i32 %83, %84
  %86 = load i32, ptr %23, align 4, !tbaa !10
  %87 = load i32, ptr %22, align 4, !tbaa !10
  %88 = load i32, ptr %20, align 4, !tbaa !10
  %89 = urem i32 %87, %88
  %90 = icmp ult i32 %86, %89
  %91 = zext i1 %90 to i32
  %92 = add i32 %85, %91
  store i32 %92, ptr %29, align 4, !tbaa !10
  store i32 0, ptr %24, align 4, !tbaa !10
  br label %93

93:                                               ; preds = %119, %63
  %94 = load i32, ptr %24, align 4, !tbaa !10
  %95 = load i32, ptr %29, align 4, !tbaa !10
  %96 = icmp ult i32 %94, %95
  br i1 %96, label %97, label %122

97:                                               ; preds = %93
  %98 = load ptr, ptr %12, align 8, !tbaa !5
  %99 = load ptr, ptr %12, align 8, !tbaa !5
  %100 = getelementptr inbounds %struct.libxsmm_generated_code, ptr %99, i32 0, i32 6
  %101 = load i32, ptr %100, align 4, !tbaa !12
  %102 = load i32, ptr %19, align 4, !tbaa !10
  %103 = load i32, ptr %14, align 4, !tbaa !10
  %104 = load i32, ptr %28, align 4, !tbaa !10
  %105 = load i32, ptr %24, align 4, !tbaa !10
  %106 = load i32, ptr %25, align 4, !tbaa !10
  %107 = mul i32 %105, %106
  %108 = add i32 %104, %107
  %109 = load i8, ptr %13, align 1, !tbaa !9
  %110 = load i32, ptr %27, align 4, !tbaa !10
  %111 = load ptr, ptr %21, align 8, !tbaa !5
  %112 = load i32, ptr %24, align 4, !tbaa !10
  %113 = zext i32 %112 to i64
  %114 = getelementptr inbounds i32, ptr %111, i64 %113
  %115 = load i32, ptr %114, align 4, !tbaa !10
  %116 = load i32, ptr %24, align 4, !tbaa !10
  %117 = icmp eq i32 %116, 0
  %118 = zext i1 %117 to i32
  call void @libxsmm_x86_instruction_vec_move(ptr noundef %98, i32 noundef %101, i32 noundef %102, i32 noundef %103, i32 noundef 127, i32 noundef 0, i32 noundef %108, i8 noundef signext %109, i32 noundef %110, i32 noundef %115, i32 noundef %118, i32 noundef 0)
  br label %119

119:                                              ; preds = %97
  %120 = load i32, ptr %24, align 4, !tbaa !10
  %121 = add i32 %120, 1
  store i32 %121, ptr %24, align 4, !tbaa !10
  br label %93, !llvm.loop !14

122:                                              ; preds = %93
  call void @llvm.lifetime.end.p0(i64 4, ptr %29) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %28) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %27) #3
  br label %123

123:                                              ; preds = %122
  %124 = load i32, ptr %23, align 4, !tbaa !10
  %125 = add i32 %124, 1
  store i32 %125, ptr %23, align 4, !tbaa !10
  br label %59, !llvm.loop !16

126:                                              ; preds = %59
  store i32 0, ptr %26, align 4
  br label %127

127:                                              ; preds = %126, %56, %42
  call void @llvm.lifetime.end.p0(i64 4, ptr %25) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %24) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %23) #3
  %128 = load i32, ptr %26, align 4
  switch i32 %128, label %130 [
    i32 0, label %129
    i32 1, label %129
  ]

129:                                              ; preds = %127, %127
  ret void

130:                                              ; preds = %127
  unreachable
}

declare void @libxsmm_x86_instruction_vec_move(ptr noundef, i32 noundef, i32 noundef, i32 noundef, i32 noundef, i32 noundef, i32 noundef, i8 noundef signext, i32 noundef, i32 noundef, i32 noundef, i32 noundef) #1

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 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 = { 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 = !{!7, !7, i64 0}
!10 = !{!11, !11, i64 0}
!11 = !{!"int", !7, i64 0}
!12 = !{!13, !11, i64 28}
!13 = !{!"libxsmm_generated_code", !6, i64 0, !11, i64 8, !11, i64 12, !11, i64 16, !11, i64 20, !11, i64 24, !11, i64 28}
!14 = distinct !{!14, !15}
!15 = !{!"llvm.loop.mustprogress"}
!16 = distinct !{!16, !15}


; 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 = external hidden unnamed_addr constant [93 x i8], align 1
@libxsmm_ninit = external local_unnamed_addr global i32, align 4
@libxsmm_verbosity = external local_unnamed_addr global i32, align 4
@__func__.libxsmm_generator_transform_Xway_half_load_blend_avx512 = external hidden unnamed_addr constant [56 x i8], align 1

declare void @libxsmm_handle_error(ptr noundef, i32 noundef, ptr noundef, ptr noundef, i32 noundef, i32 noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local void @libxsmm_generator_transform_Xway_half_load_blend_avx512(ptr noundef %0, i8 noundef signext %1, i32 noundef %2, i32 noundef %3, i32 noundef %4, ptr nocapture noundef readonly %5, i32 noundef %6, i32 noundef %7, i32 noundef %8, ptr nocapture noundef readonly %9, i32 noundef %10) local_unnamed_addr #1 {
  %12 = icmp ugt i32 %8, 32
  br i1 %12, label %.loopexit.sink.split, label %13

13:                                               ; preds = %11
  %14 = shl nuw nsw i32 %8, 1
  %15 = icmp ult i32 %14, %10
  br i1 %15, label %.loopexit.sink.split, label %.preheader

.preheader:                                       ; preds = %13
  %.not = icmp eq i32 %8, 0
  br i1 %.not, label %.loopexit, label %.lr.ph41

.lr.ph41:                                         ; preds = %.preheader
  %.lhs.trunc = trunc i32 %10 to i8
  %.rhs.trunc = trunc nuw i32 %8 to i8
  %16 = udiv i8 %.lhs.trunc, %.rhs.trunc
  %.zext = zext i8 %16 to i32
  %.lhs.trunc47 = trunc i32 %10 to i8
  %.rhs.trunc48 = trunc nuw i32 %8 to i8
  %17 = urem i8 %.lhs.trunc47, %.rhs.trunc48
  %18 = getelementptr inbounds i8, ptr %0, i64 28
  %19 = zext nneg i8 %17 to i64
  %wide.trip.count = zext nneg i32 %8 to i64
  br label %20

20:                                               ; preds = %.lr.ph41, %._crit_edge
  %indvars.iv44 = phi i64 [ 0, %.lr.ph41 ], [ %indvars.iv.next45, %._crit_edge ]
  %21 = trunc nuw nsw i64 %indvars.iv44 to i32
  %22 = add i32 %21, %3
  %23 = getelementptr inbounds i32, ptr %5, i64 %indvars.iv44
  %24 = load i32, ptr %23, align 4, !tbaa !5
  %25 = lshr i32 %24, 1
  %26 = shl i32 %24, 5
  %27 = and i32 %26, 32
  %28 = icmp ult i64 %indvars.iv44, %19
  %29 = zext i1 %28 to i32
  %30 = add nuw nsw i32 %.zext, %29
  %.not42 = icmp eq i32 %30, 0
  br i1 %.not42, label %._crit_edge, label %.lr.ph.preheader

.lr.ph.preheader:                                 ; preds = %20
  %31 = zext nneg i32 %30 to i64
  br label %.lr.ph

.lr.ph:                                           ; preds = %.lr.ph.preheader, %.lr.ph
  %indvars.iv = phi i64 [ 0, %.lr.ph.preheader ], [ %indvars.iv.next, %.lr.ph ]
  %32 = load i32, ptr %18, align 4, !tbaa !9
  %33 = trunc nuw nsw i64 %indvars.iv to i32
  %34 = mul i32 %33, %6
  %reass.add = add i32 %34, %25
  %reass.mul = mul i32 %reass.add, %4
  %35 = add i32 %reass.mul, %27
  %36 = getelementptr inbounds i32, ptr %9, i64 %indvars.iv
  %37 = load i32, ptr %36, align 4, !tbaa !5
  %38 = icmp eq i64 %indvars.iv, 0
  %39 = zext i1 %38 to i32
  tail call void @libxsmm_x86_instruction_vec_move(ptr noundef %0, i32 noundef %32, i32 noundef %7, i32 noundef %2, i32 noundef 127, i32 noundef 0, i32 noundef %35, i8 noundef signext %1, i32 noundef %22, i32 noundef %37, i32 noundef %39, i32 noundef 0) #2
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %40 = icmp ult i64 %indvars.iv.next, %31
  br i1 %40, label %.lr.ph, label %._crit_edge, !llvm.loop !12

._crit_edge:                                      ; preds = %.lr.ph, %20
  %indvars.iv.next45 = add nuw nsw i64 %indvars.iv44, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next45, %wide.trip.count
  br i1 %exitcond.not, label %.loopexit, label %20, !llvm.loop !14

.loopexit.sink.split:                             ; preds = %13, %11
  %.sink = phi i32 [ 253, %11 ], [ 258, %13 ]
  %41 = load i32, ptr @libxsmm_ninit, align 4, !tbaa !5
  %42 = icmp ugt i32 %41, 1
  %43 = load i32, ptr @libxsmm_verbosity, align 4
  %44 = select i1 %42, i32 %43, i32 1
  tail call void @libxsmm_handle_error(ptr noundef %0, i32 noundef 90000, ptr noundef nonnull @__func__.libxsmm_generator_transform_Xway_half_load_blend_avx512, ptr noundef nonnull @.str, i32 noundef %.sink, i32 noundef %44) #2
  br label %.loopexit

.loopexit:                                        ; preds = %._crit_edge, %.loopexit.sink.split, %.preheader
  ret void
}

declare void @libxsmm_x86_instruction_vec_move(ptr noundef, i32 noundef, i32 noundef, i32 noundef, i32 noundef, i32 noundef, i32 noundef, i8 noundef signext, i32 noundef, i32 noundef, i32 noundef, i32 noundef) local_unnamed_addr #0

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, !6, i64 0}
!6 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !6, i64 28}
!10 = !{!"libxsmm_generated_code", !11, i64 0, !6, i64 8, !6, i64 12, !6, i64 16, !6, i64 20, !6, i64 24, !6, i64 28}
!11 = !{!"any pointer", !7, i64 0}
!12 = distinct !{!12, !13}
!13 = !{!"llvm.loop.mustprogress"}
!14 = distinct !{!14, !13}


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