; 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_vcvtneps2int_avx512 = external hidden unnamed_addr constant [38 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_vcvtneps2int_avx512(ptr noundef %0, i32 noundef %1, i32 noundef %2, i32 noundef %3, i32 noundef %4, i32 noundef %5) #2 {
  %7 = alloca ptr, align 8
  %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 i8, align 1
  %14 = alloca i32, align 4
  store ptr %0, ptr %7, align 8, !tbaa !5
  store i32 %1, ptr %8, align 4, !tbaa !9
  store i32 %2, ptr %9, align 4, !tbaa !9
  store i32 %3, ptr %10, align 4, !tbaa !9
  store i32 %4, ptr %11, align 4, !tbaa !9
  store i32 %5, ptr %12, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 1, ptr %13) #3
  %15 = load ptr, ptr %7, align 8, !tbaa !5
  %16 = getelementptr inbounds %struct.libxsmm_generated_code, ptr %15, i32 0, i32 6
  %17 = load i32, ptr %16, align 4, !tbaa !11
  %18 = icmp ult i32 %17, 1101
  %19 = zext i1 %18 to i64
  %20 = select i1 %18, i32 121, i32 122
  %21 = trunc i32 %20 to i8
  store i8 %21, ptr %13, align 1, !tbaa !13
  %22 = load i32, ptr %11, align 4, !tbaa !9
  %23 = icmp eq i32 %22, 0
  br i1 %23, label %24, label %30

24:                                               ; preds = %6
  %25 = load ptr, ptr %7, align 8, !tbaa !5
  %26 = load i8, ptr %13, align 1, !tbaa !13
  %27 = load i32, ptr %9, align 4, !tbaa !9
  %28 = load i32, ptr %10, align 4, !tbaa !9
  %29 = load i32, ptr %9, align 4, !tbaa !9
  call void @libxsmm_x86_instruction_vec_compute_3reg(ptr noundef %25, i32 noundef 805574233, i8 noundef signext %26, i32 noundef %27, i32 noundef %28, i32 noundef %29)
  br label %30

30:                                               ; preds = %24, %6
  %31 = load ptr, ptr %7, align 8, !tbaa !5
  %32 = load i8, ptr %13, align 1, !tbaa !13
  %33 = load i32, ptr %9, align 4, !tbaa !9
  %34 = load i32, ptr %9, align 4, !tbaa !9
  call void @libxsmm_x86_instruction_vec_compute_3reg_mask_sae_imm8(ptr noundef %31, i32 noundef 537204315, 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)
  %35 = load i32, ptr %8, align 4, !tbaa !9
  %36 = icmp eq i32 %35, 10
  br i1 %36, label %37, label %51

37:                                               ; preds = %30
  %38 = load i32, ptr %12, align 4, !tbaa !9
  %39 = icmp ugt i32 %38, 0
  br i1 %39, label %40, label %45

40:                                               ; preds = %37
  %41 = load ptr, ptr %7, align 8, !tbaa !5
  %42 = load i8, ptr %13, align 1, !tbaa !13
  %43 = load i32, ptr %9, align 4, !tbaa !9
  %44 = load i32, ptr %9, align 4, !tbaa !9
  call void @libxsmm_x86_instruction_vec_compute_3reg_mask_sae_imm8(ptr noundef %41, i32 noundef 671491363, i8 noundef signext %42, i32 noundef %43, i32 noundef 255, i32 noundef %44, i32 noundef 0, i32 noundef 0, i8 noundef zeroext 0, i32 noundef 0)
  br label %50

45:                                               ; preds = %37
  %46 = load ptr, ptr %7, align 8, !tbaa !5
  %47 = load i8, ptr %13, align 1, !tbaa !13
  %48 = load i32, ptr %9, align 4, !tbaa !9
  %49 = load i32, ptr %9, align 4, !tbaa !9
  call void @libxsmm_x86_instruction_vec_compute_3reg_mask_sae_imm8(ptr noundef %46, i32 noundef 671491379, i8 noundef signext %47, i32 noundef %48, i32 noundef 255, i32 noundef %49, i32 noundef 0, i32 noundef 0, i8 noundef zeroext 0, i32 noundef 0)
  br label %50

50:                                               ; preds = %45, %40
  br label %83

51:                                               ; preds = %30
  %52 = load i32, ptr %8, align 4, !tbaa !9
  %53 = icmp eq i32 %52, 12
  br i1 %53, label %54, label %68

54:                                               ; preds = %51
  %55 = load i32, ptr %12, align 4, !tbaa !9
  %56 = icmp ugt i32 %55, 0
  br i1 %56, label %57, label %62

57:                                               ; preds = %54
  %58 = load ptr, ptr %7, align 8, !tbaa !5
  %59 = load i8, ptr %13, align 1, !tbaa !13
  %60 = load i32, ptr %9, align 4, !tbaa !9
  %61 = load i32, ptr %9, align 4, !tbaa !9
  call void @libxsmm_x86_instruction_vec_compute_3reg_mask_sae_imm8(ptr noundef %58, i32 noundef 671491105, i8 noundef signext %59, i32 noundef %60, i32 noundef 255, i32 noundef %61, i32 noundef 0, i32 noundef 0, i8 noundef zeroext 0, i32 noundef 0)
  br label %67

