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

; 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.6 = external hidden unnamed_addr constant [76 x i8], align 1
@libxsmm_ninit = external global i32, align 4
@libxsmm_verbosity = external global i32, align 4
@__func__.libxsmm_generator_vcvtint2ps_avx512 = external hidden unnamed_addr constant [36 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

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

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

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: nounwind uwtable
define dso_local void @libxsmm_generator_vcvtint2ps_avx512(ptr noundef %0, i32 noundef %1, i32 noundef %2, i32 noundef %3, i32 noundef %4) #2 {
  %6 = alloca ptr, align 8
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  %11 = alloca i8, align 1
  %12 = alloca i32, align 4
  store ptr %0, ptr %6, align 8, !tbaa !5
  store i32 %1, ptr %7, align 4, !tbaa !9
  store i32 %2, ptr %8, align 4, !tbaa !9
  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 1, ptr %11) #3
  %13 = load ptr, ptr %6, align 8, !tbaa !5
  %14 = getelementptr inbounds %struct.libxsmm_generated_code, ptr %13, i32 0, i32 6
  %15 = load i32, ptr %14, align 4, !tbaa !11
  %16 = icmp ult i32 %15, 1101
  %17 = zext i1 %16 to i64
  %18 = select i1 %16, i32 121, i32 122
  %19 = trunc i32 %18 to i8
  store i8 %19, ptr %11, align 1, !tbaa !13
  %20 = load i32, ptr %7, align 4, !tbaa !9
  %21 = icmp eq i32 %20, 10
  br i1 %21, label %22, label %27

22:                                               ; preds = %5
  %23 = load ptr, ptr %6, align 8, !tbaa !5
  %24 = load i8, ptr %11, align 1, !tbaa !13
  %25 = load i32, ptr %8, align 4, !tbaa !9
  %26 = load i32, ptr %8, align 4, !tbaa !9
  call void @libxsmm_x86_instruction_vec_compute_3reg_mask_sae_imm8(ptr noundef %23, i32 noundef 537208099, i8 noundef signext %24, i32 noundef %25, i32 noundef 255, i32 noundef %26, i32 noundef 0, i32 noundef 0, i8 noundef zeroext 0, i32 noundef 0)
  br label %50

27:                                               ; preds = %5
  %28 = load i32, ptr %7, align 4, !tbaa !9
  %29 = icmp eq i32 %28, 12
  br i1 %29, label %30, label %35

30:                                               ; preds = %27
  %31 = load ptr, ptr %6, align 8, !tbaa !5
  %32 = load i8, ptr %11, align 1, !tbaa !13
  %33 = load i32, ptr %8, align 4, !tbaa !9
  %34 = load i32, ptr %8, align 4, !tbaa !9
  call void @libxsmm_x86_instruction_vec_compute_3reg_mask_sae_imm8(ptr noundef %31, i32 noundef 537207841, i8 noundef signext %32, i32 noundef %33, i32 noundef 255, i32 noundef %34, i32 noundef 0, i32 noundef 0, i8 noundef zeroext 0, i32 noundef 0)
  br label %49

35:                                               ; preds = %27
  %36 = load i32, ptr %7, align 4, !tbaa !9
  %37 = icmp eq i32 %36, 8
  br i1 %37, label %38, label %39

38:                                               ; preds = %35
  br label %48

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

43:                                               ; preds = %39
  %44 = load i32, ptr @libxsmm_verbosity, align 4, !tbaa !9
  br label %46

45:                                               ; preds = %39
  br label %46

46:                                               ; preds = %45, %43
  %47 = phi i32 [ %44, %43 ], [ 1, %45 ]
  call void @libxsmm_handle_error(ptr noundef %40, i32 noundef 90004, ptr noundef @__func__.libxsmm_generator_vcvtint2ps_avx512, ptr noundef @.str.6, i32 noundef 3958, i32 noundef %47)
  store i32 1, ptr %12, align 4
  br label %64

48:                                               ; preds = %38
  br label %49

49:                                               ; preds = %48, %30
  br label %50

50:                                               ; preds = %49, %22
  %51 = load ptr, ptr %6, align 8, !tbaa !5
  %52 = load i8, ptr %11, align 1, !tbaa !13
  %53 = load i32, ptr %8, align 4, !tbaa !9
  %54 = load i32, ptr %8, align 4, !tbaa !9
  call void @libxsmm_x86_instruction_vec_compute_3reg_mask_sae_imm8(ptr noundef %51, i32 noundef 537138779, i8 noundef signext %52, i32 noundef %53, i32 noundef 255, i32 noundef %54, i32 noundef 0, i32 noundef 0, i8 noundef zeroext 0, i32 noundef 0)
  %55 = load i32, ptr %10, align 4, !tbaa !9
  %56 = icmp eq i32 %55, 0
  br i1 %56, label %57, label %63

