; 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
@stderr = external global ptr, align 8
@libxsmm_handle_error.last_error_code = external hidden thread_local global i32, align 4
@.str.166 = external hidden unnamed_addr constant [32 x i8], align 1
@.str.167 = external hidden unnamed_addr constant [27 x i8], align 1
@.str.168 = external hidden unnamed_addr constant [24 x i8], align 1
@.str.169 = external hidden unnamed_addr constant [19 x i8], align 1
@.str.170 = external hidden unnamed_addr constant [32 x i8], align 1
@__PRETTY_FUNCTION__.libxsmm_handle_error = external hidden unnamed_addr constant [110 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: nounwind uwtable
define dso_local void @libxsmm_handle_error(ptr noundef %0, i32 noundef %1, ptr noundef %2, ptr noundef %3, i32 noundef %4, i32 noundef %5) #1 {
  %7 = alloca ptr, align 8
  %8 = alloca i32, align 4
  %9 = alloca ptr, align 8
  %10 = alloca ptr, align 8
  %11 = alloca i32, align 4
  %12 = alloca i32, align 4
  %13 = alloca ptr, align 8
  %14 = alloca ptr, align 8
  %15 = alloca ptr, align 8
  store ptr %0, ptr %7, align 8, !tbaa !5
  store i32 %1, ptr %8, align 4, !tbaa !9
  store ptr %2, ptr %9, align 8, !tbaa !5
  store ptr %3, ptr %10, align 8, !tbaa !5
  store i32 %4, ptr %11, align 4, !tbaa !9
  store i32 %5, ptr %12, align 4, !tbaa !9
  %16 = load i32, ptr %8, align 4, !tbaa !9
  %17 = call align 4 ptr @llvm.threadlocal.address.p0(ptr align 4 @libxsmm_handle_error.last_error_code)
  %18 = load i32, ptr %17, align 4, !tbaa !9
  %19 = icmp ne i32 %16, %18
  br i1 %19, label %20, label %94

20:                                               ; preds = %6
  %21 = load i32, ptr %12, align 4, !tbaa !9
  %22 = icmp ne i32 0, %21
  br i1 %22, label %23, label %91

23:                                               ; preds = %20
  %24 = call i32 @libxsmm_get_handle_error()
  %25 = icmp ne i32 0, %24
  br i1 %25, label %26, label %91

26:                                               ; preds = %23
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #7
  %27 = load i32, ptr %8, align 4, !tbaa !9
  %28 = call ptr @libxsmm_strerror(i32 noundef %27)
  store ptr %28, ptr %13, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #7
  %29 = load ptr, ptr %10, align 8, !tbaa !5
  %30 = icmp ne ptr null, %29
  br i1 %30, label %31, label %34

31:                                               ; preds = %26
  %32 = load ptr, ptr %10, align 8, !tbaa !5
  %33 = call ptr @strrchr(ptr noundef %32, i32 noundef 47) #8
  br label %35

34:                                               ; preds = %26
  br label %35

35:                                               ; preds = %34, %31
  %36 = phi ptr [ %33, %31 ], [ null, %34 ]
  store ptr %36, ptr %14, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %15) #7
  %37 = load ptr, ptr %14, align 8, !tbaa !5
  %38 = icmp ne ptr null, %37
  br i1 %38, label %39, label %42

39:                                               ; preds = %35
  %40 = load ptr, ptr %14, align 8, !tbaa !5
  %41 = getelementptr inbounds i8, ptr %40, i64 1
  br label %43

42:                                               ; preds = %35
  br label %43

43:                                               ; preds = %42, %39
  %44 = phi ptr [ %41, %39 ], [ null, %42 ]
  store ptr %44, ptr %15, align 8, !tbaa !5
  call void @libxsmm_stdio_acquire()
  %45 = load ptr, ptr %15, align 8, !tbaa !5
  %46 = icmp ne ptr null, %45
  br i1 %46, label %47, label %72

47:                                               ; preds = %43
  %48 = load i32, ptr %11, align 4, !tbaa !9
  %49 = icmp slt i32 0, %48
  br i1 %49, label %50, label %72

50:                                               ; preds = %47
  %51 = load ptr, ptr %9, align 8, !tbaa !5
  %52 = icmp ne ptr null, %51
  br i1 %52, label %53, label %65

53:                                               ; preds = %50
  %54 = load ptr, ptr %9, align 8, !tbaa !5
  %55 = load i8, ptr %54, align 1, !tbaa !11
  %56 = sext i8 %55 to i32
  %57 = icmp ne i32 0, %56
  br i1 %57, label %58, label %65

58:                                               ; preds = %53
  %59 = load ptr, ptr @stderr, align 8, !tbaa !5
  %60 = load ptr, ptr %15, align 8, !tbaa !5
  %61 = load i32, ptr %11, align 4, !tbaa !9
  %62 = load ptr, ptr %9, align 8, !tbaa !5
  %63 = load ptr, ptr %13, align 8, !tbaa !5
  %64 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %59, ptr noundef @.str.166, ptr noundef %60, i32 noundef %61, ptr noundef %62, ptr noundef %63) #7
  br label %71

