; 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 }
%struct.libxsmm_const_data_tracker = type { [81920 x i8], i32, [128 x 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
@__func__.libxsmm_x86_instruction_add_data = external hidden unnamed_addr constant [33 x i8], align 1
@.str.176 = external hidden unnamed_addr constant [80 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: 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) #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 i32 @libxsmm_x86_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 %117

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 %116

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 = load i32, ptr %17, align 4, !tbaa !9
  %81 = add i32 %79, %80
  %82 = load i32, ptr %10, align 4, !tbaa !9
  %83 = add i32 %81, %82
  %84 = zext i32 %83 to i64
  %85 = icmp ugt i64 %84, 81920
  br i1 %85, label %86, label %95

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

90:                                               ; preds = %86
  %91 = load i32, ptr @libxsmm_verbosity, align 4, !tbaa !9
  br label %93

92:                                               ; preds = %86
  br label %93

93:                                               ; preds = %92, %90
  %94 = phi i32 [ %91, %90 ], [ 1, %92 ]
  call void @libxsmm_handle_error(ptr noundef %87, i32 noundef 90002, ptr noundef @__func__.libxsmm_x86_instruction_add_data, ptr noundef @.str, i32 noundef 5006, i32 noundef %94)
  store i32 -1, ptr %7, align 4
  store i32 1, ptr %18, align 4
  br label %116

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

116:                                              ; preds = %95, %93, %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 %128

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

123:                                              ; preds = %117
  %124 = load i32, ptr @libxsmm_verbosity, align 4, !tbaa !9
  br label %126

125:                                              ; preds = %117
  br label %126

126:                                              ; preds = %125, %123
  %127 = phi i32 [ %124, %123 ], [ 1, %125 ]
  call void @libxsmm_handle_error(ptr noundef %120, i32 noundef 90000, ptr noundef @__func__.libxsmm_x86_instruction_add_data, ptr noundef @.str, i32 noundef 5020, i32 noundef %127)
  store i32 0, ptr %7, align 4
  br label %128

128:                                              ; preds = %126, %116
  %129 = load i32, ptr %7, align 4
  ret i32 %129
}

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

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

@.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
@__func__.libxsmm_x86_instruction_add_data = external hidden unnamed_addr constant [33 x i8], align 1
@.str.176 = external hidden unnamed_addr constant [80 x i8], align 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) #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 i32 @libxsmm_x86_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 %45

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
  br i1 %or.cond, label %.lr.ph, label %.loopexit

.lr.ph:                                           ; preds = %11
  %15 = zext i32 %2 to i64
  br label %16

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

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

21:                                               ; preds = %16, %18
  %22 = add i32 %.03846, %7
  %23 = icmp ult i32 %22, %.fr43
  br i1 %23, label %16, label %.loopexit, !llvm.loop !13

.loopexit:                                        ; preds = %21, %11
  %24 = add i32 %7, -1
  %25 = add i32 %24, %.fr43
  %26 = urem i32 %25, %7
  %27 = sub nuw i32 %25, %26
  %28 = add i32 %27, %2
  %29 = icmp ugt i32 %28, 81920
  br i1 %29, label %30, label %35

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

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

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

.loopexit44:                                      ; preds = %18, %30, %35, %45
  %.1 = phi i32 [ 0, %45 ], [ -1, %30 ], [ %27, %35 ], [ %.03846, %18 ]
  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 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite) }
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 = { 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,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass