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

; 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 [82 x i8], align 1
@libxsmm_ninit = external global i32, align 4
@libxsmm_verbosity = external global i32, align 4
@stderr = external global ptr, align 8
@.str.61 = external hidden unnamed_addr constant [67 x i8], align 1
@__func__.libxsmm_x86_instruction_alu_mem = external hidden unnamed_addr constant [32 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

; Function Attrs: nounwind uwtable
declare dso_local void @libxsmm_x86_instruction_rex_compute_1reg_mem(ptr noundef, i32 noundef, i32 noundef, i32 noundef, i32 noundef, i32 noundef, i32 noundef) #1

declare void @libxsmm_handle_error(ptr noundef, i32 noundef, ptr noundef, ptr noundef, i32 noundef, i32 noundef) #2

; Function Attrs: nounwind
declare i32 @fprintf(ptr noundef, ptr noundef, ...) #3

; Function Attrs: nounwind uwtable
define dso_local void @libxsmm_x86_instruction_alu_mem(ptr noundef %0, i32 noundef %1, i32 noundef %2, i32 noundef %3, i32 noundef %4, i32 noundef %5, i32 noundef %6, i32 noundef %7) #1 {
  %9 = alloca ptr, align 8
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  %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
  store ptr %0, ptr %9, align 8, !tbaa !5
  store i32 %1, ptr %10, align 4, !tbaa !9
  store i32 %2, ptr %11, align 4, !tbaa !9
  store i32 %3, ptr %12, align 4, !tbaa !9
  store i32 %4, ptr %13, align 4, !tbaa !9
  store i32 %5, ptr %14, align 4, !tbaa !9
  store i32 %6, ptr %15, align 4, !tbaa !9
  store i32 %7, ptr %16, align 4, !tbaa !9
  %18 = load i32, ptr %10, align 4, !tbaa !9
  switch i32 %18, label %20 [
    i32 -1568407413, label %19
    i32 -1610350453, label %19
    i32 -1610334069, label %19
    i32 -1610350454, label %19
    i32 -1434189687, label %19
    i32 -1476132727, label %19
    i32 -1476116343, label %19
    i32 -1476132728, label %19
    i32 -1610334067, label %19
    i32 -1610350451, label %19
    i32 -1568407411, label %19
  ]

19:                                               ; preds = %8, %8, %8, %8, %8, %8, %8, %8, %8, %8, %8
  br label %32

20:                                               ; preds = %8
  %21 = load ptr, ptr @stderr, align 8, !tbaa !5
  %22 = load i32, ptr %10, align 4, !tbaa !9
  %23 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %21, ptr noundef @.str.61, i32 noundef %22) #4
  %24 = load ptr, ptr %9, align 8, !tbaa !5
  %25 = load i32, ptr @libxsmm_ninit, align 4, !tbaa !9
  %26 = icmp ult i32 1, %25
  br i1 %26, label %27, label %29

27:                                               ; preds = %20
  %28 = load i32, ptr @libxsmm_verbosity, align 4, !tbaa !9
  br label %30

29:                                               ; preds = %20
  br label %30

30:                                               ; preds = %29, %27
  %31 = phi i32 [ %28, %27 ], [ 1, %29 ]
  call void @libxsmm_handle_error(ptr noundef %24, i32 noundef 90000, ptr noundef @__func__.libxsmm_x86_instruction_alu_mem, ptr noundef @.str, i32 noundef 2708, i32 noundef %31)
  br label %69

32:                                               ; preds = %19
  %33 = load ptr, ptr %9, align 8, !tbaa !5
  %34 = getelementptr inbounds %struct.libxsmm_generated_code, ptr %33, i32 0, i32 3
  %35 = load i32, ptr %34, align 8, !tbaa !11
  %36 = icmp ugt i32 %35, 1
  br i1 %36, label %37, label %68

37:                                               ; preds = %32
  call void @llvm.lifetime.start.p0(i64 4, ptr %17) #4
  %38 = load i32, ptr %10, align 4, !tbaa !9
  store i32 %38, ptr %17, align 4, !tbaa !9
  %39 = load i32, ptr %10, align 4, !tbaa !9
  switch i32 %39, label %60 [
    i32 -1568407413, label %40
    i32 -1610350453, label %45
    i32 -1610334069, label %50
    i32 -1610350454, label %55
  ]

40:                                               ; preds = %37
  %41 = load i32, ptr %16, align 4, !tbaa !9
  %42 = icmp eq i32 %41, 0
  %43 = zext i1 %42 to i64
  %44 = select i1 %42, i32 -1568407413, i32 -1434189687
  store i32 %44, ptr %17, align 4, !tbaa !9
  br label %60

45:                                               ; preds = %37
  %46 = load i32, ptr %16, align 4, !tbaa !9
  %47 = icmp eq i32 %46, 0
  %48 = zext i1 %47 to i64
  %49 = select i1 %47, i32 -1610350453, i32 -1476132727
  store i32 %49, ptr %17, align 4, !tbaa !9
  br label %60

50:                                               ; preds = %37
  %51 = load i32, ptr %16, align 4, !tbaa !9
  %52 = icmp eq i32 %51, 0
  %53 = zext i1 %52 to i64
  %54 = select i1 %52, i32 -1610334069, i32 -1476116343
  store i32 %54, ptr %17, align 4, !tbaa !9
  br label %60

