; LLVM IR from libxsmm/libxsmm :: src (generator_rv64_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 }

@stderr = external global ptr, align 8
@.str.1 = external hidden unnamed_addr constant [83 x i8], align 1
@libxsmm_ninit = external global i32, align 4
@libxsmm_verbosity = external global i32, align 4
@.str.42 = external hidden unnamed_addr constant [97 x i8], align 1
@__func__.libxsmm_rv64_instruction_alu_move_imm20 = external hidden unnamed_addr constant [40 x i8], align 1
@.str.50 = external hidden unnamed_addr constant [60 x i8], align 1
@.str.51 = external hidden unnamed_addr constant [61 x i8], align 1

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

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

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

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

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

; Function Attrs: nounwind uwtable
define dso_local void @libxsmm_rv64_instruction_alu_move_imm20(ptr noundef %0, i32 noundef %1, i32 noundef %2) #2 {
  %4 = alloca ptr, align 8
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  store i32 %1, ptr %5, align 4, !tbaa !9
  store i32 %2, ptr %6, align 4, !tbaa !9
  %7 = load ptr, ptr %4, align 8, !tbaa !5
  %8 = getelementptr inbounds %struct.libxsmm_generated_code, ptr %7, i32 0, i32 6
  %9 = load i32, ptr %8, align 4, !tbaa !11
  %10 = icmp ult i32 %9, 3001
  br i1 %10, label %11, label %22

11:                                               ; preds = %3
  %12 = load ptr, ptr @stderr, align 8, !tbaa !5
  %13 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %12, ptr noundef @.str.42) #3
  %14 = load ptr, ptr %4, align 8, !tbaa !5
  %15 = load i32, ptr @libxsmm_ninit, align 4, !tbaa !9
  %16 = icmp ult i32 1, %15
  br i1 %16, label %17, label %19

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

19:                                               ; preds = %11
  br label %20

20:                                               ; preds = %19, %17
  %21 = phi i32 [ %18, %17 ], [ 1, %19 ]
  call void @libxsmm_handle_error(ptr noundef %14, i32 noundef 90000, ptr noundef @__func__.libxsmm_rv64_instruction_alu_move_imm20, ptr noundef @.str.1, i32 noundef 1157, i32 noundef %21)
  br label %60

22:                                               ; preds = %3
  %23 = load i32, ptr %5, align 4, !tbaa !9
  %24 = icmp ule i32 %23, 31
  br i1 %24, label %36, label %25

25:                                               ; preds = %22
  %26 = load ptr, ptr @stderr, align 8, !tbaa !5
  %27 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %26, ptr noundef @.str.50) #3
  %28 = load ptr, ptr %4, align 8, !tbaa !5
  %29 = load i32, ptr @libxsmm_ninit, align 4, !tbaa !9
  %30 = icmp ult i32 1, %29
  br i1 %30, label %31, label %33

31:                                               ; preds = %25
  %32 = load i32, ptr @libxsmm_verbosity, align 4, !tbaa !9
  br label %34

33:                                               ; preds = %25
  br label %34

34:                                               ; preds = %33, %31
  %35 = phi i32 [ %32, %31 ], [ 1, %33 ]
  call void @libxsmm_handle_error(ptr noundef %28, i32 noundef 90000, ptr noundef @__func__.libxsmm_rv64_instruction_alu_move_imm20, ptr noundef @.str.1, i32 noundef 1163, i32 noundef %35)
  br label %60

36:                                               ; preds = %22
  %37 = load i32, ptr %6, align 4, !tbaa !9
  %38 = icmp ugt i32 %37, 1048575
  br i1 %38, label %39, label %51

39:                                               ; preds = %36
  %40 = load ptr, ptr @stderr, align 8, !tbaa !5
  %41 = load i32, ptr %6, align 4, !tbaa !9
  %42 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %40, ptr noundef @.str.51, i32 noundef %41) #3
  %43 = load ptr, ptr %4, align 8, !tbaa !5
  %44 = load i32, ptr @libxsmm_ninit, align 4, !tbaa !9
  %45 = icmp ult i32 1, %44
  br i1 %45, label %46, label %48

46:                                               ; preds = %39
  %47 = load i32, ptr @libxsmm_verbosity, align 4, !tbaa !9
  br label %49

48:                                               ; preds = %39
  br label %49

49:                                               ; preds = %48, %46
  %50 = phi i32 [ %47, %46 ], [ 1, %48 ]
  call void @libxsmm_handle_error(ptr noundef %43, i32 noundef 90000, ptr noundef @__func__.libxsmm_rv64_instruction_alu_move_imm20, ptr noundef @.str.1, i32 noundef 1169, i32 noundef %50)
  br label %60

