; LLVM IR from robertklee/C-Optimization-DCT :: src/dct (loeffler_fixed)

; 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 @transpose_int(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
declare dso_local void @dct_1d_fixed(ptr noundef) #0

; Function Attrs: nounwind uwtable
define dso_local void @dct_loeffler_fixed(ptr noundef %0, ptr noundef %1) #0 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca [8 x [8 x i32]], align 16
  store ptr %0, ptr %3, align 8, !tbaa !5
  store ptr %1, ptr %4, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #2
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #2
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #2
  call void @llvm.lifetime.start.p0(i64 256, ptr %8) #2
  store i32 0, ptr %5, align 4, !tbaa !9
  br label %9

9:                                                ; preds = %36, %2
  %10 = load i32, ptr %5, align 4, !tbaa !9
  %11 = icmp slt i32 %10, 8
  br i1 %11, label %12, label %39

12:                                               ; preds = %9
  store i32 0, ptr %6, align 4, !tbaa !9
  br label %13

13:                                               ; preds = %32, %12
  %14 = load i32, ptr %6, align 4, !tbaa !9
  %15 = icmp slt i32 %14, 8
  br i1 %15, label %16, label %35

16:                                               ; preds = %13
  %17 = load ptr, ptr %3, align 8, !tbaa !5
  %18 = load i32, ptr %5, align 4, !tbaa !9
  %19 = sext i32 %18 to i64
  %20 = getelementptr inbounds [8 x i8], ptr %17, i64 %19
  %21 = load i32, ptr %6, align 4, !tbaa !9
  %22 = sext i32 %21 to i64
  %23 = getelementptr inbounds [8 x i8], ptr %20, i64 0, i64 %22
  %24 = load i8, ptr %23, align 1, !tbaa !11
  %25 = sext i8 %24 to i32
  %26 = load i32, ptr %5, align 4, !tbaa !9
  %27 = sext i32 %26 to i64
  %28 = getelementptr inbounds [8 x [8 x i32]], ptr %8, i64 0, i64 %27
  %29 = load i32, ptr %6, align 4, !tbaa !9
  %30 = sext i32 %29 to i64
  %31 = getelementptr inbounds [8 x i32], ptr %28, i64 0, i64 %30
  store i32 %25, ptr %31, align 4, !tbaa !9
  br label %32

32:                                               ; preds = %16
  %33 = load i32, ptr %6, align 4, !tbaa !9
  %34 = add nsw i32 %33, 1
  store i32 %34, ptr %6, align 4, !tbaa !9
  br label %13, !llvm.loop !12

35:                                               ; preds = %13
  br label %36

36:                                               ; preds = %35
  %37 = load i32, ptr %5, align 4, !tbaa !9
  %38 = add nsw i32 %37, 1
  store i32 %38, ptr %5, align 4, !tbaa !9
  br label %9, !llvm.loop !14

39:                                               ; preds = %9
  store i32 0, ptr %7, align 4, !tbaa !9
  br label %40

40:                                               ; preds = %48, %39
  %41 = load i32, ptr %7, align 4, !tbaa !9
  %42 = icmp slt i32 %41, 8
  br i1 %42, label %43, label %51

43:                                               ; preds = %40
  %44 = load i32, ptr %7, align 4, !tbaa !9
  %45 = sext i32 %44 to i64
  %46 = getelementptr inbounds [8 x [8 x i32]], ptr %8, i64 0, i64 %45
  %47 = getelementptr inbounds [8 x i32], ptr %46, i64 0, i64 0
  call void @dct_1d_fixed(ptr noundef %47)
  br label %48

48:                                               ; preds = %43
  %49 = load i32, ptr %7, align 4, !tbaa !9
  %50 = add nsw i32 %49, 1
  store i32 %50, ptr %7, align 4, !tbaa !9
  br label %40, !llvm.loop !15

51:                                               ; preds = %40
  %52 = getelementptr inbounds [8 x [8 x i32]], ptr %8, i64 0, i64 0
  call void @transpose_int(ptr noundef %52)
  store i32 0, ptr %7, align 4, !tbaa !9
  br label %53

53:                                               ; preds = %61, %51
  %54 = load i32, ptr %7, align 4, !tbaa !9
  %55 = icmp slt i32 %54, 8
  br i1 %55, label %56, label %64

56:                                               ; preds = %53
  %57 = load i32, ptr %7, align 4, !tbaa !9
  %58 = sext i32 %57 to i64
  %59 = getelementptr inbounds [8 x [8 x i32]], ptr %8, i64 0, i64 %58
  %60 = getelementptr inbounds [8 x i32], ptr %59, i64 0, i64 0
  call void @dct_1d_fixed(ptr noundef %60)
  br label %61

61:                                               ; preds = %56
  %62 = load i32, ptr %7, align 4, !tbaa !9
  %63 = add nsw i32 %62, 1
  store i32 %63, ptr %7, align 4, !tbaa !9
  br label %53, !llvm.loop !16

64:                                               ; preds = %53
  %65 = getelementptr inbounds [8 x [8 x i32]], ptr %8, i64 0, i64 0
  call void @transpose_int(ptr noundef %65)
  store i32 0, ptr %5, align 4, !tbaa !9
  br label %66

66:                                               ; preds = %95, %64
  %67 = load i32, ptr %5, align 4, !tbaa !9
  %68 = icmp slt i32 %67, 8
  br i1 %68, label %69, label %98

69:                                               ; preds = %66
  store i32 0, ptr %6, align 4, !tbaa !9
  br label %70

70:                                               ; preds = %91, %69
  %71 = load i32, ptr %6, align 4, !tbaa !9
  %72 = icmp slt i32 %71, 8
  br i1 %72, label %73, label %94

73:                                               ; preds = %70
  %74 = load i32, ptr %5, align 4, !tbaa !9
  %75 = sext i32 %74 to i64
  %76 = getelementptr inbounds [8 x [8 x i32]], ptr %8, i64 0, i64 %75
  %77 = load i32, ptr %6, align 4, !tbaa !9
  %78 = sext i32 %77 to i64
  %79 = getelementptr inbounds [8 x i32], ptr %76, i64 0, i64 %78
  %80 = load i32, ptr %79, align 4, !tbaa !9
  %81 = add nsw i32 %80, 4
  %82 = ashr i32 %81, 3
  %83 = trunc i32 %82 to i16
  %84 = load ptr, ptr %4, align 8, !tbaa !5
  %85 = load i32, ptr %5, align 4, !tbaa !9
  %86 = sext i32 %85 to i64
  %87 = getelementptr inbounds [8 x i16], ptr %84, i64 %86
  %88 = load i32, ptr %6, align 4, !tbaa !9
  %89 = sext i32 %88 to i64
  %90 = getelementptr inbounds [8 x i16], ptr %87, i64 0, i64 %89
  store i16 %83, ptr %90, align 2, !tbaa !17
  br label %91

91:                                               ; preds = %73
  %92 = load i32, ptr %6, align 4, !tbaa !9
  %93 = add nsw i32 %92, 1
  store i32 %93, ptr %6, align 4, !tbaa !9
  br label %70, !llvm.loop !19

94:                                               ; preds = %70
  br label %95

95:                                               ; preds = %94
  %96 = load i32, ptr %5, align 4, !tbaa !9
  %97 = add nsw i32 %96, 1
  store i32 %97, ptr %5, align 4, !tbaa !9
  br label %66, !llvm.loop !20

98:                                               ; preds = %66
  call void @llvm.lifetime.end.p0(i64 256, ptr %8) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #2
  ret void
}

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 = { 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 = !{!7, !7, i64 0}
!12 = distinct !{!12, !13}
!13 = !{!"llvm.loop.mustprogress"}
!14 = distinct !{!14, !13}
!15 = distinct !{!15, !13}
!16 = distinct !{!16, !13}
!17 = !{!18, !18, i64 0}
!18 = !{!"short", !7, i64 0}
!19 = distinct !{!19, !13}
!20 = distinct !{!20, !13}


; 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 @transpose_int(ptr noundef) local_unnamed_addr #0

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

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

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

; Function Attrs: nounwind uwtable
define dso_local void @dct_loeffler_fixed(ptr nocapture noundef readonly %0, ptr nocapture noundef writeonly %1) local_unnamed_addr #0 {
.preheader28:
  %2 = alloca [8 x [8 x i32]], align 16
  call void @llvm.lifetime.start.p0(i64 256, ptr nonnull %2) #2
  %3 = load <4 x i8>, ptr %0, align 1, !tbaa !5
  %4 = sext <4 x i8> %3 to <4 x i32>
  store <4 x i32> %4, ptr %2, align 16, !tbaa !8
  %5 = getelementptr inbounds i8, ptr %0, i64 4
  %6 = getelementptr inbounds i8, ptr %2, i64 16
  %7 = load <4 x i8>, ptr %5, align 1, !tbaa !5
  %8 = sext <4 x i8> %7 to <4 x i32>
  store <4 x i32> %8, ptr %6, align 16, !tbaa !8
  %9 = getelementptr inbounds i8, ptr %0, i64 8
  %10 = getelementptr inbounds i8, ptr %2, i64 32
  %11 = load <4 x i8>, ptr %9, align 1, !tbaa !5
  %12 = sext <4 x i8> %11 to <4 x i32>
  store <4 x i32> %12, ptr %10, align 16, !tbaa !8
  %13 = getelementptr inbounds i8, ptr %0, i64 12
  %14 = getelementptr inbounds i8, ptr %2, i64 48
  %15 = load <4 x i8>, ptr %13, align 1, !tbaa !5
  %16 = sext <4 x i8> %15 to <4 x i32>
  store <4 x i32> %16, ptr %14, align 16, !tbaa !8
  %17 = getelementptr inbounds i8, ptr %0, i64 16
  %18 = getelementptr inbounds i8, ptr %2, i64 64
  %19 = load <4 x i8>, ptr %17, align 1, !tbaa !5
  %20 = sext <4 x i8> %19 to <4 x i32>
  store <4 x i32> %20, ptr %18, align 16, !tbaa !8
  %21 = getelementptr inbounds i8, ptr %0, i64 20
  %22 = getelementptr inbounds i8, ptr %2, i64 80
  %23 = load <4 x i8>, ptr %21, align 1, !tbaa !5
  %24 = sext <4 x i8> %23 to <4 x i32>
  store <4 x i32> %24, ptr %22, align 16, !tbaa !8
  %25 = getelementptr inbounds i8, ptr %0, i64 24
  %26 = getelementptr inbounds i8, ptr %2, i64 96
  %27 = load <4 x i8>, ptr %25, align 1, !tbaa !5
  %28 = sext <4 x i8> %27 to <4 x i32>
  store <4 x i32> %28, ptr %26, align 16, !tbaa !8
  %29 = getelementptr inbounds i8, ptr %0, i64 28
  %30 = getelementptr inbounds i8, ptr %2, i64 112
  %31 = load <4 x i8>, ptr %29, align 1, !tbaa !5
  %32 = sext <4 x i8> %31 to <4 x i32>
  store <4 x i32> %32, ptr %30, align 16, !tbaa !8
  %33 = getelementptr inbounds i8, ptr %0, i64 32
  %34 = getelementptr inbounds i8, ptr %2, i64 128
  %35 = load <4 x i8>, ptr %33, align 1, !tbaa !5
  %36 = sext <4 x i8> %35 to <4 x i32>
  store <4 x i32> %36, ptr %34, align 16, !tbaa !8
  %37 = getelementptr inbounds i8, ptr %0, i64 36
  %38 = getelementptr inbounds i8, ptr %2, i64 144
  %39 = load <4 x i8>, ptr %37, align 1, !tbaa !5
  %40 = sext <4 x i8> %39 to <4 x i32>
  store <4 x i32> %40, ptr %38, align 16, !tbaa !8
  %41 = getelementptr inbounds i8, ptr %0, i64 40
  %42 = getelementptr inbounds i8, ptr %2, i64 160
  %43 = load <4 x i8>, ptr %41, align 1, !tbaa !5
  %44 = sext <4 x i8> %43 to <4 x i32>
  store <4 x i32> %44, ptr %42, align 16, !tbaa !8
  %45 = getelementptr inbounds i8, ptr %0, i64 44
  %46 = getelementptr inbounds i8, ptr %2, i64 176
  %47 = load <4 x i8>, ptr %45, align 1, !tbaa !5
  %48 = sext <4 x i8> %47 to <4 x i32>
  store <4 x i32> %48, ptr %46, align 16, !tbaa !8
  %49 = getelementptr inbounds i8, ptr %0, i64 48
  %50 = getelementptr inbounds i8, ptr %2, i64 192
  %51 = load <4 x i8>, ptr %49, align 1, !tbaa !5
  %52 = sext <4 x i8> %51 to <4 x i32>
  store <4 x i32> %52, ptr %50, align 16, !tbaa !8
  %53 = getelementptr inbounds i8, ptr %0, i64 52
  %54 = getelementptr inbounds i8, ptr %2, i64 208
  %55 = load <4 x i8>, ptr %53, align 1, !tbaa !5
  %56 = sext <4 x i8> %55 to <4 x i32>
  store <4 x i32> %56, ptr %54, align 16, !tbaa !8
  %57 = getelementptr inbounds i8, ptr %0, i64 56
  %58 = getelementptr inbounds i8, ptr %2, i64 224
  %59 = load <4 x i8>, ptr %57, align 1, !tbaa !5
  %60 = sext <4 x i8> %59 to <4 x i32>
  store <4 x i32> %60, ptr %58, align 16, !tbaa !8
  %61 = getelementptr inbounds i8, ptr %0, i64 60
  %62 = getelementptr inbounds i8, ptr %2, i64 240
  %63 = load <4 x i8>, ptr %61, align 1, !tbaa !5
  %64 = sext <4 x i8> %63 to <4 x i32>
  store <4 x i32> %64, ptr %62, align 16, !tbaa !8
  call void @dct_1d_fixed(ptr noundef nonnull %2)
  call void @dct_1d_fixed(ptr noundef nonnull %10)
  call void @dct_1d_fixed(ptr noundef nonnull %18)
  call void @dct_1d_fixed(ptr noundef nonnull %26)
  call void @dct_1d_fixed(ptr noundef nonnull %34)
  call void @dct_1d_fixed(ptr noundef nonnull %42)
  call void @dct_1d_fixed(ptr noundef nonnull %50)
  call void @dct_1d_fixed(ptr noundef nonnull %58)
  call void @transpose_int(ptr noundef nonnull %2)
  call void @dct_1d_fixed(ptr noundef nonnull %2)
  call void @dct_1d_fixed(ptr noundef nonnull %10)
  call void @dct_1d_fixed(ptr noundef nonnull %18)
  call void @dct_1d_fixed(ptr noundef nonnull %26)
  call void @dct_1d_fixed(ptr noundef nonnull %34)
  call void @dct_1d_fixed(ptr noundef nonnull %42)
  call void @dct_1d_fixed(ptr noundef nonnull %50)
  call void @dct_1d_fixed(ptr noundef nonnull %58)
  call void @transpose_int(ptr noundef nonnull %2)
  %65 = load <8 x i32>, ptr %2, align 16, !tbaa !8
  %66 = add nsw <8 x i32> %65, <i32 4, i32 4, i32 4, i32 4, i32 4, i32 4, i32 4, i32 4>
  %67 = lshr <8 x i32> %66, <i32 3, i32 3, i32 3, i32 3, i32 3, i32 3, i32 3, i32 3>
  %68 = trunc <8 x i32> %67 to <8 x i16>
  store <8 x i16> %68, ptr %1, align 2, !tbaa !10
  %69 = getelementptr inbounds i8, ptr %1, i64 16
  %70 = load <8 x i32>, ptr %10, align 16, !tbaa !8
  %71 = add nsw <8 x i32> %70, <i32 4, i32 4, i32 4, i32 4, i32 4, i32 4, i32 4, i32 4>
  %72 = lshr <8 x i32> %71, <i32 3, i32 3, i32 3, i32 3, i32 3, i32 3, i32 3, i32 3>
  %73 = trunc <8 x i32> %72 to <8 x i16>
  store <8 x i16> %73, ptr %69, align 2, !tbaa !10
  %74 = getelementptr inbounds i8, ptr %1, i64 32
  %75 = load <8 x i32>, ptr %18, align 16, !tbaa !8
  %76 = add nsw <8 x i32> %75, <i32 4, i32 4, i32 4, i32 4, i32 4, i32 4, i32 4, i32 4>
  %77 = lshr <8 x i32> %76, <i32 3, i32 3, i32 3, i32 3, i32 3, i32 3, i32 3, i32 3>
  %78 = trunc <8 x i32> %77 to <8 x i16>
  store <8 x i16> %78, ptr %74, align 2, !tbaa !10
  %79 = getelementptr inbounds i8, ptr %1, i64 48
  %80 = load <8 x i32>, ptr %26, align 16, !tbaa !8
  %81 = add nsw <8 x i32> %80, <i32 4, i32 4, i32 4, i32 4, i32 4, i32 4, i32 4, i32 4>
  %82 = lshr <8 x i32> %81, <i32 3, i32 3, i32 3, i32 3, i32 3, i32 3, i32 3, i32 3>
  %83 = trunc <8 x i32> %82 to <8 x i16>
  store <8 x i16> %83, ptr %79, align 2, !tbaa !10
  %84 = getelementptr inbounds i8, ptr %1, i64 64
  %85 = load <8 x i32>, ptr %34, align 16, !tbaa !8
  %86 = add nsw <8 x i32> %85, <i32 4, i32 4, i32 4, i32 4, i32 4, i32 4, i32 4, i32 4>
  %87 = lshr <8 x i32> %86, <i32 3, i32 3, i32 3, i32 3, i32 3, i32 3, i32 3, i32 3>
  %88 = trunc <8 x i32> %87 to <8 x i16>
  store <8 x i16> %88, ptr %84, align 2, !tbaa !10
  %89 = getelementptr inbounds i8, ptr %1, i64 80
  %90 = load <8 x i32>, ptr %42, align 16, !tbaa !8
  %91 = add nsw <8 x i32> %90, <i32 4, i32 4, i32 4, i32 4, i32 4, i32 4, i32 4, i32 4>
  %92 = lshr <8 x i32> %91, <i32 3, i32 3, i32 3, i32 3, i32 3, i32 3, i32 3, i32 3>
  %93 = trunc <8 x i32> %92 to <8 x i16>
  store <8 x i16> %93, ptr %89, align 2, !tbaa !10
  %94 = getelementptr inbounds i8, ptr %1, i64 96
  %95 = load <8 x i32>, ptr %50, align 16, !tbaa !8
  %96 = add nsw <8 x i32> %95, <i32 4, i32 4, i32 4, i32 4, i32 4, i32 4, i32 4, i32 4>
  %97 = lshr <8 x i32> %96, <i32 3, i32 3, i32 3, i32 3, i32 3, i32 3, i32 3, i32 3>
  %98 = trunc <8 x i32> %97 to <8 x i16>
  store <8 x i16> %98, ptr %94, align 2, !tbaa !10
  %99 = getelementptr inbounds i8, ptr %1, i64 112
  %100 = load <8 x i32>, ptr %58, align 16, !tbaa !8
  %101 = add nsw <8 x i32> %100, <i32 4, i32 4, i32 4, i32 4, i32 4, i32 4, i32 4, i32 4>
  %102 = lshr <8 x i32> %101, <i32 3, i32 3, i32 3, i32 3, i32 3, i32 3, i32 3, i32 3>
  %103 = trunc <8 x i32> %102 to <8 x i16>
  store <8 x i16> %103, ptr %99, align 2, !tbaa !10
  call void @llvm.lifetime.end.p0(i64 256, ptr nonnull %2) #2
  ret void
}

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 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = !{!6, !6, i64 0}
!6 = !{!"omnipotent char", !7, i64 0}
!7 = !{!"Simple C/C++ TBAA"}
!8 = !{!9, !9, i64 0}
!9 = !{!"int", !6, i64 0}
!10 = !{!11, !11, i64 0}
!11 = !{!"short", !6, i64 0}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IndVarSimplifyPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,LICMPass,LoopRotatePass,LoopSimplifyPass,PostOrderFunctionAttrsPass,SLPVectorizerPass,SROAPass,SimplifyCFGPass