; 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_const_data_tracker = type { [81920 x i8], i32, [128 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
@__func__.libxsmm_aarch64_instruction_add_data = external hidden unnamed_addr constant [37 x i8], align 1
@.str.6 = 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: nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #3

; Function Attrs: nounwind uwtable
define dso_local i32 @libxsmm_aarch64_instruction_add_data(ptr noundef %0, ptr noundef %1, i32 noundef %2, i32 noundef %3, i32 noundef %4, ptr noundef %5) #4 {
  %7 = alloca i32, align 4
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  %12 = alloca i32, align 4
  %13 = alloca ptr, align 8
  %14 = alloca ptr, align 8
  %15 = alloca i32, align 4
  %16 = alloca i32, align 4
  %17 = alloca i32, align 4
  %18 = alloca i32, align 4
  store ptr %0, ptr %8, align 8, !tbaa !5
  store ptr %1, ptr %9, align 8, !tbaa !5
  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 ptr %5, ptr %13, align 8, !tbaa !5
  %19 = load i32, ptr %11, align 4, !tbaa !9
  %20 = icmp ult i32 %19, 1
  br i1 %20, label %21, label %22

21:                                               ; preds = %6
  br label %24

22:                                               ; preds = %6
  %23 = load i32, ptr %11, align 4, !tbaa !9
  br label %24

24:                                               ; preds = %22, %21
  %25 = phi i32 [ 1, %21 ], [ %23, %22 ]
  store i32 %25, ptr %11, align 4, !tbaa !9
  %26 = load ptr, ptr %8, align 8, !tbaa !5
  %27 = getelementptr inbounds %struct.libxsmm_generated_code, ptr %26, i32 0, i32 3
  %28 = load i32, ptr %27, align 8, !tbaa !11
  %29 = icmp ugt i32 %28, 1
  br i1 %29, label %30, label %119

30:                                               ; preds = %24
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #6
  %31 = load ptr, ptr %13, align 8, !tbaa !5
  %32 = getelementptr inbounds %struct.libxsmm_const_data_tracker, ptr %31, i32 0, i32 0
  %33 = getelementptr inbounds [81920 x i8], ptr %32, i64 0, i64 0
  store ptr %33, ptr %14, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %15) #6
  %34 = load ptr, ptr %13, align 8, !tbaa !5
  %35 = getelementptr inbounds %struct.libxsmm_const_data_tracker, ptr %34, i32 0, i32 1
  %36 = load i32, ptr %35, align 4, !tbaa !13
  store i32 %36, ptr %15, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %16) #6
  call void @llvm.lifetime.start.p0(i64 4, ptr %17) #6
  %37 = load i32, ptr %12, align 4, !tbaa !9
  %38 = icmp ne i32 %37, 0
  br i1 %38, label %68, label %39

39:                                               ; preds = %30
  store i32 0, ptr %16, align 4, !tbaa !9
  br label %40

40:                                               ; preds = %63, %39
  %41 = load i32, ptr %16, align 4, !tbaa !9
  %42 = load i32, ptr %15, align 4, !tbaa !9
  %43 = icmp ult i32 %41, %42
  br i1 %43, label %44, label %67

44:                                               ; preds = %40
  %45 = load i32, ptr %10, align 4, !tbaa !9
  %46 = load i32, ptr %15, align 4, !tbaa !9
  %47 = load i32, ptr %16, align 4, !tbaa !9
  %48 = sub i32 %46, %47
  %49 = icmp ule i32 %45, %48
  br i1 %49, label %50, label %62

50:                                               ; preds = %44
  %51 = load ptr, ptr %14, align 8, !tbaa !5
  %52 = load i32, ptr %16, align 4, !tbaa !9
  %53 = zext i32 %52 to i64
  %54 = getelementptr inbounds i8, ptr %51, i64 %53
  %55 = load ptr, ptr %9, align 8, !tbaa !5
  %56 = load i32, ptr %10, align 4, !tbaa !9
  %57 = zext i32 %56 to i64
  %58 = call i32 @memcmp(ptr noundef %54, ptr noundef %55, i64 noundef %57) #7
  %59 = icmp ne i32 %58, 0
  br i1 %59, label %62, label %60

