; 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.52 = external hidden unnamed_addr constant [94 x i8], align 1
@__func__.libxsmm_rv64_instruction_alu_move_imm32 = external hidden unnamed_addr constant [40 x i8], align 1
@.str.53 = external hidden unnamed_addr constant [56 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: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #3

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

; 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
define dso_local void @libxsmm_rv64_instruction_alu_move_imm32(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
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = 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
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #4
  store i32 -2097152, ptr %7, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #4
  %11 = load ptr, ptr %4, align 8, !tbaa !5
  %12 = getelementptr inbounds %struct.libxsmm_generated_code, ptr %11, i32 0, i32 6
  %13 = load i32, ptr %12, align 4, !tbaa !11
  %14 = icmp ult i32 %13, 3001
  br i1 %14, label %15, label %26

15:                                               ; preds = %3
  %16 = load ptr, ptr @stderr, align 8, !tbaa !5
  %17 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %16, ptr noundef @.str.52) #4
  %18 = load ptr, ptr %4, align 8, !tbaa !5
  %19 = load i32, ptr @libxsmm_ninit, align 4, !tbaa !9
  %20 = icmp ult i32 1, %19
  br i1 %20, label %21, label %23

21:                                               ; preds = %15
  %22 = load i32, ptr @libxsmm_verbosity, align 4, !tbaa !9
  br label %24

23:                                               ; preds = %15
  br label %24

24:                                               ; preds = %23, %21
  %25 = phi i32 [ %22, %21 ], [ 1, %23 ]
  call void @libxsmm_handle_error(ptr noundef %18, i32 noundef 90000, ptr noundef @__func__.libxsmm_rv64_instruction_alu_move_imm32, ptr noundef @.str.1, i32 noundef 1196, i32 noundef %25)
  store i32 1, ptr %10, align 4
  br label %77

26:                                               ; preds = %3
  %27 = load i32, ptr %5, align 4, !tbaa !9
  %28 = icmp ule i32 %27, 31
  br i1 %28, label %40, label %29

29:                                               ; preds = %26
  %30 = load ptr, ptr @stderr, align 8, !tbaa !5
  %31 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %30, ptr noundef @.str.53) #4
  %32 = load ptr, ptr %4, align 8, !tbaa !5
  %33 = load i32, ptr @libxsmm_ninit, align 4, !tbaa !9
  %34 = icmp ult i32 1, %33
  br i1 %34, label %35, label %37

35:                                               ; preds = %29
  %36 = load i32, ptr @libxsmm_verbosity, align 4, !tbaa !9
  br label %38

37:                                               ; preds = %29
  br label %38

38:                                               ; preds = %37, %35
  %39 = phi i32 [ %36, %35 ], [ 1, %37 ]
  call void @libxsmm_handle_error(ptr noundef %32, i32 noundef 90000, ptr noundef @__func__.libxsmm_rv64_instruction_alu_move_imm32, ptr noundef @.str.1, i32 noundef 1202, i32 noundef %39)
  store i32 1, ptr %10, align 4
  br label %77

40:                                               ; preds = %26
  %41 = load ptr, ptr %4, align 8, !tbaa !5
  %42 = load i32, ptr %5, align 4, !tbaa !9
  call void @libxsmm_rv64_instruction_alu_compute(ptr noundef %41, i32 noundef 51, i32 noundef 0, i32 noundef 0, i32 noundef %42)
  store i32 -2097152, ptr %7, align 4, !tbaa !9
  store i32 0, ptr %9, align 4, !tbaa !9
  br label %43

43:                                               ; preds = %63, %40
  %44 = load i32, ptr %9, align 4, !tbaa !9
  %45 = icmp slt i32 %44, 2
  br i1 %45, label %46, label %66

46:                                               ; preds = %43
  %47 = load i32, ptr %6, align 4, !tbaa !9
  %48 = load i32, ptr %7, align 4, !tbaa !9
  %49 = and i32 %47, %48
  %50 = load i32, ptr %9, align 4, !tbaa !9
  %51 = mul nsw i32 11, %50
  %52 = sub nsw i32 21, %51
  %53 = lshr i32 %49, %52
  store i32 %53, ptr %8, align 4, !tbaa !9
  %54 = load i32, ptr %7, align 4, !tbaa !9
  %55 = lshr i32 %54, 11
  store i32 %55, ptr %7, align 4, !tbaa !9
  %56 = load ptr, ptr %4, align 8, !tbaa !5
  %57 = load i32, ptr %5, align 4, !tbaa !9
  %58 = load i32, ptr %5, align 4, !tbaa !9
  call void @libxsmm_rv64_instruction_alu_compute_imm12(ptr noundef %56, i32 noundef 4115, i32 noundef %57, i32 noundef %58, i32 noundef 11)
  %59 = load ptr, ptr %4, align 8, !tbaa !5
  %60 = load i32, ptr %5, align 4, !tbaa !9
  %61 = load i32, ptr %5, align 4, !tbaa !9
  %62 = load i32, ptr %8, align 4, !tbaa !9
  call void @libxsmm_rv64_instruction_alu_compute_imm12(ptr noundef %59, i32 noundef 19, i32 noundef %60, i32 noundef %61, i32 noundef %62)
  br label %63

