; LLVM IR from libxsmm/libxsmm :: samples/encoder (encoder_aarch64)

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

; Function Attrs: nounwind uwtable
declare dso_local void @reset_code_buffer(ptr noundef, ptr noundef) #0

; Function Attrs: nounwind uwtable
declare dso_local void @dump_code_buffer(ptr noundef, ptr noundef) #0

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

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

; Function Attrs: nounwind uwtable
define dso_local void @test_alu_move(ptr noundef %0, ptr noundef %1, i32 noundef %2) #0 {
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  %7 = alloca i8, align 1
  %8 = alloca i8, align 1
  %9 = alloca i8, align 1
  %10 = alloca i16, align 2
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  store i32 %2, ptr %6, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 1, ptr %7) #3
  call void @llvm.lifetime.start.p0(i64 1, ptr %8) #3
  call void @llvm.lifetime.start.p0(i64 1, ptr %9) #3
  call void @llvm.lifetime.start.p0(i64 2, ptr %10) #3
  store i16 64, ptr %10, align 2, !tbaa !11
  %11 = load ptr, ptr %5, align 8, !tbaa !5
  %12 = load ptr, ptr %4, align 8, !tbaa !5
  call void @reset_code_buffer(ptr noundef %11, ptr noundef %12)
  %13 = load i32, ptr %6, align 4, !tbaa !9
  %14 = icmp eq i32 %13, -1201649661
  br i1 %14, label %18, label %15

15:                                               ; preds = %3
  %16 = load i32, ptr %6, align 4, !tbaa !9
  %17 = icmp eq i32 %16, -1205843965
  br i1 %17, label %18, label %54

18:                                               ; preds = %15, %3
  store i8 32, ptr %7, align 1, !tbaa !13
  br label %19

19:                                               ; preds = %50, %18
  %20 = load i8, ptr %7, align 1, !tbaa !13
  %21 = zext i8 %20 to i32
  %22 = icmp slt i32 %21, 64
  br i1 %22, label %23, label %53

23:                                               ; preds = %19
  store i8 0, ptr %8, align 1, !tbaa !13
  br label %24

24:                                               ; preds = %46, %23
  %25 = load i8, ptr %8, align 1, !tbaa !13
  %26 = zext i8 %25 to i32
  %27 = icmp slt i32 %26, 64
  br i1 %27, label %28, label %49

28:                                               ; preds = %24
  store i8 0, ptr %9, align 1, !tbaa !13
  br label %29

29:                                               ; preds = %42, %28
  %30 = load i8, ptr %9, align 1, !tbaa !13
  %31 = zext i8 %30 to i32
  %32 = icmp slt i32 %31, 64
  br i1 %32, label %33, label %45

33:                                               ; preds = %29
  %34 = load ptr, ptr %5, align 8, !tbaa !5
  %35 = load i32, ptr %6, align 4, !tbaa !9
  %36 = load i8, ptr %7, align 1, !tbaa !13
  %37 = zext i8 %36 to i32
  %38 = load i8, ptr %8, align 1, !tbaa !13
  %39 = zext i8 %38 to i32
  %40 = load i8, ptr %9, align 1, !tbaa !13
  %41 = zext i8 %40 to i32
  call void @libxsmm_aarch64_instruction_alu_move(ptr noundef %34, i32 noundef %35, i32 noundef %37, i32 noundef %39, i32 noundef 0, i32 noundef %41)
  br label %42

42:                                               ; preds = %33
  %43 = load i8, ptr %9, align 1, !tbaa !13
  %44 = add i8 %43, 1
  store i8 %44, ptr %9, align 1, !tbaa !13
  br label %29, !llvm.loop !14

45:                                               ; preds = %29
  br label %46

46:                                               ; preds = %45
  %47 = load i8, ptr %8, align 1, !tbaa !13
  %48 = add i8 %47, 1
  store i8 %48, ptr %8, align 1, !tbaa !13
  br label %24, !llvm.loop !16

49:                                               ; preds = %24
  br label %50

50:                                               ; preds = %49
  %51 = load i8, ptr %7, align 1, !tbaa !13
  %52 = add i8 %51, 1
  store i8 %52, ptr %7, align 1, !tbaa !13
  br label %19, !llvm.loop !17

53:                                               ; preds = %19
  br label %81

54:                                               ; preds = %15
  store i8 32, ptr %7, align 1, !tbaa !13
  br label %55

55:                                               ; preds = %77, %54
  %56 = load i8, ptr %7, align 1, !tbaa !13
  %57 = zext i8 %56 to i32
  %58 = icmp slt i32 %57, 64
  br i1 %58, label %59, label %80

59:                                               ; preds = %55
  store i8 0, ptr %9, align 1, !tbaa !13
  br label %60

60:                                               ; preds = %73, %59
  %61 = load i8, ptr %9, align 1, !tbaa !13
  %62 = zext i8 %61 to i32
  %63 = icmp slt i32 %62, 64
  br i1 %63, label %64, label %76

64:                                               ; preds = %60
  %65 = load ptr, ptr %5, align 8, !tbaa !5
  %66 = load i32, ptr %6, align 4, !tbaa !9
  %67 = load i8, ptr %7, align 1, !tbaa !13
  %68 = zext i8 %67 to i32
  %69 = load i16, ptr %10, align 2, !tbaa !11
  %70 = sext i16 %69 to i32
  %71 = load i8, ptr %9, align 1, !tbaa !13
  %72 = zext i8 %71 to i32
  call void @libxsmm_aarch64_instruction_alu_move(ptr noundef %65, i32 noundef %66, i32 noundef %68, i32 noundef 0, i32 noundef %70, i32 noundef %72)
  br label %73