60:                                               ; preds = %50
  %61 = load i32, ptr %16, align 4, !tbaa !9
  store i32 %61, ptr %7, align 4
  store i32 1, ptr %18, align 4
  br label %118

62:                                               ; preds = %50, %44
  br label %63

63:                                               ; preds = %62
  %64 = load i32, ptr %11, align 4, !tbaa !9
  %65 = load i32, ptr %16, align 4, !tbaa !9
  %66 = add i32 %65, %64
  store i32 %66, ptr %16, align 4, !tbaa !9
  br label %40, !llvm.loop !15

67:                                               ; preds = %40
  br label %68

68:                                               ; preds = %67, %30
  %69 = load i32, ptr %15, align 4, !tbaa !9
  %70 = load i32, ptr %11, align 4, !tbaa !9
  %71 = sub i32 %70, 1
  %72 = add i32 %69, %71
  %73 = load i32, ptr %11, align 4, !tbaa !9
  %74 = udiv i32 %72, %73
  %75 = load i32, ptr %11, align 4, !tbaa !9
  %76 = mul i32 %74, %75
  %77 = load i32, ptr %15, align 4, !tbaa !9
  %78 = sub i32 %76, %77
  store i32 %78, ptr %17, align 4, !tbaa !9
  %79 = load i32, ptr %15, align 4, !tbaa !9
  %80 = zext i32 %79 to i64
  %81 = load i32, ptr %17, align 4, !tbaa !9
  %82 = zext i32 %81 to i64
  %83 = add i64 %80, %82
  %84 = load i32, ptr %10, align 4, !tbaa !9
  %85 = zext i32 %84 to i64
  %86 = add i64 %83, %85
  %87 = icmp ugt i64 %86, 81920
  br i1 %87, label %88, label %97

88:                                               ; preds = %68
  %89 = load ptr, ptr %8, align 8, !tbaa !5
  %90 = load i32, ptr @libxsmm_ninit, align 4, !tbaa !9
  %91 = icmp ult i32 1, %90
  br i1 %91, label %92, label %94

92:                                               ; preds = %88
  %93 = load i32, ptr @libxsmm_verbosity, align 4, !tbaa !9
  br label %95

94:                                               ; preds = %88
  br label %95

95:                                               ; preds = %94, %92
  %96 = phi i32 [ %93, %92 ], [ 1, %94 ]
  call void @libxsmm_handle_error(ptr noundef %89, i32 noundef 90002, ptr noundef @__func__.libxsmm_aarch64_instruction_add_data, ptr noundef @.str.1, i32 noundef 305, i32 noundef %96)
  store i32 -1, ptr %7, align 4
  store i32 1, ptr %18, align 4
  br label %118

97:                                               ; preds = %68
  %98 = load ptr, ptr %14, align 8, !tbaa !5
  %99 = load i32, ptr %15, align 4, !tbaa !9
  %100 = zext i32 %99 to i64
  %101 = getelementptr inbounds i8, ptr %98, i64 %100
  %102 = load i32, ptr %17, align 4, !tbaa !9
  %103 = zext i32 %102 to i64
  %104 = getelementptr inbounds i8, ptr %101, i64 %103
  %105 = load ptr, ptr %9, align 8, !tbaa !5
  %106 = load i32, ptr %10, align 4, !tbaa !9
  %107 = zext i32 %106 to i64
  call void @llvm.memcpy.p0.p0.i64(ptr align 1 %104, ptr align 1 %105, i64 %107, i1 false)
  %108 = load i32, ptr %17, align 4, !tbaa !9
  %109 = load i32, ptr %10, align 4, !tbaa !9
  %110 = add i32 %108, %109
  %111 = load ptr, ptr %13, align 8, !tbaa !5
  %112 = getelementptr inbounds %struct.libxsmm_const_data_tracker, ptr %111, i32 0, i32 1
  %113 = load i32, ptr %112, align 4, !tbaa !13
  %114 = add i32 %113, %110
  store i32 %114, ptr %112, align 4, !tbaa !13
  %115 = load i32, ptr %15, align 4, !tbaa !9
  %116 = load i32, ptr %17, align 4, !tbaa !9
  %117 = add i32 %115, %116
  store i32 %117, ptr %7, align 4
  store i32 1, ptr %18, align 4
  br label %118

