; 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
@db_bpos = external hidden constant [32 x i32], align 16
@.str.15 = external hidden unnamed_addr constant [89 x i8], align 1
@__func__.libxsmm_rv64_instruction_rvv_setvl = external hidden unnamed_addr constant [35 x i8], align 1
@.str.16 = external hidden unnamed_addr constant [55 x i8], align 1
@.str.17 = external hidden unnamed_addr constant [82 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: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #2

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

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

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

22:                                               ; preds = %16
  %23 = load i32, ptr @libxsmm_verbosity, align 4, !tbaa !9
  br label %25

24:                                               ; preds = %16
  br label %25

25:                                               ; preds = %24, %22
  %26 = phi i32 [ %23, %22 ], [ 1, %24 ]
  call void @libxsmm_handle_error(ptr noundef %19, i32 noundef 90000, ptr noundef @__func__.libxsmm_rv64_instruction_rvv_setvl, ptr noundef @.str.1, i32 noundef 465, i32 noundef %26)
  br label %130

27:                                               ; preds = %4
  %28 = load i32, ptr %6, align 4, !tbaa !9
  %29 = icmp ule i32 %28, 31
  br i1 %29, label %30, label %36

30:                                               ; preds = %27
  %31 = load i32, ptr %7, align 4, !tbaa !9
  %32 = icmp ule i32 %31, 31
  br i1 %32, label %33, label %36

33:                                               ; preds = %30
  %34 = load i32, ptr %8, align 4, !tbaa !9
  %35 = icmp ule i32 %34, 31
  br i1 %35, label %47, label %36

36:                                               ; preds = %33, %30, %27
  %37 = load ptr, ptr @stderr, align 8, !tbaa !5
  %38 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %37, ptr noundef @.str.16) #4
  %39 = load ptr, ptr %5, align 8, !tbaa !5
  %40 = load i32, ptr @libxsmm_ninit, align 4, !tbaa !9
  %41 = icmp ult i32 1, %40
  br i1 %41, label %42, label %44

42:                                               ; preds = %36
  %43 = load i32, ptr @libxsmm_verbosity, align 4, !tbaa !9
  br label %45

44:                                               ; preds = %36
  br label %45

45:                                               ; preds = %44, %42
  %46 = phi i32 [ %43, %42 ], [ 1, %44 ]
  call void @libxsmm_handle_error(ptr noundef %39, i32 noundef 90000, ptr noundef @__func__.libxsmm_rv64_instruction_rvv_setvl, ptr noundef @.str.1, i32 noundef 471, i32 noundef %46)
  br label %130

47:                                               ; preds = %33
  %48 = load ptr, ptr %5, align 8, !tbaa !5
  %49 = getelementptr inbounds %struct.libxsmm_generated_code, ptr %48, i32 0, i32 3
  %50 = load i32, ptr %49, align 8, !tbaa !13
  %51 = icmp ugt i32 %50, 1
  br i1 %51, label %52, label %119

52:                                               ; preds = %47
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #4
  %53 = load ptr, ptr %5, align 8, !tbaa !5
  %54 = getelementptr inbounds %struct.libxsmm_generated_code, ptr %53, i32 0, i32 2
  %55 = load i32, ptr %54, align 4, !tbaa !14
  %56 = udiv i32 %55, 4
  store i32 %56, ptr %9, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #4
  %57 = load ptr, ptr %5, align 8, !tbaa !5
  %58 = getelementptr inbounds %struct.libxsmm_generated_code, ptr %57, i32 0, i32 0
  %59 = load ptr, ptr %58, align 8, !tbaa !15
  store ptr %59, ptr %10, align 8, !tbaa !5
  %60 = load ptr, ptr %5, align 8, !tbaa !5
  %61 = getelementptr inbounds %struct.libxsmm_generated_code, ptr %60, i32 0, i32 1
  %62 = load i32, ptr %61, align 8, !tbaa !16
  %63 = load ptr, ptr %5, align 8, !tbaa !5
  %64 = getelementptr inbounds %struct.libxsmm_generated_code, ptr %63, i32 0, i32 2
  %65 = load i32, ptr %64, align 4, !tbaa !14
  %66 = sub i32 %62, %65
  %67 = icmp ult i32 %66, 4
  br i1 %67, label %68, label %77

68:                                               ; preds = %52
  %69 = load ptr, ptr %5, align 8, !tbaa !5
  %70 = load i32, ptr @libxsmm_ninit, align 4, !tbaa !9
  %71 = icmp ult i32 1, %70
  br i1 %71, label %72, label %74

72:                                               ; preds = %68
  %73 = load i32, ptr @libxsmm_verbosity, align 4, !tbaa !9
  br label %75

74:                                               ; preds = %68
  br label %75

