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

@.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_permute_network_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

declare void @libxsmm_x86_instruction_vec_compute_3reg_mask_sae_imm8(ptr noundef, i32 noundef, i8 noundef signext, i32 noundef, i32 noundef, i32 noundef, i32 noundef, i32 noundef, i8 noundef zeroext, 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_permute_network_avx512(ptr noundef %0, i8 noundef signext %1, ptr noundef %2, ptr noundef %3, i32 noundef %4, i32 noundef %5, i32 noundef %6) #2 {
  %8 = alloca ptr, align 8
  %9 = alloca i8, align 1
  %10 = alloca ptr, align 8
  %11 = alloca ptr, align 8
  %12 = alloca i32, align 4
  %13 = alloca i32, align 4
  %14 = alloca i32, align 4
  %15 = alloca i32, align 4
  %16 = alloca i32, align 4
  %17 = alloca i32, align 4
  %18 = alloca i32, align 4
  %19 = alloca i32, align 4
  %20 = alloca i32, align 4
  %21 = alloca i32, align 4
  %22 = alloca i32, align 4
  store ptr %0, ptr %8, align 8, !tbaa !5
  store i8 %1, ptr %9, align 1, !tbaa !9
  store ptr %2, ptr %10, align 8, !tbaa !5
  store ptr %3, ptr %11, align 8, !tbaa !5
  store i32 %4, ptr %12, align 4, !tbaa !10
  store i32 %5, ptr %13, align 4, !tbaa !10
  store i32 %6, ptr %14, align 4, !tbaa !10
  call void @llvm.lifetime.start.p0(i64 4, ptr %15) #3
  store i32 0, ptr %15, align 4, !tbaa !10
  %23 = load i32, ptr %14, align 4, !tbaa !10
  %24 = urem i32 %23, 2
  %25 = icmp ne i32 %24, 0
  br i1 %25, label %26, label %35

26:                                               ; preds = %7
  %27 = load ptr, ptr %8, align 8, !tbaa !5
  %28 = load i32, ptr @libxsmm_ninit, align 4, !tbaa !10
  %29 = icmp ult i32 1, %28
  br i1 %29, label %30, label %32

30:                                               ; preds = %26
  %31 = load i32, ptr @libxsmm_verbosity, align 4, !tbaa !10
  br label %33

32:                                               ; preds = %26
  br label %33

33:                                               ; preds = %32, %30
  %34 = phi i32 [ %31, %30 ], [ 1, %32 ]
  call void @libxsmm_handle_error(ptr noundef %27, i32 noundef 90000, ptr noundef @__func__.libxsmm_generator_transform_Xway_permute_network_avx512, ptr noundef @.str, i32 noundef 197, i32 noundef %34)
  store i32 1, ptr %16, align 4
  br label %137

35:                                               ; preds = %7
  %36 = load i32, ptr %14, align 4, !tbaa !10
  %37 = icmp ugt i32 %36, 20
  br i1 %37, label %38, label %47

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

42:                                               ; preds = %38
  %43 = load i32, ptr @libxsmm_verbosity, align 4, !tbaa !10
  br label %45

44:                                               ; preds = %38
  br label %45

45:                                               ; preds = %44, %42
  %46 = phi i32 [ %43, %42 ], [ 1, %44 ]
  call void @libxsmm_handle_error(ptr noundef %39, i32 noundef 90000, ptr noundef @__func__.libxsmm_generator_transform_Xway_permute_network_avx512, ptr noundef @.str, i32 noundef 203, i32 noundef %46)
  store i32 1, ptr %16, align 4
  br label %137

47:                                               ; preds = %35
  store i32 0, ptr %15, align 4, !tbaa !10
  br label %48

48:                                               ; preds = %67, %47
  %49 = load i32, ptr %15, align 4, !tbaa !10
  %50 = load i32, ptr %14, align 4, !tbaa !10
  %51 = udiv i32 %50, 2
  %52 = icmp ult i32 %49, %51
  br i1 %52, label %53, label %70

53:                                               ; preds = %48
  call void @llvm.lifetime.start.p0(i64 4, ptr %17) #3
  %54 = load i32, ptr %15, align 4, !tbaa !10
  %55 = load i32, ptr %12, align 4, !tbaa !10
  %56 = add i32 %54, %55
  store i32 %56, ptr %17, align 4, !tbaa !10
  call void @llvm.lifetime.start.p0(i64 4, ptr %18) #3
  %57 = load i32, ptr %15, align 4, !tbaa !10
  %58 = load i32, ptr %12, align 4, !tbaa !10
  %59 = add i32 %57, %58
  %60 = load i32, ptr %14, align 4, !tbaa !10
  %61 = add i32 %59, %60
  %62 = urem i32 %61, 32
  store i32 %62, ptr %18, align 4, !tbaa !10
  %63 = load ptr, ptr %8, align 8, !tbaa !5
  %64 = load i8, ptr %9, align 1, !tbaa !9
  %65 = load i32, ptr %17, align 4, !tbaa !10
  %66 = load i32, ptr %18, align 4, !tbaa !10
  call void @libxsmm_x86_instruction_vec_compute_3reg_mask_sae_imm8(ptr noundef %63, i32 noundef -528083345, i8 noundef signext %64, i32 noundef %65, i32 noundef 255, i32 noundef %66, i32 noundef 0, i32 noundef 0, i8 noundef zeroext 0, i32 noundef 1024)
  call void @llvm.lifetime.end.p0(i64 4, ptr %18) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %17) #3
  br label %67