63:                                               ; preds = %46
  %64 = load i32, ptr %9, align 4, !tbaa !9
  %65 = add nsw i32 %64, 1
  store i32 %65, ptr %9, align 4, !tbaa !9
  br label %43, !llvm.loop !13

66:                                               ; preds = %43
  store i32 1023, ptr %7, align 4, !tbaa !9
  %67 = load i32, ptr %6, align 4, !tbaa !9
  %68 = load i32, ptr %7, align 4, !tbaa !9
  %69 = and i32 %67, %68
  store i32 %69, ptr %8, align 4, !tbaa !9
  %70 = load ptr, ptr %4, align 8, !tbaa !5
  %71 = load i32, ptr %5, align 4, !tbaa !9
  %72 = load i32, ptr %5, align 4, !tbaa !9
  call void @libxsmm_rv64_instruction_alu_compute_imm12(ptr noundef %70, i32 noundef 4115, i32 noundef %71, i32 noundef %72, i32 noundef 10)
  %73 = load ptr, ptr %4, align 8, !tbaa !5
  %74 = load i32, ptr %5, align 4, !tbaa !9
  %75 = load i32, ptr %5, align 4, !tbaa !9
  %76 = load i32, ptr %8, align 4, !tbaa !9
  call void @libxsmm_rv64_instruction_alu_compute_imm12(ptr noundef %73, i32 noundef 19, i32 noundef %74, i32 noundef %75, i32 noundef %76)
  store i32 0, ptr %10, align 4
  br label %77

77:                                               ; preds = %66, %38, %24
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #4
  %78 = load i32, ptr %10, align 4
  switch i32 %78, label %80 [
    i32 0, label %79
    i32 1, label %79
  ]

79:                                               ; preds = %77, %77
  ret void

80:                                               ; preds = %77
  unreachable
}

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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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, !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}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}


; 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.52 = external hidden unnamed_addr constant [94 x i8], align 1
@__func__.libxsmm_rv64_instruction_alu_move_imm32 = external hidden unnamed_addr constant [40 x i8], align 1
@.str.53 = external hidden unnamed_addr constant [56 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
define dso_local void @libxsmm_rv64_instruction_alu_move_imm32(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.52) #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_imm32, ptr noundef nonnull @.str.1, i32 noundef 1196, i32 noundef %13) #4
  br label %28

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.53) #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_imm32, ptr noundef nonnull @.str.1, i32 noundef 1202, i32 noundef %22) #4
  br label %28

23:                                               ; preds = %14
  tail call void @libxsmm_rv64_instruction_alu_compute(ptr noundef nonnull %0, i32 noundef 51, i32 noundef 0, i32 noundef 0, i32 noundef %1)
  %24 = lshr i32 %2, 21
  tail call void @libxsmm_rv64_instruction_alu_compute_imm12(ptr noundef nonnull %0, i32 noundef 4115, i32 noundef %1, i32 noundef %1, i32 noundef 11)
  tail call void @libxsmm_rv64_instruction_alu_compute_imm12(ptr noundef nonnull %0, i32 noundef 19, i32 noundef %1, i32 noundef %1, i32 noundef %24)
  %25 = lshr i32 %2, 10
  %26 = and i32 %25, 2047
  tail call void @libxsmm_rv64_instruction_alu_compute_imm12(ptr noundef nonnull %0, i32 noundef 4115, i32 noundef %1, i32 noundef %1, i32 noundef 11)
  tail call void @libxsmm_rv64_instruction_alu_compute_imm12(ptr noundef nonnull %0, i32 noundef 19, i32 noundef %1, i32 noundef %1, i32 noundef %26)
  %27 = and i32 %2, 1023
  tail call void @libxsmm_rv64_instruction_alu_compute_imm12(ptr noundef nonnull %0, i32 noundef 4115, i32 noundef %1, i32 noundef %1, i32 noundef 10)
  tail call void @libxsmm_rv64_instruction_alu_compute_imm12(ptr noundef nonnull %0, i32 noundef 19, i32 noundef %1, i32 noundef %1, i32 noundef %27)
  br label %28

28:                                               ; preds = %23, %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,GVNPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,LoopRotatePass,SROAPass,SimplifyCFGPass,TailCallElimPass