; LLVM IR from libxsmm/libxsmm :: src (generator_aarch64_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 }

@stderr = external global ptr, align 8
@.str.1 = external hidden unnamed_addr constant [86 x i8], align 1
@libxsmm_ninit = external global i32, align 4
@libxsmm_verbosity = external global i32, align 4
@.str.101 = external hidden unnamed_addr constant [86 x i8], align 1
@__func__.libxsmm_aarch64_instruction_set_predication_as_counter = external hidden unnamed_addr constant [55 x i8], align 1
@.str.102 = external hidden unnamed_addr constant [84 x i8], align 1

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

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

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

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

; Function Attrs: nounwind uwtable
define dso_local void @libxsmm_aarch64_instruction_set_predication_as_counter(ptr noundef %0, i32 noundef %1, i32 noundef %2, i32 noundef %3, i32 noundef %4, i32 noundef %5, i32 noundef %6) #3 {
  %8 = alloca ptr, align 8
  %9 = alloca i32, align 4
  %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 ptr, align 8
  %17 = alloca i32, align 4
  store ptr %0, ptr %8, align 8, !tbaa !5
  store i32 %1, ptr %9, align 4, !tbaa !9
  store i32 %2, ptr %10, align 4, !tbaa !9
  store i32 %3, ptr %11, align 4, !tbaa !9
  store i32 %4, ptr %12, align 4, !tbaa !9
  store i32 %5, ptr %13, align 4, !tbaa !9
  store i32 %6, ptr %14, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %15) #4
  %18 = load ptr, ptr %8, align 8, !tbaa !5
  %19 = getelementptr inbounds %struct.libxsmm_generated_code, ptr %18, i32 0, i32 2
  %20 = load i32, ptr %19, align 4, !tbaa !11
  %21 = udiv i32 %20, 4
  store i32 %21, ptr %15, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %16) #4
  %22 = load ptr, ptr %8, align 8, !tbaa !5
  %23 = getelementptr inbounds %struct.libxsmm_generated_code, ptr %22, i32 0, i32 0
  %24 = load ptr, ptr %23, align 8, !tbaa !13
  store ptr %24, ptr %16, align 8, !tbaa !5
  %25 = load ptr, ptr %8, align 8, !tbaa !5
  %26 = getelementptr inbounds %struct.libxsmm_generated_code, ptr %25, i32 0, i32 6
  %27 = load i32, ptr %26, align 4, !tbaa !14
  %28 = icmp ne i32 %27, 2501
  br i1 %28, label %29, label %40

29:                                               ; preds = %7
  %30 = load ptr, ptr @stderr, align 8, !tbaa !5
  %31 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %30, ptr noundef @.str.101) #4
  %32 = load ptr, ptr %8, align 8, !tbaa !5
  %33 = load i32, ptr @libxsmm_ninit, align 4, !tbaa !9
  %34 = icmp ult i32 1, %33
  br i1 %34, label %35, label %37

35:                                               ; preds = %29
  %36 = load i32, ptr @libxsmm_verbosity, align 4, !tbaa !9
  br label %38

37:                                               ; preds = %29
  br label %38

38:                                               ; preds = %37, %35
  %39 = phi i32 [ %36, %35 ], [ 1, %37 ]
  call void @libxsmm_handle_error(ptr noundef %32, i32 noundef 90000, ptr noundef @__func__.libxsmm_aarch64_instruction_set_predication_as_counter, ptr noundef @.str.1, i32 noundef 2477, i32 noundef %39)
  store i32 1, ptr %17, align 4
  br label %126

40:                                               ; preds = %7
  %41 = load i32, ptr %9, align 4, !tbaa !9
  switch i32 %41, label %42 [
    i32 622871568, label %54
  ]

