; 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_loop_label_tracker_struct = type { [512 x i32], i32 }
%struct.libxsmm_generated_code = type { ptr, i32, i32, i32, i32, 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
@__func__.libxsmm_x86_instruction_register_jump_back_label = external hidden unnamed_addr constant [49 x i8], align 1
@.str.139 = external hidden unnamed_addr constant [34 x i8], align 1
@.str.140 = external hidden unnamed_addr constant [28 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

declare void @libxsmm_handle_error(ptr noundef, i32 noundef, ptr noundef, ptr noundef, i32 noundef, i32 noundef) #1

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

declare void @libxsmm_append_code_as_string(ptr noundef, ptr noundef, i32 noundef) #1

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

13:                                               ; preds = %2
  %14 = load ptr, ptr %3, align 8, !tbaa !5
  %15 = load i32, ptr @libxsmm_ninit, align 4, !tbaa !12
  %16 = icmp ult i32 1, %15
  br i1 %16, label %17, label %19

17:                                               ; preds = %13
  %18 = load i32, ptr @libxsmm_verbosity, align 4, !tbaa !12
  br label %20

19:                                               ; preds = %13
  br label %20

20:                                               ; preds = %19, %17
  %21 = phi i32 [ %18, %17 ], [ 1, %19 ]
  call void @libxsmm_handle_error(ptr noundef %14, i32 noundef 90025, ptr noundef @__func__.libxsmm_x86_instruction_register_jump_back_label, ptr noundef @.str, i32 noundef 4214, i32 noundef %21)
  br label %94

22:                                               ; preds = %2
  %23 = load ptr, ptr %3, align 8, !tbaa !5
  %24 = getelementptr inbounds %struct.libxsmm_generated_code, ptr %23, i32 0, i32 3
  %25 = load i32, ptr %24, align 8, !tbaa !13
  %26 = icmp ugt i32 %25, 1
  br i1 %26, label %27, label %43

27:                                               ; preds = %22
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #4
  %28 = load ptr, ptr %4, align 8, !tbaa !5
  %29 = getelementptr inbounds %struct.libxsmm_loop_label_tracker_struct, ptr %28, i32 0, i32 1
  %30 = load i32, ptr %29, align 4, !tbaa !9
  store i32 %30, ptr %5, align 4, !tbaa !12
  %31 = load ptr, ptr %4, align 8, !tbaa !5
  %32 = getelementptr inbounds %struct.libxsmm_loop_label_tracker_struct, ptr %31, i32 0, i32 1
  %33 = load i32, ptr %32, align 4, !tbaa !9
  %34 = add i32 %33, 1
  store i32 %34, ptr %32, align 4, !tbaa !9
  %35 = load ptr, ptr %3, align 8, !tbaa !5
  %36 = getelementptr inbounds %struct.libxsmm_generated_code, ptr %35, i32 0, i32 2
  %37 = load i32, ptr %36, align 4, !tbaa !15
  %38 = load ptr, ptr %4, align 8, !tbaa !5
  %39 = getelementptr inbounds %struct.libxsmm_loop_label_tracker_struct, ptr %38, i32 0, i32 0
  %40 = load i32, ptr %5, align 4, !tbaa !12
  %41 = sext i32 %40 to i64
  %42 = getelementptr inbounds [512 x i32], ptr %39, i64 0, i64 %41
  store i32 %37, ptr %42, align 4, !tbaa !12
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #4
  br label %94

43:                                               ; preds = %22
  call void @llvm.lifetime.start.p0(i64 512, ptr %6) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #4
  store i32 511, ptr %7, align 4, !tbaa !12
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #4
  store i32 0, ptr %8, align 4, !tbaa !12
  %44 = load ptr, ptr %4, align 8, !tbaa !5
  %45 = getelementptr inbounds %struct.libxsmm_loop_label_tracker_struct, ptr %44, i32 0, i32 1
  %46 = load i32, ptr %45, align 4, !tbaa !9
  %47 = add i32 %46, 32
  %48 = add i32 %47, 1
  %49 = load ptr, ptr %4, align 8, !tbaa !5
  %50 = getelementptr inbounds %struct.libxsmm_loop_label_tracker_struct, ptr %49, i32 0, i32 0
  %51 = load ptr, ptr %4, align 8, !tbaa !5
  %52 = getelementptr inbounds %struct.libxsmm_loop_label_tracker_struct, ptr %51, i32 0, i32 1
  %53 = load i32, ptr %52, align 4, !tbaa !9
  %54 = zext i32 %53 to i64
  %55 = getelementptr inbounds [512 x i32], ptr %50, i64 0, i64 %54
  store i32 %48, ptr %55, align 4, !tbaa !12
  %56 = load ptr, ptr %3, align 8, !tbaa !5
  %57 = getelementptr inbounds %struct.libxsmm_generated_code, ptr %56, i32 0, i32 3
  %58 = load i32, ptr %57, align 8, !tbaa !13
  %59 = icmp eq i32 %58, 0
  br i1 %59, label %60, label %73

60:                                               ; preds = %43
  %61 = getelementptr inbounds [512 x i8], ptr %6, i64 0, i64 0
  %62 = load i32, ptr %7, align 4, !tbaa !12
  %63 = sext i32 %62 to i64
  %64 = load ptr, ptr %4, align 8, !tbaa !5
  %65 = getelementptr inbounds %struct.libxsmm_loop_label_tracker_struct, ptr %64, i32 0, i32 0
  %66 = load ptr, ptr %4, align 8, !tbaa !5
  %67 = getelementptr inbounds %struct.libxsmm_loop_label_tracker_struct, ptr %66, i32 0, i32 1
  %68 = load i32, ptr %67, align 4, !tbaa !9
  %69 = zext i32 %68 to i64
  %70 = getelementptr inbounds [512 x i32], ptr %65, i64 0, i64 %69
  %71 = load i32, ptr %70, align 4, !tbaa !12
  %72 = call i32 (ptr, i64, ptr, ...) @snprintf(ptr noundef %61, i64 noundef %63, ptr noundef @.str.139, i32 noundef %71) #4
  store i32 %72, ptr %8, align 4, !tbaa !12
  br label %86

73:                                               ; preds = %43
  %74 = getelementptr inbounds [512 x i8], ptr %6, i64 0, i64 0
  %75 = load i32, ptr %7, align 4, !tbaa !12
  %76 = sext i32 %75 to i64
  %77 = load ptr, ptr %4, align 8, !tbaa !5
  %78 = getelementptr inbounds %struct.libxsmm_loop_label_tracker_struct, ptr %77, i32 0, i32 0
  %79 = load ptr, ptr %4, align 8, !tbaa !5
  %80 = getelementptr inbounds %struct.libxsmm_loop_label_tracker_struct, ptr %79, i32 0, i32 1
  %81 = load i32, ptr %80, align 4, !tbaa !9
  %82 = zext i32 %81 to i64
  %83 = getelementptr inbounds [512 x i32], ptr %78, i64 0, i64 %82
  %84 = load i32, ptr %83, align 4, !tbaa !12
  %85 = call i32 (ptr, i64, ptr, ...) @snprintf(ptr noundef %74, i64 noundef %76, ptr noundef @.str.140, i32 noundef %84) #4
  store i32 %85, ptr %8, align 4, !tbaa !12
  br label %86

86:                                               ; preds = %73, %60
  %87 = load ptr, ptr %3, align 8, !tbaa !5
  %88 = getelementptr inbounds [512 x i8], ptr %6, i64 0, i64 0
  %89 = load i32, ptr %8, align 4, !tbaa !12
  call void @libxsmm_append_code_as_string(ptr noundef %87, ptr noundef %88, i32 noundef %89)
  %90 = load ptr, ptr %4, align 8, !tbaa !5
  %91 = getelementptr inbounds %struct.libxsmm_loop_label_tracker_struct, ptr %90, i32 0, i32 1
  %92 = load i32, ptr %91, align 4, !tbaa !9
  %93 = add i32 %92, 1
  store i32 %93, ptr %91, align 4, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #4
  call void @llvm.lifetime.end.p0(i64 512, ptr %6) #4
  br label %94

94:                                               ; preds = %86, %27, %20
  ret void
}

attributes #0 = { nocallback nofree nosync 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 = { 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 = { 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 2048}
!10 = !{!"libxsmm_loop_label_tracker_struct", !7, i64 0, !11, i64 2048}
!11 = !{!"int", !7, i64 0}
!12 = !{!11, !11, i64 0}
!13 = !{!14, !11, i64 16}
!14 = !{!"libxsmm_generated_code", !6, i64 0, !11, i64 8, !11, i64 12, !11, i64 16, !11, i64 20, !11, i64 24, !11, i64 28}
!15 = !{!14, !11, i64 12}


; 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
@__func__.libxsmm_x86_instruction_register_jump_back_label = external hidden unnamed_addr constant [49 x i8], align 1
@.str.139 = external hidden unnamed_addr constant [34 x i8], align 1
@.str.140 = external hidden unnamed_addr constant [28 x i8], align 1

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

; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #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 @snprintf(ptr noalias nocapture noundef writeonly, i64 noundef, ptr nocapture noundef readonly, ...) local_unnamed_addr #2

declare void @libxsmm_append_code_as_string(ptr noundef, ptr noundef, i32 noundef) local_unnamed_addr #1

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

7:                                                ; preds = %2
  %8 = load i32, ptr @libxsmm_ninit, align 4, !tbaa !10
  %9 = icmp ugt i32 %8, 1
  %10 = load i32, ptr @libxsmm_verbosity, align 4
  %11 = select i1 %9, i32 %10, i32 1
  tail call void @libxsmm_handle_error(ptr noundef %0, i32 noundef 90025, ptr noundef nonnull @__func__.libxsmm_x86_instruction_register_jump_back_label, ptr noundef nonnull @.str, i32 noundef 4214, i32 noundef %11) #4
  br label %35

12:                                               ; preds = %2
  %13 = getelementptr inbounds i8, ptr %0, i64 16
  %14 = load i32, ptr %13, align 8, !tbaa !11
  %15 = icmp ugt i32 %14, 1
  br i1 %15, label %16, label %22

16:                                               ; preds = %12
  %17 = add i32 %5, 1
  store i32 %17, ptr %4, align 4, !tbaa !5
  %18 = getelementptr inbounds i8, ptr %0, i64 12
  %19 = load i32, ptr %18, align 4, !tbaa !14
  %20 = sext i32 %5 to i64
  %21 = getelementptr inbounds [512 x i32], ptr %1, i64 0, i64 %20
  store i32 %19, ptr %21, align 4, !tbaa !10
  br label %35

22:                                               ; preds = %12
  call void @llvm.lifetime.start.p0(i64 512, ptr nonnull %3) #4
  %23 = add i32 %5, 33
  %24 = zext i32 %5 to i64
  %25 = getelementptr inbounds [512 x i32], ptr %1, i64 0, i64 %24
  store i32 %23, ptr %25, align 4, !tbaa !10
  %26 = load i32, ptr %13, align 8, !tbaa !11
  %27 = icmp eq i32 %26, 0
  %28 = load i32, ptr %4, align 4, !tbaa !5
  %29 = zext i32 %28 to i64
  %30 = getelementptr inbounds [512 x i32], ptr %1, i64 0, i64 %29
  %31 = load i32, ptr %30, align 4, !tbaa !10
  %.str.139..str.140 = select i1 %27, ptr @.str.139, ptr @.str.140
  %32 = call i32 (ptr, i64, ptr, ...) @snprintf(ptr noundef nonnull dereferenceable(1) %3, i64 noundef 511, ptr noundef nonnull %.str.139..str.140, i32 noundef %31) #4
  call void @libxsmm_append_code_as_string(ptr noundef nonnull %0, ptr noundef nonnull %3, i32 noundef %32) #4
  %33 = load i32, ptr %4, align 4, !tbaa !5
  %34 = add i32 %33, 1
  store i32 %34, ptr %4, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 512, ptr nonnull %3) #4
  br label %35

35:                                               ; preds = %22, %16, %7
  ret void
}

attributes #0 = { mustprogress nocallback nofree nosync 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 = { 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, !9, i64 2048}
!6 = !{!"libxsmm_loop_label_tracker_struct", !7, i64 0, !9, i64 2048}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!"int", !7, i64 0}
!10 = !{!9, !9, i64 0}
!11 = !{!12, !9, i64 16}
!12 = !{!"libxsmm_generated_code", !13, i64 0, !9, i64 8, !9, i64 12, !9, i64 16, !9, i64 20, !9, i64 24, !9, i64 28}
!13 = !{!"any pointer", !7, i64 0}
!14 = !{!12, !9, i64 12}


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