; LLVM IR from libxsmm/libxsmm :: tests (threadsafety)

; 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_gemm_shape = type { i32, i32, i32, i32, i32, i32, i32, i32, i32, i32 }
%union.libxsmm_xmmfunction = type { ptr }
%struct.libxsmm_mmkernel_info = type { i32, i32, i32, i32, i32, i32, i32, i32, i32, i32 }

@stderr = external global ptr, align 8
@.str = external hidden unnamed_addr constant [47 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [45 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local i32 @test(i32 noundef %0, i32 noundef %1, i32 noundef %2) #0 {
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca %struct.libxsmm_gemm_shape, align 8
  %8 = alloca i32, align 4
  %9 = alloca %union.libxsmm_xmmfunction, align 8
  %10 = alloca i32, align 4
  %11 = alloca %struct.libxsmm_mmkernel_info, align 4
  %12 = alloca i32, align 4
  %13 = alloca i32, align 4
  %14 = alloca i32, align 4
  store i32 %0, ptr %4, align 4, !tbaa !5
  store i32 %1, ptr %5, align 4, !tbaa !5
  store i32 %2, ptr %6, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 40, ptr %7) #5
  %15 = load i32, ptr %4, align 4, !tbaa !5
  %16 = load i32, ptr %5, align 4, !tbaa !5
  %17 = load i32, ptr %6, align 4, !tbaa !5
  %18 = load i32, ptr %4, align 4, !tbaa !5
  %19 = load i32, ptr %6, align 4, !tbaa !5
  %20 = load i32, ptr %4, align 4, !tbaa !5
  call void @libxsmm_create_gemm_shape(ptr dead_on_unwind writable sret(%struct.libxsmm_gemm_shape) align 4 %7, i32 noundef %15, i32 noundef %16, i32 noundef %17, i32 noundef %18, i32 noundef %19, i32 noundef %20, i32 noundef 1, i32 noundef 1, i32 noundef 1, i32 noundef 1)
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #5
  store i32 4, ptr %8, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #5
  call void @llvm.memset.p0.i64(ptr align 8 %9, i8 0, i64 8, i1 false)
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #5
  store i32 1, ptr %10, align 4, !tbaa !5
  %21 = call ptr @libxsmm_dispatch_gemm(ptr noundef byval(%struct.libxsmm_gemm_shape) align 8 %7, i32 noundef 4, i32 noundef 0)
  store ptr %21, ptr %9, align 8, !tbaa !9
  %22 = load ptr, ptr %9, align 8, !tbaa !9
  %23 = icmp ne ptr null, %22
  br i1 %23, label %24, label %91

24:                                               ; preds = %3
  call void @llvm.lifetime.start.p0(i64 40, ptr %11) #5
  %25 = getelementptr inbounds %union.libxsmm_xmmfunction, ptr %9, i32 0, i32 0
  %26 = load ptr, ptr %25, align 8
  %27 = call i32 @libxsmm_get_mmkernel_info(ptr %26, ptr noundef %11)
  store i32 %27, ptr %10, align 4, !tbaa !5
  %28 = load i32, ptr %10, align 4, !tbaa !5
  %29 = icmp eq i32 0, %28
  br i1 %29, label %30, label %81

30:                                               ; preds = %24
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #5
  %31 = load i32, ptr %4, align 4, !tbaa !5
  store i32 %31, ptr %12, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #5
  %32 = load i32, ptr %5, align 4, !tbaa !5
  store i32 %32, ptr %13, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #5
  %33 = load i32, ptr %6, align 4, !tbaa !5
  store i32 %33, ptr %14, align 4, !tbaa !5
  %34 = load i32, ptr %12, align 4, !tbaa !5
  %35 = getelementptr inbounds %struct.libxsmm_mmkernel_info, ptr %11, i32 0, i32 6
  %36 = load i32, ptr %35, align 4, !tbaa !10
  %37 = icmp ne i32 %34, %36
  br i1 %37, label %71, label %38

38:                                               ; preds = %30
  %39 = load i32, ptr %13, align 4, !tbaa !5
  %40 = getelementptr inbounds %struct.libxsmm_mmkernel_info, ptr %11, i32 0, i32 7
  %41 = load i32, ptr %40, align 4, !tbaa !12
  %42 = icmp ne i32 %39, %41
  br i1 %42, label %71, label %43

43:                                               ; preds = %38
  %44 = load i32, ptr %14, align 4, !tbaa !5
  %45 = getelementptr inbounds %struct.libxsmm_mmkernel_info, ptr %11, i32 0, i32 8
  %46 = load i32, ptr %45, align 4, !tbaa !13
  %47 = icmp ne i32 %44, %46
  br i1 %47, label %71, label %48

48:                                               ; preds = %43
  %49 = load i32, ptr %12, align 4, !tbaa !5
  %50 = getelementptr inbounds %struct.libxsmm_mmkernel_info, ptr %11, i32 0, i32 3
  %51 = load i32, ptr %50, align 4, !tbaa !14
  %52 = icmp ne i32 %49, %51
  br i1 %52, label %71, label %53

53:                                               ; preds = %48
  %54 = load i32, ptr %14, align 4, !tbaa !5
  %55 = getelementptr inbounds %struct.libxsmm_mmkernel_info, ptr %11, i32 0, i32 4
  %56 = load i32, ptr %55, align 4, !tbaa !15
  %57 = icmp ne i32 %54, %56
  br i1 %57, label %71, label %58

58:                                               ; preds = %53
  %59 = load i32, ptr %12, align 4, !tbaa !5
  %60 = getelementptr inbounds %struct.libxsmm_mmkernel_info, ptr %11, i32 0, i32 5
  %61 = load i32, ptr %60, align 4, !tbaa !16
  %62 = icmp ne i32 %59, %61
  br i1 %62, label %71, label %63

63:                                               ; preds = %58
  %64 = getelementptr inbounds %struct.libxsmm_mmkernel_info, ptr %11, i32 0, i32 0
  %65 = load i32, ptr %64, align 4, !tbaa !17
  %66 = icmp ne i32 1, %65
  br i1 %66, label %71, label %67

67:                                               ; preds = %63
  %68 = getelementptr inbounds %struct.libxsmm_mmkernel_info, ptr %11, i32 0, i32 1
  %69 = load i32, ptr %68, align 4, !tbaa !18
  %70 = icmp ne i32 1, %69
  br i1 %70, label %71, label %80

71:                                               ; preds = %67, %63, %58, %53, %48, %43, %38, %30
  %72 = load ptr, ptr @stderr, align 8, !tbaa !19
  %73 = load i32, ptr %4, align 4, !tbaa !5
  %74 = sext i32 %73 to i64
  %75 = load i32, ptr %5, align 4, !tbaa !5
  %76 = sext i32 %75 to i64
  %77 = load i32, ptr %6, align 4, !tbaa !5
  %78 = sext i32 %77 to i64
  %79 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %72, ptr noundef @.str, i64 noundef %74, i64 noundef %76, i64 noundef %78) #5
  store i32 1, ptr %10, align 4, !tbaa !5
  br label %80