118:                                              ; preds = %97, %95, %60
  call void @llvm.lifetime.end.p0(i64 4, ptr %17) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %16) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #6
  br label %130

119:                                              ; preds = %24
  %120 = load ptr, ptr @stderr, align 8, !tbaa !5
  %121 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %120, ptr noundef @.str.6) #6
  %122 = load ptr, ptr %8, align 8, !tbaa !5
  %123 = load i32, ptr @libxsmm_ninit, align 4, !tbaa !9
  %124 = icmp ult i32 1, %123
  br i1 %124, label %125, label %127

125:                                              ; preds = %119
  %126 = load i32, ptr @libxsmm_verbosity, align 4, !tbaa !9
  br label %128

127:                                              ; preds = %119
  br label %128

128:                                              ; preds = %127, %125
  %129 = phi i32 [ %126, %125 ], [ 1, %127 ]
  call void @libxsmm_handle_error(ptr noundef %122, i32 noundef 90000, ptr noundef @__func__.libxsmm_aarch64_instruction_add_data, ptr noundef @.str.1, i32 noundef 319, i32 noundef %129)
  store i32 0, ptr %7, align 4
  br label %130

130:                                              ; preds = %128, %118
  %131 = load i32, ptr %7, align 4
  ret i32 %131
}

; Function Attrs: nounwind willreturn memory(read)
declare i32 @memcmp(ptr noundef, ptr noundef, i64 noundef) #5

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 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #4 = { 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 #5 = { nounwind willreturn memory(read) "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 #6 = { nounwind }
attributes #7 = { nounwind willreturn memory(read) }

!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}
!13 = !{!14, !10, i64 81920}
!14 = !{!"libxsmm_const_data_tracker", !7, i64 0, !10, i64 81920, !7, i64 81924, !10, i64 82436}
!15 = distinct !{!15, !16}
!16 = !{!"llvm.loop.mustprogress"}


; 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
@__func__.libxsmm_aarch64_instruction_add_data = external hidden unnamed_addr constant [37 x i8], align 1
@.str.6 = 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: mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #2

; Function Attrs: nounwind uwtable
define dso_local i32 @libxsmm_aarch64_instruction_add_data(ptr noundef %0, ptr nocapture noundef readonly %1, i32 noundef %2, i32 noundef %3, i32 noundef %4, ptr nocapture noundef %5) local_unnamed_addr #3 {
  %7 = tail call i32 @llvm.umax.i32(i32 %3, i32 1)
  %8 = getelementptr inbounds i8, ptr %0, i64 16
  %9 = load i32, ptr %8, align 8, !tbaa !5
  %10 = icmp ugt i32 %9, 1
  br i1 %10, label %11, label %44

11:                                               ; preds = %6
  %12 = getelementptr inbounds i8, ptr %5, i64 81920
  %13 = load i32, ptr %12, align 4, !tbaa !11
  %.fr43 = freeze i32 %13
  %.not = icmp eq i32 %4, 0
  %14 = icmp ne i32 %.fr43, 0
  %or.cond = and i1 %.not, %14
  %15 = zext i32 %2 to i64
  br i1 %or.cond, label %.lr.ph, label %.loopexit

.lr.ph:                                           ; preds = %11, %20
  %.03846 = phi i32 [ %21, %20 ], [ 0, %11 ]
  %16 = sub i32 %.fr43, %.03846
  %.not41 = icmp ult i32 %16, %2
  br i1 %.not41, label %20, label %17