67:                                               ; preds = %53
  %68 = load i32, ptr %15, align 4, !tbaa !10
  %69 = add i32 %68, 1
  store i32 %69, ptr %15, align 4, !tbaa !10
  br label %48, !llvm.loop !12

70:                                               ; preds = %48
  store i32 0, ptr %15, align 4, !tbaa !10
  br label %71

71:                                               ; preds = %99, %70
  %72 = load i32, ptr %15, align 4, !tbaa !10
  %73 = load i32, ptr %14, align 4, !tbaa !10
  %74 = udiv i32 %73, 2
  %75 = icmp ult i32 %72, %74
  br i1 %75, label %76, label %102

76:                                               ; preds = %71
  call void @llvm.lifetime.start.p0(i64 4, ptr %19) #3
  %77 = load i32, ptr %15, align 4, !tbaa !10
  %78 = load i32, ptr %12, align 4, !tbaa !10
  %79 = add i32 %77, %78
  %80 = load i32, ptr %14, align 4, !tbaa !10
  %81 = udiv i32 %80, 2
  %82 = add i32 %79, %81
  store i32 %82, ptr %19, align 4, !tbaa !10
  call void @llvm.lifetime.start.p0(i64 4, ptr %20) #3
  %83 = load i32, ptr %15, align 4, !tbaa !10
  %84 = load i32, ptr %12, align 4, !tbaa !10
  %85 = add i32 %83, %84
  store i32 %85, ptr %20, align 4, !tbaa !10
  %86 = load ptr, ptr %8, align 8, !tbaa !5
  %87 = load i32, ptr %13, align 4, !tbaa !10
  %88 = load i8, ptr %9, align 1, !tbaa !9
  %89 = load i32, ptr %19, align 4, !tbaa !10
  %90 = load i32, ptr %20, align 4, !tbaa !10
  %91 = load ptr, ptr %10, align 8, !tbaa !5
  %92 = getelementptr inbounds i8, ptr %91, i64 0
  %93 = load i8, ptr %92, align 1, !tbaa !9
  %94 = zext i8 %93 to i32
  %95 = load ptr, ptr %11, align 8, !tbaa !5
  %96 = getelementptr inbounds i8, ptr %95, i64 0
  %97 = load i8, ptr %96, align 1, !tbaa !9
  %98 = zext i8 %97 to i32
  call void @libxsmm_x86_instruction_vec_compute_3reg_mask_sae_imm8(ptr noundef %86, i32 noundef %87, i8 noundef signext %88, i32 noundef %89, i32 noundef 255, i32 noundef %90, i32 noundef %94, i32 noundef 0, i8 noundef zeroext 0, i32 noundef %98)
  call void @llvm.lifetime.end.p0(i64 4, ptr %20) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %19) #3
  br label %99

99:                                               ; preds = %76
  %100 = load i32, ptr %15, align 4, !tbaa !10
  %101 = add i32 %100, 1
  store i32 %101, ptr %15, align 4, !tbaa !10
  br label %71, !llvm.loop !14