80:                                               ; preds = %71, %67
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #5
  br label %90

81:                                               ; preds = %24
  %82 = load ptr, ptr @stderr, align 8, !tbaa !19
  %83 = load i32, ptr %4, align 4, !tbaa !5
  %84 = sext i32 %83 to i64
  %85 = load i32, ptr %5, align 4, !tbaa !5
  %86 = sext i32 %85 to i64
  %87 = load i32, ptr %6, align 4, !tbaa !5
  %88 = sext i32 %87 to i64
  %89 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %82, ptr noundef @.str.1, i64 noundef %84, i64 noundef %86, i64 noundef %88) #5
  br label %90

90:                                               ; preds = %81, %80
  call void @llvm.lifetime.end.p0(i64 40, ptr %11) #5
  br label %91

91:                                               ; preds = %90, %3
  %92 = load i32, ptr %10, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #5
  call void @llvm.lifetime.end.p0(i64 40, ptr %7) #5
  ret i32 %92
}

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

declare void @libxsmm_create_gemm_shape(ptr dead_on_unwind writable sret(%struct.libxsmm_gemm_shape) align 4, i32 noundef, i32 noundef, i32 noundef, i32 noundef, i32 noundef, i32 noundef, i32 noundef, i32 noundef, i32 noundef, i32 noundef) #2

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #3

