; LLVM IR from libxsmm/libxsmm :: src (generator_aarch64_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 [86 x i8], align 1
@libxsmm_ninit = external global i32, align 4
@libxsmm_verbosity = external global i32, align 4
@.str.80 = external hidden unnamed_addr constant [103 x i8], align 1
@__func__.libxsmm_aarch64_instruction_alu_compute_imm64 = external hidden unnamed_addr constant [46 x i8], align 1
@.str.81 = external hidden unnamed_addr constant [82 x i8], align 1
@.str.82 = external hidden unnamed_addr constant [94 x i8], align 1
@.str.83 = external hidden unnamed_addr constant [94 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
declare dso_local void @libxsmm_aarch64_instruction_alu_set_imm64(ptr noundef, i32 noundef, i64 noundef) #3

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

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

; Function Attrs: nounwind uwtable
define dso_local void @libxsmm_aarch64_instruction_alu_compute_imm64(ptr noundef %0, i32 noundef %1, i32 noundef %2, i32 noundef %3, i32 noundef %4, i64 noundef %5) #3 {
  %7 = alloca ptr, align 8
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  %12 = alloca i64, align 8
  %13 = alloca i32, align 4
  %14 = alloca i32, align 4
  %15 = alloca i32, align 4
  store ptr %0, ptr %7, align 8, !tbaa !5
  store i32 %1, ptr %8, align 4, !tbaa !9
  store i32 %2, ptr %9, align 4, !tbaa !9
  store i32 %3, ptr %10, align 4, !tbaa !9
  store i32 %4, ptr %11, align 4, !tbaa !9
  store i64 %5, ptr %12, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #4
  store i32 9999, ptr %13, align 4, !tbaa !9
  %16 = load ptr, ptr %7, align 8, !tbaa !5
  %17 = getelementptr inbounds %struct.libxsmm_generated_code, ptr %16, i32 0, i32 6
  %18 = load i32, ptr %17, align 4, !tbaa !13
  %19 = icmp ult i32 %18, 2001
  br i1 %19, label %20, label %31

20:                                               ; preds = %6
  %21 = load ptr, ptr @stderr, align 8, !tbaa !5
  %22 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %21, ptr noundef @.str.80) #4
  %23 = load ptr, ptr %7, align 8, !tbaa !5
  %24 = load i32, ptr @libxsmm_ninit, align 4, !tbaa !9
  %25 = icmp ult i32 1, %24
  br i1 %25, label %26, label %28

26:                                               ; preds = %20
  %27 = load i32, ptr @libxsmm_verbosity, align 4, !tbaa !9
  br label %29

28:                                               ; preds = %20
  br label %29

29:                                               ; preds = %28, %26
  %30 = phi i32 [ %27, %26 ], [ 1, %28 ]
  call void @libxsmm_handle_error(ptr noundef %23, i32 noundef 90000, ptr noundef @__func__.libxsmm_aarch64_instruction_alu_compute_imm64, ptr noundef @.str.1, i32 noundef 1944, i32 noundef %30)
  store i32 1, ptr %14, align 4
  br label %103

31:                                               ; preds = %6
  %32 = load i32, ptr %8, align 4, !tbaa !9
  switch i32 %32, label %34 [
    i32 4096, label %33
    i32 4097, label %33
  ]

33:                                               ; preds = %31, %31
  br label %46

34:                                               ; preds = %31
  %35 = load ptr, ptr @stderr, align 8, !tbaa !5
  %36 = load i32, ptr %8, align 4, !tbaa !9
  %37 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %35, ptr noundef @.str.81, i32 noundef %36) #4
  %38 = load ptr, ptr %7, align 8, !tbaa !5
  %39 = load i32, ptr @libxsmm_ninit, align 4, !tbaa !9
  %40 = icmp ult i32 1, %39
  br i1 %40, label %41, label %43

41:                                               ; preds = %34
  %42 = load i32, ptr @libxsmm_verbosity, align 4, !tbaa !9
  br label %44

43:                                               ; preds = %34
  br label %44

44:                                               ; preds = %43, %41
  %45 = phi i32 [ %42, %41 ], [ 1, %43 ]
  call void @libxsmm_handle_error(ptr noundef %38, i32 noundef 90000, ptr noundef @__func__.libxsmm_aarch64_instruction_alu_compute_imm64, ptr noundef @.str.1, i32 noundef 1954, i32 noundef %45)
  store i32 1, ptr %14, align 4
  br label %103