102:                                              ; preds = %71
  %103 = load i32, ptr %14, align 4, !tbaa !10
  %104 = udiv i32 %103, 2
  store i32 %104, ptr %15, align 4, !tbaa !10
  br label %105

105:                                              ; preds = %133, %102
  %106 = load i32, ptr %15, align 4, !tbaa !10
  %107 = load i32, ptr %14, align 4, !tbaa !10
  %108 = icmp ult i32 %106, %107
  br i1 %108, label %109, label %136

109:                                              ; preds = %105
  call void @llvm.lifetime.start.p0(i64 4, ptr %21) #3
  %110 = load i32, ptr %15, align 4, !tbaa !10
  %111 = load i32, ptr %12, align 4, !tbaa !10
  %112 = add i32 %110, %111
  %113 = load i32, ptr %14, align 4, !tbaa !10
  %114 = udiv i32 %113, 2
  %115 = add i32 %112, %114
  %116 = urem i32 %115, 32
  store i32 %116, ptr %21, align 4, !tbaa !10
  call void @llvm.lifetime.start.p0(i64 4, ptr %22) #3
  %117 = load i32, ptr %15, align 4, !tbaa !10
  %118 = load i32, ptr %12, align 4, !tbaa !10
  %119 = add i32 %117, %118
  store i32 %119, ptr %22, align 4, !tbaa !10
  %120 = load ptr, ptr %8, align 8, !tbaa !5
  %121 = load i32, ptr %13, align 4, !tbaa !10
  %122 = load i8, ptr %9, align 1, !tbaa !9
  %123 = load i32, ptr %21, align 4, !tbaa !10
  %124 = load i32, ptr %22, align 4, !tbaa !10
  %125 = load ptr, ptr %10, align 8, !tbaa !5
  %126 = getelementptr inbounds i8, ptr %125, i64 1
  %127 = load i8, ptr %126, align 1, !tbaa !9
  %128 = zext i8 %127 to i32
  %129 = load ptr, ptr %11, align 8, !tbaa !5
  %130 = getelementptr inbounds i8, ptr %129, i64 1
  %131 = load i8, ptr %130, align 1, !tbaa !9
  %132 = zext i8 %131 to i32
  call void @libxsmm_x86_instruction_vec_compute_3reg_mask_sae_imm8(ptr noundef %120, i32 noundef %121, i8 noundef signext %122, i32 noundef %123, i32 noundef 255, i32 noundef %124, i32 noundef %128, i32 noundef 0, i8 noundef zeroext 0, i32 noundef %132)
  call void @llvm.lifetime.end.p0(i64 4, ptr %22) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %21) #3
  br label %133

133:                                              ; preds = %109
  %134 = load i32, ptr %15, align 4, !tbaa !10
  %135 = add i32 %134, 1
  store i32 %135, ptr %15, align 4, !tbaa !10
  br label %105, !llvm.loop !15

136:                                              ; preds = %105
  store i32 0, ptr %16, align 4
  br label %137

137:                                              ; preds = %136, %45, %33
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #3
  %138 = load i32, ptr %16, align 4
  switch i32 %138, label %140 [
    i32 0, label %139
    i32 1, label %139
  ]

139:                                              ; preds = %137, %137
  ret void

140:                                              ; preds = %137
  unreachable
}

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 = distinct !{!12, !13}
!13 = !{!"llvm.loop.mustprogress"}
!14 = distinct !{!14, !13}
!15 = distinct !{!15, !13}


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

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

; Function Attrs: nounwind uwtable
define dso_local void @libxsmm_generator_transform_Xway_permute_network_avx512(ptr noundef %0, i8 noundef signext %1, ptr nocapture noundef readonly %2, ptr nocapture noundef readonly %3, i32 noundef %4, i32 noundef %5, i32 noundef %6) local_unnamed_addr #1 {
  %8 = and i32 %6, 1
  %.not = icmp eq i32 %8, 0
  br i1 %.not, label %9, label %.loopexit.sink.split

9:                                                ; preds = %7
  %10 = icmp ugt i32 %6, 20
  br i1 %10, label %.loopexit.sink.split, label %.preheader49

.preheader49:                                     ; preds = %9
  %11 = lshr exact i32 %6, 1
  %.not55 = icmp eq i32 %6, 0
  br i1 %.not55, label %.loopexit, label %.lr.ph