51:                                               ; preds = %36
  %52 = load ptr, ptr %4, align 8, !tbaa !5
  %53 = load i32, ptr %5, align 4, !tbaa !9
  call void @libxsmm_rv64_instruction_alu_compute(ptr noundef %52, i32 noundef 51, i32 noundef 0, i32 noundef 0, i32 noundef %53)
  %54 = load ptr, ptr %4, align 8, !tbaa !5
  %55 = load i32, ptr %5, align 4, !tbaa !9
  %56 = load i32, ptr %6, align 4, !tbaa !9
  call void @libxsmm_rv64_instruction_alu_compute_imm20(ptr noundef %54, i32 noundef 55, i32 noundef %55, i32 noundef %56)
  %57 = load ptr, ptr %4, align 8, !tbaa !5
  %58 = load i32, ptr %5, align 4, !tbaa !9
  %59 = load i32, ptr %5, align 4, !tbaa !9
  call void @libxsmm_rv64_instruction_alu_compute_imm12(ptr noundef %57, i32 noundef 20499, i32 noundef %58, i32 noundef %59, i32 noundef 12)
  br label %60

60:                                               ; preds = %51, %49, %34, %20
  ret void
}

attributes #0 = { 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 #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 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 #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, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!12, !10, i64 28}
!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}


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

@stderr = external local_unnamed_addr global ptr, align 8
@.str.1 = external hidden unnamed_addr constant [83 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.42 = external hidden unnamed_addr constant [97 x i8], align 1
@__func__.libxsmm_rv64_instruction_alu_move_imm20 = external hidden unnamed_addr constant [40 x i8], align 1
@.str.50 = external hidden unnamed_addr constant [60 x i8], align 1
@.str.51 = external hidden unnamed_addr constant [61 x i8], align 1

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

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

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

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

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

; Function Attrs: nounwind uwtable
define dso_local void @libxsmm_rv64_instruction_alu_move_imm20(ptr noundef %0, i32 noundef %1, i32 noundef %2) local_unnamed_addr #2 {
  %4 = getelementptr inbounds i8, ptr %0, i64 28
  %5 = load i32, ptr %4, align 4, !tbaa !5
  %6 = icmp ult i32 %5, 3001
  br i1 %6, label %7, label %14

7:                                                ; preds = %3
  %8 = load ptr, ptr @stderr, align 8, !tbaa !11
  %9 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %8, ptr noundef nonnull @.str.42) #3
  %10 = load i32, ptr @libxsmm_ninit, align 4, !tbaa !12
  %11 = icmp ugt i32 %10, 1
  %12 = load i32, ptr @libxsmm_verbosity, align 4
  %13 = select i1 %11, i32 %12, i32 1
  tail call void @libxsmm_handle_error(ptr noundef nonnull %0, i32 noundef 90000, ptr noundef nonnull @__func__.libxsmm_rv64_instruction_alu_move_imm20, ptr noundef nonnull @.str.1, i32 noundef 1157, i32 noundef %13) #4
  br label %33

14:                                               ; preds = %3
  %15 = icmp ult i32 %1, 32
  br i1 %15, label %23, label %16

16:                                               ; preds = %14
  %17 = load ptr, ptr @stderr, align 8, !tbaa !11
  %18 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %17, ptr noundef nonnull @.str.50) #3
  %19 = load i32, ptr @libxsmm_ninit, align 4, !tbaa !12
  %20 = icmp ugt i32 %19, 1
  %21 = load i32, ptr @libxsmm_verbosity, align 4
  %22 = select i1 %20, i32 %21, i32 1
  tail call void @libxsmm_handle_error(ptr noundef nonnull %0, i32 noundef 90000, ptr noundef nonnull @__func__.libxsmm_rv64_instruction_alu_move_imm20, ptr noundef nonnull @.str.1, i32 noundef 1163, i32 noundef %22) #4
  br label %33

23:                                               ; preds = %14
  %24 = icmp ugt i32 %2, 1048575
  br i1 %24, label %25, label %32

25:                                               ; preds = %23
  %26 = load ptr, ptr @stderr, align 8, !tbaa !11
  %27 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %26, ptr noundef nonnull @.str.51, i32 noundef %2) #3
  %28 = load i32, ptr @libxsmm_ninit, align 4, !tbaa !12
  %29 = icmp ugt i32 %28, 1
  %30 = load i32, ptr @libxsmm_verbosity, align 4
  %31 = select i1 %29, i32 %30, i32 1
  tail call void @libxsmm_handle_error(ptr noundef nonnull %0, i32 noundef 90000, ptr noundef nonnull @__func__.libxsmm_rv64_instruction_alu_move_imm20, ptr noundef nonnull @.str.1, i32 noundef 1169, i32 noundef %31) #4
  br label %33

32:                                               ; preds = %23
  tail call void @libxsmm_rv64_instruction_alu_compute(ptr noundef nonnull %0, i32 noundef 51, i32 noundef 0, i32 noundef 0, i32 noundef %1)
  tail call void @libxsmm_rv64_instruction_alu_compute_imm20(ptr noundef nonnull %0, i32 noundef 55, i32 noundef %1, i32 noundef %2)
  tail call void @libxsmm_rv64_instruction_alu_compute_imm12(ptr noundef nonnull %0, i32 noundef 20499, i32 noundef %1, i32 noundef %1, i32 noundef 12)
  br label %33

33:                                               ; preds = %32, %25, %16, %7
  ret void
}

attributes #0 = { 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 #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 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 #3 = { cold nounwind }
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, !10, i64 28}
!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 = !{!7, !7, i64 0}
!12 = !{!10, !10, i64 0}


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