; LLVM IR from libxsmm/libxsmm :: src (generator_matequation_scratch_avx_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_meqn_elem = type { ptr, ptr, ptr, ptr, i32, %union.libxsmm_meqn_info, i32, i32, %struct.libxsmm_meqn_tmp_info, i32, i32, i32, %union.libxsmm_meqn_fusion_info }
%union.libxsmm_meqn_info = type { %struct.libxsmm_meqn_arg }
%struct.libxsmm_meqn_arg = type { i32, i32, i32, i32, i32, i32, i32, %struct.libxsmm_matrix_arg_attributes }
%struct.libxsmm_matrix_arg_attributes = type { i32, i32, i32, i32 }
%struct.libxsmm_meqn_tmp_info = type { i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32 }
%union.libxsmm_meqn_fusion_info = type { %struct.libxsmm_meqn_xgemm_fusion_info }
%struct.libxsmm_meqn_xgemm_fusion_info = type { i32, i32, i32, i32, i32 }
%struct.libxsmm_meqn_ternary_op = type { i32, i32, i32, i32, i32, i32 }

@.str.1 = external hidden unnamed_addr constant [96 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [369 x i8], align 1
@__PRETTY_FUNCTION__.libxsmm_generator_matequation_create_ternary_descriptor = external hidden unnamed_addr constant [174 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [364 x i8], align 1

declare ptr @libxsmm_meltw_descriptor_init2(ptr noundef, i32 noundef, i32 noundef, i32 noundef, i32 noundef, i32 noundef, i32 noundef, i32 noundef, i32 noundef, i32 noundef, i32 noundef, i32 noundef, i16 noundef zeroext, i16 noundef zeroext, i8 noundef zeroext) #0

; Function Attrs: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) #1

; Function Attrs: nounwind uwtable
define dso_local void @libxsmm_generator_matequation_create_ternary_descriptor(ptr noundef %0, ptr noundef %1, ptr noundef %2, i32 noundef %3, i32 noundef %4) #2 {
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  store ptr %0, ptr %6, align 8, !tbaa !5
  store ptr %1, ptr %7, align 8, !tbaa !5
  store ptr %2, ptr %8, align 8, !tbaa !5
  store i32 %3, ptr %9, align 4, !tbaa !9
  store i32 %4, ptr %10, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #4
  %12 = load ptr, ptr %7, align 8, !tbaa !5
  %13 = getelementptr inbounds %struct.libxsmm_meqn_elem, ptr %12, i32 0, i32 5
  %14 = getelementptr inbounds %struct.libxsmm_meqn_ternary_op, ptr %13, i32 0, i32 0
  %15 = load i32, ptr %14, align 4, !tbaa !11
  %16 = icmp eq i32 %15, 3
  br i1 %16, label %17, label %18

17:                                               ; preds = %5
  br label %25

18:                                               ; preds = %5
  %19 = load ptr, ptr %7, align 8, !tbaa !5
  %20 = getelementptr inbounds %struct.libxsmm_meqn_elem, ptr %19, i32 0, i32 2
  %21 = load ptr, ptr %20, align 8, !tbaa !11
  %22 = getelementptr inbounds %struct.libxsmm_meqn_elem, ptr %21, i32 0, i32 8
  %23 = getelementptr inbounds %struct.libxsmm_meqn_tmp_info, ptr %22, i32 0, i32 4
  %24 = load i32, ptr %23, align 8, !tbaa !11
  br label %25

25:                                               ; preds = %18, %17
  %26 = phi i32 [ 14, %17 ], [ %24, %18 ]
  store i32 %26, ptr %11, align 4, !tbaa !9
  %27 = load ptr, ptr %6, align 8, !tbaa !5
  %28 = load i32, ptr %9, align 4, !tbaa !9
  %29 = load ptr, ptr %7, align 8, !tbaa !5
  %30 = getelementptr inbounds %struct.libxsmm_meqn_elem, ptr %29, i32 0, i32 1
  %31 = load ptr, ptr %30, align 8, !tbaa !11
  %32 = getelementptr inbounds %struct.libxsmm_meqn_elem, ptr %31, i32 0, i32 8
  %33 = getelementptr inbounds %struct.libxsmm_meqn_tmp_info, ptr %32, i32 0, i32 4
  %34 = load i32, ptr %33, align 8, !tbaa !11
  %35 = load i32, ptr %11, align 4, !tbaa !9
  %36 = load ptr, ptr %7, align 8, !tbaa !5
  %37 = getelementptr inbounds %struct.libxsmm_meqn_elem, ptr %36, i32 0, i32 5
  %38 = getelementptr inbounds %struct.libxsmm_meqn_ternary_op, ptr %37, i32 0, i32 2
  %39 = load i32, ptr %38, align 4, !tbaa !11
  %40 = load i32, ptr %10, align 4, !tbaa !9
  %41 = load ptr, ptr %7, align 8, !tbaa !5
  %42 = getelementptr inbounds %struct.libxsmm_meqn_elem, ptr %41, i32 0, i32 8
  %43 = getelementptr inbounds %struct.libxsmm_meqn_tmp_info, ptr %42, i32 0, i32 1
  %44 = load i32, ptr %43, align 4, !tbaa !11
  %45 = load ptr, ptr %7, align 8, !tbaa !5
  %46 = getelementptr inbounds %struct.libxsmm_meqn_elem, ptr %45, i32 0, i32 8
  %47 = getelementptr inbounds %struct.libxsmm_meqn_tmp_info, ptr %46, i32 0, i32 2
  %48 = load i32, ptr %47, align 8, !tbaa !11
  %49 = load ptr, ptr %7, align 8, !tbaa !5
  %50 = getelementptr inbounds %struct.libxsmm_meqn_elem, ptr %49, i32 0, i32 0
  %51 = load ptr, ptr %50, align 8, !tbaa !11
  %52 = getelementptr inbounds %struct.libxsmm_meqn_elem, ptr %51, i32 0, i32 8
  %53 = getelementptr inbounds %struct.libxsmm_meqn_tmp_info, ptr %52, i32 0, i32 3
  %54 = load i32, ptr %53, align 4, !tbaa !11
  %55 = load ptr, ptr %7, align 8, !tbaa !5
  %56 = getelementptr inbounds %struct.libxsmm_meqn_elem, ptr %55, i32 0, i32 8
  %57 = getelementptr inbounds %struct.libxsmm_meqn_tmp_info, ptr %56, i32 0, i32 3
  %58 = load i32, ptr %57, align 4, !tbaa !11
  %59 = load ptr, ptr %7, align 8, !tbaa !5
  %60 = getelementptr inbounds %struct.libxsmm_meqn_elem, ptr %59, i32 0, i32 1
  %61 = load ptr, ptr %60, align 8, !tbaa !11
  %62 = getelementptr inbounds %struct.libxsmm_meqn_elem, ptr %61, i32 0, i32 8
  %63 = getelementptr inbounds %struct.libxsmm_meqn_tmp_info, ptr %62, i32 0, i32 3
  %64 = load i32, ptr %63, align 4, !tbaa !11
  %65 = load ptr, ptr %7, align 8, !tbaa !5
  %66 = getelementptr inbounds %struct.libxsmm_meqn_elem, ptr %65, i32 0, i32 2
  %67 = load ptr, ptr %66, align 8, !tbaa !11
  %68 = getelementptr inbounds %struct.libxsmm_meqn_elem, ptr %67, i32 0, i32 8
  %69 = getelementptr inbounds %struct.libxsmm_meqn_tmp_info, ptr %68, i32 0, i32 3
  %70 = load i32, ptr %69, align 4, !tbaa !11
  %71 = load ptr, ptr %7, align 8, !tbaa !5
  %72 = getelementptr inbounds %struct.libxsmm_meqn_elem, ptr %71, i32 0, i32 5
  %73 = getelementptr inbounds %struct.libxsmm_meqn_ternary_op, ptr %72, i32 0, i32 1
  %74 = load i32, ptr %73, align 4, !tbaa !11
  %75 = trunc i32 %74 to i16
  %76 = zext i16 %75 to i32
  %77 = icmp eq i32 0, %76
  br i1 %77, label %86, label %78

78:                                               ; preds = %25
  %79 = load ptr, ptr %7, align 8, !tbaa !5
  %80 = getelementptr inbounds %struct.libxsmm_meqn_elem, ptr %79, i32 0, i32 5
  %81 = getelementptr inbounds %struct.libxsmm_meqn_ternary_op, ptr %80, i32 0, i32 1
  %82 = load i32, ptr %81, align 4, !tbaa !11
  %83 = trunc i32 %82 to i16
  %84 = zext i16 %83 to i32
  %85 = icmp slt i32 0, %84
  br i1 %85, label %86, label %113

86:                                               ; preds = %78, %25
  %87 = load ptr, ptr %7, align 8, !tbaa !5
  %88 = getelementptr inbounds %struct.libxsmm_meqn_elem, ptr %87, i32 0, i32 5
  %89 = getelementptr inbounds %struct.libxsmm_meqn_ternary_op, ptr %88, i32 0, i32 1
  %90 = load i32, ptr %89, align 4, !tbaa !11
  %91 = zext i32 %90 to i64
  %92 = mul i64 1, %91
  %93 = icmp ult i64 %92, 65535
  br i1 %93, label %94, label %101

94:                                               ; preds = %86
  %95 = load ptr, ptr %7, align 8, !tbaa !5
  %96 = getelementptr inbounds %struct.libxsmm_meqn_elem, ptr %95, i32 0, i32 5
  %97 = getelementptr inbounds %struct.libxsmm_meqn_ternary_op, ptr %96, i32 0, i32 1
  %98 = load i32, ptr %97, align 4, !tbaa !11
  %99 = zext i32 %98 to i64
  %100 = mul i64 1, %99
  br label %102

101:                                              ; preds = %86
  br label %102

102:                                              ; preds = %101, %94
  %103 = phi i64 [ %100, %94 ], [ 65535, %101 ]
  %104 = icmp ule i64 %103, 65535
  br i1 %104, label %105, label %113

105:                                              ; preds = %102
  %106 = load ptr, ptr %7, align 8, !tbaa !5
  %107 = getelementptr inbounds %struct.libxsmm_meqn_elem, ptr %106, i32 0, i32 5
  %108 = getelementptr inbounds %struct.libxsmm_meqn_ternary_op, ptr %107, i32 0, i32 1
  %109 = load i32, ptr %108, align 4, !tbaa !11
  %110 = uitofp i32 %109 to double
  %111 = fcmp ole double 0.000000e+00, %110
  br i1 %111, label %112, label %113

112:                                              ; preds = %105
  br label %114

113:                                              ; preds = %105, %102, %78
  call void @__assert_fail(ptr noundef @.str.5, ptr noundef @.str.1, i32 noundef 59, ptr noundef @__PRETTY_FUNCTION__.libxsmm_generator_matequation_create_ternary_descriptor) #5
  unreachable

114:                                              ; preds = %112
  %115 = load ptr, ptr %7, align 8, !tbaa !5
  %116 = getelementptr inbounds %struct.libxsmm_meqn_elem, ptr %115, i32 0, i32 5
  %117 = getelementptr inbounds %struct.libxsmm_meqn_ternary_op, ptr %116, i32 0, i32 1
  %118 = load i32, ptr %117, align 4, !tbaa !11
  %119 = trunc i32 %118 to i16
  %120 = load ptr, ptr %7, align 8, !tbaa !5
  %121 = getelementptr inbounds %struct.libxsmm_meqn_elem, ptr %120, i32 0, i32 5
  %122 = getelementptr inbounds %struct.libxsmm_meqn_ternary_op, ptr %121, i32 0, i32 0
  %123 = load i32, ptr %122, align 4, !tbaa !11
  %124 = trunc i32 %123 to i16
  %125 = zext i16 %124 to i32
  %126 = icmp eq i32 0, %125
  br i1 %126, label %135, label %127

127:                                              ; preds = %114
  %128 = load ptr, ptr %7, align 8, !tbaa !5
  %129 = getelementptr inbounds %struct.libxsmm_meqn_elem, ptr %128, i32 0, i32 5
  %130 = getelementptr inbounds %struct.libxsmm_meqn_ternary_op, ptr %129, i32 0, i32 0
  %131 = load i32, ptr %130, align 4, !tbaa !11
  %132 = trunc i32 %131 to i16
  %133 = zext i16 %132 to i32
  %134 = icmp slt i32 0, %133
  br i1 %134, label %135, label %162

135:                                              ; preds = %127, %114
  %136 = load ptr, ptr %7, align 8, !tbaa !5
  %137 = getelementptr inbounds %struct.libxsmm_meqn_elem, ptr %136, i32 0, i32 5
  %138 = getelementptr inbounds %struct.libxsmm_meqn_ternary_op, ptr %137, i32 0, i32 0
  %139 = load i32, ptr %138, align 4, !tbaa !11
  %140 = zext i32 %139 to i64
  %141 = mul i64 1, %140
  %142 = icmp ult i64 %141, 65535
  br i1 %142, label %143, label %150

143:                                              ; preds = %135
  %144 = load ptr, ptr %7, align 8, !tbaa !5
  %145 = getelementptr inbounds %struct.libxsmm_meqn_elem, ptr %144, i32 0, i32 5
  %146 = getelementptr inbounds %struct.libxsmm_meqn_ternary_op, ptr %145, i32 0, i32 0
  %147 = load i32, ptr %146, align 4, !tbaa !11
  %148 = zext i32 %147 to i64
  %149 = mul i64 1, %148
  br label %151

150:                                              ; preds = %135
  br label %151

151:                                              ; preds = %150, %143
  %152 = phi i64 [ %149, %143 ], [ 65535, %150 ]
  %153 = icmp ule i64 %152, 65535
  br i1 %153, label %154, label %162

154:                                              ; preds = %151
  %155 = load ptr, ptr %7, align 8, !tbaa !5
  %156 = getelementptr inbounds %struct.libxsmm_meqn_elem, ptr %155, i32 0, i32 5
  %157 = getelementptr inbounds %struct.libxsmm_meqn_ternary_op, ptr %156, i32 0, i32 0
  %158 = load i32, ptr %157, align 4, !tbaa !11
  %159 = uitofp i32 %158 to double
  %160 = fcmp ole double 0.000000e+00, %159
  br i1 %160, label %161, label %162

161:                                              ; preds = %154
  br label %163

162:                                              ; preds = %154, %151, %127
  call void @__assert_fail(ptr noundef @.str.6, ptr noundef @.str.1, i32 noundef 59, ptr noundef @__PRETTY_FUNCTION__.libxsmm_generator_matequation_create_ternary_descriptor) #5
  unreachable

163:                                              ; preds = %161
  %164 = load ptr, ptr %7, align 8, !tbaa !5
  %165 = getelementptr inbounds %struct.libxsmm_meqn_elem, ptr %164, i32 0, i32 5
  %166 = getelementptr inbounds %struct.libxsmm_meqn_ternary_op, ptr %165, i32 0, i32 0
  %167 = load i32, ptr %166, align 4, !tbaa !11
  %168 = trunc i32 %167 to i16
  %169 = call ptr @libxsmm_meltw_descriptor_init2(ptr noundef %27, i32 noundef %28, i32 noundef %34, i32 noundef %35, i32 noundef %39, i32 noundef %40, i32 noundef %44, i32 noundef %48, i32 noundef %54, i32 noundef %58, i32 noundef %64, i32 noundef %70, i16 noundef zeroext %119, i16 noundef zeroext %168, i8 noundef zeroext 3)
  %170 = load ptr, ptr %8, align 8, !tbaa !5
  store ptr %169, ptr %170, align 8, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #4
  ret void
}

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

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

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 = { noreturn nounwind "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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #4 = { nounwind }
attributes #5 = { noreturn 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 = !{!7, !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"

declare ptr @libxsmm_meltw_descriptor_init2(ptr noundef, i32 noundef, i32 noundef, i32 noundef, i32 noundef, i32 noundef, i32 noundef, i32 noundef, i32 noundef, i32 noundef, i32 noundef, i32 noundef, i16 noundef zeroext, i16 noundef zeroext, i8 noundef zeroext) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local void @libxsmm_generator_matequation_create_ternary_descriptor(ptr noundef %0, ptr nocapture noundef readonly %1, ptr nocapture noundef writeonly %2, i32 noundef %3, i32 noundef %4) local_unnamed_addr #1 {
  %6 = getelementptr inbounds i8, ptr %1, i64 36
  %7 = load i32, ptr %6, align 4, !tbaa !5
  %8 = icmp eq i32 %7, 3
  %.phi.trans.insert = getelementptr inbounds i8, ptr %1, i64 16
  %.pre = load ptr, ptr %.phi.trans.insert, align 8, !tbaa !5
  br i1 %8, label %._crit_edge, label %9

9:                                                ; preds = %5
  %10 = getelementptr inbounds i8, ptr %.pre, i64 104
  %11 = load i32, ptr %10, align 8, !tbaa !5
  br label %._crit_edge

._crit_edge:                                      ; preds = %5, %9
  %12 = phi i32 [ %11, %9 ], [ 14, %5 ]
  %13 = getelementptr inbounds i8, ptr %1, i64 8
  %14 = load ptr, ptr %13, align 8, !tbaa !5
  %15 = getelementptr inbounds i8, ptr %14, i64 104
  %16 = load i32, ptr %15, align 8, !tbaa !5
  %17 = getelementptr inbounds i8, ptr %1, i64 44
  %18 = load i32, ptr %17, align 4, !tbaa !5
  %19 = getelementptr inbounds i8, ptr %1, i64 92
  %20 = load i32, ptr %19, align 4, !tbaa !5
  %21 = getelementptr inbounds i8, ptr %1, i64 96
  %22 = load i32, ptr %21, align 8, !tbaa !5
  %23 = load ptr, ptr %1, align 8, !tbaa !5
  %24 = getelementptr inbounds i8, ptr %23, i64 100
  %25 = load i32, ptr %24, align 4, !tbaa !5
  %26 = getelementptr inbounds i8, ptr %1, i64 100
  %27 = load i32, ptr %26, align 4, !tbaa !5
  %28 = getelementptr inbounds i8, ptr %14, i64 100
  %29 = load i32, ptr %28, align 4, !tbaa !5
  %30 = getelementptr inbounds i8, ptr %.pre, i64 100
  %31 = load i32, ptr %30, align 4, !tbaa !5
  %32 = getelementptr inbounds i8, ptr %1, i64 40
  %33 = load i32, ptr %32, align 4, !tbaa !5
  %34 = trunc i32 %33 to i16
  %35 = trunc i32 %7 to i16
  %36 = tail call ptr @libxsmm_meltw_descriptor_init2(ptr noundef %0, i32 noundef %3, i32 noundef %16, i32 noundef %12, i32 noundef %18, i32 noundef %4, i32 noundef %20, i32 noundef %22, i32 noundef %25, i32 noundef %27, i32 noundef %29, i32 noundef %31, i16 noundef zeroext %34, i16 noundef zeroext %35, i8 noundef zeroext 3) #2
  store ptr %36, ptr %2, align 8, !tbaa !8
  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 = !{!6, !6, i64 0}
!6 = !{!"omnipotent char", !7, i64 0}
!7 = !{!"Simple C/C++ TBAA"}
!8 = !{!9, !9, i64 0}
!9 = !{!"any pointer", !6, i64 0}


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