17:                                               ; preds = %.lr.ph
  %18 = zext i32 %.03846 to i64
  %19 = getelementptr inbounds i8, ptr %5, i64 %18
  %bcmp = tail call i32 @bcmp(ptr %19, ptr %1, i64 %15)
  %.not42 = icmp eq i32 %bcmp, 0
  br i1 %.not42, label %.loopexit44, label %20

20:                                               ; preds = %.lr.ph, %17
  %21 = add i32 %.03846, %7
  %22 = icmp ult i32 %21, %.fr43
  br i1 %22, label %.lr.ph, label %.loopexit, !llvm.loop !13

.loopexit:                                        ; preds = %20, %11
  %23 = add i32 %7, -1
  %24 = add i32 %23, %.fr43
  %25 = urem i32 %24, %7
  %26 = sub nuw i32 %24, %25
  %27 = sub i32 %26, %.fr43
  %28 = zext i32 %.fr43 to i64
  %29 = zext i32 %27 to i64
  %30 = add nuw nsw i64 %15, %28
  %31 = add nuw nsw i64 %30, %29
  %32 = icmp ugt i64 %31, 81920
  br i1 %32, label %33, label %38

33:                                               ; preds = %.loopexit
  %34 = load i32, ptr @libxsmm_ninit, align 4, !tbaa !15
  %35 = icmp ugt i32 %34, 1
  %36 = load i32, ptr @libxsmm_verbosity, align 4
  %37 = select i1 %35, i32 %36, i32 1
  tail call void @libxsmm_handle_error(ptr noundef %0, i32 noundef 90002, ptr noundef nonnull @__func__.libxsmm_aarch64_instruction_add_data, ptr noundef nonnull @.str.1, i32 noundef 305, i32 noundef %37) #6
  br label %.loopexit44

38:                                               ; preds = %.loopexit
  %39 = getelementptr inbounds i8, ptr %5, i64 %28
  %40 = getelementptr inbounds i8, ptr %39, i64 %29
  tail call void @llvm.memcpy.p0.p0.i64(ptr align 1 %40, ptr align 1 %1, i64 %15, i1 false)
  %41 = add i32 %27, %2
  %42 = load i32, ptr %12, align 4, !tbaa !11
  %43 = add i32 %41, %42
  store i32 %43, ptr %12, align 4, !tbaa !11
  br label %.loopexit44

44:                                               ; preds = %6
  %45 = load ptr, ptr @stderr, align 8, !tbaa !16
  %46 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %45, ptr noundef nonnull @.str.6) #7
  %47 = load i32, ptr @libxsmm_ninit, align 4, !tbaa !15
  %48 = icmp ugt i32 %47, 1
  %49 = load i32, ptr @libxsmm_verbosity, align 4
  %50 = select i1 %48, i32 %49, i32 1
  tail call void @libxsmm_handle_error(ptr noundef nonnull %0, i32 noundef 90000, ptr noundef nonnull @__func__.libxsmm_aarch64_instruction_add_data, ptr noundef nonnull @.str.1, i32 noundef 319, i32 noundef %50) #6
  br label %.loopexit44

.loopexit44:                                      ; preds = %17, %33, %38, %44
  %.1 = phi i32 [ 0, %44 ], [ -1, %33 ], [ %26, %38 ], [ %.03846, %17 ]
  ret i32 %.1
}

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i32 @llvm.umax.i32(i32, i32) #4

; Function Attrs: nofree nounwind willreturn memory(argmem: read)
declare i32 @bcmp(ptr nocapture, ptr nocapture, i64) local_unnamed_addr #5

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 = { mustprogress nocallback nofree 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 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #5 = { nofree nounwind willreturn memory(argmem: read) }
attributes #6 = { nounwind }
attributes #7 = { cold 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 16}
!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 = !{!12, !10, i64 81920}
!12 = !{!"libxsmm_const_data_tracker", !8, i64 0, !10, i64 81920, !8, i64 81924, !10, i64 82436}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}
!15 = !{!10, !10, i64 0}
!16 = !{!7, !7, i64 0}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass