; 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 }
%struct.libxsmm_loop_label_tracker_struct = type { [512 x 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.84 = external hidden unnamed_addr constant [110 x i8], align 1
@__func__.libxsmm_aarch64_instruction_register_jump_back_label = external hidden unnamed_addr constant [53 x i8], align 1
@.str.85 = external hidden unnamed_addr constant [100 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_register_jump_back_label(ptr noundef %0, ptr noundef %1) #3 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca i32, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  store ptr %1, ptr %4, align 8, !tbaa !5
  %6 = load ptr, ptr %3, align 8, !tbaa !5
  %7 = getelementptr inbounds %struct.libxsmm_generated_code, ptr %6, i32 0, i32 6
  %8 = load i32, ptr %7, align 4, !tbaa !9
  %9 = icmp ult i32 %8, 2001
  br i1 %9, label %10, label %21

10:                                               ; preds = %2
  %11 = load ptr, ptr @stderr, align 8, !tbaa !5
  %12 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %11, ptr noundef @.str.84) #4
  %13 = load ptr, ptr %3, align 8, !tbaa !5
  %14 = load i32, ptr @libxsmm_ninit, align 4, !tbaa !12
  %15 = icmp ult i32 1, %14
  br i1 %15, label %16, label %18

16:                                               ; preds = %10
  %17 = load i32, ptr @libxsmm_verbosity, align 4, !tbaa !12
  br label %19

18:                                               ; preds = %10
  br label %19

19:                                               ; preds = %18, %16
  %20 = phi i32 [ %17, %16 ], [ 1, %18 ]
  call void @libxsmm_handle_error(ptr noundef %13, i32 noundef 90000, ptr noundef @__func__.libxsmm_aarch64_instruction_register_jump_back_label, ptr noundef @.str.1, i32 noundef 2009, i32 noundef %20)
  br label %67

21:                                               ; preds = %2
  %22 = load ptr, ptr %4, align 8, !tbaa !5
  %23 = getelementptr inbounds %struct.libxsmm_loop_label_tracker_struct, ptr %22, i32 0, i32 1
  %24 = load i32, ptr %23, align 4, !tbaa !13
  %25 = icmp ule i32 512, %24
  br i1 %25, label %26, label %35

26:                                               ; preds = %21
  %27 = load ptr, ptr %3, align 8, !tbaa !5
  %28 = load i32, ptr @libxsmm_ninit, align 4, !tbaa !12
  %29 = icmp ult i32 1, %28
  br i1 %29, label %30, label %32

30:                                               ; preds = %26
  %31 = load i32, ptr @libxsmm_verbosity, align 4, !tbaa !12
  br label %33

32:                                               ; preds = %26
  br label %33

33:                                               ; preds = %32, %30
  %34 = phi i32 [ %31, %30 ], [ 1, %32 ]
  call void @libxsmm_handle_error(ptr noundef %27, i32 noundef 90025, ptr noundef @__func__.libxsmm_aarch64_instruction_register_jump_back_label, ptr noundef @.str.1, i32 noundef 2015, i32 noundef %34)
  br label %67

35:                                               ; preds = %21
  %36 = load ptr, ptr %3, align 8, !tbaa !5
  %37 = getelementptr inbounds %struct.libxsmm_generated_code, ptr %36, i32 0, i32 3
  %38 = load i32, ptr %37, align 8, !tbaa !15
  %39 = icmp ugt i32 %38, 1
  br i1 %39, label %40, label %56

40:                                               ; preds = %35
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #4
  %41 = load ptr, ptr %4, align 8, !tbaa !5
  %42 = getelementptr inbounds %struct.libxsmm_loop_label_tracker_struct, ptr %41, i32 0, i32 1
  %43 = load i32, ptr %42, align 4, !tbaa !13
  store i32 %43, ptr %5, align 4, !tbaa !12
  %44 = load ptr, ptr %4, align 8, !tbaa !5
  %45 = getelementptr inbounds %struct.libxsmm_loop_label_tracker_struct, ptr %44, i32 0, i32 1
  %46 = load i32, ptr %45, align 4, !tbaa !13
  %47 = add i32 %46, 1
  store i32 %47, ptr %45, align 4, !tbaa !13
  %48 = load ptr, ptr %3, align 8, !tbaa !5
  %49 = getelementptr inbounds %struct.libxsmm_generated_code, ptr %48, i32 0, i32 2
  %50 = load i32, ptr %49, align 4, !tbaa !16
  %51 = load ptr, ptr %4, align 8, !tbaa !5
  %52 = getelementptr inbounds %struct.libxsmm_loop_label_tracker_struct, ptr %51, i32 0, i32 0
  %53 = load i32, ptr %5, align 4, !tbaa !12
  %54 = sext i32 %53 to i64
  %55 = getelementptr inbounds [512 x i32], ptr %52, i64 0, i64 %54
  store i32 %50, ptr %55, align 4, !tbaa !12
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #4
  br label %67

56:                                               ; preds = %35
  %57 = load ptr, ptr @stderr, align 8, !tbaa !5
  %58 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %57, ptr noundef @.str.85) #4
  %59 = load ptr, ptr %3, align 8, !tbaa !5
  %60 = load i32, ptr @libxsmm_ninit, align 4, !tbaa !12
  %61 = icmp ult i32 1, %60
  br i1 %61, label %62, label %64

62:                                               ; preds = %56
  %63 = load i32, ptr @libxsmm_verbosity, align 4, !tbaa !12
  br label %65

64:                                               ; preds = %56
  br label %65

65:                                               ; preds = %64, %62
  %66 = phi i32 [ %63, %62 ], [ 1, %64 ]
  call void @libxsmm_handle_error(ptr noundef %59, i32 noundef 90000, ptr noundef @__func__.libxsmm_aarch64_instruction_register_jump_back_label, ptr noundef @.str.1, i32 noundef 2026, i32 noundef %66)
  br label %67

67:                                               ; preds = %65, %40, %33, %19
  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, !11, i64 28}
