; 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.96 = external hidden unnamed_addr constant [62 x i8], align 1
@__func__.libxsmm_aarch64_instruction_sm = external hidden unnamed_addr constant [31 x i8], align 1
@.str.97 = external hidden unnamed_addr constant [71 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_sm(ptr noundef %0, i32 noundef %1) #3 {
  %3 = alloca ptr, align 8
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  %6 = alloca ptr, align 8
  %7 = alloca i32, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  store i32 %1, ptr %4, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #4
  %8 = load ptr, ptr %3, align 8, !tbaa !5
  %9 = getelementptr inbounds %struct.libxsmm_generated_code, ptr %8, i32 0, i32 2
  %10 = load i32, ptr %9, align 4, !tbaa !11
  %11 = udiv i32 %10, 4
  store i32 %11, ptr %5, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #4
  %12 = load ptr, ptr %3, align 8, !tbaa !5
  %13 = getelementptr inbounds %struct.libxsmm_generated_code, ptr %12, i32 0, i32 0
  %14 = load ptr, ptr %13, align 8, !tbaa !13
  store ptr %14, ptr %6, align 8, !tbaa !5
  %15 = load ptr, ptr %3, 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 !14
  %18 = icmp ne i32 %17, 2501
  br i1 %18, label %19, label %30

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

25:                                               ; preds = %19
  %26 = load i32, ptr @libxsmm_verbosity, align 4, !tbaa !9
  br label %28

27:                                               ; preds = %19
  br label %28

28:                                               ; preds = %27, %25
  %29 = phi i32 [ %26, %25 ], [ 1, %27 ]
  call void @libxsmm_handle_error(ptr noundef %22, i32 noundef 90000, ptr noundef @__func__.libxsmm_aarch64_instruction_sm, ptr noundef @.str.1, i32 noundef 2356, i32 noundef %29)
  store i32 1, ptr %7, align 4
  br label %73

30:                                               ; preds = %2
  %31 = load i32, ptr %4, align 4, !tbaa !9
  switch i32 %31, label %33 [
    i32 -721205377, label %32
    i32 -721205633, label %32
  ]

32:                                               ; preds = %30, %30
  br label %45

33:                                               ; preds = %30
  %34 = load ptr, ptr @stderr, align 8, !tbaa !5
  %35 = load i32, ptr %4, align 4, !tbaa !9
  %36 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %34, ptr noundef @.str.97, i32 noundef %35) #4
  %37 = load ptr, ptr %3, align 8, !tbaa !5
  %38 = load i32, ptr @libxsmm_ninit, align 4, !tbaa !9
  %39 = icmp ult i32 1, %38
  br i1 %39, label %40, label %42

40:                                               ; preds = %33
  %41 = load i32, ptr @libxsmm_verbosity, align 4, !tbaa !9
  br label %43

42:                                               ; preds = %33
  br label %43

43:                                               ; preds = %42, %40
  %44 = phi i32 [ %41, %40 ], [ 1, %42 ]
  call void @libxsmm_handle_error(ptr noundef %37, i32 noundef 90000, ptr noundef @__func__.libxsmm_aarch64_instruction_sm, ptr noundef @.str.1, i32 noundef 2365, i32 noundef %44)
  store i32 1, ptr %7, align 4
  br label %73

45:                                               ; preds = %32
  %46 = load ptr, ptr %3, align 8, !tbaa !5
  %47 = getelementptr inbounds %struct.libxsmm_generated_code, ptr %46, i32 0, i32 1
  %48 = load i32, ptr %47, align 8, !tbaa !15
  %49 = load ptr, ptr %3, align 8, !tbaa !5
  %50 = getelementptr inbounds %struct.libxsmm_generated_code, ptr %49, i32 0, i32 2
  %51 = load i32, ptr %50, align 4, !tbaa !11
  %52 = sub i32 %48, %51
  %53 = icmp ult i32 %52, 4
  br i1 %53, label %54, label %63

54:                                               ; preds = %45
  %55 = load ptr, ptr %3, align 8, !tbaa !5
  %56 = load i32, ptr @libxsmm_ninit, align 4, !tbaa !9
  %57 = icmp ult i32 1, %56
  br i1 %57, label %58, label %60

58:                                               ; preds = %54
  %59 = load i32, ptr @libxsmm_verbosity, align 4, !tbaa !9
  br label %61

60:                                               ; preds = %54
  br label %61

61:                                               ; preds = %60, %58
  %62 = phi i32 [ %59, %58 ], [ 1, %60 ]
  call void @libxsmm_handle_error(ptr noundef %55, i32 noundef 90002, ptr noundef @__func__.libxsmm_aarch64_instruction_sm, ptr noundef @.str.1, i32 noundef 2370, i32 noundef %62)
  store i32 1, ptr %7, align 4
  br label %73