62:                                               ; preds = %54
  %63 = load ptr, ptr %7, align 8, !tbaa !5
  %64 = load i8, ptr %13, align 1, !tbaa !13
  %65 = load i32, ptr %9, align 4, !tbaa !9
  %66 = load i32, ptr %9, align 4, !tbaa !9
  call void @libxsmm_x86_instruction_vec_compute_3reg_mask_sae_imm8(ptr noundef %63, i32 noundef 671491121, 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 0)
  br label %67

67:                                               ; preds = %62, %57
  br label %82

68:                                               ; preds = %51
  %69 = load i32, ptr %8, align 4, !tbaa !9
  %70 = icmp eq i32 %69, 8
  br i1 %70, label %71, label %72

71:                                               ; preds = %68
  br label %81

72:                                               ; preds = %68
  %73 = load ptr, ptr %7, align 8, !tbaa !5
  %74 = load i32, ptr @libxsmm_ninit, align 4, !tbaa !9
  %75 = icmp ult i32 1, %74
  br i1 %75, label %76, label %78

76:                                               ; preds = %72
  %77 = load i32, ptr @libxsmm_verbosity, align 4, !tbaa !9
  br label %79

78:                                               ; preds = %72
  br label %79

79:                                               ; preds = %78, %76
  %80 = phi i32 [ %77, %76 ], [ 1, %78 ]
  call void @libxsmm_handle_error(ptr noundef %73, i32 noundef 90004, ptr noundef @__func__.libxsmm_generator_vcvtneps2int_avx512, ptr noundef @.str.6, i32 noundef 3899, i32 noundef %80)
  store i32 1, ptr %14, align 4
  br label %84

81:                                               ; preds = %71
  br label %82

82:                                               ; preds = %81, %67
  br label %83

83:                                               ; preds = %82, %50
  store i32 0, ptr %14, align 4
  br label %84

84:                                               ; preds = %83, %79
  call void @llvm.lifetime.end.p0(i64 1, ptr %13) #3
  %85 = load i32, ptr %14, align 4
  switch i32 %85, label %87 [
    i32 0, label %86
    i32 1, label %86
  ]

86:                                               ; preds = %84, %84
  ret void

87:                                               ; preds = %84
  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_vcvtneps2int_avx512 = external hidden unnamed_addr constant [38 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_vcvtneps2int_avx512(ptr noundef %0, i32 noundef %1, i32 noundef %2, i32 noundef %3, i32 noundef %4, i32 noundef %5) local_unnamed_addr #1 {
  %7 = getelementptr inbounds i8, ptr %0, i64 28
  %8 = load i32, ptr %7, align 4, !tbaa !5
  %9 = icmp ult i32 %8, 1101
  %10 = select i1 %9, i8 121, i8 122
  %11 = icmp eq i32 %4, 0
  br i1 %11, label %12, label %13

12:                                               ; preds = %6
  tail call void @libxsmm_x86_instruction_vec_compute_3reg(ptr noundef nonnull %0, i32 noundef 805574233, i8 noundef signext %10, i32 noundef %2, i32 noundef %3, i32 noundef %2) #2
  br label %13

13:                                               ; preds = %12, %6
  tail call void @libxsmm_x86_instruction_vec_compute_3reg_mask_sae_imm8(ptr noundef nonnull %0, i32 noundef 537204315, i8 noundef signext %10, i32 noundef %2, i32 noundef 255, i32 noundef %2, i32 noundef 0, i32 noundef 0, i8 noundef zeroext 0, i32 noundef 0) #2
  switch i32 %1, label %20 [
    i32 10, label %14
    i32 12, label %17
    i32 8, label %25
  ]

14:                                               ; preds = %13
  %.not32 = icmp eq i32 %5, 0
  br i1 %.not32, label %16, label %15

15:                                               ; preds = %14
  tail call void @libxsmm_x86_instruction_vec_compute_3reg_mask_sae_imm8(ptr noundef nonnull %0, i32 noundef 671491363, i8 noundef signext %10, 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 %25

16:                                               ; preds = %14
  tail call void @libxsmm_x86_instruction_vec_compute_3reg_mask_sae_imm8(ptr noundef nonnull %0, i32 noundef 671491379, i8 noundef signext %10, 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 %25

17:                                               ; preds = %13
  %.not = icmp eq i32 %5, 0
  br i1 %.not, label %19, label %18

18:                                               ; preds = %17
  tail call void @libxsmm_x86_instruction_vec_compute_3reg_mask_sae_imm8(ptr noundef nonnull %0, i32 noundef 671491105, i8 noundef signext %10, 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 %25

19:                                               ; preds = %17
  tail call void @libxsmm_x86_instruction_vec_compute_3reg_mask_sae_imm8(ptr noundef nonnull %0, i32 noundef 671491121, i8 noundef signext %10, 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 %25

20:                                               ; preds = %13
  %21 = load i32, ptr @libxsmm_ninit, align 4, !tbaa !11
  %22 = icmp ugt i32 %21, 1
  %23 = load i32, ptr @libxsmm_verbosity, align 4
  %24 = select i1 %22, i32 %23, i32 1
  tail call void @libxsmm_handle_error(ptr noundef nonnull %0, i32 noundef 90004, ptr noundef nonnull @__func__.libxsmm_generator_vcvtneps2int_avx512, ptr noundef nonnull @.str.6, i32 noundef 3899, i32 noundef %24) #2
  br label %25

25:                                               ; preds = %16, %15, %18, %19, %13, %20
  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