42:                                               ; preds = %40
  %43 = load ptr, ptr @stderr, align 8, !tbaa !5
  %44 = load i32, ptr %9, align 4, !tbaa !9
  %45 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %43, ptr noundef @.str.102, i32 noundef %44) #4
  %46 = load ptr, ptr %8, align 8, !tbaa !5
  %47 = load i32, ptr @libxsmm_ninit, align 4, !tbaa !9
  %48 = icmp ult i32 1, %47
  br i1 %48, label %49, label %51

49:                                               ; preds = %42
  %50 = load i32, ptr @libxsmm_verbosity, align 4, !tbaa !9
  br label %52

51:                                               ; preds = %42
  br label %52

52:                                               ; preds = %51, %49
  %53 = phi i32 [ %50, %49 ], [ 1, %51 ]
  call void @libxsmm_handle_error(ptr noundef %46, i32 noundef 90000, ptr noundef @__func__.libxsmm_aarch64_instruction_set_predication_as_counter, ptr noundef @.str.1, i32 noundef 2485, i32 noundef %53)
  store i32 1, ptr %17, align 4
  br label %126

54:                                               ; preds = %40
  %55 = load ptr, ptr %8, align 8, !tbaa !5
  %56 = getelementptr inbounds %struct.libxsmm_generated_code, ptr %55, i32 0, i32 1
  %57 = load i32, ptr %56, align 8, !tbaa !15
  %58 = load ptr, ptr %8, align 8, !tbaa !5
  %59 = getelementptr inbounds %struct.libxsmm_generated_code, ptr %58, i32 0, i32 2
  %60 = load i32, ptr %59, align 4, !tbaa !11
  %61 = sub i32 %57, %60
  %62 = icmp ult i32 %61, 4
  br i1 %62, label %63, label %72

63:                                               ; preds = %54
  %64 = load ptr, ptr %8, align 8, !tbaa !5
  %65 = load i32, ptr @libxsmm_ninit, align 4, !tbaa !9
  %66 = icmp ult i32 1, %65
  br i1 %66, label %67, label %69

67:                                               ; preds = %63
  %68 = load i32, ptr @libxsmm_verbosity, align 4, !tbaa !9
  br label %70

69:                                               ; preds = %63
  br label %70

70:                                               ; preds = %69, %67
  %71 = phi i32 [ %68, %67 ], [ 1, %69 ]
  call void @libxsmm_handle_error(ptr noundef %64, i32 noundef 90002, ptr noundef @__func__.libxsmm_aarch64_instruction_set_predication_as_counter, ptr noundef @.str.1, i32 noundef 2490, i32 noundef %71)
  store i32 1, ptr %17, align 4
  br label %126