declare ptr @libxsmm_dispatch_gemm(ptr noundef byval(%struct.libxsmm_gemm_shape) align 8, i32 noundef, i32 noundef) #2

declare i32 @libxsmm_get_mmkernel_info(ptr, ptr noundef) #2

; Function Attrs: nounwind
declare i32 @fprintf(ptr noundef, ptr noundef, ...) #4

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

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 = { "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 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #4 = { 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 #5 = { 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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!7, !7, i64 0}
!10 = !{!11, !6, i64 24}
!11 = !{!"libxsmm_mmkernel_info", !6, i64 0, !6, i64 4, !6, i64 8, !6, i64 12, !6, i64 16, !6, i64 20, !6, i64 24, !6, i64 28, !6, i64 32, !6, i64 36}
!12 = !{!11, !6, i64 28}
!13 = !{!11, !6, i64 32}
!14 = !{!11, !6, i64 12}
!15 = !{!11, !6, i64 16}
!16 = !{!11, !6, i64 20}
!17 = !{!11, !6, i64 0}
!18 = !{!11, !6, i64 4}
!19 = !{!20, !20, i64 0}
!20 = !{!"any pointer", !7, i64 0}


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

%struct.libxsmm_gemm_shape = type { i32, i32, i32, i32, i32, i32, i32, i32, i32, i32 }
%struct.libxsmm_mmkernel_info = type { i32, i32, i32, i32, i32, i32, i32, i32, i32, i32 }

@stderr = external local_unnamed_addr global ptr, align 8
@.str = external hidden unnamed_addr constant [47 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [45 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local i32 @test(i32 noundef %0, i32 noundef %1, i32 noundef %2) local_unnamed_addr #0 {
  %4 = alloca %struct.libxsmm_gemm_shape, align 8
  %5 = alloca %struct.libxsmm_mmkernel_info, align 4
  call void @llvm.lifetime.start.p0(i64 40, ptr nonnull %4) #4
  call void @libxsmm_create_gemm_shape(ptr dead_on_unwind nonnull writable sret(%struct.libxsmm_gemm_shape) align 4 %4, i32 noundef %0, i32 noundef %1, i32 noundef %2, i32 noundef %0, i32 noundef %2, i32 noundef %0, i32 noundef 1, i32 noundef 1, i32 noundef 1, i32 noundef 1) #4
  %6 = call ptr @libxsmm_dispatch_gemm(ptr noundef nonnull byval(%struct.libxsmm_gemm_shape) align 8 %4, i32 noundef 4, i32 noundef 0) #4
  %.not = icmp eq ptr %6, null
  br i1 %.not, label %36, label %7

7:                                                ; preds = %3
  call void @llvm.lifetime.start.p0(i64 40, ptr nonnull %5) #4
  %8 = call i32 @libxsmm_get_mmkernel_info(ptr nonnull %6, ptr noundef nonnull %5) #4
  %9 = icmp eq i32 %8, 0
  br i1 %9, label %10, label %.sink.split

10:                                               ; preds = %7
  %11 = getelementptr inbounds i8, ptr %5, i64 24
  %12 = load i32, ptr %11, align 4, !tbaa !5
  %.not34 = icmp eq i32 %12, %0
  %13 = getelementptr inbounds i8, ptr %5, i64 28
  %14 = load i32, ptr %13, align 4
  %.not35 = icmp eq i32 %14, %1
  %or.cond40 = select i1 %.not34, i1 %.not35, i1 false
  %15 = getelementptr inbounds i8, ptr %5, i64 32
  %16 = load i32, ptr %15, align 4
  %.not36 = icmp eq i32 %16, %2
  %or.cond42 = select i1 %or.cond40, i1 %.not36, i1 false
  %17 = getelementptr inbounds i8, ptr %5, i64 12
  %18 = load i32, ptr %17, align 4
  %.not37 = icmp eq i32 %18, %0
  %or.cond44 = select i1 %or.cond42, i1 %.not37, i1 false
  %19 = getelementptr inbounds i8, ptr %5, i64 16
  %20 = load i32, ptr %19, align 4
  %.not38 = icmp eq i32 %20, %2
  %or.cond46 = select i1 %or.cond44, i1 %.not38, i1 false
  br i1 %or.cond46, label %21, label %.sink.split

21:                                               ; preds = %10
  %22 = getelementptr inbounds i8, ptr %5, i64 20
  %23 = load i32, ptr %22, align 4, !tbaa !10
  %24 = icmp ne i32 %23, %0
  %25 = load i32, ptr %5, align 4
  %26 = icmp ne i32 %25, 1
  %or.cond = select i1 %24, i1 true, i1 %26
  %27 = getelementptr inbounds i8, ptr %5, i64 4
  %28 = load i32, ptr %27, align 4
  %29 = icmp ne i32 %28, 1
  %or.cond5 = select i1 %or.cond, i1 true, i1 %29
  br i1 %or.cond5, label %.sink.split, label %35

.sink.split:                                      ; preds = %7, %10, %21
  %.str.sink = phi ptr [ @.str, %21 ], [ @.str, %10 ], [ @.str.1, %7 ]
  %.1.ph = phi i32 [ 1, %21 ], [ 1, %10 ], [ %8, %7 ]
  %30 = load ptr, ptr @stderr, align 8, !tbaa !11
  %31 = sext i32 %0 to i64
  %32 = sext i32 %1 to i64
  %33 = sext i32 %2 to i64
  %34 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %30, ptr noundef nonnull %.str.sink, i64 noundef %31, i64 noundef %32, i64 noundef %33) #5
  br label %35

35:                                               ; preds = %.sink.split, %21
  %.1 = phi i32 [ 0, %21 ], [ %.1.ph, %.sink.split ]
  call void @llvm.lifetime.end.p0(i64 40, ptr nonnull %5) #4
  br label %36

36:                                               ; preds = %35, %3
  %.2 = phi i32 [ %.1, %35 ], [ 1, %3 ]
  call void @llvm.lifetime.end.p0(i64 40, ptr nonnull %4) #4
  ret i32 %.2
}

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

declare void @libxsmm_create_gemm_shape(ptr dead_on_unwind writable sret(%struct.libxsmm_gemm_shape) align 4, i32 noundef, i32 noundef, i32 noundef, i32 noundef, i32 noundef, i32 noundef, i32 noundef, i32 noundef, i32 noundef, i32 noundef) local_unnamed_addr #2

declare ptr @libxsmm_dispatch_gemm(ptr noundef byval(%struct.libxsmm_gemm_shape) align 8, i32 noundef, i32 noundef) local_unnamed_addr #2

declare i32 @libxsmm_get_mmkernel_info(ptr, ptr noundef) local_unnamed_addr #2

; Function Attrs: nofree nounwind
declare noundef i32 @fprintf(ptr nocapture noundef, ptr nocapture noundef readonly, ...) local_unnamed_addr #3

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

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 = { "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 = { 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 #4 = { nounwind }
attributes #5 = { 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, !7, i64 24}
!6 = !{!"libxsmm_mmkernel_info", !7, i64 0, !7, i64 4, !7, i64 8, !7, i64 12, !7, i64 16, !7, i64 20, !7, i64 24, !7, i64 28, !7, i64 32, !7, i64 36}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!6, !7, i64 20}
!11 = !{!12, !12, i64 0}
!12 = !{!"any pointer", !8, i64 0}


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