; LLVM IR from libxsmm/libxsmm :: src (generator_common)

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

@.str = external hidden unnamed_addr constant [72 x i8], align 1
@libxsmm_ninit = external global i32, align 4
@libxsmm_verbosity = external global i32, align 4
@.str.160 = external hidden unnamed_addr constant [7 x i8], align 1
@.str.161 = external hidden unnamed_addr constant [68 x i8], align 1
@.str.162 = external hidden unnamed_addr constant [74 x i8], align 1
@.str.163 = external hidden unnamed_addr constant [9 x i8], align 1
@__func__.libxsmm_generator_isa_check_footer = external hidden unnamed_addr constant [35 x i8], align 1

; Function Attrs: nounwind uwtable
declare dso_local void @libxsmm_append_code_as_string(ptr noundef, ptr noundef, i32 noundef) #0

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

; Function Attrs: nounwind uwtable
declare dso_local void @libxsmm_handle_error(ptr noundef, i32 noundef, ptr noundef, ptr noundef, i32 noundef, i32 noundef) #0

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

; Function Attrs: nounwind
declare i32 @snprintf(ptr noundef, i64 noundef, ptr noundef, ...) #2

; Function Attrs: nounwind uwtable
define dso_local void @libxsmm_generator_isa_check_footer(ptr noundef %0) #0 {
  %2 = alloca ptr, align 8
  %3 = alloca [512 x i8], align 16
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  store ptr %0, ptr %2, align 8, !tbaa !5
  %7 = load ptr, ptr %2, align 8, !tbaa !5
  %8 = getelementptr inbounds %struct.libxsmm_generated_code, ptr %7, i32 0, i32 3
  %9 = load i32, ptr %8, align 8, !tbaa !9
  %10 = icmp eq i32 %9, 0
  br i1 %10, label %11, label %70

11:                                               ; preds = %1
  call void @llvm.lifetime.start.p0(i64 512, ptr %3) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #3
  store i32 511, ptr %4, align 4, !tbaa !12
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #3
  store i32 0, ptr %5, align 4, !tbaa !12
  %12 = load ptr, ptr %2, align 8, !tbaa !5
  %13 = getelementptr inbounds %struct.libxsmm_generated_code, ptr %12, i32 0, i32 6
  %14 = load i32, ptr %13, align 4, !tbaa !13
  %15 = icmp uge i32 %14, 1002
  br i1 %15, label %16, label %50

16:                                               ; preds = %11
  %17 = load ptr, ptr %2, align 8, !tbaa !5
  %18 = getelementptr inbounds %struct.libxsmm_generated_code, ptr %17, i32 0, i32 6
  %19 = load i32, ptr %18, align 4, !tbaa !13
  %20 = icmp ule i32 %19, 1999
  br i1 %20, label %21, label %50