72:                                               ; preds = %54
  %73 = load i32, ptr %9, align 4, !tbaa !9
  %74 = load ptr, ptr %16, align 8, !tbaa !5
  %75 = load i32, ptr %15, align 4, !tbaa !9
  %76 = zext i32 %75 to i64
  %77 = getelementptr inbounds i32, ptr %74, i64 %76
  store i32 %73, ptr %77, align 4, !tbaa !9
  %78 = load i32, ptr %10, align 4, !tbaa !9
  %79 = and i32 7, %78
  %80 = load ptr, ptr %16, align 8, !tbaa !5
  %81 = load i32, ptr %15, align 4, !tbaa !9
  %82 = zext i32 %81 to i64
  %83 = getelementptr inbounds i32, ptr %80, i64 %82
  %84 = load i32, ptr %83, align 4, !tbaa !9
  %85 = or i32 %84, %79
  store i32 %85, ptr %83, align 4, !tbaa !9
  %86 = load i32, ptr %11, align 4, !tbaa !9
  %87 = and i32 31, %86
  %88 = shl i32 %87, 5
  %89 = load ptr, ptr %16, align 8, !tbaa !5
  %90 = load i32, ptr %15, align 4, !tbaa !9
  %91 = zext i32 %90 to i64
  %92 = getelementptr inbounds i32, ptr %89, i64 %91
  %93 = load i32, ptr %92, align 4, !tbaa !9
  %94 = or i32 %93, %88
  store i32 %94, ptr %92, align 4, !tbaa !9
  %95 = load i32, ptr %12, align 4, !tbaa !9
  %96 = and i32 1, %95
  %97 = shl i32 %96, 13
  %98 = load ptr, ptr %16, align 8, !tbaa !5
  %99 = load i32, ptr %15, align 4, !tbaa !9
  %100 = zext i32 %99 to i64
  %101 = getelementptr inbounds i32, ptr %98, i64 %100
  %102 = load i32, ptr %101, align 4, !tbaa !9
  %103 = or i32 %102, %97
  store i32 %103, ptr %101, align 4, !tbaa !9
  %104 = load i32, ptr %13, align 4, !tbaa !9
  %105 = and i32 31, %104
  %106 = shl i32 %105, 16
  %107 = load ptr, ptr %16, align 8, !tbaa !5
  %108 = load i32, ptr %15, align 4, !tbaa !9
  %109 = zext i32 %108 to i64
  %110 = getelementptr inbounds i32, ptr %107, i64 %109
  %111 = load i32, ptr %110, align 4, !tbaa !9
  %112 = or i32 %111, %106
  store i32 %112, ptr %110, align 4, !tbaa !9
  %113 = load i32, ptr %14, align 4, !tbaa !9
  %114 = and i32 3, %113
  %115 = shl i32 %114, 22
  %116 = load ptr, ptr %16, align 8, !tbaa !5
  %117 = load i32, ptr %15, align 4, !tbaa !9
  %118 = zext i32 %117 to i64
  %119 = getelementptr inbounds i32, ptr %116, i64 %118
  %120 = load i32, ptr %119, align 4, !tbaa !9
  %121 = or i32 %120, %115
  store i32 %121, ptr %119, align 4, !tbaa !9
  %122 = load ptr, ptr %8, align 8, !tbaa !5
  %123 = getelementptr inbounds %struct.libxsmm_generated_code, ptr %122, i32 0, i32 2
  %124 = load i32, ptr %123, align 4, !tbaa !11
  %125 = add i32 %124, 4
  store i32 %125, ptr %123, align 4, !tbaa !11
  store i32 1, ptr %17, align 4
  br label %126

126:                                              ; preds = %72, %70, %52, %38
  call void @llvm.lifetime.end.p0(i64 8, ptr %16) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #4
  ret void
}

attributes #0 = { 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 #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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { 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 #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 12}
!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 = !{!12, !6, i64 0}
!14 = !{!12, !10, i64 28}
!15 = !{!12, !10, i64 8}


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

@stderr = external local_unnamed_addr global ptr, align 8
@.str.1 = external hidden unnamed_addr constant [86 x i8], align 1
@libxsmm_ninit = external local_unnamed_addr global i32, align 4
@libxsmm_verbosity = external local_unnamed_addr global i32, align 4
@.str.101 = external hidden unnamed_addr constant [86 x i8], align 1
@__func__.libxsmm_aarch64_instruction_set_predication_as_counter = external hidden unnamed_addr constant [55 x i8], align 1
@.str.102 = external hidden unnamed_addr constant [84 x i8], align 1

; Function Attrs: nofree nounwind
declare noundef i32 @fprintf(ptr nocapture noundef, ptr nocapture noundef readonly, ...) 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: nounwind uwtable
define dso_local void @libxsmm_aarch64_instruction_set_predication_as_counter(ptr noundef %0, i32 noundef %1, i32 noundef %2, i32 noundef %3, i32 noundef %4, i32 noundef %5, i32 noundef %6) local_unnamed_addr #2 {
  %8 = getelementptr inbounds i8, ptr %0, i64 12
  %9 = load i32, ptr %8, align 4, !tbaa !5
  %10 = lshr i32 %9, 2
  %11 = load ptr, ptr %0, align 8, !tbaa !11
  %12 = getelementptr inbounds i8, ptr %0, i64 28
  %13 = load i32, ptr %12, align 4, !tbaa !12
  %.not = icmp eq i32 %13, 2501
  br i1 %.not, label %21, label %14