57:                                               ; preds = %50
  %58 = load ptr, ptr %6, align 8, !tbaa !5
  %59 = load i8, ptr %11, align 1, !tbaa !13
  %60 = load i32, ptr %8, align 4, !tbaa !9
  %61 = load i32, ptr %9, align 4, !tbaa !9
  %62 = load i32, ptr %8, align 4, !tbaa !9
  call void @libxsmm_x86_instruction_vec_compute_3reg(ptr noundef %58, i32 noundef 805574233, i8 noundef signext %59, i32 noundef %60, i32 noundef %61, i32 noundef %62)
  br label %63

63:                                               ; preds = %57, %50
  store i32 0, ptr %12, align 4
  br label %64

64:                                               ; preds = %63, %46
  call void @llvm.lifetime.end.p0(i64 1, ptr %11) #3
  %65 = load i32, ptr %12, align 4
  switch i32 %65, label %67 [
    i32 0, label %66
    i32 1, label %66
  ]

66:                                               ; preds = %64, %64
  ret void

67:                                               ; preds = %64
  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 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!12, !10, i64 28}
!12 = !{!"libxsmm_generated_code", !6, i64 0, !10, i64 8, !10, i64 12, !10, i64 16, !10, i64 20, !10, i64 24, !10, i64 28}
!13 = !{!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"

@.str.6 = external hidden unnamed_addr constant [76 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_vcvtint2ps_avx512 = external hidden unnamed_addr constant [36 x i8], align 1

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

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_vcvtint2ps_avx512(ptr noundef %0, i32 noundef %1, i32 noundef %2, i32 noundef %3, i32 noundef %4) local_unnamed_addr #1 {
  %6 = getelementptr inbounds i8, ptr %0, i64 28
  %7 = load i32, ptr %6, align 4, !tbaa !5
  %8 = icmp ult i32 %7, 1101
  %9 = select i1 %8, i8 121, i8 122
  switch i32 %1, label %11 [
    i32 10, label %.sink.split
    i32 12, label %10
    i32 8, label %16
  ]

10:                                               ; preds = %5
  br label %.sink.split

11:                                               ; preds = %5
  %12 = load i32, ptr @libxsmm_ninit, align 4, !tbaa !11
  %13 = icmp ugt i32 %12, 1
  %14 = load i32, ptr @libxsmm_verbosity, align 4
  %15 = select i1 %13, i32 %14, i32 1
  tail call void @libxsmm_handle_error(ptr noundef nonnull %0, i32 noundef 90004, ptr noundef nonnull @__func__.libxsmm_generator_vcvtint2ps_avx512, ptr noundef nonnull @.str.6, i32 noundef 3958, i32 noundef %15) #2
  br label %19

.sink.split:                                      ; preds = %5, %10
  %.sink = phi i32 [ 537207841, %10 ], [ 537208099, %5 ]
  tail call void @libxsmm_x86_instruction_vec_compute_3reg_mask_sae_imm8(ptr noundef nonnull %0, i32 noundef %.sink, i8 noundef signext %9, i32 noundef %2, i32 noundef 255, i32 noundef %2, i32 noundef 0, i32 noundef 0, i8 noundef zeroext 0, i32 noundef 0) #2
  br label %16

16:                                               ; preds = %.sink.split, %5
  tail call void @libxsmm_x86_instruction_vec_compute_3reg_mask_sae_imm8(ptr noundef nonnull %0, i32 noundef 537138779, i8 noundef signext %9, i32 noundef %2, i32 noundef 255, i32 noundef %2, i32 noundef 0, i32 noundef 0, i8 noundef zeroext 0, i32 noundef 0) #2
  %17 = icmp eq i32 %4, 0
  br i1 %17, label %18, label %19

18:                                               ; preds = %16
  tail call void @libxsmm_x86_instruction_vec_compute_3reg(ptr noundef nonnull %0, i32 noundef 805574233, i8 noundef signext %9, i32 noundef %2, i32 noundef %3, i32 noundef %2) #2
  br label %19

19:                                               ; preds = %16, %18, %11
  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, !10, i64 28}
!6 = !{!"libxsmm_generated_code", !7, i64 0, !10, i64 8, !10, i64 12, !10, i64 16, !10, i64 20, !10, i64 24, !10, i64 28}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"int", !8, i64 0}
!11 = !{!10, !10, i64 0}


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