21:                                               ; preds = %16
  %22 = getelementptr inbounds [512 x i8], ptr %3, i64 0, i64 0
  %23 = load i32, ptr %4, align 4, !tbaa !12
  %24 = sext i32 %23 to i64
  %25 = call i32 (ptr, i64, ptr, ...) @snprintf(ptr noundef %22, i64 noundef %24, ptr noundef @.str.160) #3
  store i32 %25, ptr %5, align 4, !tbaa !12
  %26 = load ptr, ptr %2, align 8, !tbaa !5
  %27 = getelementptr inbounds [512 x i8], ptr %3, i64 0, i64 0
  %28 = load i32, ptr %5, align 4, !tbaa !12
  call void @libxsmm_append_code_as_string(ptr noundef %26, ptr noundef %27, i32 noundef %28)
  %29 = getelementptr inbounds [512 x i8], ptr %3, i64 0, i64 0
  %30 = load i32, ptr %4, align 4, !tbaa !12
  %31 = sext i32 %30 to i64
  %32 = call i32 (ptr, i64, ptr, ...) @snprintf(ptr noundef %29, i64 noundef %31, ptr noundef @.str.161) #3
  store i32 %32, ptr %5, align 4, !tbaa !12
  %33 = load ptr, ptr %2, align 8, !tbaa !5
  %34 = getelementptr inbounds [512 x i8], ptr %3, i64 0, i64 0
  %35 = load i32, ptr %5, align 4, !tbaa !12
  call void @libxsmm_append_code_as_string(ptr noundef %33, ptr noundef %34, i32 noundef %35)
  %36 = getelementptr inbounds [512 x i8], ptr %3, i64 0, i64 0
  %37 = load i32, ptr %4, align 4, !tbaa !12
  %38 = sext i32 %37 to i64
  %39 = call i32 (ptr, i64, ptr, ...) @snprintf(ptr noundef %36, i64 noundef %38, ptr noundef @.str.162) #3
  store i32 %39, ptr %5, align 4, !tbaa !12
  %40 = load ptr, ptr %2, align 8, !tbaa !5
  %41 = getelementptr inbounds [512 x i8], ptr %3, i64 0, i64 0
  %42 = load i32, ptr %5, align 4, !tbaa !12
  call void @libxsmm_append_code_as_string(ptr noundef %40, ptr noundef %41, i32 noundef %42)
  %43 = getelementptr inbounds [512 x i8], ptr %3, i64 0, i64 0
  %44 = load i32, ptr %4, align 4, !tbaa !12
  %45 = sext i32 %44 to i64
  %46 = call i32 (ptr, i64, ptr, ...) @snprintf(ptr noundef %43, i64 noundef %45, ptr noundef @.str.163) #3
  store i32 %46, ptr %5, align 4, !tbaa !12
  %47 = load ptr, ptr %2, align 8, !tbaa !5
  %48 = getelementptr inbounds [512 x i8], ptr %3, i64 0, i64 0
  %49 = load i32, ptr %5, align 4, !tbaa !12
  call void @libxsmm_append_code_as_string(ptr noundef %47, ptr noundef %48, i32 noundef %49)
  br label %66

50:                                               ; preds = %16, %11
  %51 = load ptr, ptr %2, align 8, !tbaa !5
  %52 = getelementptr inbounds %struct.libxsmm_generated_code, ptr %51, i32 0, i32 6
  %53 = load i32, ptr %52, align 4, !tbaa !13
  %54 = icmp ult i32 %53, 1002
  br i1 %54, label %55, label %56

55:                                               ; preds = %50
  br label %65

56:                                               ; preds = %50
  %57 = load ptr, ptr %2, align 8, !tbaa !5
  %58 = load i32, ptr @libxsmm_ninit, align 4, !tbaa !12
  %59 = icmp ult i32 1, %58
  br i1 %59, label %60, label %62

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

62:                                               ; preds = %56
  br label %63

63:                                               ; preds = %62, %60
  %64 = phi i32 [ %61, %60 ], [ 1, %62 ]
  call void @libxsmm_handle_error(ptr noundef %57, i32 noundef 90005, ptr noundef @__func__.libxsmm_generator_isa_check_footer, ptr noundef @.str, i32 noundef 1054, i32 noundef %64)
  store i32 1, ptr %6, align 4
  br label %67

65:                                               ; preds = %55
  br label %66

66:                                               ; preds = %65, %21
  store i32 0, ptr %6, align 4
  br label %67

67:                                               ; preds = %66, %63
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #3
  call void @llvm.lifetime.end.p0(i64 512, ptr %3) #3
  %68 = load i32, ptr %6, align 4
  switch i32 %68, label %71 [
    i32 0, label %69
    i32 1, label %70
  ]

69:                                               ; preds = %67
  br label %70

70:                                               ; preds = %69, %67, %1
  ret void

71:                                               ; preds = %67
  unreachable
}

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

!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 16}
!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 = !{!10, !11, i64 28}