73:                                               ; preds = %64
  %74 = load i8, ptr %9, align 1, !tbaa !13
  %75 = add i8 %74, 1
  store i8 %75, ptr %9, align 1, !tbaa !13
  br label %60, !llvm.loop !18

76:                                               ; preds = %60
  br label %77

77:                                               ; preds = %76
  %78 = load i8, ptr %7, align 1, !tbaa !13
  %79 = add i8 %78, 1
  store i8 %79, ptr %7, align 1, !tbaa !13
  br label %55, !llvm.loop !19

80:                                               ; preds = %55
  br label %81

81:                                               ; preds = %80, %53
  %82 = load ptr, ptr %5, align 8, !tbaa !5
  %83 = load ptr, ptr %4, align 8, !tbaa !5
  call void @dump_code_buffer(ptr noundef %82, ptr noundef %83)
  call void @llvm.lifetime.end.p0(i64 2, ptr %10) #3
  call void @llvm.lifetime.end.p0(i64 1, ptr %9) #3
  call void @llvm.lifetime.end.p0(i64 1, ptr %8) #3
  call void @llvm.lifetime.end.p0(i64 1, ptr %7) #3
  ret void
}

declare void @libxsmm_aarch64_instruction_alu_move(ptr noundef, i32 noundef, i32 noundef, i32 noundef, i32 noundef, i32 noundef) #2

attributes #0 = { 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 #1 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { "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, !12, i64 0}
!12 = !{!"short", !7, i64 0}
!13 = !{!7, !7, i64 0}
!14 = distinct !{!14, !15}
!15 = !{!"llvm.loop.mustprogress"}
!16 = distinct !{!16, !15}
!17 = distinct !{!17, !15}
!18 = distinct !{!18, !15}
!19 = distinct !{!19, !15}


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

; Function Attrs: nounwind uwtable
declare dso_local void @reset_code_buffer(ptr noundef, ptr noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare dso_local void @dump_code_buffer(ptr noundef, ptr noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local void @test_alu_move(ptr noundef %0, ptr noundef %1, i32 noundef %2) local_unnamed_addr #0 {
  tail call void @reset_code_buffer(ptr noundef %1, ptr noundef %0)
  %4 = and i32 %2, -4194305
  %or.cond = icmp eq i32 %4, -1205843965
  br i1 %or.cond, label %.preheader35, label %.preheader37

.preheader35:                                     ; preds = %3, %7
  %indvars.iv59 = phi i32 [ %indvars.iv.next60, %7 ], [ 32, %3 ]
  br label %.preheader

.preheader:                                       ; preds = %.preheader35, %6
  %indvars.iv55 = phi i32 [ 0, %.preheader35 ], [ %indvars.iv.next56, %6 ]
  br label %5

5:                                                ; preds = %.preheader, %5
  %indvars.iv51 = phi i32 [ 0, %.preheader ], [ %indvars.iv.next52, %5 ]
  tail call void @libxsmm_aarch64_instruction_alu_move(ptr noundef %1, i32 noundef %2, i32 noundef %indvars.iv59, i32 noundef %indvars.iv55, i32 noundef 0, i32 noundef %indvars.iv51) #2
  %indvars.iv.next52 = add nuw nsw i32 %indvars.iv51, 1
  %exitcond54.not = icmp eq i32 %indvars.iv.next52, 64
  br i1 %exitcond54.not, label %6, label %5, !llvm.loop !5

6:                                                ; preds = %5
  %indvars.iv.next56 = add nuw nsw i32 %indvars.iv55, 1
  %exitcond58.not = icmp eq i32 %indvars.iv.next56, 64
  br i1 %exitcond58.not, label %7, label %.preheader, !llvm.loop !7

7:                                                ; preds = %6
  %indvars.iv.next60 = add nuw nsw i32 %indvars.iv59, 1
  %exitcond62.not = icmp eq i32 %indvars.iv.next60, 64
  br i1 %exitcond62.not, label %.loopexit, label %.preheader35, !llvm.loop !8

.preheader37:                                     ; preds = %3, %9
  %indvars.iv47 = phi i32 [ %indvars.iv.next48, %9 ], [ 32, %3 ]
  br label %8

8:                                                ; preds = %.preheader37, %8
  %indvars.iv = phi i32 [ 0, %.preheader37 ], [ %indvars.iv.next, %8 ]
  tail call void @libxsmm_aarch64_instruction_alu_move(ptr noundef %1, i32 noundef %2, i32 noundef %indvars.iv47, i32 noundef 0, i32 noundef 64, i32 noundef %indvars.iv) #2
  %indvars.iv.next = add nuw nsw i32 %indvars.iv, 1
  %exitcond.not = icmp eq i32 %indvars.iv.next, 64
  br i1 %exitcond.not, label %9, label %8, !llvm.loop !9

9:                                                ; preds = %8
  %indvars.iv.next48 = add nuw nsw i32 %indvars.iv47, 1
  %exitcond50.not = icmp eq i32 %indvars.iv.next48, 64
  br i1 %exitcond50.not, label %.loopexit, label %.preheader37, !llvm.loop !10

.loopexit:                                        ; preds = %9, %7
  tail call void @dump_code_buffer(ptr noundef %1, ptr noundef %0)
  ret void
}

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

attributes #0 = { 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 #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 }

!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 = distinct !{!5, !6}
!6 = !{!"llvm.loop.mustprogress"}
!7 = distinct !{!7, !6}
!8 = distinct !{!8, !6}
!9 = distinct !{!9, !6}
!10 = distinct !{!10, !6}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,SROAPass,SimplifyCFGPass,TailCallElimPass