46:                                               ; preds = %33
  %47 = load i64, ptr %12, align 8, !tbaa !11
  %48 = icmp ule i64 %47, 16777215
  br i1 %48, label %49, label %77

49:                                               ; preds = %46
  call void @llvm.lifetime.start.p0(i64 4, ptr %15) #4
  %50 = load i32, ptr %8, align 4, !tbaa !9
  switch i32 %50, label %53 [
    i32 4096, label %51
    i32 4097, label %52
  ]

51:                                               ; preds = %49
  store i32 285212678, ptr %13, align 4, !tbaa !9
  br label %65

52:                                               ; preds = %49
  store i32 1358954502, ptr %13, align 4, !tbaa !9
  br label %65

53:                                               ; preds = %49
  %54 = load ptr, ptr @stderr, align 8, !tbaa !5
  %55 = load i32, ptr %8, align 4, !tbaa !9
  %56 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %54, ptr noundef @.str.82, i32 noundef %55) #4
  %57 = load ptr, ptr %7, align 8, !tbaa !5
  %58 = load i32, ptr @libxsmm_ninit, align 4, !tbaa !9
  %59 = icmp ult i32 1, %58
  br i1 %59, label %60, label %62

60:                                               ; preds = %53
  %61 = load i32, ptr @libxsmm_verbosity, align 4, !tbaa !9
  br label %63

62:                                               ; preds = %53
  br label %63

63:                                               ; preds = %62, %60
  %64 = phi i32 [ %61, %60 ], [ 1, %62 ]
  call void @libxsmm_handle_error(ptr noundef %57, i32 noundef 90000, ptr noundef @__func__.libxsmm_aarch64_instruction_alu_compute_imm64, ptr noundef @.str.1, i32 noundef 1972, i32 noundef %64)
  store i32 1, ptr %14, align 4
  br label %74

65:                                               ; preds = %52, %51
  %66 = load i64, ptr %12, align 8, !tbaa !11
  %67 = and i64 %66, 16777215
  %68 = trunc i64 %67 to i32
  store i32 %68, ptr %15, align 4, !tbaa !9
  %69 = load ptr, ptr %7, align 8, !tbaa !5
  %70 = load i32, ptr %13, align 4, !tbaa !9
  %71 = load i32, ptr %9, align 4, !tbaa !9
  %72 = load i32, ptr %11, align 4, !tbaa !9
  %73 = load i32, ptr %15, align 4, !tbaa !9
  call void @libxsmm_aarch64_instruction_alu_compute_imm24(ptr noundef %69, i32 noundef %70, i32 noundef %71, i32 noundef %72, i32 noundef %73)
  store i32 0, ptr %14, align 4
  br label %74

74:                                               ; preds = %65, %63
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #4
  %75 = load i32, ptr %14, align 4
  switch i32 %75, label %103 [
    i32 0, label %76
  ]

76:                                               ; preds = %74
  br label %102

77:                                               ; preds = %46
  %78 = load i32, ptr %8, align 4, !tbaa !9
  switch i32 %78, label %81 [
    i32 4096, label %79
    i32 4097, label %80
  ]

79:                                               ; preds = %77
  store i32 184549383, ptr %13, align 4, !tbaa !9
  br label %93

80:                                               ; preds = %77
  store i32 1258291207, ptr %13, align 4, !tbaa !9
  br label %93

81:                                               ; preds = %77
  %82 = load ptr, ptr @stderr, align 8, !tbaa !5
  %83 = load i32, ptr %8, align 4, !tbaa !9
  %84 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %82, ptr noundef @.str.83, i32 noundef %83) #4
  %85 = load ptr, ptr %7, align 8, !tbaa !5
  %86 = load i32, ptr @libxsmm_ninit, align 4, !tbaa !9
  %87 = icmp ult i32 1, %86
  br i1 %87, label %88, label %90

88:                                               ; preds = %81
  %89 = load i32, ptr @libxsmm_verbosity, align 4, !tbaa !9
  br label %91

90:                                               ; preds = %81
  br label %91