65:                                               ; preds = %53, %50
  %66 = load ptr, ptr @stderr, align 8, !tbaa !5
  %67 = load ptr, ptr %15, align 8, !tbaa !5
  %68 = load i32, ptr %11, align 4, !tbaa !9
  %69 = load ptr, ptr %13, align 8, !tbaa !5
  %70 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %66, ptr noundef @.str.167, ptr noundef %67, i32 noundef %68, ptr noundef %69) #7
  br label %71

71:                                               ; preds = %65, %58
  br label %90

72:                                               ; preds = %47, %43
  %73 = load ptr, ptr %9, align 8, !tbaa !5
  %74 = icmp ne ptr null, %73
  br i1 %74, label %75, label %85

75:                                               ; preds = %72
  %76 = load ptr, ptr %9, align 8, !tbaa !5
  %77 = load i8, ptr %76, align 1, !tbaa !11
  %78 = sext i8 %77 to i32
  %79 = icmp ne i32 0, %78
  br i1 %79, label %80, label %85

80:                                               ; preds = %75
  %81 = load ptr, ptr @stderr, align 8, !tbaa !5
  %82 = load ptr, ptr %9, align 8, !tbaa !5
  %83 = load ptr, ptr %13, align 8, !tbaa !5
  %84 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %81, ptr noundef @.str.168, ptr noundef %82, ptr noundef %83) #7
  br label %89

85:                                               ; preds = %75, %72
  %86 = load ptr, ptr @stderr, align 8, !tbaa !5
  %87 = load ptr, ptr %13, align 8, !tbaa !5
  %88 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %86, ptr noundef @.str.169, ptr noundef %87) #7
  br label %89

89:                                               ; preds = %85, %80
  br label %90

90:                                               ; preds = %89, %71
  call void @libxsmm_stdio_release()
  call void @llvm.lifetime.end.p0(i64 8, ptr %15) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #7
  br label %91

91:                                               ; preds = %90, %23, %20
  %92 = load i32, ptr %8, align 4, !tbaa !9
  %93 = call align 4 ptr @llvm.threadlocal.address.p0(ptr align 4 @libxsmm_handle_error.last_error_code)
  store i32 %92, ptr %93, align 4, !tbaa !9
  br label %94

94:                                               ; preds = %91, %6
  %95 = load ptr, ptr %7, align 8, !tbaa !5
  %96 = icmp ne ptr null, %95
  br i1 %96, label %97, label %98

97:                                               ; preds = %94
  br label %99

98:                                               ; preds = %94
  call void @__assert_fail(ptr noundef @.str.170, ptr noundef @.str, i32 noundef 1121, ptr noundef @__PRETTY_FUNCTION__.libxsmm_handle_error) #9
  unreachable

99:                                               ; preds = %97
  %100 = load i32, ptr %8, align 4, !tbaa !9
  %101 = load ptr, ptr %7, align 8, !tbaa !5
  %102 = getelementptr inbounds %struct.libxsmm_generated_code, ptr %101, i32 0, i32 5
  store i32 %100, ptr %102, align 8, !tbaa !12
  ret void
}

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

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

; Function Attrs: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) #3

; Function Attrs: nounwind uwtable
declare dso_local i32 @libxsmm_get_handle_error() #1

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare nonnull ptr @llvm.threadlocal.address.p0(ptr nonnull) #4

; Function Attrs: nounwind uwtable
declare dso_local ptr @libxsmm_strerror(i32 noundef) #1

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

declare void @libxsmm_stdio_acquire() #6