; 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 [72 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.160 = external hidden unnamed_addr constant [7 x i8], align 1
@.str.161 = external hidden unnamed_addr constant [68 x i8], align 1
@.str.162 = external hidden unnamed_addr constant [74 x i8], align 1
@.str.163 = external hidden unnamed_addr constant [9 x i8], align 1
@__func__.libxsmm_generator_isa_check_footer = external hidden unnamed_addr constant [35 x i8], align 1

; Function Attrs: nounwind uwtable
declare dso_local void @libxsmm_append_code_as_string(ptr noundef, ptr noundef, i32 noundef) local_unnamed_addr #0

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

; Function Attrs: nounwind uwtable
declare dso_local void @libxsmm_handle_error(ptr noundef, i32 noundef, ptr noundef, ptr noundef, i32 noundef, i32 noundef) local_unnamed_addr #0

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

; Function Attrs: nofree nounwind
declare noundef i32 @snprintf(ptr noalias nocapture noundef writeonly, i64 noundef, ptr nocapture noundef readonly, ...) local_unnamed_addr #2

; Function Attrs: nounwind uwtable
define dso_local void @libxsmm_generator_isa_check_footer(ptr noundef %0) local_unnamed_addr #0 {
  %2 = alloca [512 x i8], align 16
  %3 = getelementptr inbounds i8, ptr %0, i64 16
  %4 = load i32, ptr %3, align 8, !tbaa !5
  %5 = icmp eq i32 %4, 0
  br i1 %5, label %6, label %23

6:                                                ; preds = %1
  call void @llvm.lifetime.start.p0(i64 512, ptr nonnull %2) #3
  %7 = getelementptr inbounds i8, ptr %0, i64 28
  %8 = load i32, ptr %7, align 4, !tbaa !11
  %9 = add i32 %8, -1002
  %or.cond = icmp ult i32 %9, 998
  br i1 %or.cond, label %10, label %15

10:                                               ; preds = %6
  %11 = call i32 (ptr, i64, ptr, ...) @snprintf(ptr noundef nonnull dereferenceable(1) %2, i64 noundef 511, ptr noundef nonnull @.str.160) #3
  call void @libxsmm_append_code_as_string(ptr noundef nonnull %0, ptr noundef nonnull %2, i32 noundef %11)
  %12 = call i32 (ptr, i64, ptr, ...) @snprintf(ptr noundef nonnull dereferenceable(1) %2, i64 noundef 511, ptr noundef nonnull @.str.161) #3
  call void @libxsmm_append_code_as_string(ptr noundef nonnull %0, ptr noundef nonnull %2, i32 noundef %12)
  %13 = call i32 (ptr, i64, ptr, ...) @snprintf(ptr noundef nonnull dereferenceable(1) %2, i64 noundef 511, ptr noundef nonnull @.str.162) #3
  call void @libxsmm_append_code_as_string(ptr noundef nonnull %0, ptr noundef nonnull %2, i32 noundef %13)
  %14 = call i32 (ptr, i64, ptr, ...) @snprintf(ptr noundef nonnull dereferenceable(1) %2, i64 noundef 511, ptr noundef nonnull @.str.163) #3
  call void @libxsmm_append_code_as_string(ptr noundef nonnull %0, ptr noundef nonnull %2, i32 noundef %14)
  br label %22

15:                                               ; preds = %6
  %16 = icmp ult i32 %8, 1002
  br i1 %16, label %22, label %17

17:                                               ; preds = %15
  %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 90005, ptr noundef nonnull @__func__.libxsmm_generator_isa_check_footer, ptr noundef nonnull @.str, i32 noundef 1054, i32 noundef %21)
  br label %22

22:                                               ; preds = %10, %15, %17
  call void @llvm.lifetime.end.p0(i64 512, ptr nonnull %2) #3
  br label %23

23:                                               ; preds = %22, %1
  ret void
}

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

!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 = !{!6, !10, i64 28}
!12 = !{!10, !10, i64 0}


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