.preheader48:                                     ; preds = %.lr.ph
  br i1 %.not55, label %.loopexit, label %.lr.ph52

.lr.ph:                                           ; preds = %.preheader49, %.lr.ph
  %.050 = phi i32 [ %15, %.lr.ph ], [ 0, %.preheader49 ]
  %12 = add i32 %.050, %4
  %13 = add i32 %12, %6
  %14 = and i32 %13, 31
  tail call void @libxsmm_x86_instruction_vec_compute_3reg_mask_sae_imm8(ptr noundef %0, i32 noundef -528083345, i8 noundef signext %1, i32 noundef %12, i32 noundef 255, i32 noundef %14, i32 noundef 0, i32 noundef 0, i8 noundef zeroext 0, i32 noundef 1024) #2
  %15 = add nuw nsw i32 %.050, 1
  %exitcond.not = icmp eq i32 %15, %11
  br i1 %exitcond.not, label %.preheader48, label %.lr.ph, !llvm.loop !5

.preheader:                                       ; preds = %.lr.ph52
  br i1 %.not55, label %.loopexit, label %.lr.ph54

.lr.ph54:                                         ; preds = %.preheader
  %16 = getelementptr inbounds i8, ptr %2, i64 1
  %17 = getelementptr inbounds i8, ptr %3, i64 1
  br label %25

.lr.ph52:                                         ; preds = %.preheader48, %.lr.ph52
  %.151 = phi i32 [ %24, %.lr.ph52 ], [ 0, %.preheader48 ]
  %18 = add i32 %.151, %4
  %19 = add i32 %18, %11
  %20 = load i8, ptr %2, align 1, !tbaa !7
  %21 = zext i8 %20 to i32
  %22 = load i8, ptr %3, align 1, !tbaa !7
  %23 = zext i8 %22 to i32
  tail call void @libxsmm_x86_instruction_vec_compute_3reg_mask_sae_imm8(ptr noundef %0, i32 noundef %5, i8 noundef signext %1, i32 noundef %19, i32 noundef 255, i32 noundef %18, i32 noundef %21, i32 noundef 0, i8 noundef zeroext 0, i32 noundef %23) #2
  %24 = add nuw nsw i32 %.151, 1
  %exitcond58.not = icmp eq i32 %24, %11
  br i1 %exitcond58.not, label %.preheader, label %.lr.ph52, !llvm.loop !10

25:                                               ; preds = %.lr.ph54, %25
  %.253 = phi i32 [ %11, %.lr.ph54 ], [ %33, %25 ]
  %26 = add i32 %.253, %4
  %27 = add i32 %26, %11
  %28 = and i32 %27, 31
  %29 = load i8, ptr %16, align 1, !tbaa !7
  %30 = zext i8 %29 to i32
  %31 = load i8, ptr %17, align 1, !tbaa !7
  %32 = zext i8 %31 to i32
  tail call void @libxsmm_x86_instruction_vec_compute_3reg_mask_sae_imm8(ptr noundef %0, i32 noundef %5, i8 noundef signext %1, i32 noundef %28, i32 noundef 255, i32 noundef %26, i32 noundef %30, i32 noundef 0, i8 noundef zeroext 0, i32 noundef %32) #2
  %33 = add nuw nsw i32 %.253, 1
  %34 = icmp ult i32 %33, %6
  br i1 %34, label %25, label %.loopexit, !llvm.loop !11

.loopexit.sink.split:                             ; preds = %9, %7
  %.sink = phi i32 [ 197, %7 ], [ 203, %9 ]
  %35 = load i32, ptr @libxsmm_ninit, align 4, !tbaa !12
  %36 = icmp ugt i32 %35, 1
  %37 = load i32, ptr @libxsmm_verbosity, align 4
  %38 = select i1 %36, i32 %37, i32 1
  tail call void @libxsmm_handle_error(ptr noundef %0, i32 noundef 90000, ptr noundef nonnull @__func__.libxsmm_generator_transform_Xway_permute_network_avx512, ptr noundef nonnull @.str, i32 noundef %.sink, i32 noundef %38) #2
  br label %.loopexit

.loopexit:                                        ; preds = %25, %.loopexit.sink.split, %.preheader49, %.preheader48, %.preheader
  ret void
}

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


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