14:                                               ; preds = %7
  %15 = load ptr, ptr @stderr, align 8, !tbaa !13
  %16 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %15, ptr noundef nonnull @.str.101) #3
  %17 = load i32, ptr @libxsmm_ninit, align 4, !tbaa !14
  %18 = icmp ugt i32 %17, 1
  %19 = load i32, ptr @libxsmm_verbosity, align 4
  %20 = select i1 %18, i32 %19, i32 1
  tail call void @libxsmm_handle_error(ptr noundef nonnull %0, i32 noundef 90000, ptr noundef nonnull @__func__.libxsmm_aarch64_instruction_set_predication_as_counter, ptr noundef nonnull @.str.1, i32 noundef 2477, i32 noundef %20) #4
  br label %58

21:                                               ; preds = %7
  %cond = icmp eq i32 %1, 622871568
  br i1 %cond, label %29, label %22

22:                                               ; preds = %21
  %23 = load ptr, ptr @stderr, align 8, !tbaa !13
  %24 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %23, ptr noundef nonnull @.str.102, i32 noundef %1) #3
  %25 = load i32, ptr @libxsmm_ninit, align 4, !tbaa !14
  %26 = icmp ugt i32 %25, 1
  %27 = load i32, ptr @libxsmm_verbosity, align 4
  %28 = select i1 %26, i32 %27, i32 1
  tail call void @libxsmm_handle_error(ptr noundef nonnull %0, i32 noundef 90000, ptr noundef nonnull @__func__.libxsmm_aarch64_instruction_set_predication_as_counter, ptr noundef nonnull @.str.1, i32 noundef 2485, i32 noundef %28) #4
  br label %58

29:                                               ; preds = %21
  %30 = getelementptr inbounds i8, ptr %0, i64 8
  %31 = load i32, ptr %30, align 8, !tbaa !15
  %32 = sub i32 %31, %9
  %33 = icmp ult i32 %32, 4
  br i1 %33, label %34, label %39

34:                                               ; preds = %29
  %35 = load i32, ptr @libxsmm_ninit, align 4, !tbaa !14
  %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 nonnull %0, i32 noundef 90002, ptr noundef nonnull @__func__.libxsmm_aarch64_instruction_set_predication_as_counter, ptr noundef nonnull @.str.1, i32 noundef 2490, i32 noundef %38) #4
  br label %58

39:                                               ; preds = %29
  %40 = zext nneg i32 %10 to i64
  %41 = getelementptr inbounds i32, ptr %11, i64 %40
  %42 = and i32 %2, 7
  %43 = shl i32 %3, 5
  %44 = and i32 %43, 992
  %45 = shl i32 %4, 13
  %46 = and i32 %45, 8192
  %47 = shl i32 %5, 16
  %48 = and i32 %47, 2031616
  %49 = shl i32 %6, 22
  %50 = and i32 %49, 12582912
  %51 = or disjoint i32 %42, %44
  %52 = or disjoint i32 %51, %46
  %53 = or disjoint i32 %52, %48
  %54 = or disjoint i32 %53, %50
  %55 = or disjoint i32 %54, 622871568
  store i32 %55, ptr %41, align 4, !tbaa !14
  %56 = load i32, ptr %8, align 4, !tbaa !5
  %57 = add i32 %56, 4
  store i32 %57, ptr %8, align 4, !tbaa !5
  br label %58

58:                                               ; preds = %39, %34, %22, %14
  ret void
}

attributes #0 = { 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 #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 = { 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, !10, i64 12}
!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 = !{!6, !7, i64 0}
!12 = !{!6, !10, i64 28}
!13 = !{!7, !7, i64 0}
!14 = !{!10, !10, i64 0}
!15 = !{!6, !10, i64 8}


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