75:                                               ; preds = %74, %72
  %76 = phi i32 [ %73, %72 ], [ 1, %74 ]
  call void @libxsmm_handle_error(ptr noundef %69, i32 noundef 90002, ptr noundef @__func__.libxsmm_rv64_instruction_rvv_setvl, ptr noundef @.str.1, i32 noundef 481, i32 noundef %76)
  store i32 1, ptr %11, align 4
  br label %116

77:                                               ; preds = %52
  %78 = load ptr, ptr %10, align 8, !tbaa !5
  %79 = load i32, ptr %9, align 4, !tbaa !9
  %80 = zext i32 %79 to i64
  %81 = getelementptr inbounds i32, ptr %78, i64 %80
  store i32 -2147454889, ptr %81, align 4, !tbaa !9
  %82 = load i32, ptr %6, align 4, !tbaa !9
  %83 = load i32, ptr getelementptr inbounds ([32 x i32], ptr @db_bpos, i64 0, i64 11), align 4, !tbaa !9
  %84 = shl i32 %82, %83
  %85 = and i32 1015808, %84
  %86 = load ptr, ptr %10, align 8, !tbaa !5
  %87 = load i32, ptr %9, align 4, !tbaa !9
  %88 = zext i32 %87 to i64
  %89 = getelementptr inbounds i32, ptr %86, i64 %88
  %90 = load i32, ptr %89, align 4, !tbaa !9
  %91 = or i32 %90, %85
  store i32 %91, ptr %89, align 4, !tbaa !9
  %92 = load i32, ptr %8, align 4, !tbaa !9
  %93 = load i32, ptr getelementptr inbounds ([32 x i32], ptr @db_bpos, i64 0, i64 23), align 4, !tbaa !9
  %94 = shl i32 %92, %93
  %95 = and i32 3968, %94
  %96 = load ptr, ptr %10, align 8, !tbaa !5
  %97 = load i32, ptr %9, align 4, !tbaa !9
  %98 = zext i32 %97 to i64
  %99 = getelementptr inbounds i32, ptr %96, i64 %98
  %100 = load i32, ptr %99, align 4, !tbaa !9
  %101 = or i32 %100, %95
  store i32 %101, ptr %99, align 4, !tbaa !9
  %102 = load i32, ptr %7, align 4, !tbaa !9
  %103 = load i32, ptr getelementptr inbounds ([32 x i32], ptr @db_bpos, i64 0, i64 10), align 8, !tbaa !9
  %104 = shl i32 %102, %103
  %105 = and i32 32505856, %104
  %106 = load ptr, ptr %10, align 8, !tbaa !5
  %107 = load i32, ptr %9, align 4, !tbaa !9
  %108 = zext i32 %107 to i64
  %109 = getelementptr inbounds i32, ptr %106, i64 %108
  %110 = load i32, ptr %109, align 4, !tbaa !9
  %111 = or i32 %110, %105
  store i32 %111, ptr %109, align 4, !tbaa !9
  %112 = load ptr, ptr %5, align 8, !tbaa !5
  %113 = getelementptr inbounds %struct.libxsmm_generated_code, ptr %112, i32 0, i32 2
  %114 = load i32, ptr %113, align 4, !tbaa !14
  %115 = add i32 %114, 4
  store i32 %115, ptr %113, align 4, !tbaa !14
  store i32 0, ptr %11, align 4
  br label %116

116:                                              ; preds = %77, %75
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #4
  %117 = load i32, ptr %11, align 4
  switch i32 %117, label %131 [
    i32 0, label %118
    i32 1, label %130
  ]

118:                                              ; preds = %116
  br label %130

119:                                              ; preds = %47
  %120 = load ptr, ptr @stderr, align 8, !tbaa !5
  %121 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %120, ptr noundef @.str.17) #4
  %122 = load ptr, ptr %5, align 8, !tbaa !5
  %123 = load i32, ptr @libxsmm_ninit, align 4, !tbaa !9
  %124 = icmp ult i32 1, %123
  br i1 %124, label %125, label %127

125:                                              ; preds = %119
  %126 = load i32, ptr @libxsmm_verbosity, align 4, !tbaa !9
  br label %128

127:                                              ; preds = %119
  br label %128

128:                                              ; preds = %127, %125
  %129 = phi i32 [ %126, %125 ], [ 1, %127 ]
  call void @libxsmm_handle_error(ptr noundef %122, i32 noundef 90000, ptr noundef @__func__.libxsmm_rv64_instruction_rvv_setvl, ptr noundef @.str.1, i32 noundef 499, i32 noundef %129)
  br label %130

130:                                              ; preds = %128, %118, %116, %45, %25
  ret void

131:                                              ; preds = %116
  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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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, !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 = !{!12, !10, i64 16}