91:                                               ; preds = %90, %88
  %92 = phi i32 [ %89, %88 ], [ 1, %90 ]
  call void @libxsmm_handle_error(ptr noundef %85, i32 noundef 90000, ptr noundef @__func__.libxsmm_aarch64_instruction_alu_compute_imm64, ptr noundef @.str.1, i32 noundef 1990, i32 noundef %92)
  store i32 1, ptr %14, align 4
  br label %103

93:                                               ; preds = %80, %79
  %94 = load ptr, ptr %7, align 8, !tbaa !5
  %95 = load i32, ptr %10, align 4, !tbaa !9
  %96 = load i64, ptr %12, align 8, !tbaa !11
  call void @libxsmm_aarch64_instruction_alu_set_imm64(ptr noundef %94, i32 noundef %95, i64 noundef %96)
  %97 = load ptr, ptr %7, align 8, !tbaa !5
  %98 = load i32, ptr %13, align 4, !tbaa !9
  %99 = load i32, ptr %9, align 4, !tbaa !9
  %100 = load i32, ptr %10, align 4, !tbaa !9
  %101 = load i32, ptr %11, align 4, !tbaa !9
  call void @libxsmm_aarch64_instruction_alu_compute_shifted_reg(ptr noundef %97, i32 noundef %98, i32 noundef %99, i32 noundef %100, i32 noundef %101, i32 noundef 0, i32 noundef 0)
  br label %102

102:                                              ; preds = %93, %76
  store i32 0, ptr %14, align 4
  br label %103

103:                                              ; preds = %102, %91, %74, %44, %29
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #4
  %104 = load i32, ptr %14, align 4
  switch i32 %104, label %106 [
    i32 0, label %105
    i32 1, label %105
  ]

105:                                              ; preds = %103, %103
  ret void

106:                                              ; preds = %103
  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, !12, i64 0}
!12 = !{!"long long", !7, i64 0}
!13 = !{!14, !10, i64 28}
!14 = !{!"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 [86 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.80 = external hidden unnamed_addr constant [103 x i8], align 1
@__func__.libxsmm_aarch64_instruction_alu_compute_imm64 = external hidden unnamed_addr constant [46 x i8], align 1
@.str.81 = 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
declare dso_local void @libxsmm_aarch64_instruction_alu_set_imm64(ptr noundef, i32 noundef, i64 noundef) local_unnamed_addr #2

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

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

; Function Attrs: nounwind uwtable
define dso_local void @libxsmm_aarch64_instruction_alu_compute_imm64(ptr noundef %0, i32 noundef %1, i32 noundef %2, i32 noundef %3, i32 noundef %4, i64 noundef %5) local_unnamed_addr #2 {
  %7 = getelementptr inbounds i8, ptr %0, i64 28
  %8 = load i32, ptr %7, align 4, !tbaa !5
  %9 = icmp ult i32 %8, 2001
  br i1 %9, label %10, label %17

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

17:                                               ; preds = %6
  %18 = and i32 %1, -2
  %switch = icmp eq i32 %18, 4096
  br i1 %switch, label %26, label %19

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

26:                                               ; preds = %17
  %27 = icmp ult i64 %5, 16777216
  %switch31 = icmp eq i32 %1, 4096
  br i1 %27, label %28, label %30

28:                                               ; preds = %26
  %spec.select = select i1 %switch31, i32 285212678, i32 1358954502
  %29 = trunc nuw nsw i64 %5 to i32
  tail call void @libxsmm_aarch64_instruction_alu_compute_imm24(ptr noundef nonnull %0, i32 noundef %spec.select, i32 noundef %2, i32 noundef %4, i32 noundef %29)
  br label %31

30:                                               ; preds = %26
  %spec.select34 = select i1 %switch31, i32 184549383, i32 1258291207
  tail call void @libxsmm_aarch64_instruction_alu_set_imm64(ptr noundef nonnull %0, i32 noundef %3, i64 noundef %5)
  tail call void @libxsmm_aarch64_instruction_alu_compute_shifted_reg(ptr noundef nonnull %0, i32 noundef %spec.select34, i32 noundef %2, i32 noundef %3, i32 noundef %4, i32 noundef 0, i32 noundef 0)
  br label %31

31:                                               ; preds = %30, %28, %19, %10
  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,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,SROAPass,SimplifyCFGPass,TailCallElimPass