!10 = !{!"libxsmm_generated_code", !6, i64 0, !11, i64 8, !11, i64 12, !11, i64 16, !11, i64 20, !11, i64 24, !11, i64 28}
!11 = !{!"int", !7, i64 0}
!12 = !{!11, !11, i64 0}
!13 = !{!14, !11, i64 2048}
!14 = !{!"libxsmm_loop_label_tracker_struct", !7, i64 0, !11, i64 2048}
!15 = !{!10, !11, i64 16}
!16 = !{!10, !11, i64 12}


; 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.84 = external hidden unnamed_addr constant [110 x i8], align 1
@__func__.libxsmm_aarch64_instruction_register_jump_back_label = external hidden unnamed_addr constant [53 x i8], align 1
@.str.85 = external hidden unnamed_addr constant [100 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_register_jump_back_label(ptr noundef %0, ptr nocapture noundef %1) local_unnamed_addr #2 {
  %3 = getelementptr inbounds i8, ptr %0, i64 28
  %4 = load i32, ptr %3, align 4, !tbaa !5
  %5 = icmp ult i32 %4, 2001
  br i1 %5, label %6, label %13

6:                                                ; preds = %2
  %7 = load ptr, ptr @stderr, align 8, !tbaa !11
  %8 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %7, ptr noundef nonnull @.str.84) #3
  %9 = load i32, ptr @libxsmm_ninit, align 4, !tbaa !12
  %10 = icmp ugt i32 %9, 1
  %11 = load i32, ptr @libxsmm_verbosity, align 4
  %12 = select i1 %10, i32 %11, i32 1
  tail call void @libxsmm_handle_error(ptr noundef nonnull %0, i32 noundef 90000, ptr noundef nonnull @__func__.libxsmm_aarch64_instruction_register_jump_back_label, ptr noundef nonnull @.str.1, i32 noundef 2009, i32 noundef %12) #4
  br label %39

13:                                               ; preds = %2
  %14 = getelementptr inbounds i8, ptr %1, i64 2048
  %15 = load i32, ptr %14, align 4, !tbaa !13
  %16 = icmp ugt i32 %15, 511
  br i1 %16, label %17, label %22

17:                                               ; preds = %13
  %18 = load i32, ptr @libxsmm_ninit, align 4, !tbaa !12
  %19 = icmp ugt i32 %18, 1
  %20 = load i32, ptr @libxsmm_verbosity, align 4
  %21 = select i1 %19, i32 %20, i32 1
  tail call void @libxsmm_handle_error(ptr noundef nonnull %0, i32 noundef 90025, ptr noundef nonnull @__func__.libxsmm_aarch64_instruction_register_jump_back_label, ptr noundef nonnull @.str.1, i32 noundef 2015, i32 noundef %21) #4
  br label %39

22:                                               ; preds = %13
  %23 = getelementptr inbounds i8, ptr %0, i64 16
  %24 = load i32, ptr %23, align 8, !tbaa !15
  %25 = icmp ugt i32 %24, 1
  br i1 %25, label %26, label %32

26:                                               ; preds = %22
  %27 = add nuw nsw i32 %15, 1
  store i32 %27, ptr %14, align 4, !tbaa !13
  %28 = getelementptr inbounds i8, ptr %0, i64 12
  %29 = load i32, ptr %28, align 4, !tbaa !16
  %30 = zext nneg i32 %15 to i64
  %31 = getelementptr inbounds [512 x i32], ptr %1, i64 0, i64 %30
  store i32 %29, ptr %31, align 4, !tbaa !12
  br label %39

32:                                               ; preds = %22
  %33 = load ptr, ptr @stderr, align 8, !tbaa !11
  %34 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %33, ptr noundef nonnull @.str.85) #3
  %35 = load i32, ptr @libxsmm_ninit, align 4, !tbaa !12
  %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 90000, ptr noundef nonnull @__func__.libxsmm_aarch64_instruction_register_jump_back_label, ptr noundef nonnull @.str.1, i32 noundef 2026, i32 noundef %38) #4
  br label %39

39:                                               ; preds = %32, %26, %17, %6
  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 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 = !{!7, !7, i64 0}
!12 = !{!10, !10, i64 0}
!13 = !{!14, !10, i64 2048}
!14 = !{!"libxsmm_loop_label_tracker_struct", !8, i64 0, !10, i64 2048}
!15 = !{!6, !10, i64 16}
!16 = !{!6, !10, i64 12}


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