!14 = !{!12, !10, i64 12}
!15 = !{!12, !6, i64 0}
!16 = !{!12, !10, i64 8}


; 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
@db_bpos = external hidden local_unnamed_addr constant [32 x i32], align 16
@.str.15 = external hidden unnamed_addr constant [89 x i8], align 1
@__func__.libxsmm_rv64_instruction_rvv_setvl = external hidden unnamed_addr constant [35 x i8], align 1
@.str.16 = external hidden unnamed_addr constant [55 x i8], align 1
@.str.17 = external hidden unnamed_addr constant [82 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
define dso_local void @libxsmm_rv64_instruction_rvv_setvl(ptr noundef %0, i32 noundef %1, i32 noundef %2, i32 noundef %3) local_unnamed_addr #2 {
  %5 = getelementptr inbounds i8, ptr %0, i64 28
  %6 = load i32, ptr %5, align 4, !tbaa !5
  %7 = icmp ult i32 %6, 3001
  br i1 %7, label %8, label %15

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

15:                                               ; preds = %4
  %16 = or i32 %2, %1
  %17 = or i32 %16, %3
  %or.cond3 = icmp ult i32 %17, 32
  br i1 %or.cond3, label %25, label %18

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

25:                                               ; preds = %15
  %26 = getelementptr inbounds i8, ptr %0, i64 16
  %27 = load i32, ptr %26, align 8, !tbaa !13
  %28 = icmp ugt i32 %27, 1
  br i1 %28, label %29, label %60

29:                                               ; preds = %25
  %30 = getelementptr inbounds i8, ptr %0, i64 12
  %31 = load i32, ptr %30, align 4, !tbaa !14
  %32 = getelementptr inbounds i8, ptr %0, i64 8
  %33 = load i32, ptr %32, align 8, !tbaa !15
  %34 = sub i32 %33, %31
  %35 = icmp ult i32 %34, 4
  br i1 %35, label %36, label %41

36:                                               ; preds = %29
  %37 = load i32, ptr @libxsmm_ninit, align 4, !tbaa !12
  %38 = icmp ugt i32 %37, 1
  %39 = load i32, ptr @libxsmm_verbosity, align 4
  %40 = select i1 %38, i32 %39, i32 1
  tail call void @libxsmm_handle_error(ptr noundef nonnull %0, i32 noundef 90002, ptr noundef nonnull @__func__.libxsmm_rv64_instruction_rvv_setvl, ptr noundef nonnull @.str.1, i32 noundef 481, i32 noundef %40) #4
  br label %67

41:                                               ; preds = %29
  %42 = load ptr, ptr %0, align 8, !tbaa !16
  %43 = lshr i32 %31, 2
  %44 = zext nneg i32 %43 to i64
  %45 = getelementptr inbounds i32, ptr %42, i64 %44
  %46 = load i32, ptr getelementptr inbounds (i8, ptr @db_bpos, i64 44), align 4, !tbaa !12
  %47 = shl i32 %1, %46
  %48 = and i32 %47, 1015808
  %49 = or disjoint i32 %48, -2147454889
  %50 = load i32, ptr getelementptr inbounds (i8, ptr @db_bpos, i64 92), align 4, !tbaa !12
  %51 = shl i32 %3, %50
  %52 = and i32 %51, 3968
  %53 = or disjoint i32 %52, %49
  %54 = load i32, ptr getelementptr inbounds (i8, ptr @db_bpos, i64 40), align 8, !tbaa !12
  %55 = shl i32 %2, %54
  %56 = and i32 %55, 32505856
  %57 = or disjoint i32 %56, %53
  store i32 %57, ptr %45, align 4, !tbaa !12
  %58 = load i32, ptr %30, align 4, !tbaa !14
  %59 = add i32 %58, 4
  store i32 %59, ptr %30, align 4, !tbaa !14
  br label %67

60:                                               ; preds = %25
  %61 = load ptr, ptr @stderr, align 8, !tbaa !11
  %62 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %61, ptr noundef nonnull @.str.17) #3
  %63 = load i32, ptr @libxsmm_ninit, align 4, !tbaa !12
  %64 = icmp ugt i32 %63, 1
  %65 = load i32, ptr @libxsmm_verbosity, align 4
  %66 = select i1 %64, i32 %65, i32 1
  tail call void @libxsmm_handle_error(ptr noundef nonnull %0, i32 noundef 90000, ptr noundef nonnull @__func__.libxsmm_rv64_instruction_rvv_setvl, ptr noundef nonnull @.str.1, i32 noundef 499, i32 noundef %66) #4
  br label %67

67:                                               ; preds = %36, %41, %60, %18, %8
  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}
!13 = !{!6, !10, i64 16}
!14 = !{!6, !10, i64 12}
!15 = !{!6, !10, i64 8}
!16 = !{!6, !7, i64 0}


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