declare void @libxsmm_stdio_release() #6

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #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 = { noreturn 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 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
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 = { "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 #7 = { nounwind }
attributes #8 = { nounwind willreturn memory(read) }
attributes #9 = { noreturn 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, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!7, !7, i64 0}
!12 = !{!13, !10, i64 24}
!13 = !{!"libxsmm_generated_code", !6, i64 0, !10, i64 8, !10, i64 12, !10, i64 16, !10, i64 20, !10, i64 24, !10, 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
@stderr = external local_unnamed_addr global ptr, align 8
@libxsmm_handle_error.last_error_code = external hidden thread_local local_unnamed_addr global i32, align 4
@.str.166 = external hidden unnamed_addr constant [32 x i8], align 1
@.str.167 = external hidden unnamed_addr constant [27 x i8], align 1
@.str.168 = external hidden unnamed_addr constant [24 x i8], align 1
@.str.169 = external hidden unnamed_addr constant [19 x i8], align 1
@.str.170 = external hidden unnamed_addr constant [32 x i8], align 1
@__PRETTY_FUNCTION__.libxsmm_handle_error = external hidden unnamed_addr constant [110 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local void @libxsmm_handle_error(ptr noundef writeonly %0, i32 noundef %1, ptr noundef %2, ptr noundef %3, i32 noundef %4, i32 noundef %5) local_unnamed_addr #0 {
  %7 = tail call align 4 ptr @llvm.threadlocal.address.p0(ptr align 4 @libxsmm_handle_error.last_error_code)
  %8 = load i32, ptr %7, align 4, !tbaa !5
  %.not = icmp eq i32 %8, %1
  br i1 %.not, label %41, label %9

9:                                                ; preds = %6
  %.not31 = icmp eq i32 %5, 0
  br i1 %.not31, label %40, label %10

10:                                               ; preds = %9
  %11 = tail call i32 @libxsmm_get_handle_error()
  %.not32 = icmp eq i32 %11, 0
  br i1 %.not32, label %40, label %12

12:                                               ; preds = %10
  %13 = tail call ptr @libxsmm_strerror(i32 noundef %1)
  %.not33 = icmp eq ptr %3, null
  br i1 %.not33, label %16, label %14

14:                                               ; preds = %12
  %15 = tail call ptr @strrchr(ptr noundef nonnull dereferenceable(1) %3, i32 noundef 47) #6
  br label %16

16:                                               ; preds = %12, %14
  %17 = phi ptr [ %15, %14 ], [ null, %12 ]
  %18 = icmp ne ptr %17, null
  %19 = getelementptr inbounds i8, ptr %17, i64 1
  tail call void @libxsmm_stdio_acquire() #7
  %20 = icmp sgt i32 %4, 0
  %or.cond = and i1 %20, %18
  %.not36 = icmp eq ptr %2, null
  br i1 %or.cond, label %21, label %30

21:                                               ; preds = %16
  br i1 %.not36, label %27, label %22

22:                                               ; preds = %21
  %23 = load i8, ptr %2, align 1, !tbaa !9
  %.not37 = icmp eq i8 %23, 0
  br i1 %.not37, label %27, label %24

24:                                               ; preds = %22
  %25 = load ptr, ptr @stderr, align 8, !tbaa !10
  %26 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %25, ptr noundef nonnull @.str.166, ptr noundef nonnull %19, i32 noundef %4, ptr noundef nonnull %2, ptr noundef %13) #8
  br label %39

27:                                               ; preds = %22, %21
  %28 = load ptr, ptr @stderr, align 8, !tbaa !10
  %29 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %28, ptr noundef nonnull @.str.167, ptr noundef nonnull %19, i32 noundef %4, ptr noundef %13) #8
  br label %39

30:                                               ; preds = %16
  br i1 %.not36, label %36, label %31

31:                                               ; preds = %30
  %32 = load i8, ptr %2, align 1, !tbaa !9
  %.not35 = icmp eq i8 %32, 0
  br i1 %.not35, label %36, label %33

33:                                               ; preds = %31
  %34 = load ptr, ptr @stderr, align 8, !tbaa !10
  %35 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %34, ptr noundef nonnull @.str.168, ptr noundef nonnull %2, ptr noundef %13) #8
  br label %39

36:                                               ; preds = %31, %30
  %37 = load ptr, ptr @stderr, align 8, !tbaa !10
  %38 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %37, ptr noundef nonnull @.str.169, ptr noundef %13) #8
  br label %39

39:                                               ; preds = %33, %36, %24, %27
  tail call void @libxsmm_stdio_release() #7
  br label %40

40:                                               ; preds = %39, %10, %9
  store i32 %1, ptr %7, align 4, !tbaa !5
  br label %41

41:                                               ; preds = %40, %6
  %.not38 = icmp eq ptr %0, null
  br i1 %.not38, label %42, label %43

42:                                               ; preds = %41
  tail call void @__assert_fail(ptr noundef nonnull @.str.170, ptr noundef nonnull @.str, i32 noundef 1121, ptr noundef nonnull @__PRETTY_FUNCTION__.libxsmm_handle_error) #9
  unreachable

43:                                               ; preds = %41
  %44 = getelementptr inbounds i8, ptr %0, i64 24
  store i32 %1, ptr %44, align 8, !tbaa !12
  ret void
}

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

; Function Attrs: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) local_unnamed_addr #2

; Function Attrs: nounwind uwtable
declare dso_local i32 @libxsmm_get_handle_error() local_unnamed_addr #0

; Function Attrs: mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare nonnull ptr @llvm.threadlocal.address.p0(ptr nonnull) #3

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

; Function Attrs: mustprogress nofree nounwind willreturn memory(argmem: read)
declare ptr @strrchr(ptr noundef, i32 noundef) local_unnamed_addr #4

declare void @libxsmm_stdio_acquire() local_unnamed_addr #5

declare void @libxsmm_stdio_release() local_unnamed_addr #5

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 = { 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 #2 = { noreturn 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 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #4 = { mustprogress nofree nounwind willreturn memory(argmem: 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 #5 = { "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 willreturn memory(read) }
attributes #7 = { nounwind }
attributes #8 = { cold nounwind }
attributes #9 = { noreturn 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, !11, i64 0}
!11 = !{!"any pointer", !7, i64 0}
!12 = !{!13, !6, i64 24}
!13 = !{!"libxsmm_generated_code", !11, i64 0, !6, i64 8, !6, i64 12, !6, i64 16, !6, i64 20, !6, i64 24, !6, i64 28}


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