55:                                               ; preds = %37
  %56 = load i32, ptr %16, align 4, !tbaa !9
  %57 = icmp eq i32 %56, 0
  %58 = zext i1 %57 to i64
  %59 = select i1 %57, i32 -1610350454, i32 -1476132728
  store i32 %59, ptr %17, align 4, !tbaa !9
  br label %60

60:                                               ; preds = %55, %50, %45, %40, %37
  %61 = load ptr, ptr %9, align 8, !tbaa !5
  %62 = load i32, ptr %17, align 4, !tbaa !9
  %63 = load i32, ptr %11, align 4, !tbaa !9
  %64 = load i32, ptr %12, align 4, !tbaa !9
  %65 = load i32, ptr %13, align 4, !tbaa !9
  %66 = load i32, ptr %14, align 4, !tbaa !9
  %67 = load i32, ptr %15, align 4, !tbaa !9
  call void @libxsmm_x86_instruction_rex_compute_1reg_mem(ptr noundef %61, i32 noundef %62, i32 noundef %63, i32 noundef %64, i32 noundef %65, i32 noundef %66, i32 noundef %67)
  call void @llvm.lifetime.end.p0(i64 4, ptr %17) #4
  br label %69

68:                                               ; preds = %32
  br label %69

69:                                               ; preds = %68, %60, %30
  ret void
}

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


; 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 [82 x i8], align 1
@libxsmm_ninit = external local_unnamed_addr global i32, align 4
@libxsmm_verbosity = external local_unnamed_addr global i32, align 4
@stderr = external local_unnamed_addr global ptr, align 8
@.str.61 = external hidden unnamed_addr constant [67 x i8], align 1
@__func__.libxsmm_x86_instruction_alu_mem = external hidden unnamed_addr constant [32 x i8], align 1

; Function Attrs: nounwind uwtable
declare dso_local void @libxsmm_x86_instruction_rex_compute_1reg_mem(ptr noundef, i32 noundef, i32 noundef, i32 noundef, 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 #1

; Function Attrs: nofree nounwind
declare noundef i32 @fprintf(ptr nocapture noundef, ptr nocapture noundef readonly, ...) local_unnamed_addr #2

; Function Attrs: nounwind uwtable
define dso_local void @libxsmm_x86_instruction_alu_mem(ptr noundef %0, i32 noundef %1, i32 noundef %2, i32 noundef %3, i32 noundef %4, i32 noundef %5, i32 noundef %6, i32 noundef %7) local_unnamed_addr #0 {
  switch i32 %1, label %9 [
    i32 -1568407413, label %16
    i32 -1610350453, label %16
    i32 -1610334069, label %16
    i32 -1610350454, label %16
    i32 -1434189687, label %16
    i32 -1476132727, label %16
    i32 -1476116343, label %16
    i32 -1476132728, label %16
    i32 -1610334067, label %16
    i32 -1610350451, label %16
    i32 -1568407411, label %16
  ]

9:                                                ; preds = %8
  %10 = load ptr, ptr @stderr, align 8, !tbaa !5
  %11 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %10, ptr noundef nonnull @.str.61, i32 noundef %1) #3
  %12 = load i32, ptr @libxsmm_ninit, align 4, !tbaa !9
  %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 %0, i32 noundef 90000, ptr noundef nonnull @__func__.libxsmm_x86_instruction_alu_mem, ptr noundef nonnull @.str, i32 noundef 2708, i32 noundef %15) #4
  br label %34

16:                                               ; preds = %8, %8, %8, %8, %8, %8, %8, %8, %8, %8, %8
  %17 = getelementptr inbounds i8, ptr %0, i64 16
  %18 = load i32, ptr %17, align 8, !tbaa !11
  %19 = icmp ugt i32 %18, 1
  br i1 %19, label %20, label %34

20:                                               ; preds = %16
  switch i32 %1, label %33 [
    i32 -1568407413, label %21
    i32 -1610350453, label %24
    i32 -1610334069, label %27
    i32 -1610350454, label %30
  ]

21:                                               ; preds = %20
  %22 = icmp eq i32 %7, 0
  %23 = select i1 %22, i32 -1568407413, i32 -1434189687
  br label %33

24:                                               ; preds = %20
  %25 = icmp eq i32 %7, 0
  %26 = select i1 %25, i32 -1610350453, i32 -1476132727
  br label %33

27:                                               ; preds = %20
  %28 = icmp eq i32 %7, 0
  %29 = select i1 %28, i32 -1610334069, i32 -1476116343
  br label %33

30:                                               ; preds = %20
  %31 = icmp eq i32 %7, 0
  %32 = select i1 %31, i32 -1610350454, i32 -1476132728
  br label %33

33:                                               ; preds = %30, %27, %24, %21, %20
  %.0 = phi i32 [ %1, %20 ], [ %32, %30 ], [ %29, %27 ], [ %26, %24 ], [ %23, %21 ]
  tail call void @libxsmm_x86_instruction_rex_compute_1reg_mem(ptr noundef nonnull %0, i32 noundef %.0, i32 noundef %2, i32 noundef %3, i32 noundef %4, i32 noundef %5, i32 noundef %6)
  br label %34

34:                                               ; preds = %16, %33, %9
  ret void
}

attributes #0 = { 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 #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 = { nofree 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 #3 = { cold nounwind }
attributes #4 = { 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 16}
!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}


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