63:                                               ; preds = %45
  %64 = load i32, ptr %4, align 4, !tbaa !9
  %65 = load ptr, ptr %6, align 8, !tbaa !5
  %66 = load i32, ptr %5, align 4, !tbaa !9
  %67 = zext i32 %66 to i64
  %68 = getelementptr inbounds i32, ptr %65, i64 %67
  store i32 %64, ptr %68, align 4, !tbaa !9
  %69 = load ptr, ptr %3, align 8, !tbaa !5
  %70 = getelementptr inbounds %struct.libxsmm_generated_code, ptr %69, i32 0, i32 2
  %71 = load i32, ptr %70, align 4, !tbaa !11
  %72 = add i32 %71, 4
  store i32 %72, ptr %70, align 4, !tbaa !11
  store i32 1, ptr %7, align 4
  br label %73

73:                                               ; preds = %63, %61, %43, %28
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #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.96 = external hidden unnamed_addr constant [62 x i8], align 1
@__func__.libxsmm_aarch64_instruction_sm = external hidden unnamed_addr constant [31 x i8], align 1
@.str.97 = external hidden unnamed_addr constant [71 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_sm(ptr noundef %0, i32 noundef %1) local_unnamed_addr #2 {
  %3 = getelementptr inbounds i8, ptr %0, i64 12
  %4 = load i32, ptr %3, align 4, !tbaa !5
  %5 = lshr i32 %4, 2
  %6 = load ptr, ptr %0, align 8, !tbaa !11
  %7 = getelementptr inbounds i8, ptr %0, i64 28
  %8 = load i32, ptr %7, align 4, !tbaa !12
  %.not = icmp eq i32 %8, 2501
  br i1 %.not, label %16, label %9

9:                                                ; preds = %2
  %10 = load ptr, ptr @stderr, align 8, !tbaa !13
  %11 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %10, ptr noundef nonnull @.str.96) #3
  %12 = load i32, ptr @libxsmm_ninit, align 4, !tbaa !14
  %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 90000, ptr noundef nonnull @__func__.libxsmm_aarch64_instruction_sm, ptr noundef nonnull @.str.1, i32 noundef 2356, i32 noundef %15) #4
  br label %39

16:                                               ; preds = %2
  switch i32 %1, label %17 [
    i32 -721205377, label %24
    i32 -721205633, label %24
  ]

17:                                               ; preds = %16
  %18 = load ptr, ptr @stderr, align 8, !tbaa !13
  %19 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %18, ptr noundef nonnull @.str.97, i32 noundef %1) #3
  %20 = load i32, ptr @libxsmm_ninit, align 4, !tbaa !14
  %21 = icmp ugt i32 %20, 1
  %22 = load i32, ptr @libxsmm_verbosity, align 4
  %23 = select i1 %21, i32 %22, i32 1
  tail call void @libxsmm_handle_error(ptr noundef nonnull %0, i32 noundef 90000, ptr noundef nonnull @__func__.libxsmm_aarch64_instruction_sm, ptr noundef nonnull @.str.1, i32 noundef 2365, i32 noundef %23) #4
  br label %39

24:                                               ; preds = %16, %16
  %25 = getelementptr inbounds i8, ptr %0, i64 8
  %26 = load i32, ptr %25, align 8, !tbaa !15
  %27 = sub i32 %26, %4
  %28 = icmp ult i32 %27, 4
  br i1 %28, label %29, label %34

29:                                               ; preds = %24
  %30 = load i32, ptr @libxsmm_ninit, align 4, !tbaa !14
  %31 = icmp ugt i32 %30, 1
  %32 = load i32, ptr @libxsmm_verbosity, align 4
  %33 = select i1 %31, i32 %32, i32 1
  tail call void @libxsmm_handle_error(ptr noundef nonnull %0, i32 noundef 90002, ptr noundef nonnull @__func__.libxsmm_aarch64_instruction_sm, ptr noundef nonnull @.str.1, i32 noundef 2370, i32 noundef %33) #4
  br label %39

34:                                               ; preds = %24
  %35 = zext nneg i32 %5 to i64
  %36 = getelementptr inbounds i32, ptr %6, i64 %35
  store i32 %1, ptr %36, align 4, !tbaa !14
  %37 = load i32, ptr %3, align 4, !tbaa !5
  %38 = add i32 %37, 4
  store i32 %38, ptr %3, align 4, !tbaa !5
  br label %39

39:                                               ; preds = %34, %29, %17, %9
  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,SROAPass,SimplifyCFGPass,TailCallElimPass